@@ -14,6 +14,7 @@ use std::hash::Hash;
14
14
use std:: intrinsics;
15
15
use ty:: { self , Ty , TyCtxt } ;
16
16
use ty:: subst:: Substs ;
17
+ use mir;
17
18
use mir:: interpret:: Allocation ;
18
19
19
20
/// The shorthand encoding uses an enum's variant index `usize`
@@ -264,6 +265,20 @@ pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D)
264
265
Ok ( decoder. tcx ( ) . intern_const_alloc ( Decodable :: decode ( decoder) ?) )
265
266
}
266
267
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
+
267
282
#[ macro_export]
268
283
macro_rules! __impl_decoder_methods {
269
284
( $( $name: ident -> $ty: ty; ) * ) => {
@@ -404,6 +419,15 @@ macro_rules! implement_ty_decoder {
404
419
decode_allocation( self )
405
420
}
406
421
}
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
+ }
407
431
}
408
432
}
409
433
}
0 commit comments