Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor error message when using attributes without derive #1144

Closed
mwillsey opened this issue Jan 20, 2018 · 1 comment
Closed

Poor error message when using attributes without derive #1144

mwillsey opened this issue Jan 20, 2018 · 1 comment

Comments

@mwillsey
Copy link

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!

@dtolnay
Copy link
Member

dtolnay commented Jan 20, 2018

Thanks! This isn't something we can fix on our end. I filed rust-lang/rust#47608 to follow up in the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants