Skip to content

Commit b919aa4

Browse files
committed
Add reserved identifier test cases for snake case lint
1 parent a609fb4 commit b919aa4

2 files changed

+84
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![warn(unused)]
2+
#![allow(dead_code)]
3+
#![deny(non_snake_case)]
4+
5+
mod Impl {}
6+
//~^ ERROR module `Impl` should have a snake case name
7+
8+
fn While() {}
9+
//~^ ERROR function `While` should have a snake case name
10+
11+
fn main() {
12+
let Mod: usize = 0;
13+
//~^ ERROR variable `Mod` should have a snake case name
14+
//~^^ WARN unused variable: `Mod`
15+
16+
let Super: usize = 0;
17+
//~^ ERROR variable `Super` should have a snake case name
18+
//~^^ WARN unused variable: `Super`
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
warning: unused variable: `Mod`
2+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9
3+
|
4+
LL | let Mod: usize = 0;
5+
| ^^^ help: if this is intentional, prefix it with an underscore: `_Mod`
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:1:9
9+
|
10+
LL | #![warn(unused)]
11+
| ^^^^^^
12+
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
13+
14+
warning: unused variable: `Super`
15+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9
16+
|
17+
LL | let Super: usize = 0;
18+
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_Super`
19+
20+
error: module `Impl` should have a snake case name
21+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:5:5
22+
|
23+
LL | mod Impl {}
24+
| ^^^^
25+
|
26+
note: the lint level is defined here
27+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:3:9
28+
|
29+
LL | #![deny(non_snake_case)]
30+
| ^^^^^^^^^^^^^^
31+
help: rename the identifier or convert it to a snake case raw identifier
32+
|
33+
LL | mod r#impl {}
34+
| ^^^^^^
35+
36+
error: function `While` should have a snake case name
37+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:8:4
38+
|
39+
LL | fn While() {}
40+
| ^^^^^
41+
|
42+
help: rename the identifier or convert it to a snake case raw identifier
43+
|
44+
LL | fn r#while() {}
45+
| ^^^^^^^
46+
47+
error: variable `Mod` should have a snake case name
48+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9
49+
|
50+
LL | let Mod: usize = 0;
51+
| ^^^
52+
|
53+
help: rename the identifier or convert it to a snake case raw identifier
54+
|
55+
LL | let r#mod: usize = 0;
56+
| ^^^^^
57+
58+
error: variable `Super` should have a snake case name
59+
--> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9
60+
|
61+
LL | let Super: usize = 0;
62+
| ^^^^^ help: rename the identifier
63+
64+
error: aborting due to 4 previous errors; 2 warnings emitted
65+

0 commit comments

Comments
 (0)