2023-10-03 11:36:35 +00:00
|
|
|
//@aux-build:proc_macro_derive.rs
|
2023-07-27 17:04:01 +00:00
|
|
|
#![warn(clippy::ignored_unit_patterns)]
|
2023-09-02 21:06:16 +00:00
|
|
|
#![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() {
|
2023-09-04 15:04:04 +00:00
|
|
|
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() {}
|
2023-09-04 15:04:04 +00:00
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
2023-07-27 17:04:01 +00:00
|
|
|
let _ = foo().map_err(|()| todo!());
|
2023-09-04 15:04:04 +00:00
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
2023-10-03 11:36:35 +00:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"{:?}",
|
|
|
|
match foo() {
|
|
|
|
Ok(()) => {},
|
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
|
|
Err(()) => {},
|
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
|
|
}
|
|
|
|
);
|
2023-07-27 17:04:01 +00:00
|
|
|
}
|
2023-09-02 21:06:16 +00:00
|
|
|
|
2023-10-03 11:36:35 +00:00
|
|
|
// ignored_unit_patterns in derive macro should be ok
|
|
|
|
#[derive(proc_macro_derive::StructIgnoredUnitPattern)]
|
|
|
|
pub struct B;
|
|
|
|
|
2023-09-02 21:06:16 +00:00
|
|
|
#[allow(unused)]
|
|
|
|
pub fn moo(_: ()) {
|
|
|
|
let () = foo().unwrap();
|
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
|
|
let _: () = foo().unwrap();
|
|
|
|
let _: () = ();
|
|
|
|
}
|
2023-10-15 00:40:47 +00:00
|
|
|
|
|
|
|
fn test_unit_ref_1() {
|
|
|
|
let x: (usize, &&&&&()) = (1, &&&&&&());
|
|
|
|
match x {
|
|
|
|
(1, ()) => unimplemented!(),
|
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
|
|
_ => unimplemented!(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_unit_ref_2(v: &[(usize, ())]) {
|
|
|
|
for (x, ()) in v {
|
|
|
|
//~^ ERROR: matching over `()` is more explicit
|
|
|
|
let _ = x;
|
|
|
|
}
|
|
|
|
}
|