From dc87fec34dedbdefda8a7e4cb06aecda620356ee Mon Sep 17 00:00:00 2001 From: Doug Smith Date: Mon, 10 Jul 2023 15:04:57 -0400 Subject: [PATCH 1/3] chore(deps): Bump to syn 2, serde_with 3, darling 0.20, and serde_derive_internals 0.28 --- Cargo.lock | 80 +++++++++++++++---- Cargo.toml | 2 +- lib/vector-config-common/Cargo.toml | 4 +- lib/vector-config-common/src/validation.rs | 26 +++--- lib/vector-config-macros/Cargo.toml | 6 +- lib/vector-config-macros/src/ast/container.rs | 2 +- lib/vector-config-macros/src/ast/field.rs | 28 +++---- lib/vector-config-macros/src/ast/mod.rs | 66 ++++++++------- lib/vector-config-macros/src/ast/util.rs | 39 +++++---- lib/vector-config-macros/src/ast/variant.rs | 12 +-- .../src/component_name.rs | 10 ++- lib/vector-config-macros/src/configurable.rs | 4 +- .../src/configurable_component.rs | 16 ++-- lib/vector-config/Cargo.toml | 6 +- lib/vector-core/Cargo.toml | 2 +- 15 files changed, 192 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1edc908749f4..27593972d5bd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2485,6 +2485,16 @@ dependencies = [ "darling_macro 0.14.2", ] +[[package]] +name = "darling" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +dependencies = [ + "darling_core 0.20.1", + "darling_macro 0.20.1", +] + [[package]] name = "darling_core" version = "0.13.4" @@ -2513,6 +2523,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2 1.0.64", + "quote 1.0.29", + "strsim 0.10.0", + "syn 2.0.23", +] + [[package]] name = "darling_macro" version = "0.13.4" @@ -2535,6 +2559,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +dependencies = [ + "darling_core 0.20.1", + "quote 1.0.29", + "syn 2.0.23", +] + [[package]] name = "dashmap" version = "5.5.0" @@ -7408,13 +7443,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "e578a843d40b4189a4d66bba51d7684f57da5bd7c304c64e14bd63efbef49509" dependencies = [ "proc-macro2 1.0.64", "quote 1.0.29", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] @@ -7512,7 +7547,22 @@ dependencies = [ "indexmap 1.9.3", "serde", "serde_json", - "serde_with_macros 2.3.2", + "time", +] + +[[package]] +name = "serde_with" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02d8aa6e3c385bf084924f660ce2a3a6bd333ba55b35e8590b321f35d88513" +dependencies = [ + "base64 0.21.2", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros 3.0.0", "time", ] @@ -7530,14 +7580,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.3.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859011bddcc11f289f07f467cc1fe01c7a941daa4d8f6c40d4d1c92eb6d9319c" +checksum = "edc7d5d3932fb12ce722ee5e64dd38c504efba37567f0c402f6ca728c3b8b070" dependencies = [ - "darling 0.14.2", + "darling 0.20.1", "proc-macro2 1.0.64", "quote 1.0.29", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] @@ -9326,7 +9376,7 @@ dependencies = [ "serde-toml-merge", "serde_bytes", "serde_json", - "serde_with 2.3.2", + "serde_with 3.0.0", "serde_yaml 0.9.22", "sha2 0.10.7", "similar-asserts", @@ -9494,7 +9544,7 @@ dependencies = [ "once_cell", "serde", "serde_json", - "serde_with 2.3.2", + "serde_with 3.0.0", "snafu", "toml 0.7.6", "tracing 0.1.37", @@ -9509,13 +9559,13 @@ name = "vector-config-common" version = "0.1.0" dependencies = [ "convert_case 0.6.0", - "darling 0.13.4", + "darling 0.20.1", "once_cell", "proc-macro2 1.0.64", "quote 1.0.29", "serde", "serde_json", - "syn 1.0.109", + "syn 2.0.23", "tracing 0.1.37", ] @@ -9523,12 +9573,12 @@ dependencies = [ name = "vector-config-macros" version = "0.1.0" dependencies = [ - "darling 0.13.4", + "darling 0.20.1", "proc-macro2 1.0.64", "quote 1.0.29", "serde", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.23", "vector-config", "vector-config-common", ] @@ -9586,7 +9636,7 @@ dependencies = [ "security-framework", "serde", "serde_json", - "serde_with 2.3.2", + "serde_with 3.0.0", "similar-asserts", "smallvec", "snafu", diff --git a/Cargo.toml b/Cargo.toml index b8ade5046d7c5..64eb41e97fe59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -198,7 +198,7 @@ serde = { version = "1.0.168", default-features = false, features = ["derive"] } serde-toml-merge = { version = "0.3.0", default-features = false } serde_bytes = { version = "0.11.11", default-features = false, features = ["std"], optional = true } serde_json = { version = "1.0.100", default-features = false, features = ["raw_value"] } -serde_with = { version = "2.3.2", default-features = false, features = ["macros", "std"] } +serde_with = { version = "3.0.0", default-features = false, features = ["macros", "std"] } serde_yaml = { version = "0.9.22", default-features = false } # Messagepack diff --git a/lib/vector-config-common/Cargo.toml b/lib/vector-config-common/Cargo.toml index 0d4ddaed219a0..9de0b5159865a 100644 --- a/lib/vector-config-common/Cargo.toml +++ b/lib/vector-config-common/Cargo.toml @@ -6,11 +6,11 @@ license = "MPL-2.0" [dependencies] convert_case = { version = "0.6", default-features = false } -darling = { version = "0.13", default-features = false, features = ["suggestions"] } +darling = { version = "0.20", default-features = false, features = ["suggestions"] } once_cell = { version = "1", default-features = false, features = ["std"] } proc-macro2 = { version = "1.0", default-features = false } serde = { version = "1.0", default-features = false, features = ["derive"] } serde_json = { version = "1.0", default-features = false, features = ["std"] } -syn = { version = "1.0", features = ["full", "extra-traits", "visit-mut", "visit"] } +syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut", "visit"] } tracing = { version = "0.1.34", default-features = false } quote = { version = "1.0", default-features = false } diff --git a/lib/vector-config-common/src/validation.rs b/lib/vector-config-common/src/validation.rs index f264b707fe461..569f80cf33007 100644 --- a/lib/vector-config-common/src/validation.rs +++ b/lib/vector-config-common/src/validation.rs @@ -1,7 +1,7 @@ use darling::FromMeta; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; -use syn::{Lit, Meta}; +use syn::{Expr, Lit, Meta}; use crate::{ num::{ERR_NUMERIC_OUT_OF_RANGE, NUMERIC_ENFORCED_LOWER_BOUND, NUMERIC_ENFORCED_UPPER_BOUND}, @@ -336,17 +336,19 @@ fn maybe_float_or_int(meta: &Meta) -> darling::Result> { // First make sure we can even get a valid f64 from this meta item. let result = match meta { Meta::Path(_) => Err(darling::Error::unexpected_type("path")), - Meta::List(_) => Err(darling::Error::unexpected_type("path")), - Meta::NameValue(nv) => match &nv.lit { - Lit::Str(s) => { - let s = s.value(); - s.as_str() - .parse() - .map_err(|_| darling::Error::unknown_value(s.as_str())) - } - Lit::Int(i) => i.base10_parse::().map_err(Into::into), - Lit::Float(f) => f.base10_parse::().map_err(Into::into), - lit => Err(darling::Error::unexpected_lit_type(lit)), + Meta::List(_) => Err(darling::Error::unexpected_type("list")), + Meta::NameValue(nv) => match &nv.value { + Expr::Lit(expr) => match &expr.lit { + Lit::Str(s) => { + let s = s.value(); + s.parse() + .map_err(|_| darling::Error::unknown_value(s.as_str())) + } + Lit::Int(i) => i.base10_parse::().map_err(Into::into), + Lit::Float(f) => f.base10_parse::().map_err(Into::into), + lit => Err(darling::Error::unexpected_lit_type(lit)), + }, + expr => Err(darling::Error::unexpected_expr_type(expr)), }, }; diff --git a/lib/vector-config-macros/Cargo.toml b/lib/vector-config-macros/Cargo.toml index 9b3b2eb91ff74..357065d8465a1 100644 --- a/lib/vector-config-macros/Cargo.toml +++ b/lib/vector-config-macros/Cargo.toml @@ -8,11 +8,11 @@ license = "MPL-2.0" proc-macro = true [dependencies] -darling = { version = "0.13", default-features = false, features = ["suggestions"] } +darling = { version = "0.20", default-features = false, features = ["suggestions"] } proc-macro2 = { version = "1.0", default-features = false } quote = { version = "1.0", default-features = false } -serde_derive_internals = "0.26" -syn = { version = "1.0", default-features = false, features = ["full", "extra-traits", "visit-mut", "visit"] } +serde_derive_internals = "0.28" +syn = { version = "2.0", default-features = false, features = ["full", "extra-traits", "visit-mut", "visit"] } vector-config-common = { path = "../vector-config-common" } [dev-dependencies] diff --git a/lib/vector-config-macros/src/ast/container.rs b/lib/vector-config-macros/src/ast/container.rs index f4a47e71d18e7..a29117a118795 100644 --- a/lib/vector-config-macros/src/ast/container.rs +++ b/lib/vector-config-macros/src/ast/container.rs @@ -368,7 +368,7 @@ impl<'a> Container<'a> { /// standard `#[deprecated]` attribute, neither automatically applying it nor deriving the /// deprecation status of a field when it is present. pub fn deprecated(&self) -> bool { - self.attrs.deprecated.is_some() + self.attrs.deprecated.is_present() } /// Metadata (custom attributes) for the container, if any. diff --git a/lib/vector-config-macros/src/ast/field.rs b/lib/vector-config-macros/src/ast/field.rs index 790bf07b7dadd..d38ce6c95417c 100644 --- a/lib/vector-config-macros/src/ast/field.rs +++ b/lib/vector-config-macros/src/ast/field.rs @@ -2,9 +2,10 @@ use darling::{ util::{Flag, Override, SpannedValue}, FromAttributes, }; -use proc_macro2::Span; +use proc_macro2::{Span, TokenStream}; +use quote::ToTokens; use serde_derive_internals::ast as serde_ast; -use syn::{parse_quote, spanned::Spanned, ExprPath, Ident}; +use syn::{parse_quote, ExprPath, Ident}; use vector_config_common::validation::Validation; use super::{ @@ -174,7 +175,7 @@ impl<'a> Field<'a> { /// variants, to simply document themselves at the container/variant level and avoid needing to /// document that inner field which itself needs no further title/description. pub fn transparent(&self) -> bool { - self.attrs.transparent.is_some() + self.attrs.transparent.is_present() } /// Whether or not the field is deprecated. @@ -239,12 +240,9 @@ impl<'a> Field<'a> { } } -impl<'a> Spanned for Field<'a> { - fn span(&self) -> proc_macro2::Span { - match self.original.ident.as_ref() { - Some(ident) => ident.span(), - None => self.original.ty.span(), - } +impl<'a> ToTokens for Field<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.original.to_tokens(tokens) } } @@ -300,12 +298,12 @@ impl Attributes { // to throw an error if they are. As we're going to forcefully mark the field as // transparent, there's no reason to allow setting derived/transparent manually, as it // only leads to boilerplate and potential confusion. - if self.transparent.is_some() { - return Err(err_field_implicit_transparent(&self.transparent)); + if self.transparent.is_present() { + return Err(err_field_implicit_transparent(&self.transparent.span())); } - if self.derived.is_some() { - return Err(err_field_implicit_transparent(&self.derived)); + if self.derived.is_present() { + return Err(err_field_implicit_transparent(&self.derived.span())); } self.transparent = SpannedValue::new(Flag::present(), Span::call_site()); @@ -339,8 +337,8 @@ impl Attributes { // like a field that is flattened or not visible, it makes no sense to require a description or title for fields // in a virtual newtype. if self.description.is_none() - && !self.derived.is_some() - && !self.transparent.is_some() + && !self.derived.is_present() + && !self.transparent.is_present() && self.visible && !self.flatten && !is_virtual_newtype diff --git a/lib/vector-config-macros/src/ast/mod.rs b/lib/vector-config-macros/src/ast/mod.rs index 7688d6f2df511..1825f9e6fd4e9 100644 --- a/lib/vector-config-macros/src/ast/mod.rs +++ b/lib/vector-config-macros/src/ast/mod.rs @@ -1,4 +1,4 @@ -use darling::{error::Accumulator, util::path_to_string, FromMeta}; +use darling::{ast::NestedMeta, error::Accumulator, util::path_to_string, FromMeta}; use quote::ToTokens; use serde_derive_internals::{ast as serde_ast, attr as serde_attr}; @@ -9,7 +9,7 @@ mod variant; pub use container::Container; pub use field::Field; -use syn::{Expr, NestedMeta}; +use syn::Expr; pub use variant::Variant; use vector_config_common::constants; @@ -196,36 +196,46 @@ impl FromMeta for Metadata { errors.push(darling::Error::unexpected_type("list").with_span(nmeta)); None } - syn::Meta::NameValue(nv) => match &nv.lit { - // When dealing with a string literal, we check if it ends in `()`. If so, - // we emit that as-is, leading to doing a function call and using the return - // value of that function as the value for this key/value pair. - // - // Otherwise, we just treat the string literal normally. - syn::Lit::Str(s) => { - if s.value().ends_with("()") { - if let Ok(expr) = s.parse::() { - Some(LazyCustomAttribute::KeyValue { - key: path_to_string(&nv.path), - value: expr.to_token_stream(), - }) - } else { - errors.push( - darling::Error::custom(INVALID_VALUE_EXPR).with_span(nmeta), - ); - None + syn::Meta::NameValue(nv) => match &nv.value { + Expr::Lit(expr) => { + match &expr.lit { + // When dealing with a string literal, we check if it ends in `()`. If so, + // we emit that as-is, leading to doing a function call and using the return + // value of that function as the value for this key/value pair. + // + // Otherwise, we just treat the string literal normally. + syn::Lit::Str(s) => { + if s.value().ends_with("()") { + if let Ok(expr) = s.parse::() { + Some(LazyCustomAttribute::KeyValue { + key: path_to_string(&nv.path), + value: expr.to_token_stream(), + }) + } else { + errors.push( + darling::Error::custom(INVALID_VALUE_EXPR) + .with_span(nmeta), + ); + None + } + } else { + Some(LazyCustomAttribute::KeyValue { + key: path_to_string(&nv.path), + value: s.value().to_token_stream(), + }) + } } - } else { - Some(LazyCustomAttribute::KeyValue { + lit => Some(LazyCustomAttribute::KeyValue { key: path_to_string(&nv.path), - value: s.value().to_token_stream(), - }) + value: lit.to_token_stream(), + }), } } - lit => Some(LazyCustomAttribute::KeyValue { - key: path_to_string(&nv.path), - value: lit.to_token_stream(), - }), + expr => { + errors + .push(darling::Error::unexpected_expr_type(expr).with_span(nmeta)); + None + } }, }, NestedMeta::Lit(_) => { diff --git a/lib/vector-config-macros/src/ast/util.rs b/lib/vector-config-macros/src/ast/util.rs index 30f66bd6a406a..ddd36c5739448 100644 --- a/lib/vector-config-macros/src/ast/util.rs +++ b/lib/vector-config-macros/src/ast/util.rs @@ -1,7 +1,10 @@ -use darling::error::Accumulator; +use darling::{ast::NestedMeta, error::Accumulator}; use quote::{quote, ToTokens}; use serde_derive_internals::{attr as serde_attr, Ctxt}; -use syn::{spanned::Spanned, Attribute, ExprPath, Lit, Meta, MetaNameValue, NestedMeta}; +use syn::{ + punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, Expr, ExprLit, ExprPath, + Lit, Meta, MetaNameValue, +}; const ERR_FIELD_MISSING_DESCRIPTION: &str = "field must have a description -- i.e. `/// This is a widget...` or `#[configurable(description = \"...\")] -- or derive it from the underlying type of the field by specifying `#[configurable(derived)]`"; const ERR_FIELD_IMPLICIT_TRANSPARENT: &str = @@ -15,12 +18,16 @@ pub fn try_extract_doc_title_description( let doc_comments = attributes .iter() // We only care about `doc` attributes. - .filter(|attribute| attribute.path.is_ident("doc")) + .filter(|attribute| attribute.path().is_ident("doc")) // Extract the value of the attribute if it's in the form of `doc = "..."`. - .filter_map(|attribute| match attribute.parse_meta() { - Ok(Meta::NameValue(MetaNameValue { - lit: Lit::Str(s), .. - })) => Some(s.value()), + .filter_map(|attribute| match &attribute.meta { + Meta::NameValue(MetaNameValue { + value: + Expr::Lit(ExprLit { + lit: Lit::Str(s), .. + }), + .. + }) => Some(s.value()), _ => None, }) .collect::>(); @@ -209,12 +216,13 @@ fn find_name_value_attribute( attributes .iter() // Only take attributes whose name matches `attr_name`. - .filter(|attr| path_matches(&attr.path, attr_name)) - // Make sure the contents actually parse as a normal structured attribute. - .filter_map(|attr| attr.parse_meta().ok()) + .filter(|attr| path_matches(attr.path(), attr_name)) // Derive macro helper attributes will always be in the list form. - .filter_map(|meta| match meta { - Meta::List(ml) => Some(ml.nested.into_iter()), + .filter_map(|attr| match &attr.meta { + Meta::List(ml) => ml + .parse_args_with(Punctuated::::parse_terminated) + .map(|nested| nested.into_iter()) + .ok(), _ => None, }) .flatten() @@ -222,7 +230,10 @@ fn find_name_value_attribute( // name matches `name_key`, and return their value. .find_map(|nm| match nm { NestedMeta::Meta(meta) => match meta { - Meta::NameValue(nv) if path_matches(&nv.path, name_key) => Some(nv.lit), + Meta::NameValue(nv) if path_matches(&nv.path, name_key) => match nv.value { + Expr::Lit(ExprLit { lit, .. }) => Some(lit), + _ => None, + }, _ => None, }, _ => None, @@ -259,7 +270,7 @@ fn find_name_value_attribute( /// returned. pub fn find_delegated_serde_deser_ty(attributes: &[syn::Attribute]) -> Option { // Make sure `#[serde_as(as = "...")]` is present. - find_name_value_attribute(attributes, "serde_as", "as") + find_name_value_attribute(attributes, "serde_as", "r#as") // Make sure `#[serde(with = "...")]` is present, and grab its value. .and_then(|_| find_name_value_attribute(attributes, "serde", "with")) // Try and parse the value as a type path. diff --git a/lib/vector-config-macros/src/ast/variant.rs b/lib/vector-config-macros/src/ast/variant.rs index ea25903a9ec00..5b54ebc30d18f 100644 --- a/lib/vector-config-macros/src/ast/variant.rs +++ b/lib/vector-config-macros/src/ast/variant.rs @@ -1,7 +1,7 @@ use darling::{error::Accumulator, util::Flag, FromAttributes}; -use proc_macro2::Ident; +use proc_macro2::{Ident, TokenStream}; +use quote::ToTokens; use serde_derive_internals::ast as serde_ast; -use syn::spanned::Spanned; use super::{ util::{try_extract_doc_title_description, DarlingResultIterator}, @@ -140,7 +140,7 @@ impl<'a> Variant<'a> { /// standard `#[deprecated]` attribute, neither automatically applying it nor deriving the /// deprecation status of a variant when it is present. pub fn deprecated(&self) -> bool { - self.attrs.deprecated.is_some() + self.attrs.deprecated.is_present() } /// Whether or not this variant is visible during either serialization or deserialization. @@ -166,9 +166,9 @@ impl<'a> Variant<'a> { } } -impl<'a> Spanned for Variant<'a> { - fn span(&self) -> proc_macro2::Span { - self.original.span() +impl<'a> ToTokens for Variant<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.original.to_tokens(tokens) } } diff --git a/lib/vector-config-macros/src/component_name.rs b/lib/vector-config-macros/src/component_name.rs index 1dd974d604a7b..8c7e5efd2e65e 100644 --- a/lib/vector-config-macros/src/component_name.rs +++ b/lib/vector-config-macros/src/component_name.rs @@ -106,7 +106,7 @@ pub fn derive_component_name_impl(input: TokenStream) -> TokenStream { fn attr_to_component_name(attr: &Attribute) -> Result, Error> { // First, filter out anything that isn't ours. if !path_matches( - &attr.path, + attr.path(), &[ attrs::ENRICHMENT_TABLE_COMPONENT, attrs::PROVIDER_COMPONENT, @@ -121,14 +121,14 @@ fn attr_to_component_name(attr: &Attribute) -> Result, Error> { // Reconstruct the original attribute path (i.e. `source`) from our marker version of it (i.e. // `source_component`), so that any error message we emit is contextually relevant. - let path_str = path_to_string(&attr.path); + let path_str = path_to_string(attr.path()); let component_type_attr = path_str.replace("_component", ""); let component_type = component_type_attr.replace('_', " "); // Make sure the attribute actually has inner tokens. If it doesn't, this means they forgot // entirely to specify a component name, and we want to give back a meaningful error that looks // correct when applied in the context of `#[configurable_component(...)]`. - if attr.tokens.is_empty() { + if attr.meta.require_list().is_err() { return Err(Error::new( attr.span(), format!( @@ -162,6 +162,10 @@ fn check_component_name_validity(component_name: &str) -> Result<(), String> { // In a nutshell, component names must contain only lowercase ASCII alphabetic characters, or // numbers, or underscores. + if component_name.is_empty() { + return Err("component name must be non-empty".to_string()); + } + // We only support ASCII names, so get that out of the way. if !component_name.is_ascii() { return Err("component names may only contain ASCII characters".to_string()); diff --git a/lib/vector-config-macros/src/configurable.rs b/lib/vector-config-macros/src/configurable.rs index 21c87804e34bf..b26e317b998f5 100644 --- a/lib/vector-config-macros/src/configurable.rs +++ b/lib/vector-config-macros/src/configurable.rs @@ -2,7 +2,7 @@ use proc_macro::TokenStream; use proc_macro2::Span; use quote::{quote, quote_spanned}; use syn::{ - parse_macro_input, parse_quote, spanned::Spanned, token::Colon2, DeriveInput, ExprPath, Ident, + parse_macro_input, parse_quote, spanned::Spanned, token::PathSep, DeriveInput, ExprPath, Ident, PathArguments, Type, }; use vector_config_common::validation::Validation; @@ -1058,7 +1058,7 @@ fn get_ty_for_expr_pos(ty: &syn::Type) -> syn::Type { let mut new_tp = tp.clone(); for segment in new_tp.path.segments.iter_mut() { if let PathArguments::AngleBracketed(ab) = &mut segment.arguments { - ab.colon2_token = Some(Colon2::default()); + ab.colon2_token = Some(PathSep::default()); } } diff --git a/lib/vector-config-macros/src/configurable_component.rs b/lib/vector-config-macros/src/configurable_component.rs index 37acc7703f24d..3a32583f19278 100644 --- a/lib/vector-config-macros/src/configurable_component.rs +++ b/lib/vector-config-macros/src/configurable_component.rs @@ -1,10 +1,10 @@ -use darling::{Error, FromMeta}; +use darling::{ast::NestedMeta, Error, FromMeta}; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{quote, quote_spanned}; use syn::{ parse_macro_input, parse_quote, parse_quote_spanned, punctuated::Punctuated, spanned::Spanned, - token::Comma, AttributeArgs, DeriveInput, Lit, LitStr, Meta, MetaList, NestedMeta, Path, + token::Comma, DeriveInput, Lit, LitStr, Meta, MetaList, Path, }; use vector_config_common::{ constants::ComponentType, human_friendly::generate_human_friendly_string, @@ -41,7 +41,10 @@ impl TypedComponent { /// If the meta list does not have a path that matches a known component type, `None` is /// returned. Otherwise, `Some(...)` is returned with a valid `TypedComponent`. fn from_meta_list(ml: &MetaList) -> Option { - let mut items = ml.nested.iter(); + let mut items = ml + .parse_args_with(Punctuated::::parse_terminated) + .unwrap_or_default() + .into_iter(); ComponentType::try_from(&ml.path) .ok() .map(|component_type| { @@ -157,7 +160,7 @@ struct Options { } impl FromMeta for Options { - fn from_list(items: &[syn::NestedMeta]) -> darling::Result { + fn from_list(items: &[NestedMeta]) -> darling::Result { let mut typed_component = None; let mut no_ser = false; let mut no_deser = false; @@ -255,7 +258,10 @@ impl Options { } pub fn configurable_component_impl(args: TokenStream, item: TokenStream) -> TokenStream { - let args = parse_macro_input!(args as AttributeArgs); + let args: Vec = + parse_macro_input!(args with Punctuated::::parse_terminated) + .into_iter() + .collect(); let input = parse_macro_input!(item as DeriveInput); let options = match Options::from_list(&args) { diff --git a/lib/vector-config/Cargo.toml b/lib/vector-config/Cargo.toml index e03ddb12d56a4..fcd208be02704 100644 --- a/lib/vector-config/Cargo.toml +++ b/lib/vector-config/Cargo.toml @@ -16,12 +16,12 @@ chrono-tz = { version = "0.8.3", default-features = false } encoding_rs = { version = "0.8", default-features = false, features = ["alloc", "serde"] } indexmap = { version = "2.0", default-features = false, features = ["std"] } inventory = { version = "0.3" } -no-proxy = { version = "0.3.1", default-features = false, features = ["serialize"] } +no-proxy = { version = "0.3.1", default-features = false, features = ["serialize"] } num-traits = { version = "0.2.15", default-features = false } once_cell = { version = "1", default-features = false } serde = { version = "1.0", default-features = false } serde_json = { version = "1.0", default-features = false, features = ["std"] } -serde_with = { version = "2.3.2", default-features = false, features = ["std"] } +serde_with = { version = "3.0.0", default-features = false, features = ["std"] } snafu = { version = "0.7.5", default-features = false } toml = { version = "0.7.6", default-features = false } tracing = { version = "0.1.34", default-features = false } @@ -32,4 +32,4 @@ vector-config-macros = { path = "../vector-config-macros" } [dev-dependencies] assert-json-diff = { version = "2", default-features = false } -serde_with = { version = "2.3.2", default-features = false, features = ["std", "macros"] } +serde_with = { version = "3.0.0", default-features = false, features = ["std", "macros"] } diff --git a/lib/vector-core/Cargo.toml b/lib/vector-core/Cargo.toml index 9fd0347209f8c..14f34bf82f0fc 100644 --- a/lib/vector-core/Cargo.toml +++ b/lib/vector-core/Cargo.toml @@ -42,7 +42,7 @@ regex = { version = "1.9.1", default-features = false, features = ["std", "perf" ryu = { version = "1", default-features = false } serde = { version = "1.0.168", default-features = false, features = ["derive", "rc"] } serde_json = { version = "1.0.100", default-features = false } -serde_with = { version = "2.3.2", default-features = false, features = ["std", "macros"] } +serde_with = { version = "3.0.0", default-features = false, features = ["std", "macros"] } smallvec = { version = "1", default-features = false, features = ["serde", "const_generics"] } snafu = { version = "0.7.5", default-features = false } socket2 = { version = "0.5.3", default-features = false } From ca435bb5d9940dc40c77feeb28cc479475b966d8 Mon Sep 17 00:00:00 2001 From: Doug Smith Date: Mon, 10 Jul 2023 15:45:08 -0400 Subject: [PATCH 2/3] clippy --- lib/vector-config-macros/src/configurable_component.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vector-config-macros/src/configurable_component.rs b/lib/vector-config-macros/src/configurable_component.rs index 3a32583f19278..42d7813768aa6 100644 --- a/lib/vector-config-macros/src/configurable_component.rs +++ b/lib/vector-config-macros/src/configurable_component.rs @@ -49,11 +49,11 @@ impl TypedComponent { .ok() .map(|component_type| { let component_name = match items.next() { - Some(NestedMeta::Lit(Lit::Str(component_name))) => Some(component_name.clone()), + Some(NestedMeta::Lit(Lit::Str(component_name))) => Some(component_name), _ => None, }; let description = match items.next() { - Some(NestedMeta::Lit(Lit::Str(description))) => Some(description.clone()), + Some(NestedMeta::Lit(Lit::Str(description))) => Some(description), _ => None, }; Self { From 1b5f79e03a34cdf54449c1ef0ef98cea6db018d6 Mon Sep 17 00:00:00 2001 From: Doug Smith Date: Tue, 11 Jul 2023 13:00:23 -0400 Subject: [PATCH 3/3] fix test --- lib/vector-config-macros/src/ast/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vector-config-macros/src/ast/container.rs b/lib/vector-config-macros/src/ast/container.rs index a29117a118795..28cc12f69a35a 100644 --- a/lib/vector-config-macros/src/ast/container.rs +++ b/lib/vector-config-macros/src/ast/container.rs @@ -584,7 +584,7 @@ mod tests { assert_eq!(literals_to_idents(&["T"]), idents); // We don't support parenthesized type parameters, like when using a function pointer type. - let parenthesized_type: Type = parse_quote! { Something String> }; + let parenthesized_type: Type = parse_quote! { Something String> }; let idents = get_generic_type_param_idents(&parenthesized_type); assert_eq!(None, idents); }