1717// persisting to incr. comp. caches.
1818
1919use hir:: def_id:: { DefId , CrateNum } ;
20+ use infer:: canonical:: { CanonicalVarInfo , CanonicalVarInfos } ;
2021use rustc_data_structures:: fx:: FxHashMap ;
2122use rustc_serialize:: { Decodable , Decoder , Encoder , Encodable , opaque} ;
2223use std:: hash:: Hash ;
@@ -239,6 +240,19 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
239240 . mk_existential_predicates ( ( 0 ..len) . map ( |_| Decodable :: decode ( decoder) ) ) ?)
240241}
241242
243+ #[ inline]
244+ pub fn decode_canonical_var_infos < ' a , ' tcx , D > ( decoder : & mut D )
245+ -> Result < CanonicalVarInfos < ' tcx > , D :: Error >
246+ where D : TyDecoder < ' a , ' tcx > ,
247+ ' tcx : ' a ,
248+ {
249+ let len = decoder. read_usize ( ) ?;
250+ let interned: Result < Vec < CanonicalVarInfo > , _ > = ( 0 ..len) . map ( |_| Decodable :: decode ( decoder) )
251+ . collect ( ) ;
252+ Ok ( decoder. tcx ( )
253+ . intern_canonical_var_infos ( interned?. as_slice ( ) ) )
254+ }
255+
242256#[ inline]
243257pub fn decode_const < ' a , ' tcx , D > ( decoder : & mut D )
244258 -> Result < & ' tcx ty:: Const < ' tcx > , D :: Error >
@@ -262,6 +276,7 @@ macro_rules! implement_ty_decoder {
262276 ( $DecoderName: ident <$( $typaram: tt) ,* >) => {
263277 mod __ty_decoder_impl {
264278 use super :: $DecoderName;
279+ use $crate:: infer:: canonical:: CanonicalVarInfos ;
265280 use $crate:: ty;
266281 use $crate:: ty:: codec:: * ;
267282 use $crate:: ty:: subst:: Substs ;
@@ -364,6 +379,14 @@ macro_rules! implement_ty_decoder {
364379 }
365380 }
366381
382+ impl <$( $typaram) ,* > SpecializedDecoder <CanonicalVarInfos <' tcx>>
383+ for $DecoderName<$( $typaram) ,* > {
384+ fn specialized_decode( & mut self )
385+ -> Result <CanonicalVarInfos <' tcx>, Self :: Error > {
386+ decode_canonical_var_infos( self )
387+ }
388+ }
389+
367390 impl <$( $typaram) ,* > SpecializedDecoder <& ' tcx $crate:: ty:: Const <' tcx>>
368391 for $DecoderName<$( $typaram) ,* > {
369392 fn specialized_decode( & mut self ) -> Result <& ' tcx ty:: Const <' tcx>, Self :: Error > {
0 commit comments