From 0c49d63d45b76fcade8edcbe89e7211da80f5218 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 2 Apr 2018 13:23:26 -0600 Subject: [PATCH] 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 #48407, we can no longer make that assumption. This is related to #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. --- src/librustc/infer/canonical.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/librustc/infer/canonical.rs b/src/librustc/infer/canonical.rs index 4357c9a5a776a..8cb07fa6465a9 100644 --- a/src/librustc/infer/canonical.rs +++ b/src/librustc/infer/canonical.rs @@ -557,31 +557,24 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> .unwrap() .borrow_region_constraints() .opportunistic_resolve_var(self.tcx, vid); - let info = CanonicalVarInfo { - kind: CanonicalVarKind::Region, - }; debug!( "canonical: region var found with vid {:?}, \ opportunistically resolved to {:?}", vid, r ); - let cvar = self.canonical_var(info, Kind::from(r)); - self.tcx().mk_region(ty::ReCanonical(cvar)) + self.canonicalize_region(r) } + ty::ReSkolemized(..) => self.canonicalize_region(r), + ty::ReStatic | ty::ReEarlyBound(..) | ty::ReFree(_) | ty::ReScope(_) - | ty::ReSkolemized(..) | ty::ReEmpty | ty::ReErased => { if self.canonicalize_all_free_regions.0 { - let info = CanonicalVarInfo { - kind: CanonicalVarKind::Region, - }; - let cvar = self.canonical_var(info, Kind::from(r)); - self.tcx().mk_region(ty::ReCanonical(cvar)) + self.canonicalize_region(r) } else { r } @@ -764,6 +757,14 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> { self.tcx().mk_infer(ty::InferTy::CanonicalTy(cvar)) } } + + fn canonicalize_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { + let info = CanonicalVarInfo { + kind: CanonicalVarKind::Region, + }; + let cvar = self.canonical_var(info, Kind::from(r)); + self.tcx().mk_region(ty::ReCanonical(cvar)) + } } impl<'tcx, V> Canonical<'tcx, V> {