1 #![warn(clippy::if_same_then_else)]
3 clippy::blacklisted_name,
4 clippy::collapsible_if,
6 clippy::needless_return,
7 clippy::single_element_loop
10 fn if_same_then_else2() -> Result<&'static str, ()> {
13 let foo: &Option<_> = &Some::<u8>(42);
21 //~ ERROR same body as `if` block
23 let foo: &Option<_> = &Some::<u8>(42);
33 if let Some(a) = Some(42) {}
35 //~ ERROR same body as `if` block
36 if let Some(a) = Some(42) {}
40 if let (1, .., 3) = (1, 2, 3) {}
42 //~ ERROR same body as `if` block
43 if let (1, .., 3) = (1, 2, 3) {}
47 if let (1, .., 3) = (1, 2, 3) {}
49 if let (.., 3) = (1, 2, 3) {}
53 if let (1, .., 3) = (1, 2, 3) {}
55 if let (.., 4) = (1, 2, 3) {}
59 if let (1, .., 3) = (1, 2, 3) {}
61 if let (.., 1, 3) = (1, 2, 3) {}
65 if let Some(42) = None {}
67 if let Option::Some(42) = None {}
71 if let Some(42) = None::<u8> {}
73 if let Some(42) = None {}
77 if let Some(42) = None::<u8> {}
79 if let Some(42) = None::<u32> {}
83 if let Some(a) = Some(42) {}
85 if let Some(a) = Some(43) {}
92 //~ ERROR same body as `if` block
99 //~ ERROR same body as `if` block
105 return Ok(&foo[0..]);
108 return Ok(&foo[0..]);
111 return Ok(&foo[0..]);
116 return Ok(&foo[0..]);
119 return Ok(&foo[0..]);
122 return Ok(&foo[0..]);
125 return Ok(&foo[0..]);
128 // False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559.
132 return Ok(&foo[x..y]);
136 return Ok(&foo[x..y]);