Skip to content

Commit 18e10ca

Browse files
committed
Auto merge of #9580 - TennyZhuang:upper_case_acronyms-enum, r=llogiq
let `upper_case_acronyms` check the enum name Signed-off-by: TennyZhuang <[email protected]> Fix #9579 changelog: [`upper_case_acronyms`]: check the enum name
2 parents 2be6c4a + bf18768 commit 18e10ca

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

clippy_lints/src/upper_case_acronyms.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
114114
check_ident(cx, &it.ident, self.upper_case_acronyms_aggressive);
115115
},
116116
ItemKind::Enum(ref enumdef, _) => {
117+
check_ident(cx, &it.ident, self.upper_case_acronyms_aggressive);
117118
// check enum variants separately because again we only want to lint on private enums and
118119
// the fn check_variant does not know about the vis of the enum of its variants
119120
enumdef

tests/ui/upper_case_acronyms.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,13 @@ enum ParseErrorPrivate<T> {
3838
Parse(T, String),
3939
}
4040

41+
// do lint here
42+
struct JSON;
43+
44+
// do lint here
45+
enum YAML {
46+
Num(u32),
47+
Str(String),
48+
}
49+
4150
fn main() {}

tests/ui/upper_case_acronyms.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,17 @@ error: name `WASD` contains a capitalized acronym
5454
LL | WASD(u8),
5555
| ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd`
5656

57-
error: aborting due to 9 previous errors
57+
error: name `JSON` contains a capitalized acronym
58+
--> $DIR/upper_case_acronyms.rs:42:8
59+
|
60+
LL | struct JSON;
61+
| ^^^^ help: consider making the acronym lowercase, except the initial letter: `Json`
62+
63+
error: name `YAML` contains a capitalized acronym
64+
--> $DIR/upper_case_acronyms.rs:45:6
65+
|
66+
LL | enum YAML {
67+
| ^^^^ help: consider making the acronym lowercase, except the initial letter: `Yaml`
68+
69+
error: aborting due to 11 previous errors
5870

0 commit comments

Comments
 (0)