@@ -14,6 +14,7 @@ use std::hash::Hash;
1414use std:: intrinsics;
1515use ty:: { self , Ty , TyCtxt } ;
1616use ty:: subst:: Substs ;
17+ use mir;
1718use mir:: interpret:: Allocation ;
1819
1920/// The shorthand encoding uses an enum's variant index `usize`
@@ -264,6 +265,20 @@ pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D)
264265 Ok ( decoder. tcx ( ) . intern_const_alloc ( Decodable :: decode ( decoder) ?) )
265266}
266267
268+ #[ inline]
269+ pub fn decode_neo_place < ' a , ' tcx , D > ( decoder : & mut D )
270+ -> Result < mir:: NeoPlace < ' tcx > , D :: Error >
271+ where D : TyDecoder < ' a , ' tcx > ,
272+ ' tcx : ' a ,
273+ {
274+ let base: mir:: PlaceBase < ' tcx > = Decodable :: decode ( decoder) ?;
275+ let len = decoder. read_usize ( ) ?;
276+ let interned: Vec < mir:: PlaceElem < ' tcx > > = ( 0 ..len) . map ( |_| Decodable :: decode ( decoder) )
277+ . collect :: < Result < _ , _ > > ( ) ?;
278+ let elems: & ' tcx [ mir:: PlaceElem < ' tcx > ] = decoder. tcx ( ) . mk_place_elems ( interned. into_iter ( ) ) ;
279+ Ok ( mir:: NeoPlace { base, elems } )
280+ }
281+
267282#[ macro_export]
268283macro_rules! __impl_decoder_methods {
269284 ( $( $name: ident -> $ty: ty; ) * ) => {
@@ -404,6 +419,15 @@ macro_rules! implement_ty_decoder {
404419 decode_allocation( self )
405420 }
406421 }
422+
423+ impl <$( $typaram) ,* > SpecializedDecoder <$crate:: mir:: NeoPlace <' tcx>>
424+ for $DecoderName<$( $typaram) ,* > {
425+ fn specialized_decode(
426+ & mut self
427+ ) -> Result <$crate:: mir:: NeoPlace <' tcx>, Self :: Error > {
428+ decode_neo_place( self )
429+ }
430+ }
407431 }
408432 }
409433}
0 commit comments