Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Bump to syn 2, serde_with 3, darling 0.20, and serde_derive_internals 0.28 #17930

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 65 additions & 15 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/vector-config-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
26 changes: 14 additions & 12 deletions lib/vector-config-common/src/validation.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -336,17 +336,19 @@ fn maybe_float_or_int(meta: &Meta) -> darling::Result<Option<f64>> {
// 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::<f64>().map_err(Into::into),
Lit::Float(f) => f.base10_parse::<f64>().map_err(Into::into),
lit => Err(darling::Error::unexpected_lit_type(lit)),
Meta::List(_) => Err(darling::Error::unexpected_type("list")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, nice catch here. 👍🏻

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::<f64>().map_err(Into::into),
Lit::Float(f) => f.base10_parse::<f64>().map_err(Into::into),
lit => Err(darling::Error::unexpected_lit_type(lit)),
},
expr => Err(darling::Error::unexpected_expr_type(expr)),
},
};

Expand Down
6 changes: 3 additions & 3 deletions lib/vector-config-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions lib/vector-config-macros/src/ast/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Fn(bool) -> String> };
let parenthesized_type: Type = parse_quote! { Something<fn(bool) -> String> };
let idents = get_generic_type_param_idents(&parenthesized_type);
assert_eq!(None, idents);
}
Expand Down
28 changes: 13 additions & 15 deletions lib/vector-config-macros/src/ast/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down
Loading