rust-clippy/tests/ui/ignored_unit_patterns.fixed

26 lines
711 B
Rust
Raw Normal View History

2023-07-27 17:04:01 +00:00
#![warn(clippy::ignored_unit_patterns)]
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
2023-07-27 17:04:01 +00:00
fn foo() -> Result<(), ()> {
unimplemented!()
}
fn main() {
match foo() {
Ok(()) => {}, //~ ERROR: matching over `()` is more explicit
Err(()) => {}, //~ ERROR: matching over `()` is more explicit
2023-07-27 17:04:01 +00:00
}
if let Ok(()) = foo() {}
//~^ ERROR: matching over `()` is more explicit
2023-07-27 17:04:01 +00:00
let _ = foo().map_err(|()| todo!());
//~^ ERROR: matching over `()` is more explicit
2023-07-27 17:04:01 +00:00
}
#[allow(unused)]
pub fn moo(_: ()) {
let () = foo().unwrap();
//~^ ERROR: matching over `()` is more explicit
let _: () = foo().unwrap();
let _: () = ();
}