Skip to content

Commit

Permalink
Merge #578
Browse files Browse the repository at this point in the history
578: Prepare for syn v2 r=jonasbb a=jonasbb

Update darling to v0.20 and syn to v2, require serde v1.0.157 (first using syn v2).
This moves all direct dependencies to crates using syn v2.

syn v2 has problems with the `#[serde_as(as = "..")]` style of attributes, since `as` is a keyword and keywords are not allowed in meta attributes. Instead pre-process the token stream to replace all `as` with `r#as` which can be parsed.

Bump thiserror and cxx in the lock file.
Not all crates are using syn v2 yet.

Co-authored-by: Jonas Bushart <jonas@bushart.org>
  • Loading branch information
bors[bot] and jonasbb committed Apr 27, 2023
2 parents 74858ec + 008a62f commit f95573c
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 85 deletions.
85 changes: 48 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions serde_with/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

* Update `syn` to v2 and `darling` to v0.20 (#578)
Update proc-macro dependencies.
This change should have no impact on users, but now uses the same dependency as `serde_derive`.

## [2.3.2] - 2023-04-05

### Changed
Expand Down
2 changes: 1 addition & 1 deletion serde_with/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ hex = {version = "0.4.3", optional = true, default-features = false}
indexmap_1 = {package = "indexmap", version = "1.8", optional = true, default-features = false, features = ["serde-1"]}
# The derive feature is needed for the flattened_maybe macro.
# https://github.com/jonasbb/serde_with/blob/eb1965a74a3be073ecd13ec05f02a01bc1c44309/serde_with/src/flatten_maybe.rs#L67
serde = {version = "1.0.139", default-features = false, features = ["derive"] }
serde = {version = "1.0.157", default-features = false, features = ["derive"] }
serde_json = {version = "1.0.45", optional = true, default-features = false}
serde_with_macros = {path = "../serde_with_macros", version = "=2.3.2", optional = true}
time_0_3 = {package = "time", version = "~0.3.11", optional = true, default-features = false}
Expand Down
2 changes: 1 addition & 1 deletion serde_with/src/flatten_maybe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/// ```
#[macro_export]
macro_rules! flattened_maybe {
($fn:ident, $field:literal) => {
($fn:ident, $field:tt) => {
fn $fn<'de, T, D>(deserializer: D) -> $crate::__private__::Result<T, D::Error>
where
T: $crate::serde::Deserialize<'de>,
Expand Down
6 changes: 6 additions & 0 deletions serde_with_macros/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

* Update `syn` to v2 and `darling` to v0.20 (#578)
Update proc-macro dependencies.
This change should have no impact on users, but now uses the same dependency as `serde_derive`.

## [2.3.2] - 2023-04-05

No changes.
Expand Down
6 changes: 3 additions & 3 deletions serde_with_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ proc-macro = true
maintenance = {status = "actively-developed"}

[dependencies]
darling = "0.14.0"
darling = "0.20.0"
proc-macro2 = "1.0.1"
quote = "1.0.0"

Expand All @@ -40,13 +40,13 @@ features = [
"full",
"parsing",
]
version = "1.0.3"
version = "2.0.0"

[dev-dependencies]
expect-test = "1.4.0"
pretty_assertions = "1.0.0"
rustversion = "1.0.0"
serde = {version = "1.0.75", features = ["derive"]}
serde = {version = "1.0.157", features = ["derive"]}
serde_json = "1.0.25"
trybuild = "1.0.80"
version-sync = "0.9.1"
Expand Down
8 changes: 4 additions & 4 deletions serde_with_macros/src/apply.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use darling::{Error as DarlingError, FromMeta};
use darling::{ast::NestedMeta, Error as DarlingError, FromMeta};
use proc_macro::TokenStream;
use quote::ToTokens as _;
use syn::{
parse::{Parse, ParseStream},
punctuated::Punctuated,
Attribute, Error, Field, NestedMeta, Path, Token, Type, TypeArray, TypeGroup, TypeParen,
TypePath, TypePtr, TypeReference, TypeSlice, TypeTuple,
Attribute, Error, Field, Path, Token, Type, TypeArray, TypeGroup, TypeParen, TypePath, TypePtr,
TypeReference, TypeSlice, TypeTuple,
};

/// Parsed form of a single rule in the `#[apply(...)]` attribute.
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Parse for ApplyInput {
}

let rules: Punctuated<AddAttributesRule, Token![,]> =
input.parse_terminated(AddAttributesRule::parse)?;
input.parse_terminated(AddAttributesRule::parse, Token![,])?;
Ok(Self { metas, rules })
}
}
Expand Down
Loading

0 comments on commit f95573c

Please sign in to comment.