mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Remove u32 on BoundTyKind::Anon
This commit is contained in:
parent
f0edcc8a6f
commit
b15195a304
@ -2139,7 +2139,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
|||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_u32(idx),
|
var: ty::BoundVar::from_u32(idx),
|
||||||
kind: ty::BoundTyKind::Anon(idx),
|
kind: ty::BoundTyKind::Anon,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -389,9 +389,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
let index = entry.index();
|
let index = entry.index();
|
||||||
let var = ty::BoundVar::from_usize(index);
|
let var = ty::BoundVar::from_usize(index);
|
||||||
let kind = entry
|
let kind = entry
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon))
|
||||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon(index as u32))
|
|
||||||
})
|
|
||||||
.expect_ty();
|
.expect_ty();
|
||||||
self.tcx.mk_bound(ty::INNERMOST, BoundTy { var, kind })
|
self.tcx.mk_bound(ty::INNERMOST, BoundTy { var, kind })
|
||||||
}
|
}
|
||||||
|
@ -701,9 +701,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
ty::Error(_) => p!("[type error]"),
|
ty::Error(_) => p!("[type error]"),
|
||||||
ty::Param(ref param_ty) => p!(print(param_ty)),
|
ty::Param(ref param_ty) => p!(print(param_ty)),
|
||||||
ty::Bound(debruijn, bound_ty) => match bound_ty.kind {
|
ty::Bound(debruijn, bound_ty) => match bound_ty.kind {
|
||||||
ty::BoundTyKind::Anon(bv) => {
|
ty::BoundTyKind::Anon => self.pretty_print_bound_var(debruijn, bound_ty.var)?,
|
||||||
self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))?
|
|
||||||
}
|
|
||||||
ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() {
|
ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() {
|
||||||
true if debruijn == ty::INNERMOST => p!(write("^{}", s)),
|
true if debruijn == ty::INNERMOST => p!(write("^{}", s)),
|
||||||
true => p!(write("^{}_{}", debruijn.index(), s)),
|
true => p!(write("^{}_{}", debruijn.index(), s)),
|
||||||
@ -740,7 +738,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Placeholder(placeholder) => match placeholder.bound.kind {
|
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::BoundTyKind::Param(_, name) => p!(write("{}", name)),
|
||||||
},
|
},
|
||||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
||||||
|
@ -1524,13 +1524,13 @@ pub struct BoundTy {
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub enum BoundTyKind {
|
pub enum BoundTyKind {
|
||||||
Anon(u32),
|
Anon,
|
||||||
Param(DefId, Symbol),
|
Param(DefId, Symbol),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BoundVar> for BoundTy {
|
impl From<BoundVar> for BoundTy {
|
||||||
fn from(var: BoundVar) -> Self {
|
fn from(var: BoundVar) -> Self {
|
||||||
BoundTy { var, kind: BoundTyKind::Anon(var.as_u32()) }
|
BoundTy { var, kind: BoundTyKind::Anon }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||||||
universe: placeholder.universe,
|
universe: placeholder.universe,
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(self.variables.len()),
|
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),
|
CanonicalizeMode::Response { .. } => CanonicalVarKind::PlaceholderTy(placeholder),
|
||||||
@ -312,7 +312,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(self.variables.len()),
|
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:?}"),
|
CanonicalizeMode::Response { .. } => bug!("param ty in response: {t:?}"),
|
||||||
@ -351,7 +351,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||||||
var
|
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)
|
self.interner().mk_bound(self.binder_index, bt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,17 +95,15 @@ fn replace_erased_lifetimes_with_bound_vars<'tcx>(
|
|||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
let ty = tcx.fold_regions(ty, |mut r, current_depth| {
|
let ty = tcx.fold_regions(ty, |mut r, current_depth| {
|
||||||
if let ty::ReErased = r.kind() {
|
if let ty::ReErased = r.kind() {
|
||||||
let br = ty::BoundRegion {
|
let br =
|
||||||
var: ty::BoundVar::from_u32(counter),
|
ty::BoundRegion { var: ty::BoundVar::from_u32(counter), kind: ty::BrAnon(None) };
|
||||||
kind: ty::BrAnon(counter, None),
|
|
||||||
};
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
r = tcx.mk_re_late_bound(current_depth, br);
|
r = tcx.mk_re_late_bound(current_depth, br);
|
||||||
}
|
}
|
||||||
r
|
r
|
||||||
});
|
});
|
||||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
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)
|
ty::Binder::bind_with_vars(ty, bound_vars)
|
||||||
}
|
}
|
||||||
|
@ -479,14 +479,14 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
|||||||
ty::DebruijnIndex::from_usize(bound.debruijn.depth() as usize),
|
ty::DebruijnIndex::from_usize(bound.debruijn.depth() as usize),
|
||||||
ty::BoundTy {
|
ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(bound.index),
|
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 {
|
TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
|
||||||
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(placeholder.idx),
|
var: ty::BoundVar::from_usize(placeholder.idx),
|
||||||
kind: ty::BoundTyKind::Anon(placeholder.idx as u32),
|
kind: ty::BoundTyKind::Anon,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
TyKind::InferenceVar(_, _) => unimplemented!(),
|
TyKind::InferenceVar(_, _) => unimplemented!(),
|
||||||
@ -691,7 +691,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
|
|||||||
let self_ty = interner.tcx.mk_bound(
|
let self_ty = interner.tcx.mk_bound(
|
||||||
// This is going to be wrapped in a binder
|
// This is going to be wrapped in a binder
|
||||||
ty::DebruijnIndex::from_usize(1),
|
ty::DebruijnIndex::from_usize(1),
|
||||||
ty::BoundTy { var: ty::BoundVar::from_usize(0), kind: ty::BoundTyKind::Anon(0) },
|
ty::BoundTy { var: ty::BoundVar::from_usize(0), kind: ty::BoundTyKind::Anon },
|
||||||
);
|
);
|
||||||
let where_clauses = predicates.into_iter().map(|predicate| {
|
let where_clauses = predicates.into_iter().map(|predicate| {
|
||||||
let (predicate, binders, _named_regions) =
|
let (predicate, binders, _named_regions) =
|
||||||
@ -1098,7 +1098,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
|
|||||||
universe: ty::UniverseIndex::from_usize(0),
|
universe: ty::UniverseIndex::from_usize(0),
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(idx),
|
var: ty::BoundVar::from_usize(idx),
|
||||||
kind: ty::BoundTyKind::Anon(idx as u32),
|
kind: ty::BoundTyKind::Anon,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
None => {
|
None => {
|
||||||
@ -1109,7 +1109,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
|
|||||||
universe: ty::UniverseIndex::from_usize(0),
|
universe: ty::UniverseIndex::from_usize(0),
|
||||||
bound: ty::BoundTy {
|
bound: ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(idx),
|
var: ty::BoundVar::from_usize(idx),
|
||||||
kind: ty::BoundTyKind::Anon(idx as u32),
|
kind: ty::BoundTyKind::Anon,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user