File tree 4 files changed +12
-34
lines changed
rustc_trait_selection/src/solve/eval_ctxt
4 files changed +12
-34
lines changed Original file line number Diff line number Diff line change @@ -149,17 +149,15 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
149
149
}
150
150
}
151
151
152
- pub fn expect_anon_placeholder ( self ) -> u32 {
152
+ pub fn expect_placeholder_index ( self ) -> usize {
153
153
match self . kind {
154
154
CanonicalVarKind :: Ty ( _)
155
155
| CanonicalVarKind :: Region ( _)
156
156
| CanonicalVarKind :: Const ( _, _) => bug ! ( "expected placeholder: {self:?}" ) ,
157
157
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 ( ) ,
163
161
}
164
162
}
165
163
}
Original file line number Diff line number Diff line change @@ -107,15 +107,6 @@ impl BoundRegionKind {
107
107
_ => None ,
108
108
}
109
109
}
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
- }
119
110
}
120
111
121
112
pub trait Article {
@@ -1537,15 +1528,6 @@ pub enum BoundTyKind {
1537
1528
Param ( DefId , Symbol ) ,
1538
1529
}
1539
1530
1540
- impl BoundTyKind {
1541
- pub fn expect_anon ( self ) -> u32 {
1542
- match self {
1543
- BoundTyKind :: Anon ( i) => i,
1544
- _ => bug ! ( ) ,
1545
- }
1546
- }
1547
- }
1548
-
1549
1531
impl From < BoundVar > for BoundTy {
1550
1532
fn from ( var : BoundVar ) -> Self {
1551
1533
BoundTy { var, kind : BoundTyKind :: Anon ( var. as_u32 ( ) ) }
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
188
188
} else {
189
189
// For placeholders which were already part of the input, we simply map this
190
190
// 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 ( ) ]
192
192
}
193
193
} ,
194
194
) ) ;
Original file line number Diff line number Diff line change @@ -1168,13 +1168,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> {
1168
1168
1169
1169
fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
1170
1170
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
+ }
1178
1177
1179
1178
_ => t. super_fold_with ( self ) ,
1180
1179
}
@@ -1202,8 +1201,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlaceholdersCollector {
1202
1201
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
1203
1202
match t. kind ( ) {
1204
1203
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 ) ;
1207
1205
}
1208
1206
1209
1207
_ => ( ) ,
You can’t perform that action at this time.
0 commit comments