1 #![warn(clippy::if_same_then_else)]
3 clippy::blacklisted_name,
4 clippy::collapsible_if,
6 clippy::needless_return
9 fn if_same_then_else2() -> Result<&'static str, ()> {
12 let foo: &Option<_> = &Some::<u8>(42);
20 //~ ERROR same body as `if` block
22 let foo: &Option<_> = &Some::<u8>(42);
32 if let Some(a) = Some(42) {}
34 //~ ERROR same body as `if` block
35 if let Some(a) = Some(42) {}
39 if let (1, .., 3) = (1, 2, 3) {}
41 //~ ERROR same body as `if` block
42 if let (1, .., 3) = (1, 2, 3) {}
46 if let (1, .., 3) = (1, 2, 3) {}
48 if let (.., 3) = (1, 2, 3) {}
52 if let (1, .., 3) = (1, 2, 3) {}
54 if let (.., 4) = (1, 2, 3) {}
58 if let (1, .., 3) = (1, 2, 3) {}
60 if let (.., 1, 3) = (1, 2, 3) {}
64 if let Some(42) = None {}
66 if let Option::Some(42) = None {}
70 if let Some(42) = None::<u8> {}
72 if let Some(42) = None {}
76 if let Some(42) = None::<u8> {}
78 if let Some(42) = None::<u32> {}
82 if let Some(a) = Some(42) {}
84 if let Some(a) = Some(43) {}
91 //~ ERROR same body as `if` block
98 //~ ERROR same body as `if` block
104 return Ok(&foo[0..]);
107 return Ok(&foo[0..]);
110 return Ok(&foo[0..]);
115 return Ok(&foo[0..]);
118 return Ok(&foo[0..]);
121 return Ok(&foo[0..]);
124 return Ok(&foo[0..]);
127 // False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559.
131 return Ok(&foo[x..y]);
135 return Ok(&foo[x..y]);