Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f0edcc8

Browse files
committed
Remove index from BrAnon
1 parent e4edf00 commit f0edcc8

33 files changed

+68
-88
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13421342

13431343
let region_ctxt_fn = || {
13441344
let reg_info = match br.kind {
1345-
ty::BoundRegionKind::BrAnon(_, Some(span)) => {
1346-
BoundRegionInfo::Span(span)
1347-
}
1345+
ty::BoundRegionKind::BrAnon(Some(span)) => BoundRegionInfo::Span(span),
13481346
ty::BoundRegionKind::BrAnon(..) => {
13491347
BoundRegionInfo::Name(Symbol::intern("anon"))
13501348
}

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
124124
.placeholder_region(self.type_checker.infcx, placeholder);
125125

126126
let reg_info = match placeholder.bound.kind {
127-
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
127+
ty::BoundRegionKind::BrAnon(Some(span)) => BoundRegionInfo::Span(span),
128128
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
129129
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
130130
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
139139
let name_str = intrinsic_name.as_str();
140140

141141
let bound_vars = tcx.mk_bound_variable_kinds(&[
142-
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
142+
ty::BoundVariableKind::Region(ty::BrAnon(None)),
143143
ty::BoundVariableKind::Region(ty::BrEnv),
144144
]);
145145
let mk_va_list_ty = |mutbl| {
146146
tcx.lang_items().va_list().map(|did| {
147147
let region = tcx.mk_re_late_bound(
148148
ty::INNERMOST,
149-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(0, None) },
149+
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) },
150150
);
151151
let env_region = tcx.mk_re_late_bound(
152152
ty::INNERMOST,
@@ -387,8 +387,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
387387
);
388388
let discriminant_def_id = assoc_items[0];
389389

390-
let br =
391-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(0, None) };
390+
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) };
392391
(
393392
1,
394393
vec![tcx.mk_imm_ref(tcx.mk_re_late_bound(ty::INNERMOST, br), param(0))],
@@ -440,8 +439,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
440439
sym::nontemporal_store => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)], tcx.mk_unit()),
441440

442441
sym::raw_eq => {
443-
let br =
444-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(0, None) };
442+
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) };
445443
let param_ty = tcx.mk_imm_ref(tcx.mk_re_late_bound(ty::INNERMOST, br), param(0));
446444
(1, vec![param_ty; 2], tcx.types.bool)
447445
}

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub fn resolve_interior<'a, 'tcx>(
240240

241241
let mut counter = 0;
242242
let mut mk_bound_region = |span| {
243-
let kind = ty::BrAnon(counter, span);
243+
let kind = ty::BrAnon(span);
244244
let var = ty::BoundVar::from_u32(counter);
245245
counter += 1;
246246
ty::BoundRegion { var, kind }
@@ -263,7 +263,7 @@ pub fn resolve_interior<'a, 'tcx>(
263263
}
264264
ty::ReLateBound(_, ty::BoundRegion { kind, .. })
265265
| ty::ReFree(ty::FreeRegion { bound_region: kind, .. }) => match kind {
266-
ty::BoundRegionKind::BrAnon(_, span) => mk_bound_region(span),
266+
ty::BoundRegionKind::BrAnon(span) => mk_bound_region(span),
267267
ty::BoundRegionKind::BrNamed(def_id, _) => {
268268
mk_bound_region(Some(fcx.tcx.def_span(def_id)))
269269
}
@@ -294,7 +294,7 @@ pub fn resolve_interior<'a, 'tcx>(
294294
FnMutDelegate {
295295
regions: &mut |br| {
296296
let kind = match br.kind {
297-
ty::BrAnon(_, span) => ty::BrAnon(counter, span),
297+
ty::BrAnon(span) => ty::BrAnon(span),
298298
_ => br.kind,
299299
};
300300
let var = ty::BoundVar::from_usize(bound_vars.len());

compiler/rustc_infer/src/errors/note_and_explain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a> DescriptionCtx<'a> {
9090
};
9191
me.span = Some(sp);
9292
}
93-
ty::BrAnon(_, span) => {
93+
ty::BrAnon(span) => {
9494
me.kind = "defined_here";
9595
me.span = match span {
9696
Some(_) => span,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
772772
r: ty::Region<'tcx>,
773773
) -> ty::Region<'tcx> {
774774
let var = self.canonical_var(info, r.into());
775-
let br = ty::BoundRegion { var, kind: ty::BrAnon(var.as_u32(), None) };
775+
let br = ty::BoundRegion { var, kind: ty::BrAnon(None) };
776776
self.interner().mk_re_late_bound(self.binder_index, br)
777777
}
778778

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ fn msg_span_from_named_region<'tcx>(
174174
..
175175
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
176176
ty::RePlaceholder(ty::PlaceholderRegion {
177-
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, Some(span)), .. },
177+
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(Some(span)), .. },
178178
..
179179
}) => (format!("the anonymous lifetime defined here"), Some(span)),
180180
ty::RePlaceholder(ty::PlaceholderRegion {
181-
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, None), .. },
181+
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(None), .. },
182182
..
183183
}) => (format!("an anonymous lifetime"), None),
184184
_ => bug!("{:?}", region),
@@ -226,7 +226,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
226226
};
227227
(text, sp)
228228
}
229-
ty::BrAnon(_, span) => (
229+
ty::BrAnon(span) => (
230230
"the anonymous lifetime as defined here".to_string(),
231231
match span {
232232
Some(span) => span,

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
3636
ty::BrNamed(def_id, symbol) => {
3737
(Some(self.tcx().def_span(def_id)), Some(symbol))
3838
}
39-
ty::BrAnon(_, span) => (*span, None),
39+
ty::BrAnon(span) => (*span, None),
4040
ty::BrEnv => (None, None),
4141
};
4242
let (sup_span, sup_symbol) = match sup_name {
4343
ty::BrNamed(def_id, symbol) => {
4444
(Some(self.tcx().def_span(def_id)), Some(symbol))
4545
}
46-
ty::BrAnon(_, span) => (*span, None),
46+
ty::BrAnon(span) => (*span, None),
4747
ty::BrEnv => (None, None),
4848
};
4949
let diag = match (sub_span, sup_span, sub_symbol, sup_symbol) {

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
411411
CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => {
412412
let br = ty::BoundRegion {
413413
var: ty::BoundVar::from_usize(i),
414-
kind: ty::BrAnon(i as u32, None),
414+
kind: ty::BrAnon(None),
415415
};
416416
tcx.mk_re_late_bound(ty::INNERMOST, br).into()
417417
}

compiler/rustc_middle/src/mir/query.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,8 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
411411
pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self {
412412
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
413413
ty::ReVar(vid) => {
414-
let br = ty::BoundRegion {
415-
var: ty::BoundVar::new(vid.index()),
416-
kind: ty::BrAnon(vid.as_u32(), None),
417-
};
414+
let br =
415+
ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon(None) };
418416
tcx.mk_re_late_bound(depth, br)
419417
}
420418
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),

0 commit comments

Comments
 (0)