This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-34
lines changed
rustc_trait_selection/src/solve/eval_ctxt Expand file tree Collapse file tree 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> {
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}
Original file line number Diff line number Diff 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
121112pub 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-
15491531impl From < BoundVar > for BoundTy {
15501532 fn from ( var : BoundVar ) -> Self {
15511533 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> {
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 ) ) ;
Original file line number Diff line number Diff 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 _ => ( ) ,
You can’t perform that action at this time.
0 commit comments