Skip to content

Commit 3921a24

Browse files
authored
chore(deps): Bump to syn 2, serde_with 3, darling 0.20, and serde_derive_internals 0.28 (vectordotdev#17930)
1 parent d29424d commit 3921a24

File tree

15 files changed

+195
-114
lines changed

15 files changed

+195
-114
lines changed

Cargo.lock

+65-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ serde = { version = "1.0.168", default-features = false, features = ["derive"] }
198198
serde-toml-merge = { version = "0.3.0", default-features = false }
199199
serde_bytes = { version = "0.11.11", default-features = false, features = ["std"], optional = true }
200200
serde_json = { version = "1.0.100", default-features = false, features = ["raw_value"] }
201-
serde_with = { version = "2.3.2", default-features = false, features = ["macros", "std"] }
201+
serde_with = { version = "3.0.0", default-features = false, features = ["macros", "std"] }
202202
serde_yaml = { version = "0.9.22", default-features = false }
203203

204204
# Messagepack

lib/vector-config-common/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ license = "MPL-2.0"
66

77
[dependencies]
88
convert_case = { version = "0.6", default-features = false }
9-
darling = { version = "0.13", default-features = false, features = ["suggestions"] }
9+
darling = { version = "0.20", default-features = false, features = ["suggestions"] }
1010
once_cell = { version = "1", default-features = false, features = ["std"] }
1111
proc-macro2 = { version = "1.0", default-features = false }
1212
serde = { version = "1.0", default-features = false, features = ["derive"] }
1313
serde_json = { version = "1.0", default-features = false, features = ["std"] }
14-
syn = { version = "1.0", features = ["full", "extra-traits", "visit-mut", "visit"] }
14+
syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut", "visit"] }
1515
tracing = { version = "0.1.34", default-features = false }
1616
quote = { version = "1.0", default-features = false }

lib/vector-config-common/src/validation.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use darling::FromMeta;
22
use proc_macro2::TokenStream;
33
use quote::{quote, ToTokens};
4-
use syn::{Lit, Meta};
4+
use syn::{Expr, Lit, Meta};
55

66
use crate::{
77
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<Option<f64>> {
336336
// First make sure we can even get a valid f64 from this meta item.
337337
let result = match meta {
338338
Meta::Path(_) => Err(darling::Error::unexpected_type("path")),
339-
Meta::List(_) => Err(darling::Error::unexpected_type("path")),
340-
Meta::NameValue(nv) => match &nv.lit {
341-
Lit::Str(s) => {
342-
let s = s.value();
343-
s.as_str()
344-
.parse()
345-
.map_err(|_| darling::Error::unknown_value(s.as_str()))
346-
}
347-
Lit::Int(i) => i.base10_parse::<f64>().map_err(Into::into),
348-
Lit::Float(f) => f.base10_parse::<f64>().map_err(Into::into),
349-
lit => Err(darling::Error::unexpected_lit_type(lit)),
339+
Meta::List(_) => Err(darling::Error::unexpected_type("list")),
340+
Meta::NameValue(nv) => match &nv.value {
341+
Expr::Lit(expr) => match &expr.lit {
342+
Lit::Str(s) => {
343+
let s = s.value();
344+
s.parse()
345+
.map_err(|_| darling::Error::unknown_value(s.as_str()))
346+
}
347+
Lit::Int(i) => i.base10_parse::<f64>().map_err(Into::into),
348+
Lit::Float(f) => f.base10_parse::<f64>().map_err(Into::into),
349+
lit => Err(darling::Error::unexpected_lit_type(lit)),
350+
},
351+
expr => Err(darling::Error::unexpected_expr_type(expr)),
350352
},
351353
};
352354

lib/vector-config-macros/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ license = "MPL-2.0"
88
proc-macro = true
99

1010
[dependencies]
11-
darling = { version = "0.13", default-features = false, features = ["suggestions"] }
11+
darling = { version = "0.20", default-features = false, features = ["suggestions"] }
1212
proc-macro2 = { version = "1.0", default-features = false }
1313
quote = { version = "1.0", default-features = false }
14-
serde_derive_internals = "0.26"
15-
syn = { version = "1.0", default-features = false, features = ["full", "extra-traits", "visit-mut", "visit"] }
14+
serde_derive_internals = "0.28"
15+
syn = { version = "2.0", default-features = false, features = ["full", "extra-traits", "visit-mut", "visit"] }
1616
vector-config-common = { path = "../vector-config-common" }
1717

1818
[dev-dependencies]

lib/vector-config-macros/src/ast/container.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'a> Container<'a> {
368368
/// standard `#[deprecated]` attribute, neither automatically applying it nor deriving the
369369
/// deprecation status of a field when it is present.
370370
pub fn deprecated(&self) -> bool {
371-
self.attrs.deprecated.is_some()
371+
self.attrs.deprecated.is_present()
372372
}
373373

374374
/// Metadata (custom attributes) for the container, if any.
@@ -584,7 +584,7 @@ mod tests {
584584
assert_eq!(literals_to_idents(&["T"]), idents);
585585

586586
// We don't support parenthesized type parameters, like when using a function pointer type.
587-
let parenthesized_type: Type = parse_quote! { Something<Fn(bool) -> String> };
587+
let parenthesized_type: Type = parse_quote! { Something<fn(bool) -> String> };
588588
let idents = get_generic_type_param_idents(&parenthesized_type);
589589
assert_eq!(None, idents);
590590
}

lib/vector-config-macros/src/ast/field.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use darling::{
22
util::{Flag, Override, SpannedValue},
33
FromAttributes,
44
};
5-
use proc_macro2::Span;
5+
use proc_macro2::{Span, TokenStream};
6+
use quote::ToTokens;
67
use serde_derive_internals::ast as serde_ast;
7-
use syn::{parse_quote, spanned::Spanned, ExprPath, Ident};
8+
use syn::{parse_quote, ExprPath, Ident};
89
use vector_config_common::validation::Validation;
910

1011
use super::{
@@ -174,7 +175,7 @@ impl<'a> Field<'a> {
174175
/// variants, to simply document themselves at the container/variant level and avoid needing to
175176
/// document that inner field which itself needs no further title/description.
176177
pub fn transparent(&self) -> bool {
177-
self.attrs.transparent.is_some()
178+
self.attrs.transparent.is_present()
178179
}
179180

180181
/// Whether or not the field is deprecated.
@@ -239,12 +240,9 @@ impl<'a> Field<'a> {
239240
}
240241
}
241242

242-
impl<'a> Spanned for Field<'a> {
243-
fn span(&self) -> proc_macro2::Span {
244-
match self.original.ident.as_ref() {
245-
Some(ident) => ident.span(),
246-
None => self.original.ty.span(),
247-
}
243+
impl<'a> ToTokens for Field<'a> {
244+
fn to_tokens(&self, tokens: &mut TokenStream) {
245+
self.original.to_tokens(tokens)
248246
}
249247
}
250248

@@ -300,12 +298,12 @@ impl Attributes {
300298
// to throw an error if they are. As we're going to forcefully mark the field as
301299
// transparent, there's no reason to allow setting derived/transparent manually, as it
302300
// only leads to boilerplate and potential confusion.
303-
if self.transparent.is_some() {
304-
return Err(err_field_implicit_transparent(&self.transparent));
301+
if self.transparent.is_present() {
302+
return Err(err_field_implicit_transparent(&self.transparent.span()));
305303
}
306304

307-
if self.derived.is_some() {
308-
return Err(err_field_implicit_transparent(&self.derived));
305+
if self.derived.is_present() {
306+
return Err(err_field_implicit_transparent(&self.derived.span()));
309307
}
310308

311309
self.transparent = SpannedValue::new(Flag::present(), Span::call_site());
@@ -339,8 +337,8 @@ impl Attributes {
339337
// like a field that is flattened or not visible, it makes no sense to require a description or title for fields
340338
// in a virtual newtype.
341339
if self.description.is_none()
342-
&& !self.derived.is_some()
343-
&& !self.transparent.is_some()
340+
&& !self.derived.is_present()
341+
&& !self.transparent.is_present()
344342
&& self.visible
345343
&& !self.flatten
346344
&& !is_virtual_newtype

0 commit comments

Comments
 (0)