Skip to content

Regression in serde 1.0.157 when a proc macro enables syn's full feature #2409

@nox

Description

@nox

With https://github.com/nox/serde-none-group, the command cargo build --features syn-full fails while the command cargo build succeeds. The only difference is that the failing command enables the "full" feature of the crate syn from a proc macro.

The build failure is:

± cargo build --features syn-full
   Compiling syn v2.0.2
   Compiling serde_derive v1.0.157
   Compiling another-proc-macro v0.1.67 (/Users/nox/src/serde-none-group/another-proc-macro)
   Compiling serde v1.0.157
   Compiling serde-none-group v0.1.0 (/Users/nox/src/serde-none-group)
error: expected serde crate attribute to be a string: `crate = "..."`
  --> src/lib.rs:4:25
   |
4  |           #[serde(crate = $serde_path)]
   |                           ^^^^^^^^^^^
...
9  | / bug_if_async_trait! {
10 | |     "serde"
11 | | }
   | |_- in this macro invocation
   |
   = note: this error originates in the macro `bug_if_async_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

I've debugged it and the reason is that serde_derive sees a None-delimited group instead of a bare literal, but only when the "full" feature of syn is enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions