@@ -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;
@@ -205,7 +204,10 @@ impl DekuData {
205204 ast:: Data :: Struct ( _) => {
206205 // Validate id_* attributes are being used on an enum
207206 if data. id_type . is_some ( ) {
208- Err ( cerror ( data. id_type . span ( ) , "`type` only supported on enum" ) )
207+ Err ( cerror (
208+ data. id_type . span ( ) ,
209+ "`id_type` only supported on enum" ,
210+ ) )
209211 } else if data. id . is_some ( ) {
210212 Err ( cerror ( data. id . span ( ) , "`id` only supported on enum" ) )
211213 } else if data. bytes . is_some ( ) {
@@ -217,19 +219,19 @@ impl DekuData {
217219 }
218220 }
219221 ast:: Data :: Enum ( _) => {
220- // Validate `type ` or `id` is specified
222+ // Validate `id_type ` or `id` is specified
221223 if data. id_type . is_none ( ) && data. id . is_none ( ) {
222224 return Err ( cerror (
223225 data. ident . span ( ) ,
224- "`type ` or `id` must be specified on enum" ,
226+ "`id_type ` or `id` must be specified on enum" ,
225227 ) ) ;
226228 }
227229
228- // Validate either `type ` or `id` is specified
230+ // Validate either `id_type ` or `id` is specified
229231 if data. id_type . is_some ( ) && data. id . is_some ( ) {
230232 return Err ( cerror (
231233 data. ident . span ( ) ,
232- "conflicting: both `type ` and `id` specified on enum" ,
234+ "conflicting: both `id_type ` and `id` specified on enum" ,
233235 ) ) ;
234236 }
235237
@@ -635,11 +637,7 @@ struct DekuReceiver {
635637 id : Option < Id > ,
636638
637639 /// enum only: type of the enum `id`
638- #[ darling(
639- rename = "type" ,
640- default = "default_res_opt" ,
641- map = "map_litstr_as_tokenstream"
642- ) ]
640+ #[ darling( default = "default_res_opt" , map = "map_litstr_as_tokenstream" ) ]
643641 id_type : Result < Option < TokenStream > , ReplacementError > ,
644642
645643 /// enum only: bit size of the enum `id`
@@ -875,7 +873,7 @@ pub fn proc_deku_write(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
875873}
876874
877875fn is_not_deku ( attr : & syn:: Attribute ) -> bool {
878- attr. path
876+ attr. path ( )
879877 . get_ident ( )
880878 . map ( |ident| ident != "deku" && ident != "deku_derive" )
881879 . unwrap_or ( true )
@@ -939,8 +937,8 @@ pub fn deku_derive(
939937 item : proc_macro:: TokenStream ,
940938) -> proc_macro:: TokenStream {
941939 // Parse `deku_derive` attribute
942- let attr_args = syn :: parse_macro_input! ( attr as AttributeArgs ) ;
943- let args = match DekuDerive :: from_list ( & attr_args ) {
940+ let nested_meta = darling :: ast :: NestedMeta :: parse_meta_list ( attr. into ( ) ) . unwrap ( ) ;
941+ let args = match DekuDerive :: from_list ( & nested_meta ) {
944942 Ok ( v) => v,
945943 Err ( e) => {
946944 return proc_macro:: TokenStream :: from ( e. write_errors ( ) ) ;
@@ -1039,9 +1037,9 @@ mod tests {
10391037 }"# ) ,
10401038
10411039 // Valid Enum
1042- case:: enum_empty( r#"#[deku(type = "u8")] enum Test {}"# ) ,
1040+ case:: enum_empty( r#"#[deku(id_id_type = "u8")] enum Test {}"# ) ,
10431041 case:: enum_all( r#"
1044- #[deku(type = "u8")]
1042+ #[deku(id_id_type = "u8")]
10451043 enum Test {
10461044 #[deku(id = "1")]
10471045 A,
0 commit comments