-
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.
Add restrictive pat use in full binded struct
- Loading branch information
Showing
7 changed files
with
125 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![warn(clippy::rest_pat_in_fully_bound_structs)] | ||
|
||
struct A { | ||
a: i32, | ||
b: i64, | ||
c: &'static str, | ||
} | ||
|
||
fn main() { | ||
let a_struct = A { a: 5, b: 42, c: "A" }; | ||
|
||
match a_struct { | ||
A { a: 5, b: 42, c: "", .. } => {}, // Lint | ||
A { a: 0, b: 0, c: "", .. } => {}, // Lint | ||
_ => {}, | ||
} | ||
|
||
match a_struct { | ||
A { a: 5, b: 42, .. } => {}, | ||
A { a: 0, b: 0, c: "", .. } => {}, // Lint | ||
_ => {}, | ||
} | ||
|
||
// No lint | ||
match a_struct { | ||
A { a: 5, .. } => {}, | ||
A { a: 0, b: 0, .. } => {}, | ||
_ => {}, | ||
} | ||
} |
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,27 @@ | ||
error: unnecessary use of `..` pattern in struct binding. All fields were already bound | ||
--> $DIR/rest_pat_in_fully_bound_structs.rs:13:9 | ||
| | ||
LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::rest-pat-in-fully-bound-structs` implied by `-D warnings` | ||
= help: consider removing `..` from this binding | ||
|
||
error: unnecessary use of `..` pattern in struct binding. All fields were already bound | ||
--> $DIR/rest_pat_in_fully_bound_structs.rs:14:9 | ||
| | ||
LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing `..` from this binding | ||
|
||
error: unnecessary use of `..` pattern in struct binding. All fields were already bound | ||
--> $DIR/rest_pat_in_fully_bound_structs.rs:20:9 | ||
| | ||
LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing `..` from this binding | ||
|
||
error: aborting due to 3 previous errors | ||
|