Skip to content

Commit 6261f18

Browse files
committed
Fix non_camel_case_types for screaming words
1 parent 2e5a9dd commit 6261f18

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/rustc_lint/src/nonstandard_style.rs

+3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ fn is_camel_case(name: &str) -> bool {
9393
// contains a capitalisable character followed by, or preceded by, an underscore
9494
char_has_case(fst) && snd == '_' || char_has_case(snd) && fst == '_'
9595
})
96+
&& !name.chars().collect::<Vec<_>>().array_windows().any(|&[fst, snd, thr]| {
97+
fst.is_uppercase() && snd.is_uppercase() && thr.is_uppercase()
98+
})
9699
}
97100

98101
fn to_camel_case(s: &str) -> String {

compiler/rustc_lint/src/nonstandard_style/tests.rs

+5
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ fn camel_case() {
1818

1919
assert!(!is_camel_case("ONE_TWO_THREE"));
2020
assert_eq!(to_camel_case("ONE_TWO_THREE"), "OneTwoThree");
21+
22+
assert!(!is_camel_case("ONE"));
23+
assert_eq!(to_camel_case("ONE"), "One");
24+
25+
assert!(is_camel_case("AStr"));
2126
}

0 commit comments

Comments
 (0)