Skip to content

Commit bc64bfd

Browse files
committed
Tweak bound region pre-interning.
- Cover `DebruijnIndex(2)`, for slightly better coverage. - Rename some things, to account for other region things that were renamed.
1 parent e05ab47 commit bc64bfd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,8 @@ const NUM_PREINTERNED_FRESH_FLOAT_TYS: u32 = 3;
10441044

10451045
// This number may seem high, but it is reached in all but the smallest crates.
10461046
const NUM_PREINTERNED_RE_VARS: u32 = 500;
1047-
const NUM_PREINTERNED_RE_LATE_BOUNDS_I: u32 = 2;
1048-
const NUM_PREINTERNED_RE_LATE_BOUNDS_V: u32 = 20;
1047+
const NUM_PREINTERNED_ANON_RE_BOUNDS_I: u32 = 3;
1048+
const NUM_PREINTERNED_ANON_RE_BOUNDS_V: u32 = 20;
10491049

10501050
pub struct CommonTypes<'tcx> {
10511051
pub unit: Ty<'tcx>,
@@ -1101,9 +1101,9 @@ pub struct CommonLifetimes<'tcx> {
11011101
pub re_vars: Vec<Region<'tcx>>,
11021102

11031103
/// Pre-interned values of the form:
1104-
/// `ReBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon })`
1104+
/// `ReBound(DebruijnIndex(i), BoundRegion { var: v, kind: BoundRegionKind::Anon })`
11051105
/// for small values of `i` and `v`.
1106-
pub re_late_bounds: Vec<Vec<Region<'tcx>>>,
1106+
pub anon_re_bounds: Vec<Vec<Region<'tcx>>>,
11071107
}
11081108

11091109
pub struct CommonConsts<'tcx> {
@@ -1176,9 +1176,9 @@ impl<'tcx> CommonLifetimes<'tcx> {
11761176
let re_vars =
11771177
(0..NUM_PREINTERNED_RE_VARS).map(|n| mk(ty::ReVar(ty::RegionVid::from(n)))).collect();
11781178

1179-
let re_late_bounds = (0..NUM_PREINTERNED_RE_LATE_BOUNDS_I)
1179+
let anon_re_bounds = (0..NUM_PREINTERNED_ANON_RE_BOUNDS_I)
11801180
.map(|i| {
1181-
(0..NUM_PREINTERNED_RE_LATE_BOUNDS_V)
1181+
(0..NUM_PREINTERNED_ANON_RE_BOUNDS_V)
11821182
.map(|v| {
11831183
mk(ty::ReBound(
11841184
ty::DebruijnIndex::from(i),
@@ -1196,7 +1196,7 @@ impl<'tcx> CommonLifetimes<'tcx> {
11961196
re_static: mk(ty::ReStatic),
11971197
re_erased: mk(ty::ReErased),
11981198
re_vars,
1199-
re_late_bounds,
1199+
anon_re_bounds,
12001200
}
12011201
}
12021202
}

compiler/rustc_middle/src/ty/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> Region<'tcx> {
5454
) -> Region<'tcx> {
5555
// Use a pre-interned one when possible.
5656
if let ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon } = bound_region
57-
&& let Some(inner) = tcx.lifetimes.re_late_bounds.get(debruijn.as_usize())
57+
&& let Some(inner) = tcx.lifetimes.anon_re_bounds.get(debruijn.as_usize())
5858
&& let Some(re) = inner.get(var.as_usize()).copied()
5959
{
6060
re

0 commit comments

Comments
 (0)