Extend struct_field_names lint ui test

This commit is contained in:
Guillaume Gomez 2024-01-05 16:44:41 +01:00
parent 9e4e8ef102
commit 7aa4624a8f
2 changed files with 41 additions and 9 deletions

View file

@ -39,14 +39,14 @@ struct DataStruct {
struct DoublePrefix {
//~^ ERROR: all fields have the same prefix: `some_data`
some_data_a: bool,
some_data_b: bool,
some_data_b: i8,
some_data_c: bool,
}
struct DoublePostfix {
//~^ ERROR: all fields have the same postfix: `some_data`
a_some_data: bool,
b_some_data: bool,
b_some_data: i8,
c_some_data: bool,
}
@ -54,14 +54,14 @@ struct DoublePostfix {
struct NotSnakeCase {
//~^ ERROR: all fields have the same postfix: `someData`
a_someData: bool,
b_someData: bool,
b_someData: i8,
c_someData: bool,
}
#[allow(non_snake_case)]
struct NotSnakeCase2 {
//~^ ERROR: all fields have the same prefix: `someData`
someData_c: bool,
someData_b: bool,
someData_b: i8,
someData_a_b: bool,
}
@ -328,4 +328,18 @@ external! {
}
// Should not warn
struct Config {
use_foo: bool,
use_bar: bool,
use_baz: bool,
}
struct Use {
use_foo: bool,
//~^ ERROR: field name starts with the struct's name
use_bar: bool,
use_baz: bool,
}
fn main() {}

View file

@ -45,7 +45,7 @@ error: all fields have the same prefix: `some_data`
LL | / struct DoublePrefix {
LL | |
LL | | some_data_a: bool,
LL | | some_data_b: bool,
LL | | some_data_b: i8,
LL | | some_data_c: bool,
LL | | }
| |_^
@ -58,7 +58,7 @@ error: all fields have the same postfix: `some_data`
LL | / struct DoublePostfix {
LL | |
LL | | a_some_data: bool,
LL | | b_some_data: bool,
LL | | b_some_data: i8,
LL | | c_some_data: bool,
LL | | }
| |_^
@ -71,7 +71,7 @@ error: all fields have the same postfix: `someData`
LL | / struct NotSnakeCase {
LL | |
LL | | a_someData: bool,
LL | | b_someData: bool,
LL | | b_someData: i8,
LL | | c_someData: bool,
LL | | }
| |_^
@ -84,7 +84,7 @@ error: all fields have the same prefix: `someData`
LL | / struct NotSnakeCase2 {
LL | |
LL | | someData_c: bool,
LL | | someData_b: bool,
LL | | someData_b: i8,
LL | | someData_a_b: bool,
LL | | }
| |_^
@ -261,5 +261,23 @@ LL | mk_struct_full_def!(PrefixData, some_data, some_meta, some_other);
= help: remove the prefixes
= note: this error originates in the macro `mk_struct_full_def` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 21 previous errors
error: field name starts with the struct's name
--> $DIR/struct_fields.rs:339:5
|
LL | use_foo: bool,
| ^^^^^^^^^^^^^
error: field name starts with the struct's name
--> $DIR/struct_fields.rs:341:5
|
LL | use_bar: bool,
| ^^^^^^^^^^^^^
error: field name starts with the struct's name
--> $DIR/struct_fields.rs:342:5
|
LL | use_baz: bool,
| ^^^^^^^^^^^^^
error: aborting due to 24 previous errors