Auto merge of #11454 - samueltardieu:issue-11403, r=Centri3
Ignore wildcards in function arguments and local bindings Fix #11403 changelog: none
This commit is contained in:
commit
eb0df1d4f4
4 changed files with 46 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#![warn(clippy::ignored_unit_patterns)]
|
||||
#![allow(clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
|
||||
fn foo() -> Result<(), ()> {
|
||||
unimplemented!()
|
||||
|
|
@ -7,9 +7,19 @@ fn foo() -> Result<(), ()> {
|
|||
|
||||
fn main() {
|
||||
match foo() {
|
||||
Ok(()) => {},
|
||||
Err(()) => {},
|
||||
Ok(()) => {}, //~ ERROR: matching over `()` is more explicit
|
||||
Err(()) => {}, //~ ERROR: matching over `()` is more explicit
|
||||
}
|
||||
if let Ok(()) = foo() {}
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
let _ = foo().map_err(|()| todo!());
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn moo(_: ()) {
|
||||
let () = foo().unwrap();
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
let _: () = foo().unwrap();
|
||||
let _: () = ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![warn(clippy::ignored_unit_patterns)]
|
||||
#![allow(clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
|
||||
fn foo() -> Result<(), ()> {
|
||||
unimplemented!()
|
||||
|
|
@ -7,9 +7,19 @@ fn foo() -> Result<(), ()> {
|
|||
|
||||
fn main() {
|
||||
match foo() {
|
||||
Ok(_) => {},
|
||||
Err(_) => {},
|
||||
Ok(_) => {}, //~ ERROR: matching over `()` is more explicit
|
||||
Err(_) => {}, //~ ERROR: matching over `()` is more explicit
|
||||
}
|
||||
if let Ok(_) = foo() {}
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
let _ = foo().map_err(|_| todo!());
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn moo(_: ()) {
|
||||
let _ = foo().unwrap();
|
||||
//~^ ERROR: matching over `()` is more explicit
|
||||
let _: () = foo().unwrap();
|
||||
let _: () = ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,16 @@ LL | if let Ok(_) = foo() {}
|
|||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:14:28
|
||||
--> $DIR/ignored_unit_patterns.rs:15:28
|
||||
|
|
||||
LL | let _ = foo().map_err(|_| todo!());
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:21:9
|
||||
|
|
||||
LL | let _ = foo().unwrap();
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue