Skip to content

Commit f6d7c6f

Browse files
committed
Fix build failure
1 parent 0e059c2 commit f6d7c6f

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
190190
/// `to_error_region`.
191191
pub(super) fn to_error_region_vid(&self, r: RegionVid) -> Option<RegionVid> {
192192
if self.regioncx.universal_regions().is_universal_region(r) {
193-
Some(r)
194-
} else {
195-
// We just want something nameable, even if it's not
196-
// actually an upper bound.
197-
let upper_bound = self.regioncx.approx_universal_upper_bound(r);
193+
return Some(r);
194+
}
195+
// We just want something nameable, even if it's not
196+
// actually an upper bound.
197+
let upper_bound = self.regioncx.approx_universal_upper_bound(r);
198198

199-
if self.regioncx.upper_bound_in_region_scc(r, upper_bound) {
200-
self.to_error_region_vid(upper_bound)
201-
} else {
202-
None
203-
}
199+
if self.regioncx.upper_bound_in_region_scc(r, upper_bound) {
200+
self.to_error_region_vid(upper_bound)
201+
} else {
202+
None
204203
}
205204
}
206205

@@ -210,7 +209,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
210209
T: TypeFoldable<TyCtxt<'tcx>>,
211210
{
212211
fold_regions(tcx, ty, |region, _| match *region {
213-
ty::ReVar(vid) => self.to_error_region(vid).unwrap_or(region),
212+
ty::ReVar(vid) => self.regioncx.first_named_region_reached(vid).unwrap_or(region),
214213
_ => region,
215214
})
216215
}
@@ -373,7 +372,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
373372
);
374373
};
375374
debug!(?lower_bound_region);
376-
let generic_ty = generic_kind.to_ty(self.infcx.tcx);
375+
let generic_ty =
376+
self.name_regions(self.infcx.tcx, generic_kind.to_ty(self.infcx.tcx));
377377
let origin = RelateParamBound(type_test_span, generic_ty, None);
378378
self.buffer_error(self.infcx.err_ctxt().construct_generic_bound_failure(
379379
self.body.source.def_id().expect_local(),

compiler/rustc_borrowck/src/eliminate_placeholders.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,6 @@ fn rewrite_verify_bound<'t>(
619619
// in an unnameable universe, they would compare equal since they
620620
// are both empty. This bit checks if we
621621
VerifyBound::IfEq(binder) => {
622-
info!("Assuming, incorrectly, that Eq bound is universe-fine: {binder:?}");
623-
624-
// FIXME: does it matter that I don't normalise to SCCs?
625622
match test_type_match::extract_verify_if_eq(tcx, &binder, generic_kind.to_ty(tcx)) {
626623
Some(r) => {
627624
let r_vid = universal_regions.to_region_vid(r);
@@ -638,7 +635,13 @@ fn rewrite_verify_bound<'t>(
638635
Either::Right(RewrittenVerifyBound::Unsatisfied)
639636
}
640637
}
641-
None => Either::Right(RewrittenVerifyBound::Unsatisfied),
638+
None => {
639+
info!(
640+
"Failed to extract type from {:#?}; assuming we are fine!",
641+
generic_kind.to_ty(tcx)
642+
);
643+
Either::Left(bound)
644+
}
642645
}
643646
}
644647
// Rewrite an outlives bound to an outlives-static bound upon referencing

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
957957
Some(ClosureOutlivesSubject::Ty(ClosureOutlivesSubjectTy::bind(tcx, ty)))
958958
}
959959

960+
/// Returns the first named region reachable in the constraint graph
961+
/// from `from`. For when you are really desperate for something
962+
/// nameable.
963+
#[instrument(level = "info", skip(self), ret)]
964+
pub(crate) fn first_named_region_reached(&self, from: RegionVid) -> Option<ty::Region<'tcx>> {
965+
self.find_constraint_path_to(
966+
from,
967+
|reached| self.region_definition(reached).external_name.is_some(),
968+
true,
969+
)
970+
.and_then(|x| self.region_definition(x.1).external_name)
971+
}
972+
960973
/// Like `universal_upper_bound`, but returns an approximation more suitable
961974
/// for diagnostics. If `r` contains multiple disjoint universal regions
962975
/// (e.g. 'a and 'b in `fn foo<'a, 'b> { ... }`, we pick the lower-numbered region.

0 commit comments

Comments
 (0)