4 #![warn(clippy::redundant_pattern_matching)]
8 clippy::match_like_matches_macro,
9 clippy::unnecessary_wraps,
14 let result: Result<usize, usize> = Err(5);
15 if let Ok(_) = &result {}
17 if let Ok(_) = Ok::<i32, i32>(42) {}
19 if let Err(_) = Err::<i32, i32>(42) {}
21 while let Ok(_) = Ok::<i32, i32>(10) {}
23 while let Err(_) = Ok::<i32, i32>(10) {}
25 if Ok::<i32, i32>(42).is_ok() {}
27 if Err::<i32, i32>(42).is_err() {}
29 if let Ok(x) = Ok::<i32, i32>(42) {
33 match Ok::<i32, i32>(42) {
38 match Ok::<i32, i32>(42) {
43 match Err::<i32, i32>(42) {
48 match Err::<i32, i32>(42) {
53 let _ = if let Ok(_) = Ok::<usize, ()>(4) { true } else { false };
59 let _ = if let Ok(_) = gen_res() {
61 } else if let Err(_) = gen_res() {
68 fn gen_res() -> Result<(), ()> {
79 fn result_opt() -> Result<Option<i32>, i32> {
83 fn try_result_opt() -> Result<i32, i32> {
84 while let Some(_) = r#try!(result_opt()) {}
85 if let Some(_) = r#try!(result_opt()) {}
91 if let Some(_) = m!() {}
92 while let Some(_) = m!() {}
96 macro_rules! if_let_in_macro {
97 ($pat:pat, $x:expr) => {
98 if let Some($pat) = $x {}
102 // shouldn't be linted
103 if_let_in_macro!(_, Some(42));
106 // Methods that are unstable const should not be suggested within a const context, see issue #5697.
107 // However, in Rust 1.48.0 the methods `is_ok` and `is_err` of `Result` were stabilized as const,
108 // so the following should be linted.
109 const fn issue6067() {
110 if let Ok(_) = Ok::<i32, i32>(42) {}
112 if let Err(_) = Err::<i32, i32>(42) {}
114 while let Ok(_) = Ok::<i32, i32>(10) {}
116 while let Err(_) = Ok::<i32, i32>(10) {}
118 match Ok::<i32, i32>(42) {
123 match Err::<i32, i32>(42) {