@@ -393,40 +393,40 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
393393 // Note that types_with_generics contains also field types
394394 // *containing* a type parameter, but that just slows down
395395 // the search.
396- if ! t. bounds . is_empty ( ) &&
396+ //
397+ // In zero-copy types we do not need to add bounds to
398+ // the associated SerType/DeserType, as generics are not
399+ // replaced with their SerType/DeserType.
400+ if ! is_zero_copy && ! t. bounds . is_empty ( ) &&
397401 types_with_generics. iter ( ) . any ( |x| * ty == x. to_token_stream ( ) . to_string ( ) ) {
398402
399- // In zero-copy types we do not need to add bounds to
400- // DeserTypes, as generics are not replaced with their
401- // DeserType.
402- if ! is_zero_copy {
403- let mut lifetimes = Punctuated :: new ( ) ;
404- // Add a lifetime so we express bounds on DeserType
405- lifetimes. push ( GenericParam :: Lifetime ( LifetimeParam {
406- attrs : vec ! [ ] ,
407- lifetime : syn:: Lifetime :: new ( "'epserde_desertype" , proc_macro2:: Span :: call_site ( ) ) ,
408- colon_token : None ,
409- bounds : Punctuated :: new ( ) ,
410- } ) ) ;
411- // Add the type bounds to the DeserType
412- where_clause_des
413- . predicates
414- . push ( WherePredicate :: Type ( PredicateType {
415- lifetimes : Some ( BoundLifetimes {
416- for_token : token:: For :: default ( ) ,
417- lt_token : token:: Lt :: default ( ) ,
418- lifetimes,
419- gt_token : token:: Gt :: default ( ) ,
420- } ) ,
421- bounded_ty : syn:: parse_quote!(
422- <#ty as epserde:: deser:: DeserializeInner >:: DeserType <' epserde_desertype>
423- ) ,
424- colon_token : token:: Colon :: default ( ) ,
425- bounds : t. bounds . clone ( ) ,
426- } ) ) ;
427- }
403+ let mut lifetimes = Punctuated :: new ( ) ;
404+ // Add a lifetime so we express bounds on DeserType
405+ lifetimes. push ( GenericParam :: Lifetime ( LifetimeParam {
406+ attrs : vec ! [ ] ,
407+ lifetime : syn:: Lifetime :: new ( "'epserde_desertype" , proc_macro2:: Span :: call_site ( ) ) ,
408+ colon_token : None ,
409+ bounds : Punctuated :: new ( ) ,
410+ } ) ) ;
411+ // Add the type bounds to the DeserType
412+ where_clause_des
413+ . predicates
414+ . push ( WherePredicate :: Type ( PredicateType {
415+ lifetimes : Some ( BoundLifetimes {
416+ for_token : token:: For :: default ( ) ,
417+ lt_token : token:: Lt :: default ( ) ,
418+ lifetimes,
419+ gt_token : token:: Gt :: default ( ) ,
420+ } ) ,
421+ bounded_ty : syn:: parse_quote!(
422+ <#ty as epserde:: deser:: DeserializeInner >:: DeserType <' epserde_desertype>
423+ ) ,
424+ colon_token : token:: Colon :: default ( ) ,
425+ bounds : t. bounds . clone ( ) ,
426+ } ) ) ;
427+
428428 // Add the type bounds to the SerType
429- if ! is_zero_copy { where_clause_ser
429+ where_clause_ser
430430 . predicates
431431 . push ( WherePredicate :: Type ( PredicateType {
432432 lifetimes : None ,
@@ -435,7 +435,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
435435 ) ,
436436 colon_token : token:: Colon :: default ( ) ,
437437 bounds : t. bounds . clone ( ) ,
438- } ) ) ; }
438+ } ) ) ;
439439 }
440440 }
441441 } ) ;
0 commit comments