Skip to content

Maybe Regression: failing to parse serde macros #76520

Closed
@elichai

Description

@elichai

I'm not sure if this is a regression in nightly, or older serde_derive code did something weird that broke under a new compiler, but this code compiles on stable but fails on nightly:

lib.rs:

extern crate serde;
#[macro_use]
extern crate serde_derive;
use serde::Serializer;

pub fn serialize<S: Serializer>(_: &(), _: S) -> Result<S::Ok, S::Error> {
    panic!("");
}

#[derive(Serialize, Deserialize)]
struct Test {
    #[serde(serialize_with = "::serialize")]
    pub amt: (),
}

Cargo.toml:

[package]
name = "newweird"
version = "0.1.0"

[dependencies]
serde = { version = "1" }
serde_derive = { version = "<1.0.99" }

output:

$ rustc --version
$ cargo check
    Checking serde v1.0.115
    Checking newweird v0.1.0 (/home/elichai2/gits/newweird)
    Finished dev [unoptimized + debuginfo] target(s) in 3.52s

$ rustc +nightly --version
rustc 1.48.0-nightly (5099914a1 2020-09-08)
$ cargo +nightly check
    Checking serde v1.0.115
    Checking newweird v0.1.0 (/home/elichai2/gits/newweird)
error: failed to parse path: "::serialize"
  --> src/lib.rs:12:30
   |
12 |     #[serde(serialize_with = "::serialize")]
   |                              ^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `newweird`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions