Skip to content

Commit

Permalink
use syn2
Browse files Browse the repository at this point in the history
  • Loading branch information
o0Ignition0o committed May 4, 2024
1 parent 21c25b1 commit e9628ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-span-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
8 changes: 3 additions & 5 deletions test-span-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ 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;
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;
Expand All @@ -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(
Expand Down

0 comments on commit e9628ba

Please sign in to comment.