@@ -115,18 +115,11 @@ impl<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<E> for Ty<'tcx> {
115115 }
116116}
117117
118- impl < ' tcx , E : TyEncoder < I = TyCtxt < ' tcx > > > Encodable < E >
119- for ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > >
120- {
121- fn encode ( & self , e : & mut E ) {
122- self . bound_vars ( ) . encode ( e) ;
123- encode_with_shorthand ( e, & self . skip_binder ( ) , TyEncoder :: predicate_shorthands) ;
124- }
125- }
126-
127118impl < ' tcx , E : TyEncoder < I = TyCtxt < ' tcx > > > Encodable < E > for ty:: Predicate < ' tcx > {
128119 fn encode ( & self , e : & mut E ) {
129- self . kind ( ) . encode ( e) ;
120+ let kind = self . kind ( ) ;
121+ kind. bound_vars ( ) . encode ( e) ;
122+ encode_with_shorthand ( e, & kind. skip_binder ( ) , TyEncoder :: predicate_shorthands) ;
130123 }
131124}
132125
@@ -233,13 +226,11 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for Ty<'tcx> {
233226 }
234227}
235228
236- impl < ' tcx , D : TyDecoder < I = TyCtxt < ' tcx > > > Decodable < D >
237- for ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > >
238- {
239- fn decode ( decoder : & mut D ) -> ty:: Binder < ' tcx , ty:: PredicateKind < ' tcx > > {
229+ impl < ' tcx , D : TyDecoder < I = TyCtxt < ' tcx > > > Decodable < D > for ty:: Predicate < ' tcx > {
230+ fn decode ( decoder : & mut D ) -> ty:: Predicate < ' tcx > {
240231 let bound_vars = Decodable :: decode ( decoder) ;
241232 // Handle shorthands first, if we have a usize > 0x80.
242- ty:: Binder :: bind_with_vars (
233+ let predicate_kind = ty:: Binder :: bind_with_vars (
243234 if decoder. positioned_at_shorthand ( ) {
244235 let pos = decoder. read_usize ( ) ;
245236 assert ! ( pos >= SHORTHAND_OFFSET ) ;
@@ -250,13 +241,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D>
250241 <ty:: PredicateKind < ' tcx > as Decodable < D > >:: decode ( decoder)
251242 } ,
252243 bound_vars,
253- )
254- }
255- }
256-
257- impl < ' tcx , D : TyDecoder < I = TyCtxt < ' tcx > > > Decodable < D > for ty:: Predicate < ' tcx > {
258- fn decode ( decoder : & mut D ) -> ty:: Predicate < ' tcx > {
259- let predicate_kind = Decodable :: decode ( decoder) ;
244+ ) ;
260245 decoder. interner ( ) . mk_predicate ( predicate_kind)
261246 }
262247}
@@ -599,32 +584,3 @@ macro_rules! implement_ty_decoder {
599584 }
600585 }
601586}
602-
603- macro_rules! impl_binder_encode_decode {
604- ( $( $t: ty) ,+ $( , ) ?) => {
605- $(
606- impl <' tcx, E : TyEncoder <I = TyCtxt <' tcx>>> Encodable <E > for ty:: Binder <' tcx, $t> {
607- fn encode( & self , e: & mut E ) {
608- self . bound_vars( ) . encode( e) ;
609- self . as_ref( ) . skip_binder( ) . encode( e) ;
610- }
611- }
612- impl <' tcx, D : TyDecoder <I = TyCtxt <' tcx>>> Decodable <D > for ty:: Binder <' tcx, $t> {
613- fn decode( decoder: & mut D ) -> Self {
614- let bound_vars = Decodable :: decode( decoder) ;
615- ty:: Binder :: bind_with_vars( Decodable :: decode( decoder) , bound_vars)
616- }
617- }
618- ) *
619- }
620- }
621-
622- impl_binder_encode_decode ! {
623- & ' tcx ty:: List <Ty <' tcx>>,
624- ty:: FnSig <' tcx>,
625- ty:: Predicate <' tcx>,
626- ty:: TraitPredicate <' tcx>,
627- ty:: ExistentialPredicate <' tcx>,
628- ty:: TraitRef <' tcx>,
629- ty:: ExistentialTraitRef <' tcx>,
630- }
0 commit comments