Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e143ec4

Browse files
committed
Fix build failure
1 parent cf5ed30 commit e143ec4

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
580580
}
581581

582582
// Now take member constraints into account.
583-
self.member_constraints
584-
.clone()
583+
Rc::clone(&self.member_constraints)
585584
.apply(scc_a, |m_c_i, regions| self.apply_member_constraint(scc_a, m_c_i, regions));
586585

587586
debug!(value = ?self.scc_values.region_value_str(scc_a));
@@ -957,6 +956,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
957956
Some(ClosureOutlivesSubject::Ty(ClosureOutlivesSubjectTy::bind(tcx, ty)))
958957
}
959958

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

0 commit comments

Comments
 (0)