Skip to content

Commit

Permalink
add test for non_snake_case case
Browse files Browse the repository at this point in the history
  • Loading branch information
jonboh committed Sep 28, 2023
1 parent 3a1083b commit 07c662e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
15 changes: 15 additions & 0 deletions tests/ui/struct_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ struct DoublePostfix {
c_some_data: bool,
}

#[allow(non_snake_case)]
struct NotSnakeCase {
//~^ ERROR: all fields have the same postfix: `someData`
a_someData: bool,
b_someData: bool,
c_someData: bool,
}
#[allow(non_snake_case)]
struct NotSnakeCase2 {
//~^ ERROR: all fields have the same prefix: `someData`
someData_c: bool,
someData_b: bool,
someData_a_b: bool,
}

// no error, threshold is 3 fiels by default
struct Fooo {
foo: u8,
Expand Down
34 changes: 30 additions & 4 deletions tests/ui/struct_fields.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,34 @@ LL | | }
|
= help: remove the postfixes

error: all fields have the same postfix: `someData`
--> $DIR/struct_fields.rs:49:1
|
LL | / struct NotSnakeCase {
LL | |
LL | | a_someData: bool,
LL | | b_someData: bool,
LL | | c_someData: bool,
LL | | }
| |_^
|
= help: remove the postfixes

error: all fields have the same prefix: `someData`
--> $DIR/struct_fields.rs:56:1
|
LL | / struct NotSnakeCase2 {
LL | |
LL | | someData_c: bool,
LL | | someData_b: bool,
LL | | someData_a_b: bool,
LL | | }
| |_^
|
= help: remove the prefixes

error: all fields have the same prefix: `prefix`
--> $DIR/struct_fields.rs:54:1
--> $DIR/struct_fields.rs:69:1
|
LL | / struct NonCaps {
LL | |
Expand All @@ -79,7 +105,7 @@ LL | | }
= help: remove the prefixes

error: all fields have the same prefix: `_type`
--> $DIR/struct_fields.rs:104:5
--> $DIR/struct_fields.rs:119:5
|
LL | / struct DoLint {
LL | |
Expand All @@ -93,7 +119,7 @@ LL | | }
= help: remove the prefixes

error: all fields have the same postfix: `type`
--> $DIR/struct_fields.rs:112:5
--> $DIR/struct_fields.rs:127:5
|
LL | / struct DoLintToo {
LL | |
Expand All @@ -105,5 +131,5 @@ LL | | }
|
= help: remove the postfixes

error: aborting due to 9 previous errors
error: aborting due to 11 previous errors

0 comments on commit 07c662e

Please sign in to comment.