17
17
// persisting to incr. comp. caches.
18
18
19
19
use hir:: def_id:: { DefId , CrateNum } ;
20
+ use infer:: canonical:: { CanonicalVarInfo , CanonicalVarInfos } ;
20
21
use rustc_data_structures:: fx:: FxHashMap ;
21
22
use rustc_serialize:: { Decodable , Decoder , Encoder , Encodable , opaque} ;
22
23
use std:: hash:: Hash ;
@@ -239,6 +240,19 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
239
240
. mk_existential_predicates ( ( 0 ..len) . map ( |_| Decodable :: decode ( decoder) ) ) ?)
240
241
}
241
242
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
+
242
256
#[ inline]
243
257
pub fn decode_const < ' a , ' tcx , D > ( decoder : & mut D )
244
258
-> Result < & ' tcx ty:: Const < ' tcx > , D :: Error >
@@ -262,6 +276,7 @@ macro_rules! implement_ty_decoder {
262
276
( $DecoderName: ident <$( $typaram: tt) ,* >) => {
263
277
mod __ty_decoder_impl {
264
278
use super :: $DecoderName;
279
+ use $crate:: infer:: canonical:: CanonicalVarInfos ;
265
280
use $crate:: ty;
266
281
use $crate:: ty:: codec:: * ;
267
282
use $crate:: ty:: subst:: Substs ;
@@ -364,6 +379,14 @@ macro_rules! implement_ty_decoder {
364
379
}
365
380
}
366
381
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
+
367
390
impl <$( $typaram) ,* > SpecializedDecoder <& ' tcx $crate:: ty:: Const <' tcx>>
368
391
for $DecoderName<$( $typaram) ,* > {
369
392
fn specialized_decode( & mut self ) -> Result <& ' tcx ty:: Const <' tcx>, Self :: Error > {
0 commit comments