4 #![warn(clippy::redundant_pattern_matching)]
8 clippy::match_like_matches_macro,
9 clippy::unnecessary_wraps,
11 clippy::if_same_then_else
15 let result: Result<usize, usize> = Err(5);
16 if let Ok(_) = &result {}
18 if let Ok(_) = Ok::<i32, i32>(42) {}
20 if let Err(_) = Err::<i32, i32>(42) {}
22 while let Ok(_) = Ok::<i32, i32>(10) {}
24 while let Err(_) = Ok::<i32, i32>(10) {}
26 if Ok::<i32, i32>(42).is_ok() {}
28 if Err::<i32, i32>(42).is_err() {}
30 if let Ok(x) = Ok::<i32, i32>(42) {
34 match Ok::<i32, i32>(42) {
39 match Ok::<i32, i32>(42) {
44 match Err::<i32, i32>(42) {
49 match Err::<i32, i32>(42) {
54 let _ = if let Ok(_) = Ok::<usize, ()>(4) { true } else { false };
60 let _ = if let Ok(_) = gen_res() {
62 } else if let Err(_) = gen_res() {
69 fn gen_res() -> Result<(), ()> {
80 fn result_opt() -> Result<Option<i32>, i32> {
84 fn try_result_opt() -> Result<i32, i32> {
85 while let Some(_) = r#try!(result_opt()) {}
86 if let Some(_) = r#try!(result_opt()) {}
92 if let Some(_) = m!() {}
93 while let Some(_) = m!() {}
97 macro_rules! if_let_in_macro {
98 ($pat:pat, $x:expr) => {
99 if let Some($pat) = $x {}
103 // shouldn't be linted
104 if_let_in_macro!(_, Some(42));
107 // Methods that are unstable const should not be suggested within a const context, see issue #5697.
108 // However, in Rust 1.48.0 the methods `is_ok` and `is_err` of `Result` were stabilized as const,
109 // so the following should be linted.
110 const fn issue6067() {
111 if let Ok(_) = Ok::<i32, i32>(42) {}
113 if let Err(_) = Err::<i32, i32>(42) {}
115 while let Ok(_) = Ok::<i32, i32>(10) {}
117 while let Err(_) = Ok::<i32, i32>(10) {}
119 match Ok::<i32, i32>(42) {
124 match Err::<i32, i32>(42) {