From e9628ba2f2f77b597c23a14e983217765bedd1b0 Mon Sep 17 00:00:00 2001 From: o0Ignition0o Date: Sat, 4 May 2024 14:09:31 +0200 Subject: [PATCH] use syn2 --- Cargo.lock | 2 +- test-span-macro/Cargo.toml | 2 +- test-span-macro/src/lib.rs | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cd2be6..51e9ca4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -657,7 +657,7 @@ version = "0.7.0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] diff --git a/test-span-macro/Cargo.toml b/test-span-macro/Cargo.toml index 7832333..ed4c339 100644 --- a/test-span-macro/Cargo.toml +++ b/test-span-macro/Cargo.toml @@ -16,4 +16,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0" quote = { version = "1.0" } -syn = { version = "1.0", features = ["full"] } +syn = { version = "2.0", features = ["full"] } diff --git a/test-span-macro/src/lib.rs b/test-span-macro/src/lib.rs index 24c6209..746393f 100644 --- a/test-span-macro/src/lib.rs +++ b/test-span-macro/src/lib.rs @@ -4,7 +4,6 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; use syn::parse_macro_input; -use syn::AttributeArgs; use syn::ExprAssign; use syn::ItemFn; use syn::Path; @@ -12,13 +11,12 @@ use syn::ReturnType; #[proc_macro_attribute] pub fn test_span(attr: TokenStream, item: TokenStream) -> TokenStream { - let attrs = parse_macro_input!(attr as AttributeArgs); let test_fn = parse_macro_input!(item as ItemFn); - let macro_attrs = if attrs.as_slice().is_empty() { + let macro_attrs = if attr.is_empty() { quote! { test } } else { - quote! {#(#attrs)*} + attr.into() }; let fn_attrs = &test_fn.attrs; @@ -31,7 +29,7 @@ pub fn test_span(attr: TokenStream, item: TokenStream) -> TokenStream { let fn_attrs = fn_attrs .iter() .filter(|attr| { - let path = &attr.path; + let path = &attr.path(); match quote!(#path).to_string().as_str() { "level" => { let value: Path = attr.parse_args().expect(