Static rustc_lint::builtin::LEGACY_DERIVE_HELPERS

source ·
pub static LEGACY_DERIVE_HELPERS: &'static Lint
Expand description

The legacy_derive_helpers lint detects derive helper attributes that are used before they are introduced.


#[serde(rename_all = "camelCase")]
struct S { /* fields */ }


warning: derive helper attribute is used before it is introduced
  --> $DIR/
 1 | #[serde(rename_all = "camelCase")]
   |   ^^^^^
 2 | #[derive(Deserialize)]
   |          ----------- the attribute is introduced here


Attributes like this work for historical reasons, but attribute expansion works in left-to-right order in general, so, to resolve #[serde], compiler has to try to “look into the future” at not yet expanded part of the item , but such attempts are not always reliable.

To fix the warning place the helper attribute after its corresponding derive.

#[serde(rename_all = "camelCase")]
struct S { /* fields */ }