mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 07:30:57 +00:00
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
//@aux-build:proc_macro_derive.rs
|
|
#![warn(clippy::ignored_unit_patterns)]
|
|
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
|
|
|
|
fn foo() -> Result<(), ()> {
|
|
unimplemented!()
|
|
}
|
|
|
|
fn main() {
|
|
match foo() {
|
|
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
|
|
|
|
println!(
|
|
"{:?}",
|
|
match foo() {
|
|
Ok(_) => {},
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
Err(_) => {},
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
}
|
|
);
|
|
}
|
|
|
|
// ignored_unit_patterns in derive macro should be ok
|
|
#[derive(proc_macro_derive::StructIgnoredUnitPattern)]
|
|
pub struct B;
|
|
|
|
#[allow(unused)]
|
|
pub fn moo(_: ()) {
|
|
let _ = foo().unwrap();
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
let _: () = foo().unwrap();
|
|
let _: () = ();
|
|
}
|