@@ -12,7 +12,6 @@ use proc_macro2::TokenStream;
1212use quote:: quote;
1313use syn:: punctuated:: Punctuated ;
1414use syn:: spanned:: Spanned ;
15- use syn:: AttributeArgs ;
1615
1716use crate :: macros:: deku_read:: emit_deku_read;
1817use crate :: macros:: deku_write:: emit_deku_write;
@@ -208,7 +207,10 @@ impl DekuData {
208207 ast:: Data :: Struct ( _) => {
209208 // Validate id_* attributes are being used on an enum
210209 if data. id_type . is_some ( ) {
211- Err ( cerror ( data. id_type . span ( ) , "`type` only supported on enum" ) )
210+ Err ( cerror (
211+ data. id_type . span ( ) ,
212+ "`id_type` only supported on enum" ,
213+ ) )
212214 } else if data. id . is_some ( ) {
213215 Err ( cerror ( data. id . span ( ) , "`id` only supported on enum" ) )
214216 } else if data. bytes . is_some ( ) {
@@ -220,19 +222,19 @@ impl DekuData {
220222 }
221223 }
222224 ast:: Data :: Enum ( _) => {
223- // Validate `type ` or `id` is specified
225+ // Validate `id_type ` or `id` is specified
224226 if data. id_type . is_none ( ) && data. id . is_none ( ) {
225227 return Err ( cerror (
226228 data. ident . span ( ) ,
227- "`type ` or `id` must be specified on enum" ,
229+ "`id_type ` or `id` must be specified on enum" ,
228230 ) ) ;
229231 }
230232
231- // Validate either `type ` or `id` is specified
233+ // Validate either `id_type ` or `id` is specified
232234 if data. id_type . is_some ( ) && data. id . is_some ( ) {
233235 return Err ( cerror (
234236 data. ident . span ( ) ,
235- "conflicting: both `type ` and `id` specified on enum" ,
237+ "conflicting: both `id_type ` and `id` specified on enum" ,
236238 ) ) ;
237239 }
238240
@@ -654,11 +656,7 @@ struct DekuReceiver {
654656 id : Option < Id > ,
655657
656658 /// enum only: type of the enum `id`
657- #[ darling(
658- rename = "type" ,
659- default = "default_res_opt" ,
660- map = "map_litstr_as_tokenstream"
661- ) ]
659+ #[ darling( default = "default_res_opt" , map = "map_litstr_as_tokenstream" ) ]
662660 id_type : Result < Option < TokenStream > , ReplacementError > ,
663661
664662 /// enum only: bit size of the enum `id`
@@ -898,7 +896,7 @@ pub fn proc_deku_write(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
898896}
899897
900898fn is_not_deku ( attr : & syn:: Attribute ) -> bool {
901- attr. path
899+ attr. path ( )
902900 . get_ident ( )
903901 . map ( |ident| ident != "deku" && ident != "deku_derive" )
904902 . unwrap_or ( true )
@@ -962,8 +960,8 @@ pub fn deku_derive(
962960 item : proc_macro:: TokenStream ,
963961) -> proc_macro:: TokenStream {
964962 // Parse `deku_derive` attribute
965- let attr_args = syn :: parse_macro_input! ( attr as AttributeArgs ) ;
966- let args = match DekuDerive :: from_list ( & attr_args ) {
963+ let nested_meta = darling :: ast :: NestedMeta :: parse_meta_list ( attr. into ( ) ) . unwrap ( ) ;
964+ let args = match DekuDerive :: from_list ( & nested_meta ) {
967965 Ok ( v) => v,
968966 Err ( e) => {
969967 return proc_macro:: TokenStream :: from ( e. write_errors ( ) ) ;
@@ -1062,9 +1060,9 @@ mod tests {
10621060 }"# ) ,
10631061
10641062 // Valid Enum
1065- case:: enum_empty( r#"#[deku(type = "u8")] enum Test {}"# ) ,
1063+ case:: enum_empty( r#"#[deku(id_type = "u8")] enum Test {}"# ) ,
10661064 case:: enum_all( r#"
1067- #[deku(type = "u8")]
1065+ #[deku(id_type = "u8")]
10681066 enum Test {
10691067 #[deku(id = "1")]
10701068 A,
0 commit comments