Skip to content

Poor error message when using attributes without derive #1144

@mwillsey

Description

@mwillsey

The following code doesn't compile on 1.23:

#[macro_use]
extern crate serde_derive;
extern crate serde;

#[serde(untagged)]
enum CellIndex {
    Auto,
    Index(u32),
}

The error message is:

error: The attribute `serde` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> src/lib.rs:20:1
   |
20 | #[serde(untagged)]
   | ^^^^^^^^^^^^^^^^^^

When you add #[derive(Serialize, Deserialize)] to the enum, it compiles, but the error message was quite confusing. It sent me on a feature-flag-enabling goose hunt, and it took someone who knew what they were doing (h/t @dtolnay) to set me straight. A better error message would be great!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions