33
44#![ doc( html_logo_url = "https://avatars.githubusercontent.com/u/46717278" ) ]
55
6- use darling:: FromMeta ;
6+ use darling:: { ast :: NestedMeta , FromMeta } ;
77use proc_macro:: { self , Span , TokenStream } ;
88use proc_macro_error:: { abort, proc_macro_error} ;
99use quote:: quote;
@@ -23,7 +23,6 @@ use syn::{
2323use syn:: {
2424 parse:: { Parse , ParseStream } ,
2525 parse_macro_input,
26- AttributeArgs ,
2726} ;
2827
2928#[ derive( Debug , Default , FromMeta ) ]
@@ -47,7 +46,12 @@ struct RamArgs {
4746#[ proc_macro_attribute]
4847#[ proc_macro_error]
4948pub fn ram ( args : TokenStream , input : TokenStream ) -> TokenStream {
50- let attr_args = parse_macro_input ! ( args as AttributeArgs ) ;
49+ let attr_args = match NestedMeta :: parse_meta_list ( args. into ( ) ) {
50+ Ok ( v) => v,
51+ Err ( e) => {
52+ return TokenStream :: from ( darling:: Error :: from ( e) . write_errors ( ) ) ;
53+ }
54+ } ;
5155
5256 let RamArgs {
5357 rtc_fast,
@@ -142,7 +146,12 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
142146
143147 let mut f: ItemFn = syn:: parse ( input) . expect ( "`#[interrupt]` must be applied to a function" ) ;
144148
145- let attr_args = parse_macro_input ! ( args as AttributeArgs ) ;
149+ let attr_args = match NestedMeta :: parse_meta_list ( args. into ( ) ) {
150+ Ok ( v) => v,
151+ Err ( e) => {
152+ return TokenStream :: from ( darling:: Error :: from ( e) . write_errors ( ) ) ;
153+ }
154+ } ;
146155
147156 if attr_args. len ( ) > 1 {
148157 abort ! (
@@ -156,7 +165,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
156165
157166 if attr_args. len ( ) == 1 {
158167 match & attr_args[ 0 ] {
159- syn :: NestedMeta :: Meta ( Path ( x) ) => {
168+ NestedMeta :: Meta ( Path ( x) ) => {
160169 ident_s = x. get_ident ( ) . unwrap ( ) ;
161170 }
162171 _ => {
@@ -285,12 +294,6 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
285294 ( f. sig . inputs . len ( ) == 1 ) . then ( || Ident :: new ( "context" , proc_macro2:: Span :: call_site ( ) ) ) ;
286295
287296 quote ! (
288- macro_rules! foo {
289- ( ) => {
290- } ;
291- }
292- foo!( ) ;
293-
294297 #( #cfgs) *
295298 #( #attrs) *
296299 #[ doc( hidden) ]
@@ -351,7 +354,7 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result<
351354/// Returns `true` if `attr.path` matches `name`
352355#[ cfg( feature = "interrupt" ) ]
353356fn eq ( attr : & Attribute , name : & str ) -> bool {
354- attr. style == AttrStyle :: Outer && attr. path . is_ident ( name)
357+ attr. style == AttrStyle :: Outer && attr. path ( ) . is_ident ( name)
355358}
356359
357360#[ cfg( feature = "interrupt" ) ]
0 commit comments