Revert to only using opportunistic_resolve_vars for existing places
This commit is contained in:
parent
61157b341e
commit
fb6cec440a
12 changed files with 47 additions and 94 deletions
|
@ -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(..)
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue