Skip to content

Commit

Permalink
Merge pull request #2422 from dtolnay/emptyattr
Browse files Browse the repository at this point in the history
Accept empty #[serde()] attribute
  • Loading branch information
dtolnay committed Mar 28, 2023
2 parents acfd19c + 4cb8d07 commit 04af322
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions serde_derive/src/internals/attr.rs
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
5 changes: 5 additions & 0 deletions test_suite/tests/regression/issue2415.rs
@@ -0,0 +1,5 @@
use serde_derive::Serialize;

#[derive(Serialize)]
#[serde()]
pub struct S;

0 comments on commit 04af322

Please sign in to comment.