From 94686565dc145122fbb7b4132ac89fb79bbe3fde Mon Sep 17 00:00:00 2001 From: Nikita Strygin Date: Mon, 11 Mar 2024 15:27:08 +0300 Subject: [PATCH] [refactor] #3682: remove direct dependency on syn 1 Signed-off-by: Nikita Strygin --- Cargo.lock | 2 -- Cargo.toml | 1 - macro/utils/Cargo.toml | 1 - macro/utils/src/lib.rs | 66 ---------------------------------------- schema/derive/Cargo.toml | 2 +- 5 files changed, 1 insertion(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5373aded67..0d83e78f461 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3064,7 +3064,6 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 1.0.109", "syn 2.0.41", ] @@ -3675,7 +3674,6 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 1.0.109", "syn 2.0.41", ] diff --git a/Cargo.toml b/Cargo.toml index c7277102586..b44da28f4f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,6 @@ test_network = { version = "=2.0.0-pre-rc.20", path = "core/test_network" } proc-macro-error = "1.0.4" proc-macro2 = "1.0.69" -syn = { package = "syn", version = "1.0.109", default-features = false } syn2 = { package = "syn", version = "2.0.38", default-features = false } quote = "1.0.33" manyhow = { version = "0.8.1", features = ["darling"] } diff --git a/macro/utils/Cargo.toml b/macro/utils/Cargo.toml index 6ee6c66a572..7167dafe639 100644 --- a/macro/utils/Cargo.toml +++ b/macro/utils/Cargo.toml @@ -13,7 +13,6 @@ is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/ir maintenance = { status = "actively-developed" } [dependencies] -syn = { workspace = true, features = ["default", "parsing", "printing"] } syn2 = { workspace = true, features = ["default", "parsing", "printing"] } darling = { workspace = true } quote = { workspace = true } diff --git a/macro/utils/src/lib.rs b/macro/utils/src/lib.rs index 1e069d1bfd8..77127e73c02 100644 --- a/macro/utils/src/lib.rs +++ b/macro/utils/src/lib.rs @@ -4,72 +4,6 @@ mod emitter; pub use emitter::Emitter; -/// Trait for attribute parsing generalization -pub trait AttrParser { - /// Attribute identifier `#[IDENT...]` - const IDENT: &'static str; - - /// Parse `Inner` content of attribute - /// - /// # Errors - /// - If `Inner` parsing failed - /// - If `IDENT` doesn't match - fn parse(attr: &syn::Attribute) -> syn::Result { - attr.path - .is_ident(&>::IDENT) - .then(|| attr.parse_args::()) - .map_or_else( - || { - Err(syn::parse::Error::new_spanned( - attr, - format!( - "Attribute must be in form #[{}...]", - >::IDENT - ), - )) - }, - |inner| inner, - ) - } -} - -/// Macro for automatic [`syn::parse::Parse`] impl generation for keyword -/// attribute structs in derive macros. -#[macro_export] -macro_rules! attr_struct { - // Matching struct with named fields - ( - $( #[$meta:meta] )* - // ^~~~attributes~~~~^ - $vis:vis struct $name:ident { - $( - $( #[$field_meta:meta] )* - // ^~~~field attributes~~~!^ - $field_vis:vis $field_name:ident : $field_ty:ty - // ^~~~~~~~~~~~~~~~~a single field~~~~~~~~~~~~~~~^ - ),* - $(,)? } - ) => { - $( #[$meta] )* - $vis struct $name { - $( - $( #[$field_meta] )* - $field_vis $field_name : $field_ty - ),* - } - - impl syn::parse::Parse for $name { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - Ok(Self { - $( - $field_name: input.parse()?, - )* - }) - } - } - }; -} - /// Extension trait for [`darling::Error`]. /// /// Currently exists to add `with_spans` method. diff --git a/schema/derive/Cargo.toml b/schema/derive/Cargo.toml index d17a56721ee..d7d8e10527f 100644 --- a/schema/derive/Cargo.toml +++ b/schema/derive/Cargo.toml @@ -17,7 +17,7 @@ proc-macro = true syn2 = { workspace = true, features = ["default", "full"] } proc-macro2 = { workspace = true } quote = { workspace = true } -manyhow = { workspace = true, features = ["syn1", "darling"] } +manyhow = { workspace = true, features = ["darling"] } darling = { workspace = true } [dev-dependencies]