Static rustc_lint::builtin::KEYWORD_IDENTS
source · pub static KEYWORD_IDENTS: &'static Lint
Expand description
The keyword_idents
lint detects edition keywords being used as an
identifier.
Example
#![deny(keyword_idents)]
// edition 2015
fn dyn() {}
{{produces}}
Explanation
Rust editions allow the language to evolve without breaking backwards compatibility. This lint catches code that uses new keywords that are added to the language that are used as identifiers (such as a variable name, function name, etc.). If you switch the compiler to a new edition without updating the code, then it will fail to compile if you are using a new keyword as an identifier.
You can manually change the identifiers to a non-keyword, or use a
raw identifier, for example r#dyn
, to transition to a new edition.
This lint solves the problem automatically. It is “allow” by default
because the code is perfectly valid in older editions. The cargo fix
tool with the --edition
flag will switch this lint to “warn”
and automatically apply the suggested fix from the compiler (which is
to use a raw identifier). This provides a completely automated way to
update old code for a new edition.