diff options
| author | davidsemakula <hello@davidsemakula.com> | 2024-02-02 15:50:00 +0300 |
|---|---|---|
| committer | davidsemakula <hello@davidsemakula.com> | 2024-02-02 17:07:08 +0300 |
| commit | 46d79e21b5e2f5d9ce86a22d209453fcc8205372 (patch) | |
| tree | 17f180dfbb4db2ab24392639174ddaf8d8382321 | |
| parent | 080d223dd4775cddebe496d86c419d72ab52e4e5 (diff) | |
| download | rust-46d79e21b5e2f5d9ce86a22d209453fcc8205372.tar.gz rust-46d79e21b5e2f5d9ce86a22d209453fcc8205372.zip | |
add allow and deny attribute tests for incorrect case diagnostics for traits
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/incorrect_case.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/crates/ide-diagnostics/src/handlers/incorrect_case.rs index 59031e44cc8..ecba53a1b8b 100644 --- a/crates/ide-diagnostics/src/handlers/incorrect_case.rs +++ b/crates/ide-diagnostics/src/handlers/incorrect_case.rs @@ -503,10 +503,10 @@ trait BAD_TRAIT { } impl BAD_TRAIT for () { - const bad_const: u8 = 1; + const bad_const: u8 = 0; type BAD_TYPE = (); fn BAD_FUNCTION(BAD_PARAM: u8) { - let BAD_VAR = 10; + let BAD_VAR = 0; // ^^^^^^^ 💡 warn: Variable `BAD_VAR` should have snake_case name, e.g. `bad_var` } fn BadFunction() {} @@ -560,6 +560,14 @@ pub const some_const: u8 = 10; #[allow(non_upper_case_globals)] pub static SomeStatic: u8 = 10; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +trait BAD_TRAIT { + const bad_const: u8; + type BAD_TYPE; + fn BAD_FUNCTION(BAD_PARAM: u8); + fn BadFunction(); +} "#, ); } @@ -619,6 +627,20 @@ pub const some_const: u8 = 10; #[deny(non_upper_case_globals)] pub static SomeStatic: u8 = 10; //^^^^^^^^^^ 💡 error: Static variable `SomeStatic` should have UPPER_SNAKE_CASE name, e.g. `SOME_STATIC` + +#[deny(non_snake_case, non_camel_case_types, non_upper_case_globals)] +trait BAD_TRAIT { + // ^^^^^^^^^ 💡 error: Trait `BAD_TRAIT` should have CamelCase name, e.g. `BadTrait` + const bad_const: u8; + // ^^^^^^^^^ 💡 error: Constant `bad_const` should have UPPER_SNAKE_CASE name, e.g. `BAD_CONST` + type BAD_TYPE; + // ^^^^^^^^ 💡 error: Type alias `BAD_TYPE` should have CamelCase name, e.g. `BadType` + fn BAD_FUNCTION(BAD_PARAM: u8); + // ^^^^^^^^^^^^ 💡 error: Function `BAD_FUNCTION` should have snake_case name, e.g. `bad_function` + // ^^^^^^^^^ 💡 error: Parameter `BAD_PARAM` should have snake_case name, e.g. `bad_param` + fn BadFunction(); + // ^^^^^^^^^^^ 💡 error: Function `BadFunction` should have snake_case name, e.g. `bad_function` +} "#, ); } |
