Skip to content

Commit 167b706

Browse files
committed
Remove expect_anon and expect_anon_placeholder in favor of var
1 parent 4646b3d commit 167b706

File tree

4 files changed

+12
-34
lines changed

4 files changed

+12
-34
lines changed

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,15 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
149149
}
150150
}
151151

152-
pub fn expect_anon_placeholder(self) -> u32 {
152+
pub fn expect_placeholder_index(self) -> usize {
153153
match self.kind {
154154
CanonicalVarKind::Ty(_)
155155
| CanonicalVarKind::Region(_)
156156
| CanonicalVarKind::Const(_, _) => bug!("expected placeholder: {self:?}"),
157157

158-
CanonicalVarKind::PlaceholderRegion(placeholder) => {
159-
placeholder.bound.kind.expect_anon()
160-
}
161-
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.bound.kind.expect_anon(),
162-
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.bound.as_u32(),
158+
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.bound.var.as_usize(),
159+
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.bound.var.as_usize(),
160+
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.bound.as_usize(),
163161
}
164162
}
165163
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ impl BoundRegionKind {
107107
_ => None,
108108
}
109109
}
110-
111-
pub fn expect_anon(&self) -> u32 {
112-
match *self {
113-
BoundRegionKind::BrNamed(_, _) | BoundRegionKind::BrEnv => {
114-
bug!("expected anon region: {self:?}")
115-
}
116-
BoundRegionKind::BrAnon(idx, _) => idx,
117-
}
118-
}
119110
}
120111

121112
pub trait Article {
@@ -1537,15 +1528,6 @@ pub enum BoundTyKind {
15371528
Param(DefId, Symbol),
15381529
}
15391530

1540-
impl BoundTyKind {
1541-
pub fn expect_anon(self) -> u32 {
1542-
match self {
1543-
BoundTyKind::Anon(i) => i,
1544-
_ => bug!(),
1545-
}
1546-
}
1547-
}
1548-
15491531
impl From<BoundVar> for BoundTy {
15501532
fn from(var: BoundVar) -> Self {
15511533
BoundTy { var, kind: BoundTyKind::Anon(var.as_u32()) }

compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
188188
} else {
189189
// For placeholders which were already part of the input, we simply map this
190190
// universal bound variable back the placeholder of the input.
191-
original_values[info.expect_anon_placeholder() as usize]
191+
original_values[info.expect_placeholder_index()]
192192
}
193193
},
194194
));

compiler/rustc_traits/src/chalk/lowering.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,13 +1168,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> {
11681168

11691169
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
11701170
match *t.kind() {
1171-
ty::Placeholder(ty::PlaceholderType {
1172-
universe: ty::UniverseIndex::ROOT,
1173-
bound: ty::BoundTy { kind: name, .. },
1174-
}) => match self.params.get(&name.expect_anon()) {
1175-
Some(&ty::ParamTy { index, name }) => self.tcx.mk_ty_param(index, name),
1176-
None => t,
1177-
},
1171+
ty::Placeholder(ty::PlaceholderType { universe: ty::UniverseIndex::ROOT, bound }) => {
1172+
match self.params.get(&bound.var.as_u32()) {
1173+
Some(&ty::ParamTy { index, name }) => self.tcx.mk_ty_param(index, name),
1174+
None => t,
1175+
}
1176+
}
11781177

11791178
_ => t.super_fold_with(self),
11801179
}
@@ -1202,8 +1201,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlaceholdersCollector {
12021201
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
12031202
match t.kind() {
12041203
ty::Placeholder(p) if p.universe == self.universe_index => {
1205-
self.next_ty_placeholder =
1206-
self.next_ty_placeholder.max(p.bound.kind.expect_anon() as usize + 1);
1204+
self.next_ty_placeholder = self.next_ty_placeholder.max(p.bound.var.as_usize() + 1);
12071205
}
12081206

12091207
_ => (),

0 commit comments

Comments
 (0)