@@ -17,8 +17,8 @@ use crate::traits;
1717use crate :: ty:: subst:: SubstsRef ;
1818use crate :: ty:: { self , AdtDef , Ty } ;
1919use rustc_data_structures:: fx:: FxHashMap ;
20- use rustc_serialize:: { Decodable , Encodable } ;
2120use rustc_middle:: ty:: TyInterner ;
21+ use rustc_serialize:: { Decodable , Encodable } ;
2222use rustc_span:: Span ;
2323pub use rustc_type_ir:: { TyDecoder , TyEncoder } ;
2424use std:: hash:: Hash ;
@@ -165,25 +165,6 @@ impl<'tcx, E: TyEncoder<I = TyInterner<'tcx>>> Encodable<E> for AllocId {
165165 }
166166}
167167
168- macro_rules! encodable_via_deref {
169- ( $( $t: ty) ,+) => {
170- $( impl <' tcx, E : TyEncoder <I = TyInterner <' tcx>>> Encodable <E > for $t {
171- fn encode( & self , e: & mut E ) -> Result <( ) , E :: Error > {
172- ( * * self ) . encode( e)
173- }
174- } ) *
175- }
176- }
177-
178- encodable_via_deref ! {
179- & ' tcx ty:: TypeckResults <' tcx>,
180- & ' tcx traits:: ImplSource <' tcx, ( ) >,
181- & ' tcx mir:: Body <' tcx>,
182- & ' tcx mir:: UnsafetyCheckResult ,
183- & ' tcx mir:: BorrowCheckResult <' tcx>,
184- & ' tcx mir:: coverage:: CodeRegion
185- }
186-
187168#[ inline]
188169fn decode_arena_allocable <
189170 ' tcx ,
@@ -231,7 +212,9 @@ impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D> for Ty<'tcx> {
231212 }
232213}
233214
234- impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > Decodable < D > for ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > > {
215+ impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > Decodable < D >
216+ for ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > >
217+ {
235218 fn decode ( decoder : & mut D ) -> ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > > {
236219 let bound_vars = Decodable :: decode ( decoder) ;
237220 // Handle shorthands first, if we have a usize > 0x80.
@@ -318,7 +301,10 @@ macro_rules! impl_decodable_via_ref {
318301impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for ty:: List < Ty < ' tcx > > {
319302 fn decode ( decoder : & mut D ) -> & ' tcx Self {
320303 let len = decoder. read_usize ( ) ;
321- decoder. interner ( ) . tcx . mk_type_list ( ( 0 ..len) . map :: < Ty < ' tcx > , _ > ( |_| Decodable :: decode ( decoder) ) )
304+ decoder
305+ . interner ( )
306+ . tcx
307+ . mk_type_list ( ( 0 ..len) . map :: < Ty < ' tcx > , _ > ( |_| Decodable :: decode ( decoder) ) )
322308 }
323309}
324310
@@ -359,31 +345,39 @@ impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D> for AdtDef<'tcx> {
359345 }
360346}
361347
362- impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for [ ( ty:: Predicate < ' tcx > , Span ) ] {
348+ impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D >
349+ for [ ( ty:: Predicate < ' tcx > , Span ) ]
350+ {
363351 fn decode ( decoder : & mut D ) -> & ' tcx Self {
364352 decoder. interner ( ) . tcx . arena . alloc_from_iter (
365353 ( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
366354 )
367355 }
368356}
369357
370- impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for [ thir:: abstract_const:: Node < ' tcx > ] {
358+ impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D >
359+ for [ thir:: abstract_const:: Node < ' tcx > ]
360+ {
371361 fn decode ( decoder : & mut D ) -> & ' tcx Self {
372362 decoder. interner ( ) . tcx . arena . alloc_from_iter (
373363 ( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
374364 )
375365 }
376366}
377367
378- impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for [ thir:: abstract_const:: NodeId ] {
368+ impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D >
369+ for [ thir:: abstract_const:: NodeId ]
370+ {
379371 fn decode ( decoder : & mut D ) -> & ' tcx Self {
380372 decoder. interner ( ) . tcx . arena . alloc_from_iter (
381373 ( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
382374 )
383375 }
384376}
385377
386- impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for ty:: List < ty:: BoundVariableKind > {
378+ impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D >
379+ for ty:: List < ty:: BoundVariableKind >
380+ {
387381 fn decode ( decoder : & mut D ) -> & ' tcx Self {
388382 let len = decoder. read_usize ( ) ;
389383 decoder. interner ( ) . tcx . mk_bound_variable_kinds (
@@ -449,17 +443,17 @@ arena_types!(impl_arena_allocatable_decoders);
449443
450444macro_rules! impl_arena_copy_decoder {
451445 ( <$tcx: tt> $( $ty: ty, ) * ) => {
452- $( impl <' tcx, D : TyDecoder <' tcx>> RefDecodable <' tcx, D > for $ty {
446+ $( impl <' tcx, D : TyDecoder <I = TyInterner < ' tcx> >> RefDecodable <' tcx, D > for $ty {
453447 #[ inline]
454448 fn decode( decoder: & mut D ) -> & ' tcx Self {
455- decoder. tcx ( ) . arena. alloc( Decodable :: decode( decoder) )
449+ decoder. interner ( ) . tcx . arena. alloc( Decodable :: decode( decoder) )
456450 }
457451 }
458452
459- impl <' tcx, D : TyDecoder <' tcx>> RefDecodable <' tcx, D > for [ $ty] {
453+ impl <' tcx, D : TyDecoder <I = TyInterner < ' tcx> >> RefDecodable <' tcx, D > for [ $ty] {
460454 #[ inline]
461455 fn decode( decoder: & mut D ) -> & ' tcx Self {
462- decoder. tcx ( ) . arena. alloc_from_iter( <Vec <_> as Decodable <D >>:: decode( decoder) )
456+ decoder. interner ( ) . tcx . arena. alloc_from_iter( <Vec <_> as Decodable <D >>:: decode( decoder) )
463457 }
464458 } ) *
465459 } ;
0 commit comments