diff --git a/Cargo.lock b/Cargo.lock index 7f1cefe2..3fb9157a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3255,7 +3255,7 @@ dependencies = [ [[package]] name = "trustfall" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "csv", @@ -3293,11 +3293,11 @@ dependencies = [ [[package]] name = "trustfall_derive" -version = "0.3.0" +version = "0.3.1" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.27", "trustfall", "trybuild", ] diff --git a/Cargo.toml b/Cargo.toml index e7d3913c..19af6c00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,3 +38,6 @@ once_cell = "1.17" ron = "0.8.0" similar-asserts = "1.4.2" maplit = "1.0.2" +syn = "2.0" +quote = "1.0" +proc-macro2 = "1.0.51" diff --git a/trustfall/Cargo.toml b/trustfall/Cargo.toml index 865572f1..4fbea940 100644 --- a/trustfall/Cargo.toml +++ b/trustfall/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trustfall" -version = "0.6.0" +version = "0.6.1" license = "Apache-2.0" description = "The trustfall query engine, empowering you to query everything." repository = "https://github.com/obi1kenobi/trustfall" @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] anyhow = { workspace = true } trustfall_core = { version = "=0.6.0", path = "../trustfall_core" } -trustfall_derive = { version = "=0.3.0", path = "../trustfall_derive" } +trustfall_derive = { version = "=0.3.1", path = "../trustfall_derive" } [dev-dependencies] # including examples dependencies ron = { workspace = true } diff --git a/trustfall_derive/Cargo.toml b/trustfall_derive/Cargo.toml index 2dfcbe54..b46b62df 100644 --- a/trustfall_derive/Cargo.toml +++ b/trustfall_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trustfall_derive" -version = "0.3.0" +version = "0.3.1" license = "Apache-2.0" description = "Derive macros for the trustfall query engine." repository = "https://github.com/obi1kenobi/trustfall" @@ -15,9 +15,9 @@ authors.workspace = true proc-macro = true [dependencies] -quote = "1.0" -syn = "1.0" -proc-macro2 = "1.0.51" +quote = { workspace = true } +syn = { workspace = true } +proc-macro2 = { workspace = true } [dev-dependencies] trybuild = "1.0" diff --git a/trustfall_derive/src/lib.rs b/trustfall_derive/src/lib.rs index 5643aedb..c925a03f 100644 --- a/trustfall_derive/src/lib.rs +++ b/trustfall_derive/src/lib.rs @@ -249,57 +249,25 @@ fn generate_conversion_method(variant: &syn::Variant) -> syn::Result { - return Err(syn::Error::new_spanned( - attr, - "no arguments found, did you mean `#[trustfall(skip_conversion)]`?", - )); - } - syn::Meta::List(values) => { - let mut skipping = false; - for nested in values.nested.iter() { - match nested { - syn::NestedMeta::Meta(syn::Meta::Path(path)) => { - if let Some(ident) = path.get_ident() { - if ident == SKIP_CONVERSION_ATTRIBUTE { - skipping = true; - } else { - return Err(syn::Error::new_spanned( - nested, - "unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`?", - )); - } - } - } - _ => { - return Err(syn::Error::new_spanned( - attr, - "unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`?", - )); - } - } - } - if skipping { - return Ok(Default::default()); - } - } - syn::Meta::NameValue(name_value) => { - return Err(syn::Error::new_spanned( - &name_value.lit, - "unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`?", - )); - } - }; + let content: syn::Ident = attr.parse_args().map_err(|_| { + syn::Error::new_spanned( + attr, + "unexpected attribute, did you mean `#[trustfall(skip_conversion)]`?", + ) + })?; + if content == SKIP_CONVERSION_ATTRIBUTE { + return Ok(Default::default()); + } else { + return Err(syn::Error::new_spanned( + attr, + "unexpected attribute, did you mean `#[trustfall(skip_conversion)]`?", + )); + } } let variant_ident = &variant.ident; diff --git a/trustfall_derive/tests/ui/invalid_attr_as_path_only.stderr b/trustfall_derive/tests/ui/invalid_attr_as_path_only.stderr index f1a2a594..fbc148cc 100644 --- a/trustfall_derive/tests/ui/invalid_attr_as_path_only.stderr +++ b/trustfall_derive/tests/ui/invalid_attr_as_path_only.stderr @@ -1,4 +1,4 @@ -error: no arguments found, did you mean `#[trustfall(skip_conversion)]`? +error: unexpected attribute, did you mean `#[trustfall(skip_conversion)]`? --> tests/ui/invalid_attr_as_path_only.rs:5:5 | 5 | #[trustfall] diff --git a/trustfall_derive/tests/ui/invalid_attr_unexpected_assignment.stderr b/trustfall_derive/tests/ui/invalid_attr_unexpected_assignment.stderr index 4f4014d2..307e0494 100644 --- a/trustfall_derive/tests/ui/invalid_attr_unexpected_assignment.stderr +++ b/trustfall_derive/tests/ui/invalid_attr_unexpected_assignment.stderr @@ -1,4 +1,4 @@ -error: unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`? +error: unexpected attribute, did you mean `#[trustfall(skip_conversion)]`? --> tests/ui/invalid_attr_unexpected_assignment.rs:6:5 | 6 | #[trustfall(skip_conversion = "yes")] diff --git a/trustfall_derive/tests/ui/invalid_attr_unexpected_list_element.stderr b/trustfall_derive/tests/ui/invalid_attr_unexpected_list_element.stderr index da708f01..756f2b97 100644 --- a/trustfall_derive/tests/ui/invalid_attr_unexpected_list_element.stderr +++ b/trustfall_derive/tests/ui/invalid_attr_unexpected_list_element.stderr @@ -1,11 +1,11 @@ -error: unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`? - --> tests/ui/invalid_attr_unexpected_list_element.rs:5:34 +error: unexpected attribute, did you mean `#[trustfall(skip_conversion)]`? + --> tests/ui/invalid_attr_unexpected_list_element.rs:5:5 | 5 | #[trustfall(skip_conversion, unexpected_arg)] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unexpected arguments found, did you mean `#[trustfall(skip_conversion)]`? - --> tests/ui/invalid_attr_unexpected_list_element.rs:13:17 +error: unexpected attribute, did you mean `#[trustfall(skip_conversion)]`? + --> tests/ui/invalid_attr_unexpected_list_element.rs:13:5 | 13 | #[trustfall(unexpected_arg, skip_conversion)] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/trustfall_stubgen/Cargo.toml b/trustfall_stubgen/Cargo.toml index a721e4a2..2a36533e 100644 --- a/trustfall_stubgen/Cargo.toml +++ b/trustfall_stubgen/Cargo.toml @@ -20,9 +20,9 @@ default = ["cli"] cli = ["dep:clap"] [dependencies] -quote = "1.0" -syn = "2.0" -proc-macro2 = "1.0.51" +quote = { workspace = true } +syn = { workspace = true } +proc-macro2 = { workspace = true } trustfall = { path = "../trustfall", version = "0.6.0" } maplit = { workspace = true } async-graphql-parser = { workspace = true }