Skip to content

Commit b15195a

Browse files
committed
Remove u32 on BoundTyKind::Anon
1 parent f0edcc8 commit b15195a

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

compiler/rustc_infer/src/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
21392139
universe: ty::UniverseIndex::ROOT,
21402140
bound: ty::BoundTy {
21412141
var: ty::BoundVar::from_u32(idx),
2142-
kind: ty::BoundTyKind::Anon(idx),
2142+
kind: ty::BoundTyKind::Anon,
21432143
},
21442144
})
21452145
} else {

compiler/rustc_middle/src/ty/fold.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,7 @@ impl<'tcx> TyCtxt<'tcx> {
389389
let index = entry.index();
390390
let var = ty::BoundVar::from_usize(index);
391391
let kind = entry
392-
.or_insert_with(|| {
393-
ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon(index as u32))
394-
})
392+
.or_insert_with(|| ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon))
395393
.expect_ty();
396394
self.tcx.mk_bound(ty::INNERMOST, BoundTy { var, kind })
397395
}

compiler/rustc_middle/src/ty/print/pretty.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,7 @@ pub trait PrettyPrinter<'tcx>:
701701
ty::Error(_) => p!("[type error]"),
702702
ty::Param(ref param_ty) => p!(print(param_ty)),
703703
ty::Bound(debruijn, bound_ty) => match bound_ty.kind {
704-
ty::BoundTyKind::Anon(bv) => {
705-
self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))?
706-
}
704+
ty::BoundTyKind::Anon => self.pretty_print_bound_var(debruijn, bound_ty.var)?,
707705
ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() {
708706
true if debruijn == ty::INNERMOST => p!(write("^{}", s)),
709707
true => p!(write("^{}_{}", debruijn.index(), s)),
@@ -740,7 +738,7 @@ pub trait PrettyPrinter<'tcx>:
740738
}
741739
}
742740
ty::Placeholder(placeholder) => match placeholder.bound.kind {
743-
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
741+
ty::BoundTyKind::Anon => p!(write("Placeholder({:?})", placeholder)),
744742
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
745743
},
746744
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {

compiler/rustc_middle/src/ty/sty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1524,13 +1524,13 @@ pub struct BoundTy {
15241524
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
15251525
#[derive(HashStable)]
15261526
pub enum BoundTyKind {
1527-
Anon(u32),
1527+
Anon,
15281528
Param(DefId, Symbol),
15291529
}
15301530

15311531
impl From<BoundVar> for BoundTy {
15321532
fn from(var: BoundVar) -> Self {
1533-
BoundTy { var, kind: BoundTyKind::Anon(var.as_u32()) }
1533+
BoundTy { var, kind: BoundTyKind::Anon }
15341534
}
15351535
}
15361536

compiler/rustc_trait_selection/src/solve/canonicalize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
302302
universe: placeholder.universe,
303303
bound: ty::BoundTy {
304304
var: ty::BoundVar::from_usize(self.variables.len()),
305-
kind: ty::BoundTyKind::Anon(self.variables.len() as u32),
305+
kind: ty::BoundTyKind::Anon,
306306
},
307307
}),
308308
CanonicalizeMode::Response { .. } => CanonicalVarKind::PlaceholderTy(placeholder),
@@ -312,7 +312,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
312312
universe: ty::UniverseIndex::ROOT,
313313
bound: ty::BoundTy {
314314
var: ty::BoundVar::from_usize(self.variables.len()),
315-
kind: ty::BoundTyKind::Anon(self.variables.len() as u32),
315+
kind: ty::BoundTyKind::Anon,
316316
},
317317
}),
318318
CanonicalizeMode::Response { .. } => bug!("param ty in response: {t:?}"),
@@ -351,7 +351,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
351351
var
352352
}),
353353
);
354-
let bt = ty::BoundTy { var, kind: BoundTyKind::Anon(var.index() as u32) };
354+
let bt = ty::BoundTy { var, kind: BoundTyKind::Anon };
355355
self.interner().mk_bound(self.binder_index, bt)
356356
}
357357

compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,15 @@ fn replace_erased_lifetimes_with_bound_vars<'tcx>(
9595
let mut counter = 0;
9696
let ty = tcx.fold_regions(ty, |mut r, current_depth| {
9797
if let ty::ReErased = r.kind() {
98-
let br = ty::BoundRegion {
99-
var: ty::BoundVar::from_u32(counter),
100-
kind: ty::BrAnon(counter, None),
101-
};
98+
let br =
99+
ty::BoundRegion { var: ty::BoundVar::from_u32(counter), kind: ty::BrAnon(None) };
102100
counter += 1;
103101
r = tcx.mk_re_late_bound(current_depth, br);
104102
}
105103
r
106104
});
107105
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
108-
(0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))),
106+
(0..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon(None))),
109107
);
110108
ty::Binder::bind_with_vars(ty, bound_vars)
111109
}

compiler/rustc_traits/src/chalk/lowering.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,14 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
479479
ty::DebruijnIndex::from_usize(bound.debruijn.depth() as usize),
480480
ty::BoundTy {
481481
var: ty::BoundVar::from_usize(bound.index),
482-
kind: ty::BoundTyKind::Anon(bound.index as u32),
482+
kind: ty::BoundTyKind::Anon,
483483
},
484484
),
485485
TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
486486
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
487487
bound: ty::BoundTy {
488488
var: ty::BoundVar::from_usize(placeholder.idx),
489-
kind: ty::BoundTyKind::Anon(placeholder.idx as u32),
489+
kind: ty::BoundTyKind::Anon,
490490
},
491491
}),
492492
TyKind::InferenceVar(_, _) => unimplemented!(),
@@ -691,7 +691,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
691691
let self_ty = interner.tcx.mk_bound(
692692
// This is going to be wrapped in a binder
693693
ty::DebruijnIndex::from_usize(1),
694-
ty::BoundTy { var: ty::BoundVar::from_usize(0), kind: ty::BoundTyKind::Anon(0) },
694+
ty::BoundTy { var: ty::BoundVar::from_usize(0), kind: ty::BoundTyKind::Anon },
695695
);
696696
let where_clauses = predicates.into_iter().map(|predicate| {
697697
let (predicate, binders, _named_regions) =
@@ -1098,7 +1098,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
10981098
universe: ty::UniverseIndex::from_usize(0),
10991099
bound: ty::BoundTy {
11001100
var: ty::BoundVar::from_usize(idx),
1101-
kind: ty::BoundTyKind::Anon(idx as u32),
1101+
kind: ty::BoundTyKind::Anon,
11021102
},
11031103
}),
11041104
None => {
@@ -1109,7 +1109,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
11091109
universe: ty::UniverseIndex::from_usize(0),
11101110
bound: ty::BoundTy {
11111111
var: ty::BoundVar::from_usize(idx),
1112-
kind: ty::BoundTyKind::Anon(idx as u32),
1112+
kind: ty::BoundTyKind::Anon,
11131113
},
11141114
})
11151115
}

0 commit comments

Comments
 (0)