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) {
147 Some(a) => 24, // bindings are different
151 match (Some(42), Some(42)) {
152 (Some(a), None) => bar(a),
153 (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
157 match (Some(42), Some("")) {
158 (Some(a), None) => bar(a),
159 (None, Some(a)) => bar(a), // bindings have different types
166 else { //~ERROR this `if` has identical blocks
172 return Ok(&foo[0..]);
176 return Ok(&foo[0..]);
178 else { //~ERROR this `if` has identical blocks
180 return Ok(&foo[0..]);
184 #[deny(ifs_same_cond)]
185 #[allow(if_same_then_else)] // all empty blocks
192 else if b { //~ERROR this `if` has the same condition as a previous if
197 else if a == 1 { //~ERROR this `if` has the same condition as a previous if
204 else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
210 if cfg!(feature = "feature1-659") {
212 } else if cfg!(feature = "feature2-659") {
219 if v.pop() == None { // ok, functions
221 else if v.pop() == None {
224 if v.len() == 42 { // ok, functions
226 else if v.len() == 42 {