Skip to content

Commit 86fa131

Browse files
committed
rename ReLateBound to ReBound
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
1 parent 28328c8 commit 86fa131

File tree

80 files changed

+192
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+192
-195
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
462462
// lifetimes without names with the value `'0`.
463463
if let ty::Ref(region, ..) = ty.kind() {
464464
match **region {
465-
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
465+
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
466466
| ty::RePlaceholder(ty::PlaceholderRegion {
467467
bound: ty::BoundRegion { kind: br, .. },
468468
..
@@ -482,7 +482,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
482482

483483
let region = if let ty::Ref(region, ..) = ty.kind() {
484484
match **region {
485-
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
485+
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
486486
| ty::RePlaceholder(ty::PlaceholderRegion {
487487
bound: ty::BoundRegion { kind: br, .. },
488488
..

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
357357
ty::BoundRegionKind::BrAnon => None,
358358
},
359359

360-
ty::ReLateBound(..)
360+
ty::ReBound(..)
361361
| ty::ReVar(..)
362362
| ty::RePlaceholder(..)
363363
| ty::ReErased

compiler/rustc_borrowck/src/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
665665
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
666666
kind: ty::BrEnv,
667667
};
668-
let env_region = ty::Region::new_late_bound(tcx, ty::INNERMOST, br);
668+
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
669669
let closure_ty = tcx.closure_env_ty(def_id, args, env_region).unwrap();
670670

671671
// The "inputs" of the closure in the

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
350350
let args =
351351
candidate.skip_binder().args.extend_to(tcx, assoc_item.def_id, |param, _| {
352352
let subst = match param.kind {
353-
ty::GenericParamDefKind::Lifetime => ty::Region::new_late_bound(
353+
ty::GenericParamDefKind::Lifetime => ty::Region::new_bound(
354354
tcx,
355355
ty::INNERMOST,
356356
ty::BoundRegion {

compiler/rustc_hir_analysis/src/astconv/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
250250
var: ty::BoundVar::from_u32(index),
251251
kind: ty::BrNamed(def_id, name),
252252
};
253-
ty::Region::new_late_bound(tcx, debruijn, br)
253+
ty::Region::new_bound(tcx, debruijn, br)
254254
}
255255

256256
Some(rbv::ResolvedArg::EarlyBound(def_id)) => {
@@ -1622,7 +1622,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16221622
}
16231623

16241624
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
1625-
if r.is_late_bound() { self.tcx.lifetimes.re_erased } else { r }
1625+
// FIXME(@lcnr): This is broken, erasing bound regions
1626+
// impacts selection as it results in different types.
1627+
if r.is_bound() { self.tcx.lifetimes.re_erased } else { r }
16261628
}
16271629

16281630
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@ fn param_env_with_gat_bounds<'tcx>(
23452345
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
23462346
let bound_var = ty::BoundVariableKind::Region(kind);
23472347
bound_vars.push(bound_var);
2348-
ty::Region::new_late_bound(
2348+
ty::Region::new_bound(
23492349
tcx,
23502350
ty::INNERMOST,
23512351
ty::BoundRegion {

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
143143
]);
144144
let mk_va_list_ty = |mutbl| {
145145
tcx.lang_items().va_list().map(|did| {
146-
let region = ty::Region::new_late_bound(
146+
let region = ty::Region::new_bound(
147147
tcx,
148148
ty::INNERMOST,
149149
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
150150
);
151-
let env_region = ty::Region::new_late_bound(
151+
let env_region = ty::Region::new_bound(
152152
tcx,
153153
ty::INNERMOST,
154154
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrEnv },
@@ -411,7 +411,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
411411
1,
412412
vec![Ty::new_imm_ref(
413413
tcx,
414-
ty::Region::new_late_bound(tcx, ty::INNERMOST, br),
414+
ty::Region::new_bound(tcx, ty::INNERMOST, br),
415415
param(0),
416416
)],
417417
Ty::new_projection(tcx, discriminant_def_id, tcx.mk_args(&[param(0).into()])),
@@ -465,11 +465,8 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
465465

466466
sym::raw_eq => {
467467
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
468-
let param_ty = Ty::new_imm_ref(
469-
tcx,
470-
ty::Region::new_late_bound(tcx, ty::INNERMOST, br),
471-
param(0),
472-
);
468+
let param_ty =
469+
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
473470
(1, vec![param_ty; 2], tcx.types.bool)
474471
}
475472

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATSubstCollector<'tcx> {
763763
ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
764764
for (idx, subst) in p.args.iter().enumerate() {
765765
match subst.unpack() {
766-
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => {
766+
GenericArgKind::Lifetime(lt) if !lt.is_bound() => {
767767
self.regions.insert((lt, idx));
768768
}
769769
GenericArgKind::Type(t) => {

compiler/rustc_hir_analysis/src/hir_wf_check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
196196
self.tcx
197197
}
198198
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {
199-
if r.is_late_bound() { self.tcx.lifetimes.re_erased } else { r }
199+
// FIXME(@lcnr): only erase escaping bound regions!
200+
if r.is_bound() { self.tcx.lifetimes.re_erased } else { r }
200201
}
201202
}

compiler/rustc_hir_analysis/src/outlives/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ fn is_free_region(region: Region<'_>) -> bool {
167167
// }
168168
//
169169
// The type above might generate a `T: 'b` bound, but we can
170-
// ignore it. We can't put it on the struct header anyway.
171-
ty::ReLateBound(..) => false,
170+
// ignore it. We can't name this lifetime pn the struct header anyway.
171+
ty::ReBound(..) => false,
172172

173173
ty::ReError(_) => false,
174174

compiler/rustc_hir_analysis/src/variance/constraints.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
419419

420420
ty::ReStatic => {}
421421

422-
ty::ReLateBound(..) => {
423-
// Late-bound regions do not get substituted the same
424-
// way early-bound regions do, so we skip them here.
422+
ty::ReBound(..) => {
423+
// Either a higher-ranked region inside of a type or a
424+
// late-bound function parameter.
425+
//
426+
// We do not compute constraints for either of these.
425427
}
426428

427429
ty::ReError(_) => {}

compiler/rustc_hir_typeck/src/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
214214
// build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
215215
let panic_info_ty = tcx.type_of(panic_info_did).instantiate(
216216
tcx,
217-
&[ty::GenericArg::from(ty::Region::new_late_bound(
217+
&[ty::GenericArg::from(ty::Region::new_bound(
218218
tcx,
219219
ty::INNERMOST,
220220
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon },
221221
))],
222222
);
223223
let panic_info_ref_ty = Ty::new_imm_ref(
224224
tcx,
225-
ty::Region::new_late_bound(
225+
ty::Region::new_bound(
226226
tcx,
227227
ty::INNERMOST,
228228
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },

compiler/rustc_hir_typeck/src/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
784784
}
785785
}
786786
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
787-
if r.is_late_bound() { r } else { self.tcx.lifetimes.re_erased }
787+
if r.is_bound() { r } else { self.tcx.lifetimes.re_erased }
788788
}
789789
}
790790

@@ -822,7 +822,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
822822
}
823823

824824
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
825-
debug_assert!(!r.is_late_bound(), "Should not be resolving bound region.");
825+
debug_assert!(!r.is_bound(), "Should not be resolving bound region.");
826826
self.fcx.tcx.lifetimes.re_erased
827827
}
828828

compiler/rustc_infer/src/errors/note_and_explain.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ impl<'a> DescriptionCtx<'a> {
7373
// ReFree rather than dumping Debug output on the user.
7474
//
7575
// We shouldn't really be having unification failures with ReVar
76-
// and ReLateBound though.
77-
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => {
76+
// and ReBound though.
77+
//
78+
// FIXME(@lcnr): figure out why we `ReBound` have to handle `ReBound`
79+
// here, this feels somewhat off.
80+
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => {
7881
(alt_span, "revar", format!("{region:?}"))
7982
}
8083
};

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation {
232232
match *r {
233233
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r,
234234
ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r),
235-
ty::RePlaceholder(..) | ty::ReLateBound(..) => {
235+
ty::RePlaceholder(..) | ty::ReBound(..) => {
236236
// We only expect region names that the user can type.
237237
bug!("unexpected region in query response: `{:?}`", r)
238238
}
@@ -343,7 +343,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
343343

344344
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
345345
match *r {
346-
ty::ReLateBound(index, ..) => {
346+
ty::ReBound(index, ..) => {
347347
if index >= self.binder_index {
348348
bug!("escaping late-bound region during canonicalization");
349349
} else {
@@ -776,7 +776,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
776776
) -> ty::Region<'tcx> {
777777
let var = self.canonical_var(info, r.into());
778778
let br = ty::BoundRegion { var, kind: ty::BrAnon };
779-
ty::Region::new_late_bound(self.interner(), self.binder_index, br)
779+
ty::Region::new_bound(self.interner(), self.binder_index, br)
780780
}
781781

782782
/// Given a type variable `ty_var` of the given kind, first check

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'tcx> InferCtxt<'tcx> {
460460
}
461461
GenericArgKind::Lifetime(result_value) => {
462462
// e.g., here `result_value` might be `'?1` in the example above...
463-
if let ty::ReLateBound(debruijn, br) = *result_value {
463+
if let ty::ReBound(debruijn, br) = *result_value {
464464
// ... in which case we would set `canonical_vars[0]` to `Some('static)`.
465465

466466
// We only allow a `ty::INNERMOST` index in substitutions.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ pub(super) fn note_and_explain_region<'tcx>(
175175
ty::ReError(_) => return,
176176

177177
// We shouldn't really be having unification failures with ReVar
178-
// and ReLateBound though.
179-
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => {
180-
(format!("lifetime `{region}`"), alt_span)
181-
}
178+
// and ReBound though.
179+
//
180+
// FIXME(@lcnr): Figure out whether this is reachable and if so, why.
181+
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => (format!("lifetime `{region}`"), alt_span),
182182
};
183183

184184
emit_msg_span(err, prefix, description, span, suffix);
@@ -1285,7 +1285,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12851285
if lifetimes.0 != lifetimes.1 {
12861286
values.0.push_highlighted(l1);
12871287
values.1.push_highlighted(l2);
1288-
} else if lifetimes.0.is_late_bound() {
1288+
} else if lifetimes.0.is_bound() {
12891289
values.0.push_normal(l1);
12901290
values.1.push_normal(l2);
12911291
} else {

compiler/rustc_infer/src/infer/error_reporting/suggest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
572572

573573
if let ty::Ref(expected_region, _, _) = expected.kind()
574574
&& let ty::Ref(found_region, _, _) = found.kind()
575-
&& expected_region.is_late_bound()
576-
&& !found_region.is_late_bound()
575+
&& expected_region.is_bound()
576+
&& !found_region.is_bound()
577577
&& let hir::TyKind::Infer = arg_hir.kind
578578
{
579579
// If the expected region is late bound, the found region is not, and users are asking compiler

compiler/rustc_infer/src/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
110110

111111
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
112112
match *r {
113-
ty::ReLateBound(..) => {
113+
ty::ReBound(..) => {
114114
// leave bound regions alone
115115
r
116116
}

compiler/rustc_infer/src/infer/generalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ where
327327
match *r {
328328
// Never make variables for regions bound within the type itself,
329329
// nor for erased regions.
330-
ty::ReLateBound(..) | ty::ReErased => {
330+
ty::ReBound(..) | ty::ReErased => {
331331
return Ok(r);
332332
}
333333

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use rustc_data_structures::intern::Interned;
1616
use rustc_index::{IndexSlice, IndexVec};
1717
use rustc_middle::ty::fold::TypeFoldable;
1818
use rustc_middle::ty::{self, Ty, TyCtxt};
19+
use rustc_middle::ty::{ReBound, RePlaceholder, ReVar};
1920
use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic};
20-
use rustc_middle::ty::{ReLateBound, RePlaceholder, ReVar};
2121
use rustc_middle::ty::{Region, RegionVid};
2222
use rustc_span::Span;
2323
use std::fmt;
@@ -378,7 +378,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
378378
// so it doesn't really matter if it's shorter or longer than an empty region
379379
ReError(_) => false,
380380

381-
ReLateBound(..) | ReErased => {
381+
ReBound(..) | ReErased => {
382382
bug!("cannot relate region: {:?}", a);
383383
}
384384

@@ -411,7 +411,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
411411
// so it doesn't really matter if it's shorter or longer than an empty region
412412
ReError(_) => false,
413413

414-
ReLateBound(..) | ReErased => {
414+
ReBound(..) | ReErased => {
415415
bug!("cannot relate region: {:?}", b);
416416
}
417417

@@ -478,7 +478,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
478478
#[instrument(level = "trace", skip(self), ret)]
479479
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
480480
match (*a, *b) {
481-
(ReLateBound(..), _) | (_, ReLateBound(..)) | (ReErased, _) | (_, ReErased) => {
481+
(ReBound(..), _) | (_, ReBound(..)) | (ReErased, _) | (_, ReErased) => {
482482
bug!("cannot relate region: LUB({:?}, {:?})", a, b);
483483
}
484484

compiler/rustc_infer/src/infer/opaque_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ where
432432
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
433433
match *r {
434434
// ignore bound regions, keep visiting
435-
ty::ReLateBound(_, _) => ControlFlow::Continue(()),
435+
ty::ReBound(_, _) => ControlFlow::Continue(()),
436436
_ => {
437437
(self.op)(r);
438438
ControlFlow::Continue(())

compiler/rustc_infer/src/infer/outlives/components.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ pub(super) fn compute_alias_components_recursive<'tcx>(
213213
compute_components(tcx, ty, out, visited);
214214
}
215215
GenericArgKind::Lifetime(lt) => {
216-
// Ignore late-bound regions.
217-
if !lt.is_late_bound() {
216+
// Ignore higher ranked regions.
217+
if !lt.is_bound() {
218218
out.push(Component::Region(lt));
219219
}
220220
}
@@ -241,8 +241,8 @@ fn compute_components_recursive<'tcx>(
241241
compute_components(tcx, ty, out, visited);
242242
}
243243
GenericArgKind::Lifetime(lt) => {
244-
// Ignore late-bound regions.
245-
if !lt.is_late_bound() {
244+
// Ignore higher ranked regions.
245+
if !lt.is_bound() {
246246
out.push(Component::Region(lt));
247247
}
248248
}

compiler/rustc_infer/src/infer/outlives/for_liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
3838
match *r {
3939
// ignore bound regions, keep visiting
40-
ty::ReLateBound(_, _) => ControlFlow::Continue(()),
40+
ty::ReBound(_, _) => ControlFlow::Continue(()),
4141
_ => {
4242
(self.op)(r);
4343
ControlFlow::Continue(())

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn extract_verify_if_eq<'tcx>(
4848
let verify_if_eq = verify_if_eq_b.skip_binder();
4949
m.relate(verify_if_eq.ty, test_ty).ok()?;
5050

51-
if let ty::RegionKind::ReLateBound(depth, br) = verify_if_eq.bound.kind() {
51+
if let ty::RegionKind::ReBound(depth, br) = verify_if_eq.bound.kind() {
5252
assert!(depth == ty::INNERMOST);
5353
match m.map.get(&br) {
5454
Some(&r) => Some(r),
@@ -177,7 +177,7 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
177177
value: ty::Region<'tcx>,
178178
) -> RelateResult<'tcx, ty::Region<'tcx>> {
179179
debug!("self.pattern_depth = {:?}", self.pattern_depth);
180-
if let ty::RegionKind::ReLateBound(depth, br) = pattern.kind()
180+
if let ty::RegionKind::ReBound(depth, br) = pattern.kind()
181181
&& depth == self.pattern_depth
182182
{
183183
self.bind(br, value)

0 commit comments

Comments
 (0)