1 #![feature(plugin, inclusive_range_syntax)]
4 #![allow(dead_code, no_effect)]
5 #![allow(let_and_return)]
6 #![allow(needless_return)]
7 #![allow(unused_variables)]
8 #![allow(cyclomatic_complexity)]
9 #![allow(blacklisted_name)]
12 fn foo() -> bool { unimplemented!() }
18 #[deny(if_same_then_else)]
19 #[deny(match_same_arms)]
20 fn if_same_then_else() -> Result<&'static str, ()> {
30 else { //~ERROR this `if` has identical blocks
66 else { //~ERROR this `if` has identical blocks
78 else { //~ERROR this `if` has identical blocks
90 while foo() { break; }
93 else { //~ERROR this `if` has identical blocks
101 while foo() { break; }
116 else if foo() { //~ERROR this `if` has identical blocks
126 if let Some(a) = Some(42) {}
128 else { //~ERROR this `if` has identical blocks
129 if let Some(a) = Some(42) {}
133 if let Some(a) = Some(42) {}
136 if let Some(a) = Some(43) {}
141 51 => foo(), //~ERROR this `match` has identical arm bodies
145 let _ = match Some(42) {
150 let _ = match Some(42) {
152 Some(a) => 24, // bindings are different
156 let _ = match Some(42) {
157 Some(a) if a > 0 => 24,
158 Some(a) => 24, // one arm has a guard
162 match (Some(42), Some(42)) {
163 (Some(a), None) => bar(a),
164 (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
168 match (Some(42), Some("")) {
169 (Some(a), None) => bar(a),
170 (None, Some(a)) => bar(a), // bindings have different types
177 else { //~ERROR this `if` has identical blocks
183 return Ok(&foo[0..]);
187 return Ok(&foo[0..]);
189 else { //~ERROR this `if` has identical blocks
191 return Ok(&foo[0..]);
195 #[deny(ifs_same_cond)]
196 #[allow(if_same_then_else)] // all empty blocks
203 else if b { //~ERROR this `if` has the same condition as a previous if
208 else if a == 1 { //~ERROR this `if` has the same condition as a previous if
215 else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
221 if cfg!(feature = "feature1-659") {
223 } else if cfg!(feature = "feature2-659") {
230 if v.pop() == None { // ok, functions
232 else if v.pop() == None {
235 if v.len() == 42 { // ok, functions
237 else if v.len() == 42 {