@@ -370,7 +370,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
370
370
ty:: Placeholder ( _placeholder) => {
371
371
chalk_ir:: TyKind :: Placeholder ( chalk_ir:: PlaceholderIndex {
372
372
ui : chalk_ir:: UniverseIndex { counter : _placeholder. universe . as_usize ( ) } ,
373
- idx : _placeholder. name . as_usize ( ) ,
373
+ idx : _placeholder. name . expect_anon ( ) as usize ,
374
374
} )
375
375
}
376
376
ty:: Infer ( _infer) => unimplemented ! ( ) ,
@@ -452,10 +452,6 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
452
452
) ,
453
453
TyKind :: Foreign ( def_id) => ty:: Foreign ( def_id. 0 ) ,
454
454
TyKind :: Error => return interner. tcx . ty_error ( ) ,
455
- TyKind :: Placeholder ( placeholder) => ty:: Placeholder ( ty:: Placeholder {
456
- universe : ty:: UniverseIndex :: from_usize ( placeholder. ui . counter ) ,
457
- name : ty:: BoundVar :: from_usize ( placeholder. idx ) ,
458
- } ) ,
459
455
TyKind :: Alias ( alias_ty) => match alias_ty {
460
456
chalk_ir:: AliasTy :: Projection ( projection) => ty:: Alias (
461
457
ty:: Projection ,
@@ -473,13 +469,17 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
473
469
) ,
474
470
} ,
475
471
TyKind :: Function ( _quantified_ty) => unimplemented ! ( ) ,
476
- TyKind :: BoundVar ( _bound ) => ty:: Bound (
477
- ty:: DebruijnIndex :: from_usize ( _bound . debruijn . depth ( ) as usize ) ,
472
+ TyKind :: BoundVar ( bound ) => ty:: Bound (
473
+ ty:: DebruijnIndex :: from_usize ( bound . debruijn . depth ( ) as usize ) ,
478
474
ty:: BoundTy {
479
- var : ty:: BoundVar :: from_usize ( _bound . index ) ,
480
- kind : ty:: BoundTyKind :: Anon ,
475
+ var : ty:: BoundVar :: from_usize ( bound . index ) ,
476
+ kind : ty:: BoundTyKind :: Anon ( bound . index as u32 ) ,
481
477
} ,
482
478
) ,
479
+ TyKind :: Placeholder ( placeholder) => ty:: Placeholder ( ty:: Placeholder {
480
+ universe : ty:: UniverseIndex :: from_usize ( placeholder. ui . counter ) ,
481
+ name : ty:: BoundTyKind :: Anon ( placeholder. idx as u32 ) ,
482
+ } ) ,
483
483
TyKind :: InferenceVar ( _, _) => unimplemented ! ( ) ,
484
484
TyKind :: Dyn ( _) => unimplemented ! ( ) ,
485
485
} ;
@@ -504,7 +504,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
504
504
ty:: RePlaceholder ( placeholder_region) => {
505
505
chalk_ir:: LifetimeData :: Placeholder ( chalk_ir:: PlaceholderIndex {
506
506
ui : chalk_ir:: UniverseIndex { counter : placeholder_region. universe . index ( ) } ,
507
- idx : 0 ,
507
+ idx : 0 , // FIXME: This `idx: 0` is sus.
508
508
} )
509
509
. intern ( interner)
510
510
}
@@ -674,7 +674,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
674
674
let self_ty = interner. tcx . mk_ty ( ty:: Bound (
675
675
// This is going to be wrapped in a binder
676
676
ty:: DebruijnIndex :: from_usize ( 1 ) ,
677
- ty:: BoundTy { var : ty:: BoundVar :: from_usize ( 0 ) , kind : ty:: BoundTyKind :: Anon } ,
677
+ ty:: BoundTy { var : ty:: BoundVar :: from_usize ( 0 ) , kind : ty:: BoundTyKind :: Anon ( 0 ) } ,
678
678
) ) ;
679
679
let where_clauses = predicates. into_iter ( ) . map ( |predicate| {
680
680
let ( predicate, binders, _named_regions) =
@@ -1038,7 +1038,7 @@ pub(crate) struct ParamsSubstitutor<'tcx> {
1038
1038
binder_index : ty:: DebruijnIndex ,
1039
1039
list : Vec < rustc_middle:: ty:: ParamTy > ,
1040
1040
next_ty_placeholder : usize ,
1041
- pub ( crate ) params : rustc_data_structures:: fx:: FxHashMap < usize , rustc_middle:: ty:: ParamTy > ,
1041
+ pub ( crate ) params : rustc_data_structures:: fx:: FxHashMap < u32 , rustc_middle:: ty:: ParamTy > ,
1042
1042
pub ( crate ) named_regions : BTreeMap < DefId , u32 > ,
1043
1043
}
1044
1044
@@ -1072,15 +1072,15 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> {
1072
1072
ty:: Param ( param) => match self . list . iter ( ) . position ( |r| r == & param) {
1073
1073
Some ( idx) => self . tcx . mk_ty ( ty:: Placeholder ( ty:: PlaceholderType {
1074
1074
universe : ty:: UniverseIndex :: from_usize ( 0 ) ,
1075
- name : ty:: BoundVar :: from_usize ( idx) ,
1075
+ name : ty:: BoundTyKind :: Anon ( idx as u32 ) ,
1076
1076
} ) ) ,
1077
1077
None => {
1078
1078
self . list . push ( param) ;
1079
1079
let idx = self . list . len ( ) - 1 + self . next_ty_placeholder ;
1080
- self . params . insert ( idx, param) ;
1080
+ self . params . insert ( idx as u32 , param) ;
1081
1081
self . tcx . mk_ty ( ty:: Placeholder ( ty:: PlaceholderType {
1082
1082
universe : ty:: UniverseIndex :: from_usize ( 0 ) ,
1083
- name : ty:: BoundVar :: from_usize ( idx) ,
1083
+ name : ty:: BoundTyKind :: Anon ( idx as u32 ) ,
1084
1084
} ) )
1085
1085
}
1086
1086
} ,
@@ -1119,13 +1119,13 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> {
1119
1119
1120
1120
pub ( crate ) struct ReverseParamsSubstitutor < ' tcx > {
1121
1121
tcx : TyCtxt < ' tcx > ,
1122
- params : rustc_data_structures:: fx:: FxHashMap < usize , rustc_middle:: ty:: ParamTy > ,
1122
+ params : rustc_data_structures:: fx:: FxHashMap < u32 , rustc_middle:: ty:: ParamTy > ,
1123
1123
}
1124
1124
1125
1125
impl < ' tcx > ReverseParamsSubstitutor < ' tcx > {
1126
1126
pub ( crate ) fn new (
1127
1127
tcx : TyCtxt < ' tcx > ,
1128
- params : rustc_data_structures:: fx:: FxHashMap < usize , rustc_middle:: ty:: ParamTy > ,
1128
+ params : rustc_data_structures:: fx:: FxHashMap < u32 , rustc_middle:: ty:: ParamTy > ,
1129
1129
) -> Self {
1130
1130
Self { tcx, params }
1131
1131
}
@@ -1139,7 +1139,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseParamsSubstitutor<'tcx> {
1139
1139
fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
1140
1140
match * t. kind ( ) {
1141
1141
ty:: Placeholder ( ty:: PlaceholderType { universe : ty:: UniverseIndex :: ROOT , name } ) => {
1142
- match self . params . get ( & name. as_usize ( ) ) {
1142
+ match self . params . get ( & name. expect_anon ( ) ) {
1143
1143
Some ( param) => self . tcx . mk_ty ( ty:: Param ( * param) ) ,
1144
1144
None => t,
1145
1145
}
@@ -1171,7 +1171,8 @@ impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
1171
1171
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
1172
1172
match t. kind ( ) {
1173
1173
ty:: Placeholder ( p) if p. universe == self . universe_index => {
1174
- self . next_ty_placeholder = self . next_ty_placeholder . max ( p. name . as_usize ( ) + 1 ) ;
1174
+ self . next_ty_placeholder =
1175
+ self . next_ty_placeholder . max ( p. name . expect_anon ( ) as usize + 1 ) ;
1175
1176
}
1176
1177
1177
1178
_ => ( ) ,
@@ -1186,6 +1187,7 @@ impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
1186
1187
if let ty:: BoundRegionKind :: BrAnon ( anon, _) = p. name {
1187
1188
self . next_anon_region_placeholder = self . next_anon_region_placeholder . max ( anon) ;
1188
1189
}
1190
+ // FIXME: This doesn't seem to handle BrNamed at all?
1189
1191
}
1190
1192
1191
1193
_ => ( ) ,
0 commit comments