@@ -120,9 +120,9 @@ impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Ty<'tcx> {
120120 }
121121}
122122
123- impl < ' tcx , E : TyEncoder < ' tcx > > Encodable < E > for ty:: PredicateKind < ' tcx > {
123+ impl < ' tcx , E : TyEncoder < ' tcx > > Encodable < E > for ty:: Binder < ty :: PredicateKind < ' tcx > > {
124124 fn encode ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
125- encode_with_shorthand ( e, self , TyEncoder :: predicate_shorthands)
125+ encode_with_shorthand ( e, & self . skip_binder ( ) , TyEncoder :: predicate_shorthands)
126126 }
127127}
128128
@@ -226,18 +226,18 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Ty<'tcx> {
226226 }
227227}
228228
229- impl < ' tcx , D : TyDecoder < ' tcx > > Decodable < D > for ty:: PredicateKind < ' tcx > {
230- fn decode ( decoder : & mut D ) -> Result < ty:: PredicateKind < ' tcx > , D :: Error > {
229+ impl < ' tcx , D : TyDecoder < ' tcx > > Decodable < D > for ty:: Binder < ty :: PredicateKind < ' tcx > > {
230+ fn decode ( decoder : & mut D ) -> Result < ty:: Binder < ty :: PredicateKind < ' tcx > > , D :: Error > {
231231 // Handle shorthands first, if we have an usize > 0x80.
232- if decoder. positioned_at_shorthand ( ) {
232+ Ok ( ty :: Binder :: bind ( if decoder. positioned_at_shorthand ( ) {
233233 let pos = decoder. read_usize ( ) ?;
234234 assert ! ( pos >= SHORTHAND_OFFSET ) ;
235235 let shorthand = pos - SHORTHAND_OFFSET ;
236236
237- decoder. with_position ( shorthand, ty:: PredicateKind :: decode)
237+ decoder. with_position ( shorthand, ty:: PredicateKind :: decode) ?
238238 } else {
239- Ok ( ty:: PredicateKind :: decode ( decoder) ?)
240- }
239+ ty:: PredicateKind :: decode ( decoder) ?
240+ } ) )
241241 }
242242}
243243
@@ -471,3 +471,28 @@ macro_rules! implement_ty_decoder {
471471 }
472472 }
473473}
474+
475+ macro_rules! impl_binder_encode_decode {
476+ ( $( $t: ty) ,+ $( , ) ?) => {
477+ $(
478+ impl <' tcx, E : TyEncoder <' tcx>> Encodable <E > for ty:: Binder <$t> {
479+ fn encode( & self , e: & mut E ) -> Result <( ) , E :: Error > {
480+ self . as_ref( ) . skip_binder( ) . encode( e)
481+ }
482+ }
483+ impl <' tcx, D : TyDecoder <' tcx>> Decodable <D > for ty:: Binder <$t> {
484+ fn decode( decoder: & mut D ) -> Result <Self , D :: Error > {
485+ Ok ( ty:: Binder :: bind( Decodable :: decode( decoder) ?) )
486+ }
487+ }
488+ ) *
489+ }
490+ }
491+
492+ impl_binder_encode_decode ! {
493+ & ' tcx ty:: List <Ty <' tcx>>,
494+ ty:: FnSig <' tcx>,
495+ ty:: ExistentialPredicate <' tcx>,
496+ ty:: TraitRef <' tcx>,
497+ Vec <ty:: GeneratorInteriorTypeCause <' tcx>>,
498+ }
0 commit comments