@@ -17,8 +17,8 @@ use crate::traits;
17
17
use crate :: ty:: subst:: SubstsRef ;
18
18
use crate :: ty:: { self , AdtDef , Ty } ;
19
19
use rustc_data_structures:: fx:: FxHashMap ;
20
- use rustc_serialize:: { Decodable , Encodable } ;
21
20
use rustc_middle:: ty:: TyInterner ;
21
+ use rustc_serialize:: { Decodable , Encodable } ;
22
22
use rustc_span:: Span ;
23
23
pub use rustc_type_ir:: { TyDecoder , TyEncoder } ;
24
24
use std:: hash:: Hash ;
@@ -165,25 +165,6 @@ impl<'tcx, E: TyEncoder<I = TyInterner<'tcx>>> Encodable<E> for AllocId {
165
165
}
166
166
}
167
167
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
-
187
168
#[ inline]
188
169
fn decode_arena_allocable <
189
170
' tcx ,
@@ -231,7 +212,9 @@ impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D> for Ty<'tcx> {
231
212
}
232
213
}
233
214
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
+ {
235
218
fn decode ( decoder : & mut D ) -> ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > > {
236
219
let bound_vars = Decodable :: decode ( decoder) ;
237
220
// Handle shorthands first, if we have a usize > 0x80.
@@ -318,7 +301,10 @@ macro_rules! impl_decodable_via_ref {
318
301
impl < ' tcx , D : TyDecoder < I = TyInterner < ' tcx > > > RefDecodable < ' tcx , D > for ty:: List < Ty < ' tcx > > {
319
302
fn decode ( decoder : & mut D ) -> & ' tcx Self {
320
303
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) ) )
322
308
}
323
309
}
324
310
@@ -359,31 +345,39 @@ impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D> for AdtDef<'tcx> {
359
345
}
360
346
}
361
347
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
+ {
363
351
fn decode ( decoder : & mut D ) -> & ' tcx Self {
364
352
decoder. interner ( ) . tcx . arena . alloc_from_iter (
365
353
( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
366
354
)
367
355
}
368
356
}
369
357
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
+ {
371
361
fn decode ( decoder : & mut D ) -> & ' tcx Self {
372
362
decoder. interner ( ) . tcx . arena . alloc_from_iter (
373
363
( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
374
364
)
375
365
}
376
366
}
377
367
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
+ {
379
371
fn decode ( decoder : & mut D ) -> & ' tcx Self {
380
372
decoder. interner ( ) . tcx . arena . alloc_from_iter (
381
373
( 0 ..decoder. read_usize ( ) ) . map ( |_| Decodable :: decode ( decoder) ) . collect :: < Vec < _ > > ( ) ,
382
374
)
383
375
}
384
376
}
385
377
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
+ {
387
381
fn decode ( decoder : & mut D ) -> & ' tcx Self {
388
382
let len = decoder. read_usize ( ) ;
389
383
decoder. interner ( ) . tcx . mk_bound_variable_kinds (
@@ -449,17 +443,17 @@ arena_types!(impl_arena_allocatable_decoders);
449
443
450
444
macro_rules! impl_arena_copy_decoder {
451
445
( <$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 {
453
447
#[ inline]
454
448
fn decode( decoder: & mut D ) -> & ' tcx Self {
455
- decoder. tcx ( ) . arena. alloc( Decodable :: decode( decoder) )
449
+ decoder. interner ( ) . tcx . arena. alloc( Decodable :: decode( decoder) )
456
450
}
457
451
}
458
452
459
- impl <' tcx, D : TyDecoder <' tcx>> RefDecodable <' tcx, D > for [ $ty] {
453
+ impl <' tcx, D : TyDecoder <I = TyInterner < ' tcx> >> RefDecodable <' tcx, D > for [ $ty] {
460
454
#[ inline]
461
455
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) )
463
457
}
464
458
} ) *
465
459
} ;
0 commit comments