Remove reuse_or_mk_region.

It's not used on any hot paths, and so has little perf benefit, and it
interferes with the optimizations in the following commits.
This commit is contained in:
Nicholas Nethercote 2023-02-13 13:44:56 +11:00
parent 6e0115778b
commit 7439028374
5 changed files with 4 additions and 11 deletions

View File

@ -363,7 +363,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
opportunistically resolved to {:?}",
vid, resolved_vid
);
let r = self.tcx.reuse_or_mk_region(r, ty::ReVar(resolved_vid));
let r = self.tcx.mk_region(ty::ReVar(resolved_vid));
self.canonicalize_mode.canonicalize_free_region(self, r)
}

View File

@ -651,7 +651,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
let unified_region = self.unification_table().probe_value(rid);
unified_region.0.unwrap_or_else(|| {
let root = self.unification_table().find(rid).vid;
tcx.reuse_or_mk_region(region, ty::ReVar(root))
tcx.mk_region(ty::ReVar(root))
})
}
_ => region,

View File

@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(rid);
TypeFolder::interner(self).reuse_or_mk_region(r, ty::ReVar(resolved))
TypeFolder::interner(self).mk_region(ty::ReVar(resolved))
}
_ => r,
}

View File

@ -1631,13 +1631,6 @@ impl<'tcx> TyCtxt<'tcx> {
})
}
/// Same a `self.mk_region(kind)`, but avoids accessing the interners if
/// `*r == kind`.
#[inline]
pub fn reuse_or_mk_region(self, r: Region<'tcx>, kind: RegionKind<'tcx>) -> Region<'tcx> {
if *r == kind { r } else { self.mk_region(kind) }
}
// Avoid this in favour of more specific `mk_*` methods, where possible.
#[allow(rustc::usage_of_ty_tykind)]
#[inline]

View File

@ -234,7 +234,7 @@ where
// debruijn index. Then we adjust it to the
// correct depth.
assert_eq!(debruijn1, ty::INNERMOST);
self.tcx.reuse_or_mk_region(region, ty::ReLateBound(debruijn, br))
self.tcx.mk_region(ty::ReLateBound(debruijn, br))
} else {
region
}