diff options
| author | Jack Huey <jack.huey@umassmed.edu> | 2021-05-15 12:10:56 -0400 |
|---|---|---|
| committer | Jack Huey <jack.huey@umassmed.edu> | 2021-05-15 12:10:56 -0400 |
| commit | fb6cec440a920c06eebea65c117dbc604899975e (patch) | |
| tree | aad60de6eddcf75d81c25ea137f464ba1990688c /compiler/rustc_infer/src/infer | |
| parent | 61157b341eab1b555cb5bd099e030817e6d41ba1 (diff) | |
| download | rust-fb6cec440a920c06eebea65c117dbc604899975e.tar.gz rust-fb6cec440a920c06eebea65c117dbc604899975e.zip | |
Revert to only using opportunistic_resolve_vars for existing places
Diffstat (limited to 'compiler/rustc_infer/src/infer')
| -rw-r--r-- | compiler/rustc_infer/src/infer/canonical/canonicalizer.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/region_constraints/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/resolve.rs | 18 |
3 files changed, 33 insertions, 9 deletions
diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 27ac817463f..337b8365d8c 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -322,7 +322,22 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { } } - ty::ReVar(_) => self.canonicalize_region_mode.canonicalize_free_region(self, r), + ty::ReVar(vid) => { + let resolved_vid = self + .infcx + .unwrap() + .inner + .borrow_mut() + .unwrap_region_constraints() + .opportunistic_resolve_var(vid); + debug!( + "canonical: region var found with vid {:?}, \ + opportunistically resolved to {:?}", + vid, r + ); + let r = self.tcx.reuse_or_mk_region(r, ty::ReVar(resolved_vid)); + self.canonicalize_region_mode.canonicalize_free_region(self, r) + } ty::ReStatic | ty::ReEarlyBound(..) diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index dfbb82bd657..d46a91b6a77 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -623,6 +623,10 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { } } + pub fn opportunistic_resolve_var(&mut self, rid: ty::RegionVid) -> ty::RegionVid { + self.unification_table().find(rid).vid + } + pub fn opportunistic_resolve_region( &mut self, tcx: TyCtxt<'tcx>, @@ -692,8 +696,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { &self, value_count: usize, ) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) { - let range = RegionVid::from(value_count as u32) - ..RegionVid::from(self.unification_table.len() as u32); + let range = RegionVid::from(value_count)..RegionVid::from(self.unification_table.len()); ( range.clone(), (range.start.index()..range.end.index()) diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index 4eec65b3d96..48b8ee17594 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -84,12 +84,18 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> { } fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - let tcx = self.tcx(); - self.infcx - .inner - .borrow_mut() - .unwrap_region_constraints() - .opportunistic_resolve_region(tcx, r) + match *r { + ty::ReVar(rid) => { + let resolved = self + .infcx + .inner + .borrow_mut() + .unwrap_region_constraints() + .opportunistic_resolve_var(rid); + self.tcx().reuse_or_mk_region(r, ty::ReVar(resolved)) + } + _ => r, + } } fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { |
