From: Skynoodle Date: Sat, 2 Jan 2021 15:46:41 +0000 (+0000) Subject: Add snake case lint note about keyword identifiers which cannot be raw X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=750c52af7334e325e9c3980dbdad10dedeb22f82;p=rust.git Add snake case lint note about keyword identifiers which cannot be raw --- diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 39cebe7f969..8bb3ff0dde0 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -283,6 +283,7 @@ fn is_snake_case(ident: &str) -> bool { if sc_ident.name.can_be_raw() { ("rename the identifier or convert it to a snake case raw identifier", sc_ident.to_string()) } else { + err.note(&format!("`{}` cannot be used as a raw identifier", sc)); ("rename the identifier", String::new()) } } else { diff --git a/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr index d2618773f6b..c179f4a25bd 100644 --- a/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr +++ b/src/test/ui/lint/lint-non-snake-case-identifiers-suggestion-reserved.stderr @@ -60,6 +60,8 @@ error: variable `Super` should have a snake case name | LL | let Super: usize = 0; | ^^^^^ help: rename the identifier + | + = note: `super` cannot be used as a raw identifier error: aborting due to 4 previous errors; 2 warnings emitted