@@ -411,6 +411,9 @@ fn size_with(
411411 syn:: Ident :: new ( "ctx" , proc_macro2:: Span :: call_site ( ) ) . into_token_stream ( ) ;
412412 let ctx = custom_ctx. unwrap_or ( default_ctx) ;
413413 match ty {
414+ syn:: Type :: Reference ( _) => {
415+ panic ! ( "SizeWith cannot be derived for references" )
416+ }
414417 syn:: Type :: Array ( array) => {
415418 let elem = & array. elem ;
416419 match & array. len {
@@ -423,7 +426,7 @@ fn size_with(
423426 ( #size * <#elem>:: size_with( #ctx) )
424427 }
425428 }
426- _ => panic ! ( "Pread derive with bad array constexpr" ) ,
429+ _ => panic ! ( "SizeWith derive has bad array constexpr" ) ,
427430 }
428431 }
429432 _ => {
@@ -447,15 +450,18 @@ fn size_with(
447450 } ) ;
448451 let gn = quote ! { #gl #( #gn ) , * #gg } ;
449452 let gw = if !gp. is_empty ( ) {
450- let gi = gp. iter ( ) . map ( |param : & syn:: GenericParam | match param {
451- syn:: GenericParam :: Type ( t) => {
452- let ident = & t. ident ;
453- quote ! {
454- #ident : :: scroll:: ctx:: SizeWith <:: scroll:: Endian >
453+ let gi = gp
454+ . iter ( )
455+ . filter_map ( |param : & syn:: GenericParam | match param {
456+ syn:: GenericParam :: Type ( t) => {
457+ let ident = & t. ident ;
458+ Some ( quote ! {
459+ #ident : :: scroll:: ctx:: SizeWith <:: scroll:: Endian >
460+ } )
455461 }
456- }
457- p => quote ! { #p } ,
458- } ) ;
462+ syn :: GenericParam :: Lifetime ( _ ) => None ,
463+ p => Some ( quote ! { #p } ) ,
464+ } ) ;
459465 quote ! { where #( #gi ) , * }
460466 } else {
461467 quote ! { }
@@ -507,6 +513,9 @@ fn impl_cread_struct(
507513 syn:: Ident :: new ( "ctx" , proc_macro2:: Span :: call_site ( ) ) . into_token_stream ( ) ;
508514 let ctx = custom_ctx. unwrap_or ( default_ctx) ;
509515 match ty {
516+ syn:: Type :: Reference ( _) => {
517+ panic ! ( "IOread cannot be derived for references, because SizeWith cannot be derived for references" )
518+ }
510519 syn:: Type :: Array ( array) => {
511520 let arrty = & array. elem ;
512521 match & array. len {
@@ -618,6 +627,9 @@ fn impl_into_ctx(
618627 syn:: Ident :: new ( "ctx" , proc_macro2:: Span :: call_site ( ) ) . into_token_stream ( ) ;
619628 let ctx = custom_ctx. unwrap_or ( default_ctx) ;
620629 match ty {
630+ syn:: Type :: Reference ( _) => {
631+ panic ! ( "IOwrite cannot be derived for references, because SizeWith cannot be derived for references" )
632+ }
621633 syn:: Type :: Array ( array) => {
622634 let arrty = & array. elem ;
623635 quote ! {
0 commit comments