Skip to content

Commit

Permalink
Accept empty #[serde()] attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 28, 2023
1 parent 6ab55a1 commit 4cb8d07
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions serde_derive/src/internals/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ impl Container {
continue;
}

if let syn::Meta::List(meta) = &attr.meta {
if meta.tokens.is_empty() {
continue;
}
}

if let Err(err) = attr.parse_nested_meta(|meta| {
if meta.path == RENAME {
// #[serde(rename = "foo")]
Expand Down Expand Up @@ -762,6 +768,12 @@ impl Variant {
continue;
}

if let syn::Meta::List(meta) = &attr.meta {
if meta.tokens.is_empty() {
continue;
}
}

if let Err(err) = attr.parse_nested_meta(|meta| {
if meta.path == RENAME {
// #[serde(rename = "foo")]
Expand Down Expand Up @@ -1033,6 +1045,12 @@ impl Field {
continue;
}

if let syn::Meta::List(meta) = &attr.meta {
if meta.tokens.is_empty() {
continue;
}
}

if let Err(err) = attr.parse_nested_meta(|meta| {
if meta.path == RENAME {
// #[serde(rename = "foo")]
Expand Down

0 comments on commit 4cb8d07

Please sign in to comment.