-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make "all fields are shorthand" requirement configurable
- Loading branch information
Showing
11 changed files
with
191 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
initializer-suggestions = "machine-applicable" |
21 changes: 21 additions & 0 deletions
21
...s/ui-toml/toml_inconsistent_struct_constructor/conf_inconsistent_struct_constructor.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![warn(clippy::inconsistent_struct_constructor)] | ||
#![allow(clippy::redundant_field_names)] | ||
#![allow(clippy::unnecessary_operation)] | ||
#![allow(clippy::no_effect)] | ||
|
||
#[derive(Default)] | ||
struct Foo { | ||
x: i32, | ||
y: i32, | ||
z: i32, | ||
} | ||
|
||
fn main() { | ||
let x = 1; | ||
let y = 1; | ||
let z = 1; | ||
|
||
Foo { x, y, z: z }; | ||
|
||
Foo { x, z: z, ..Default::default() }; | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/ui-toml/toml_inconsistent_struct_constructor/conf_inconsistent_struct_constructor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![warn(clippy::inconsistent_struct_constructor)] | ||
#![allow(clippy::redundant_field_names)] | ||
#![allow(clippy::unnecessary_operation)] | ||
#![allow(clippy::no_effect)] | ||
|
||
#[derive(Default)] | ||
struct Foo { | ||
x: i32, | ||
y: i32, | ||
z: i32, | ||
} | ||
|
||
fn main() { | ||
let x = 1; | ||
let y = 1; | ||
let z = 1; | ||
|
||
Foo { y, x, z: z }; | ||
|
||
Foo { | ||
z: z, | ||
x, | ||
..Default::default() | ||
}; | ||
} |
21 changes: 21 additions & 0 deletions
21
.../ui-toml/toml_inconsistent_struct_constructor/conf_inconsistent_struct_constructor.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error: struct constructor field order is inconsistent with struct definition field order | ||
--> tests/ui-toml/toml_inconsistent_struct_constructor/conf_inconsistent_struct_constructor.rs:18:5 | ||
| | ||
LL | Foo { y, x, z: z }; | ||
| ^^^^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z: z }` | ||
| | ||
= note: `-D clippy::inconsistent-struct-constructor` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::inconsistent_struct_constructor)]` | ||
|
||
error: struct constructor field order is inconsistent with struct definition field order | ||
--> tests/ui-toml/toml_inconsistent_struct_constructor/conf_inconsistent_struct_constructor.rs:20:5 | ||
| | ||
LL | / Foo { | ||
LL | | z: z, | ||
LL | | x, | ||
LL | | ..Default::default() | ||
LL | | }; | ||
| |_____^ help: try: `Foo { x, z: z, ..Default::default() }` | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters