@@ -10,7 +10,7 @@ use rustc_span::Symbol;
1010use stable_mir:: abi:: Layout ;
1111use stable_mir:: mir:: alloc:: AllocId ;
1212use stable_mir:: mir:: mono:: { Instance , MonoItem , StaticDef } ;
13- use stable_mir:: mir:: { Mutability , Safety } ;
13+ use stable_mir:: mir:: { Mutability , Place , ProjectionElem , Safety } ;
1414use stable_mir:: ty:: {
1515 Abi , AdtDef , Binder , BoundRegionKind , BoundTyKind , BoundVariableKind , ClosureKind , Const ,
1616 DynKind , ExistentialPredicate , ExistentialProjection , ExistentialTraitRef , FloatTy , FnSig ,
@@ -492,6 +492,50 @@ impl RustcInternal for Layout {
492492 }
493493}
494494
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+
495539impl < T > RustcInternal for & T
496540where
497541 T : RustcInternal ,
0 commit comments