diff --git a/Cargo.lock b/Cargo.lock index 9f89a7c2..b015231e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,7 +256,7 @@ version = "0.6.0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.110", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 103448c1..8ae5904b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ semver = "1.0.27" serde = "1.0.228" serde_yaml = "0.9.34" sha256 = "1.6.0" -syn = "1.0.109" +syn = "2.0.110" tempfile = "3.23.0" walrus = "0.23.3" wasmparser = "0.235.0" diff --git a/canbench-rs-macros/src/lib.rs b/canbench-rs-macros/src/lib.rs index 37fea20a..0895fc33 100644 --- a/canbench-rs-macros/src/lib.rs +++ b/canbench-rs-macros/src/lib.rs @@ -1,6 +1,7 @@ use proc_macro::TokenStream; use quote::{quote, ToTokens}; -use syn::{parse_macro_input, AttributeArgs, ItemFn, NestedMeta, ReturnType}; +use syn::punctuated::Punctuated; +use syn::{parse_macro_input, ItemFn, Meta, ReturnType, Token}; /// A macro for declaring a benchmark where only some part of the function is /// benchmarked. @@ -10,7 +11,7 @@ pub fn bench(arg_tokens: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as ItemFn); // Parse the attribute arguments - let args = parse_macro_input!(arg_tokens as AttributeArgs); + let args = parse_macro_input!(arg_tokens with Punctuated::::parse_terminated); // Extract function name, inputs, and output let func_name = &input.sig.ident; @@ -32,8 +33,9 @@ pub fn bench(arg_tokens: TokenStream, item: TokenStream) -> TokenStream { let tracing_func_name = syn::Ident::new(&format!("__tracing__{}", func_name), func_name.span()); // Validate the argument and generate code accordingly + let args: Vec = args.into_iter().collect(); let expanded = match args.as_slice() { - [NestedMeta::Meta(meta)] if meta.path().is_ident("raw") => { + [meta] if meta.path().is_ident("raw") => { // If the argument is "raw", validate that the function returns BenchResult if let ReturnType::Type(_, ty) = output { if ty.to_token_stream().to_string() != quote!(BenchResult).to_string()