@@ -427,13 +427,20 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
427
427
chalk_ir:: FloatTy :: F64 => ty:: Float ( ast:: FloatTy :: F64 ) ,
428
428
} ,
429
429
} ,
430
- chalk_ir:: TypeName :: Array => unimplemented ! ( ) ,
430
+ chalk_ir:: TypeName :: Array => {
431
+ let substs = application_ty. substitution . as_slice ( interner) ;
432
+ let ty = substs[ 0 ] . assert_ty_ref ( interner) . lower_into ( interner) ;
433
+ let c = substs[ 1 ] . assert_const_ref ( interner) . lower_into ( interner) ;
434
+ ty:: Array ( ty, interner. tcx . mk_const ( c) )
435
+ }
431
436
chalk_ir:: TypeName :: FnDef ( id) => {
432
437
ty:: FnDef ( id. 0 , application_ty. substitution . lower_into ( interner) )
433
438
}
434
439
chalk_ir:: TypeName :: Closure ( closure) => {
435
440
ty:: Closure ( closure. 0 , application_ty. substitution . lower_into ( interner) )
436
441
}
442
+ chalk_ir:: TypeName :: Generator ( _) => unimplemented ! ( ) ,
443
+ chalk_ir:: TypeName :: GeneratorWitness ( _) => unimplemented ! ( ) ,
437
444
chalk_ir:: TypeName :: Never => ty:: Never ,
438
445
chalk_ir:: TypeName :: Tuple ( _size) => {
439
446
ty:: Tuple ( application_ty. substitution . lower_into ( interner) )
@@ -483,7 +490,15 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
483
490
universe : ty:: UniverseIndex :: from_usize ( placeholder. ui . counter ) ,
484
491
name : ty:: BoundVar :: from_usize ( placeholder. idx ) ,
485
492
} ) ,
486
- TyData :: Alias ( _alias_ty) => unimplemented ! ( ) ,
493
+ chalk_ir:: TyData :: Alias ( alias_ty) => match alias_ty {
494
+ chalk_ir:: AliasTy :: Projection ( projection) => ty:: Projection ( ty:: ProjectionTy {
495
+ item_def_id : projection. associated_ty_id . 0 ,
496
+ substs : projection. substitution . lower_into ( interner) ,
497
+ } ) ,
498
+ chalk_ir:: AliasTy :: Opaque ( opaque) => {
499
+ ty:: Opaque ( opaque. opaque_ty_id . 0 , opaque. substitution . lower_into ( interner) )
500
+ }
501
+ } ,
487
502
TyData :: Function ( _quantified_ty) => unimplemented ! ( ) ,
488
503
TyData :: BoundVar ( _bound) => ty:: Bound (
489
504
ty:: DebruijnIndex :: from_usize ( _bound. debruijn . depth ( ) as usize ) ,
@@ -519,8 +534,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
519
534
ty:: BrEnv => unimplemented ! ( ) ,
520
535
} ,
521
536
ReFree ( _) => unimplemented ! ( ) ,
522
- // FIXME(chalk): need to handle ReStatic
523
- ReStatic => unimplemented ! ( ) ,
537
+ ReStatic => chalk_ir:: LifetimeData :: Static . intern ( interner) ,
524
538
ReVar ( _) => unimplemented ! ( ) ,
525
539
RePlaceholder ( placeholder_region) => {
526
540
chalk_ir:: LifetimeData :: Placeholder ( chalk_ir:: PlaceholderIndex {
@@ -550,6 +564,7 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'t
550
564
name : ty:: BoundRegion :: BrAnon ( p. idx as u32 ) ,
551
565
} )
552
566
}
567
+ chalk_ir:: LifetimeData :: Static => ty:: RegionKind :: ReStatic ,
553
568
chalk_ir:: LifetimeData :: Phantom ( _, _) => unimplemented ! ( ) ,
554
569
} ;
555
570
interner. tcx . mk_region ( kind)
@@ -701,7 +716,16 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
701
716
} ) ,
702
717
)
703
718
}
704
- ty:: ExistentialPredicate :: Projection ( _predicate) => unimplemented ! ( ) ,
719
+ ty:: ExistentialPredicate :: Projection ( predicate) => chalk_ir:: Binders :: new (
720
+ chalk_ir:: VariableKinds :: empty ( interner) ,
721
+ chalk_ir:: WhereClause :: AliasEq ( chalk_ir:: AliasEq {
722
+ alias : chalk_ir:: AliasTy :: Projection ( chalk_ir:: ProjectionTy {
723
+ associated_ty_id : chalk_ir:: AssocTypeId ( predicate. item_def_id ) ,
724
+ substitution : predicate. substs . lower_into ( interner) ,
725
+ } ) ,
726
+ ty : predicate. ty . lower_into ( interner) ,
727
+ } ) ,
728
+ ) ,
705
729
ty:: ExistentialPredicate :: AutoTrait ( def_id) => chalk_ir:: Binders :: new (
706
730
chalk_ir:: VariableKinds :: empty ( interner) ,
707
731
chalk_ir:: WhereClause :: Implemented ( chalk_ir:: TraitRef {
@@ -1116,17 +1140,12 @@ impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
1116
1140
/// Used to substitute specific `Regions`s with placeholders.
1117
1141
crate struct RegionsSubstitutor < ' tcx > {
1118
1142
tcx : TyCtxt < ' tcx > ,
1119
- restatic_placeholder : ty:: Region < ' tcx > ,
1120
1143
reempty_placeholder : ty:: Region < ' tcx > ,
1121
1144
}
1122
1145
1123
1146
impl < ' tcx > RegionsSubstitutor < ' tcx > {
1124
- crate fn new (
1125
- tcx : TyCtxt < ' tcx > ,
1126
- restatic_placeholder : ty:: Region < ' tcx > ,
1127
- reempty_placeholder : ty:: Region < ' tcx > ,
1128
- ) -> Self {
1129
- RegionsSubstitutor { tcx, restatic_placeholder, reempty_placeholder }
1147
+ crate fn new ( tcx : TyCtxt < ' tcx > , reempty_placeholder : ty:: Region < ' tcx > ) -> Self {
1148
+ RegionsSubstitutor { tcx, reempty_placeholder }
1130
1149
}
1131
1150
}
1132
1151
@@ -1137,7 +1156,6 @@ impl<'tcx> TypeFolder<'tcx> for RegionsSubstitutor<'tcx> {
1137
1156
1138
1157
fn fold_region ( & mut self , r : Region < ' tcx > ) -> Region < ' tcx > {
1139
1158
match r {
1140
- ty:: ReStatic => self . restatic_placeholder ,
1141
1159
ty:: ReEmpty ( ui) => {
1142
1160
assert_eq ! ( ui. as_usize( ) , 0 ) ;
1143
1161
self . reempty_placeholder
0 commit comments