Skip to content

Commit 46d79e2

Browse files
committed
add allow and deny attribute tests for incorrect case diagnostics for traits
1 parent 080d223 commit 46d79e2

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

crates/ide-diagnostics/src/handlers/incorrect_case.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ trait BAD_TRAIT {
503503
}
504504
505505
impl BAD_TRAIT for () {
506-
const bad_const: u8 = 1;
506+
const bad_const: u8 = 0;
507507
type BAD_TYPE = ();
508508
fn BAD_FUNCTION(BAD_PARAM: u8) {
509-
let BAD_VAR = 10;
509+
let BAD_VAR = 0;
510510
// ^^^^^^^ 💡 warn: Variable `BAD_VAR` should have snake_case name, e.g. `bad_var`
511511
}
512512
fn BadFunction() {}
@@ -560,6 +560,14 @@ pub const some_const: u8 = 10;
560560
561561
#[allow(non_upper_case_globals)]
562562
pub static SomeStatic: u8 = 10;
563+
564+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
565+
trait BAD_TRAIT {
566+
const bad_const: u8;
567+
type BAD_TYPE;
568+
fn BAD_FUNCTION(BAD_PARAM: u8);
569+
fn BadFunction();
570+
}
563571
"#,
564572
);
565573
}
@@ -619,6 +627,20 @@ pub const some_const: u8 = 10;
619627
#[deny(non_upper_case_globals)]
620628
pub static SomeStatic: u8 = 10;
621629
//^^^^^^^^^^ 💡 error: Static variable `SomeStatic` should have UPPER_SNAKE_CASE name, e.g. `SOME_STATIC`
630+
631+
#[deny(non_snake_case, non_camel_case_types, non_upper_case_globals)]
632+
trait BAD_TRAIT {
633+
// ^^^^^^^^^ 💡 error: Trait `BAD_TRAIT` should have CamelCase name, e.g. `BadTrait`
634+
const bad_const: u8;
635+
// ^^^^^^^^^ 💡 error: Constant `bad_const` should have UPPER_SNAKE_CASE name, e.g. `BAD_CONST`
636+
type BAD_TYPE;
637+
// ^^^^^^^^ 💡 error: Type alias `BAD_TYPE` should have CamelCase name, e.g. `BadType`
638+
fn BAD_FUNCTION(BAD_PARAM: u8);
639+
// ^^^^^^^^^^^^ 💡 error: Function `BAD_FUNCTION` should have snake_case name, e.g. `bad_function`
640+
// ^^^^^^^^^ 💡 error: Parameter `BAD_PARAM` should have snake_case name, e.g. `bad_param`
641+
fn BadFunction();
642+
// ^^^^^^^^^^^ 💡 error: Function `BadFunction` should have snake_case name, e.g. `bad_function`
643+
}
622644
"#,
623645
);
624646
}

0 commit comments

Comments
 (0)