diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index ac8349e4c3a..b4f2ad0bb34 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -2139,7 +2139,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>( universe: ty::UniverseIndex::ROOT, bound: ty::BoundTy { var: ty::BoundVar::from_u32(idx), - kind: ty::BoundTyKind::Anon(idx), + kind: ty::BoundTyKind::Anon, }, }) } else { diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index b5c2bc60952..203e16bea27 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -389,9 +389,7 @@ impl<'tcx> TyCtxt<'tcx> { let index = entry.index(); let var = ty::BoundVar::from_usize(index); let kind = entry - .or_insert_with(|| { - ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon(index as u32)) - }) + .or_insert_with(|| ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon)) .expect_ty(); self.tcx.mk_bound(ty::INNERMOST, BoundTy { var, kind }) } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index fb681f1114d..bc0ccc1ebc3 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -701,9 +701,7 @@ pub trait PrettyPrinter<'tcx>: ty::Error(_) => p!("[type error]"), ty::Param(ref param_ty) => p!(print(param_ty)), ty::Bound(debruijn, bound_ty) => match bound_ty.kind { - ty::BoundTyKind::Anon(bv) => { - self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))? - } + ty::BoundTyKind::Anon => self.pretty_print_bound_var(debruijn, bound_ty.var)?, ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() { true if debruijn == ty::INNERMOST => p!(write("^{}", s)), true => p!(write("^{}_{}", debruijn.index(), s)), @@ -740,7 +738,7 @@ pub trait PrettyPrinter<'tcx>: } } ty::Placeholder(placeholder) => match placeholder.bound.kind { - ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)), + ty::BoundTyKind::Anon => p!(write("Placeholder({:?})", placeholder)), ty::BoundTyKind::Param(_, name) => p!(write("{}", name)), }, ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 7e526e631ce..d542d93b8c8 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1524,13 +1524,13 @@ pub struct BoundTy { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable)] pub enum BoundTyKind { - Anon(u32), + Anon, Param(DefId, Symbol), } impl From for BoundTy { fn from(var: BoundVar) -> Self { - BoundTy { var, kind: BoundTyKind::Anon(var.as_u32()) } + BoundTy { var, kind: BoundTyKind::Anon } } } diff --git a/compiler/rustc_trait_selection/src/solve/canonicalize.rs b/compiler/rustc_trait_selection/src/solve/canonicalize.rs index 60d96e28cd3..55025e2e72b 100644 --- a/compiler/rustc_trait_selection/src/solve/canonicalize.rs +++ b/compiler/rustc_trait_selection/src/solve/canonicalize.rs @@ -302,7 +302,7 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { universe: placeholder.universe, bound: ty::BoundTy { var: ty::BoundVar::from_usize(self.variables.len()), - kind: ty::BoundTyKind::Anon(self.variables.len() as u32), + kind: ty::BoundTyKind::Anon, }, }), CanonicalizeMode::Response { .. } => CanonicalVarKind::PlaceholderTy(placeholder), @@ -312,7 +312,7 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { universe: ty::UniverseIndex::ROOT, bound: ty::BoundTy { var: ty::BoundVar::from_usize(self.variables.len()), - kind: ty::BoundTyKind::Anon(self.variables.len() as u32), + kind: ty::BoundTyKind::Anon, }, }), CanonicalizeMode::Response { .. } => bug!("param ty in response: {t:?}"), @@ -351,7 +351,7 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { var }), ); - let bt = ty::BoundTy { var, kind: BoundTyKind::Anon(var.index() as u32) }; + let bt = ty::BoundTy { var, kind: BoundTyKind::Anon }; self.interner().mk_bound(self.binder_index, bt) } diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs index 4a3b7e42bac..9e851b788a5 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs @@ -95,17 +95,15 @@ fn replace_erased_lifetimes_with_bound_vars<'tcx>( let mut counter = 0; let ty = tcx.fold_regions(ty, |mut r, current_depth| { if let ty::ReErased = r.kind() { - let br = ty::BoundRegion { - var: ty::BoundVar::from_u32(counter), - kind: ty::BrAnon(counter, None), - }; + let br = + ty::BoundRegion { var: ty::BoundVar::from_u32(counter), kind: ty::BrAnon(None) }; counter += 1; r = tcx.mk_re_late_bound(current_depth, br); } r }); let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - (0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))), + (0..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon(None))), ); ty::Binder::bind_with_vars(ty, bound_vars) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 373082d8092..2be72879b7b 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -479,14 +479,14 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { ty::DebruijnIndex::from_usize(bound.debruijn.depth() as usize), ty::BoundTy { var: ty::BoundVar::from_usize(bound.index), - kind: ty::BoundTyKind::Anon(bound.index as u32), + kind: ty::BoundTyKind::Anon, }, ), TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder { universe: ty::UniverseIndex::from_usize(placeholder.ui.counter), bound: ty::BoundTy { var: ty::BoundVar::from_usize(placeholder.idx), - kind: ty::BoundTyKind::Anon(placeholder.idx as u32), + kind: ty::BoundTyKind::Anon, }, }), TyKind::InferenceVar(_, _) => unimplemented!(), @@ -691,7 +691,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders TypeFolder> for ParamsSubstitutor<'tcx> { universe: ty::UniverseIndex::from_usize(0), bound: ty::BoundTy { var: ty::BoundVar::from_usize(idx), - kind: ty::BoundTyKind::Anon(idx as u32), + kind: ty::BoundTyKind::Anon, }, }), None => { @@ -1109,7 +1109,7 @@ impl<'tcx> TypeFolder> for ParamsSubstitutor<'tcx> { universe: ty::UniverseIndex::from_usize(0), bound: ty::BoundTy { var: ty::BoundVar::from_usize(idx), - kind: ty::BoundTyKind::Anon(idx as u32), + kind: ty::BoundTyKind::Anon, }, }) }