1 #![feature(plugin, inclusive_range_syntax)]
2 #![feature(dotdot_in_tuple_patterns)]
5 #![allow(dead_code, no_effect, unnecessary_operation)]
6 #![allow(let_and_return)]
7 #![allow(needless_return)]
8 #![allow(unused_variables)]
9 #![allow(cyclomatic_complexity)]
10 #![allow(blacklisted_name)]
11 #![allow(collapsible_if)]
14 fn foo() -> bool { unimplemented!() }
20 #[deny(if_same_then_else)]
21 #[deny(match_same_arms)]
22 fn if_same_then_else() -> Result<&'static str, ()> {
32 else { //~ERROR this `if` has identical blocks
68 else { //~ERROR this `if` has identical blocks
80 else { //~ERROR this `if` has identical blocks
92 while foo() { break; }
95 else { //~ERROR this `if` has identical blocks
103 while foo() { break; }
118 else if foo() { //~ERROR this `if` has identical blocks
128 if let Some(a) = Some(42) {}
130 else { //~ERROR this `if` has identical blocks
131 if let Some(a) = Some(42) {}
135 if let (1, .., 3) = (1, 2, 3) {}
137 else { //~ERROR this `if` has identical blocks
138 if let (1, .., 3) = (1, 2, 3) {}
142 if let (1, .., 3) = (1, 2, 3) {}
145 if let (.., 3) = (1, 2, 3) {}
149 if let (1, .., 3) = (1, 2, 3) {}
152 if let (.., 4) = (1, 2, 3) {}
156 if let (1, .., 3) = (1, 2, 3) {}
159 if let (.., 1, 3) = (1, 2, 3) {}
163 if let Some(a) = Some(42) {}
166 if let Some(a) = Some(43) {}
171 51 => foo(), //~ERROR this `match` has identical arm bodies
175 let _ = match Some(42) {
177 None => 24, //~ERROR this `match` has identical arm bodies
180 let _ = match Some(42) {
185 let _ = match Some(42) {
187 Some(a) => 24, // bindings are different
191 let _ = match Some(42) {
192 Some(a) if a > 0 => 24,
193 Some(a) => 24, // one arm has a guard
197 match (Some(42), Some(42)) {
198 (Some(a), None) => bar(a),
199 (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
203 match (Some(42), Some(42)) {
204 (Some(a), ..) => bar(a),
205 (.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
211 (.., 3) => 42, //~ERROR this `match` has identical arm bodies
215 match (Some(42), Some("")) {
216 (Some(a), None) => bar(a),
217 (None, Some(a)) => bar(a), // bindings have different types
224 else { //~ERROR this `if` has identical blocks
230 return Ok(&foo[0..]);
234 return Ok(&foo[0..]);
236 else { //~ERROR this `if` has identical blocks
238 return Ok(&foo[0..]);
242 #[deny(ifs_same_cond)]
243 #[allow(if_same_then_else)] // all empty blocks
250 else if b { //~ERROR this `if` has the same condition as a previous if
255 else if a == 1 { //~ERROR this `if` has the same condition as a previous if
262 else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
268 if cfg!(feature = "feature1-659") {
270 } else if cfg!(feature = "feature2-659") {
277 if v.pop() == None { // ok, functions
279 else if v.pop() == None {
282 if v.len() == 42 { // ok, functions
284 else if v.len() == 42 {