Skip to content

Commit 0c49d63

Browse files
committed
Always canonicalize skolemized regions
Since `ReSkolemized` has the flag `KEEP_IN_LOCAL_TCX`, and canonicalization is meant to ensure that flag is no longer present, it implicitly is depending on the existence of the leak check. However, since we want to remove that in rust-lang#48407, we can no longer make that assumption. This is related to rust-lang#48696, but does not resolve it. This does unblock that PR, however. It could have been tacked on there, but I wanted to make sure this is a reasonable short term approach separately from that.
1 parent 097efa9 commit 0c49d63

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Diff for: src/librustc/infer/canonical.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -557,31 +557,24 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
557557
.unwrap()
558558
.borrow_region_constraints()
559559
.opportunistic_resolve_var(self.tcx, vid);
560-
let info = CanonicalVarInfo {
561-
kind: CanonicalVarKind::Region,
562-
};
563560
debug!(
564561
"canonical: region var found with vid {:?}, \
565562
opportunistically resolved to {:?}",
566563
vid, r
567564
);
568-
let cvar = self.canonical_var(info, Kind::from(r));
569-
self.tcx().mk_region(ty::ReCanonical(cvar))
565+
self.canonicalize_region(r)
570566
}
571567

568+
ty::ReSkolemized(..) => self.canonicalize_region(r),
569+
572570
ty::ReStatic
573571
| ty::ReEarlyBound(..)
574572
| ty::ReFree(_)
575573
| ty::ReScope(_)
576-
| ty::ReSkolemized(..)
577574
| ty::ReEmpty
578575
| ty::ReErased => {
579576
if self.canonicalize_all_free_regions.0 {
580-
let info = CanonicalVarInfo {
581-
kind: CanonicalVarKind::Region,
582-
};
583-
let cvar = self.canonical_var(info, Kind::from(r));
584-
self.tcx().mk_region(ty::ReCanonical(cvar))
577+
self.canonicalize_region(r)
585578
} else {
586579
r
587580
}
@@ -764,6 +757,14 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
764757
self.tcx().mk_infer(ty::InferTy::CanonicalTy(cvar))
765758
}
766759
}
760+
761+
fn canonicalize_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
762+
let info = CanonicalVarInfo {
763+
kind: CanonicalVarKind::Region,
764+
};
765+
let cvar = self.canonical_var(info, Kind::from(r));
766+
self.tcx().mk_region(ty::ReCanonical(cvar))
767+
}
767768
}
768769

769770
impl<'tcx, V> Canonical<'tcx, V> {

0 commit comments

Comments
 (0)