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

The attribute serde is currently unknown to the compiler #1261

Closed
thijsc opened this issue May 17, 2018 · 5 comments
Closed

The attribute serde is currently unknown to the compiler #1261

thijsc opened this issue May 17, 2018 · 5 comments
Labels

Comments

@thijsc
Copy link

thijsc commented May 17, 2018

I've been trying to use attributes on Rust stable 1.26.0, but the compiler won't allow it:

error[E0658]: The attribute `serde` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> / .../src/data.rs:16:5
   |
16 |     #[serde(serialize_with = "ordered_map")]
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The documentation on https://serde.rs/attributes.html says:

They require a Rust compiler version 1.15 or newer.

This statement seems incorrect. Or am I misunderstanding something?

@thijsc thijsc changed the title Compatbility in attributes documentation incorrect Compatibility in attributes documentation incorrect May 17, 2018
@thijsc
Copy link
Author

thijsc commented May 17, 2018

The stabilisation of this feature is being tracked here: rust-lang/rust#29642

@dtolnay
Copy link
Member

dtolnay commented May 17, 2018

rust-lang/rust#29642 is a different feature. Attributes in custom derive have been stable since 1.15.0.

Check if you missed any steps on this checklist: https://serde.rs/derive.html.

@thijsc
Copy link
Author

thijsc commented May 17, 2018

I took all the steps on the steplist, derive is working fine. Only when adding an attribute as described in the doc it requires nightly, for example:

#[serde(serialize_with = "ordered_map")]

Is this supposed to work on stable if you set up the derive steps correctly?

@dtolnay
Copy link
Member

dtolnay commented May 17, 2018

Can you share the definition of the struct that contains #[serde(serialize_with = "ordered_map")]?

@dtolnay dtolnay changed the title Compatibility in attributes documentation incorrect The attribute serde is currently unknown to the compiler May 19, 2018
@dtolnay
Copy link
Member

dtolnay commented May 19, 2018

Your struct is missing a #[derive(Serialize)]. rust-lang/rust#47608 tracks improving this error message in the compiler.

@dtolnay dtolnay closed this as completed May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants