Skip to content

Commit 7439028

Browse files
committed
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.
1 parent 6e01157 commit 7439028

File tree

5 files changed

+4
-11
lines changed

5 files changed

+4
-11
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
363363
opportunistically resolved to {:?}",
364364
vid, resolved_vid
365365
);
366-
let r = self.tcx.reuse_or_mk_region(r, ty::ReVar(resolved_vid));
366+
let r = self.tcx.mk_region(ty::ReVar(resolved_vid));
367367
self.canonicalize_mode.canonicalize_free_region(self, r)
368368
}
369369

compiler/rustc_infer/src/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
651651
let unified_region = self.unification_table().probe_value(rid);
652652
unified_region.0.unwrap_or_else(|| {
653653
let root = self.unification_table().find(rid).vid;
654-
tcx.reuse_or_mk_region(region, ty::ReVar(root))
654+
tcx.mk_region(ty::ReVar(root))
655655
})
656656
}
657657
_ => region,

compiler/rustc_infer/src/infer/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
9595
.borrow_mut()
9696
.unwrap_region_constraints()
9797
.opportunistic_resolve_var(rid);
98-
TypeFolder::interner(self).reuse_or_mk_region(r, ty::ReVar(resolved))
98+
TypeFolder::interner(self).mk_region(ty::ReVar(resolved))
9999
}
100100
_ => r,
101101
}

compiler/rustc_middle/src/ty/context.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1631,13 +1631,6 @@ impl<'tcx> TyCtxt<'tcx> {
16311631
})
16321632
}
16331633

1634-
/// Same a `self.mk_region(kind)`, but avoids accessing the interners if
1635-
/// `*r == kind`.
1636-
#[inline]
1637-
pub fn reuse_or_mk_region(self, r: Region<'tcx>, kind: RegionKind<'tcx>) -> Region<'tcx> {
1638-
if *r == kind { r } else { self.mk_region(kind) }
1639-
}
1640-
16411634
// Avoid this in favour of more specific `mk_*` methods, where possible.
16421635
#[allow(rustc::usage_of_ty_tykind)]
16431636
#[inline]

compiler/rustc_middle/src/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ where
234234
// debruijn index. Then we adjust it to the
235235
// correct depth.
236236
assert_eq!(debruijn1, ty::INNERMOST);
237-
self.tcx.reuse_or_mk_region(region, ty::ReLateBound(debruijn, br))
237+
self.tcx.mk_region(ty::ReLateBound(debruijn, br))
238238
} else {
239239
region
240240
}

0 commit comments

Comments
 (0)