@@ -10,7 +10,7 @@ use rustc_span::Symbol;
10
10
use stable_mir:: abi:: Layout ;
11
11
use stable_mir:: mir:: alloc:: AllocId ;
12
12
use stable_mir:: mir:: mono:: { Instance , MonoItem , StaticDef } ;
13
- use stable_mir:: mir:: { Mutability , Safety } ;
13
+ use stable_mir:: mir:: { Mutability , Place , ProjectionElem , Safety } ;
14
14
use stable_mir:: ty:: {
15
15
Abi , AdtDef , Binder , BoundRegionKind , BoundTyKind , BoundVariableKind , ClosureKind , Const ,
16
16
DynKind , ExistentialPredicate , ExistentialProjection , ExistentialTraitRef , FloatTy , FnSig ,
@@ -492,6 +492,50 @@ impl RustcInternal for Layout {
492
492
}
493
493
}
494
494
495
+ impl RustcInternal for Place {
496
+ type T < ' tcx > = rustc_middle:: mir:: Place < ' tcx > ;
497
+
498
+ fn internal < ' tcx > ( & self , tables : & mut Tables < ' _ > , tcx : TyCtxt < ' tcx > ) -> Self :: T < ' tcx > {
499
+ rustc_middle:: mir:: Place {
500
+ local : rustc_middle:: mir:: Local :: from_usize ( self . local ) ,
501
+ projection : tcx. mk_place_elems ( & self . projection . internal ( tables, tcx) ) ,
502
+ }
503
+ }
504
+ }
505
+
506
+ impl RustcInternal for ProjectionElem {
507
+ type T < ' tcx > = rustc_middle:: mir:: PlaceElem < ' tcx > ;
508
+
509
+ fn internal < ' tcx > ( & self , tables : & mut Tables < ' _ > , tcx : TyCtxt < ' tcx > ) -> Self :: T < ' tcx > {
510
+ match self {
511
+ ProjectionElem :: Deref => rustc_middle:: mir:: PlaceElem :: Deref ,
512
+ ProjectionElem :: Field ( idx, ty) => {
513
+ rustc_middle:: mir:: PlaceElem :: Field ( ( * idx) . into ( ) , ty. internal ( tables, tcx) )
514
+ }
515
+ ProjectionElem :: Index ( idx) => rustc_middle:: mir:: PlaceElem :: Index ( ( * idx) . into ( ) ) ,
516
+ ProjectionElem :: ConstantIndex { offset, min_length, from_end } => {
517
+ rustc_middle:: mir:: PlaceElem :: ConstantIndex {
518
+ offset : * offset,
519
+ min_length : * min_length,
520
+ from_end : * from_end,
521
+ }
522
+ }
523
+ ProjectionElem :: Subslice { from, to, from_end } => {
524
+ rustc_middle:: mir:: PlaceElem :: Subslice { from : * from, to : * to, from_end : * from_end }
525
+ }
526
+ ProjectionElem :: Downcast ( idx) => {
527
+ rustc_middle:: mir:: PlaceElem :: Downcast ( None , idx. internal ( tables, tcx) )
528
+ }
529
+ ProjectionElem :: OpaqueCast ( ty) => {
530
+ rustc_middle:: mir:: PlaceElem :: OpaqueCast ( ty. internal ( tables, tcx) )
531
+ }
532
+ ProjectionElem :: Subtype ( ty) => {
533
+ rustc_middle:: mir:: PlaceElem :: Subtype ( ty. internal ( tables, tcx) )
534
+ }
535
+ }
536
+ }
537
+ }
538
+
495
539
impl < T > RustcInternal for & T
496
540
where
497
541
T : RustcInternal ,
0 commit comments