1 #![warn(clippy::if_same_then_else)]
3 clippy::blacklisted_name,
4 clippy::collapsible_else_if,
5 clippy::collapsible_if,
7 clippy::needless_return,
8 clippy::single_element_loop
11 fn if_same_then_else2() -> Result<&'static str, ()> {
14 let foo: &Option<_> = &Some::<u8>(42);
22 //~ ERROR same body as `if` block
24 let bar: &Option<_> = &Some::<u8>(42);
34 if let Some(a) = Some(42) {}
36 //~ ERROR same body as `if` block
37 if let Some(a) = Some(42) {}
41 if let (1, .., 3) = (1, 2, 3) {}
43 //~ ERROR same body as `if` block
44 if let (1, .., 3) = (1, 2, 3) {}
48 if let (1, .., 3) = (1, 2, 3) {}
50 if let (.., 3) = (1, 2, 3) {}
54 if let (1, .., 3) = (1, 2, 3) {}
56 if let (.., 4) = (1, 2, 3) {}
60 if let (1, .., 3) = (1, 2, 3) {}
62 if let (.., 1, 3) = (1, 2, 3) {}
66 if let Some(42) = None {}
68 if let Option::Some(42) = None {}
72 if let Some(42) = None::<u8> {}
74 if let Some(42) = None {}
78 if let Some(42) = None::<u8> {}
80 if let Some(42) = None::<u32> {}
84 if let Some(a) = Some(42) {}
86 if let Some(a) = Some(43) {}
93 //~ ERROR same body as `if` block
100 //~ ERROR same body as `if` block
106 return Ok(&foo[0..]);
109 return Ok(&foo[0..]);
112 return Ok(&foo[0..]);
117 return Ok(&foo[0..]);
120 return Ok(&foo[0..]);
123 return Ok(&foo[0..]);
126 return Ok(&foo[0..]);
129 // False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559.
133 return Ok(&foo[x..y]);
137 return Ok(&foo[x..y]);