mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Auto merge of #18207 - mbwilding:master, r=Veykril
fix: Ambiguity with CamelCase diagnostic messages, align with rustc warnings Fixed diagnostic messages so they say UpperCamelCase rather than CamelCase, as it is ambiguous. Usually I'd call it PascalCase, but in the code base it is called UpperCamelCase so I left it with that naming choice. `rustc` says `upper camel case` also when the case is wrong ``` warning: trait `testThing` should have an upper camel case name --> src/main.rs:5:7 | 5 | trait testThing { | ^^^^^^^^^ help: convert the identifier to upper camel case: `TestThing` | = note: `#[warn(non_camel_case_types)]` on by default ``` This is in line with the UPPER_SNAKE_CASE diagnostic messages.546339a7be/crates/hir-ty/src/diagnostics/decl_check.rs (L60)
546339a7be/crates/ide-diagnostics/src/handlers/incorrect_case.rs (L535)
This commit is contained in:
commit
7b60339273
4 changed files with 21 additions and 21 deletions
|
@ -58,7 +58,7 @@ impl fmt::Display for CaseType {
|
|||
let repr = match self {
|
||||
CaseType::LowerSnakeCase => "snake_case",
|
||||
CaseType::UpperSnakeCase => "UPPER_SNAKE_CASE",
|
||||
CaseType::UpperCamelCase => "CamelCase",
|
||||
CaseType::UpperCamelCase => "UpperCamelCase",
|
||||
};
|
||||
|
||||
repr.fmt(f)
|
||||
|
|
|
@ -111,7 +111,7 @@ mod tests {
|
|||
check(to_lower_snake_case, "lower_snake_case", expect![[""]]);
|
||||
check(to_lower_snake_case, "UPPER_SNAKE_CASE", expect![["upper_snake_case"]]);
|
||||
check(to_lower_snake_case, "Weird_Case", expect![["weird_case"]]);
|
||||
check(to_lower_snake_case, "CamelCase", expect![["camel_case"]]);
|
||||
check(to_lower_snake_case, "UpperCamelCase", expect![["upper_camel_case"]]);
|
||||
check(to_lower_snake_case, "lowerCamelCase", expect![["lower_camel_case"]]);
|
||||
check(to_lower_snake_case, "a", expect![[""]]);
|
||||
check(to_lower_snake_case, "abc", expect![[""]]);
|
||||
|
@ -121,8 +121,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_to_camel_case() {
|
||||
check(to_camel_case, "CamelCase", expect![[""]]);
|
||||
check(to_camel_case, "CamelCase_", expect![[""]]);
|
||||
check(to_camel_case, "UpperCamelCase", expect![[""]]);
|
||||
check(to_camel_case, "UpperCamelCase_", expect![[""]]);
|
||||
check(to_camel_case, "_CamelCase", expect![[""]]);
|
||||
check(to_camel_case, "lowerCamelCase", expect![["LowerCamelCase"]]);
|
||||
check(to_camel_case, "lower_snake_case", expect![["LowerSnakeCase"]]);
|
||||
|
@ -143,7 +143,7 @@ mod tests {
|
|||
check(to_upper_snake_case, "UPPER_SNAKE_CASE", expect![[""]]);
|
||||
check(to_upper_snake_case, "lower_snake_case", expect![["LOWER_SNAKE_CASE"]]);
|
||||
check(to_upper_snake_case, "Weird_Case", expect![["WEIRD_CASE"]]);
|
||||
check(to_upper_snake_case, "CamelCase", expect![["CAMEL_CASE"]]);
|
||||
check(to_upper_snake_case, "UpperCamelCase", expect![["UPPER_CAMEL_CASE"]]);
|
||||
check(to_upper_snake_case, "lowerCamelCase", expect![["LOWER_CAMEL_CASE"]]);
|
||||
check(to_upper_snake_case, "A", expect![[""]]);
|
||||
check(to_upper_snake_case, "ABC", expect![[""]]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue