Serde: The attribute `serde` is currently unknown to the compiler

Created on 17 May 2018  路  5Comments  路  Source: serde-rs/serde

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?

support

Most helpful comment

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

All 5 comments

The stabilisation of this feature is being tracked here: https://github.com/rust-lang/rust/issues/29642

https://github.com/rust-lang/rust/issues/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.

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?

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swfsql picture swfsql  路  3Comments

pwoolcoc picture pwoolcoc  路  3Comments

Yamakaky picture Yamakaky  路  3Comments

dtolnay picture dtolnay  路  3Comments

dtolnay picture dtolnay  路  3Comments