aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-22 15:24:10 +0100
committerGitHub <[email protected]>2020-10-22 15:24:10 +0100
commit31db677a948cfad7c0651fb3cd45a2cf577bb95f (patch)
tree0e4e1e8575616e272d1bf4ca5da881fe4f152c3b /crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
parentab53bb8718bb93b72085c19337f7e766ea7196f6 (diff)
parent854b1331810b503e266be96708ed753db2677865 (diff)
Merge #6319
6319: Properly identify camel cased acronyms as UpperCamelCase r=popzxc a=ArifRoktim This closes #6305. Co-authored-by: Arif Roktim <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/diagnostics/decl_check/case_conv.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check/case_conv.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
index 3800f2a6b..324d60765 100644
--- a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs
@@ -29,7 +29,13 @@ fn detect_case(ident: &str) -> DetectedCase {
29 29
30 if has_uppercase { 30 if has_uppercase {
31 if !has_lowercase { 31 if !has_lowercase {
32 DetectedCase::UpperSnakeCase 32 if has_underscore {
33 DetectedCase::UpperSnakeCase
34 } else {
35 // It has uppercase only and no underscores. Ex: "AABB"
36 // This is a camel cased acronym.
37 DetectedCase::UpperCamelCase
38 }
33 } else if !has_underscore { 39 } else if !has_underscore {
34 if first_lowercase { 40 if first_lowercase {
35 DetectedCase::LowerCamelCase 41 DetectedCase::LowerCamelCase
@@ -180,6 +186,7 @@ mod tests {
180 check(to_camel_case, "Weird_Case", expect![["WeirdCase"]]); 186 check(to_camel_case, "Weird_Case", expect![["WeirdCase"]]);
181 check(to_camel_case, "name", expect![["Name"]]); 187 check(to_camel_case, "name", expect![["Name"]]);
182 check(to_camel_case, "A", expect![[""]]); 188 check(to_camel_case, "A", expect![[""]]);
189 check(to_camel_case, "AABB", expect![[""]]);
183 } 190 }
184 191
185 #[test] 192 #[test]