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)]
11 fn foo() -> bool { unimplemented!() }
17 #[deny(if_same_then_else)]
18 #[deny(match_same_arms)]
19 fn if_same_then_else() -> Result<&'static str, ()> {
29 else { //~ERROR this `if` has identical blocks
65 else { //~ERROR this `if` has identical blocks
77 else { //~ERROR this `if` has identical blocks
89 while foo() { break; }
92 else { //~ERROR this `if` has identical blocks
100 while foo() { break; }
115 else if foo() { //~ERROR this `if` has identical blocks
125 if let Some(a) = Some(42) {}
127 else { //~ERROR this `if` has identical blocks
128 if let Some(a) = Some(42) {}
132 if let Some(a) = Some(42) {}
135 if let Some(a) = Some(43) {}
140 51 => foo(), //~ERROR this `match` has identical arm bodies
144 let _ = match Some(42) {
146 Some(a) => 24, // bindings are different
150 match (Some(42), Some(42)) {
151 (Some(a), None) => bar(a),
152 (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
156 match (Some(42), Some("")) {
157 (Some(a), None) => bar(a),
158 (None, Some(a)) => bar(a), // bindings have different types
165 else { //~ERROR this `if` has identical blocks
171 return Ok(&foo[0..]);
175 return Ok(&foo[0..]);
177 else { //~ERROR this `if` has identical blocks
179 return Ok(&foo[0..]);
183 #[deny(ifs_same_cond)]
184 #[allow(if_same_then_else)] // all empty blocks
191 else if b { //~ERROR this `if` has the same condition as a previous if
196 else if a == 1 { //~ERROR this `if` has the same condition as a previous if
203 else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
209 if cfg!(feature = "feature1-659") {
211 } else if cfg!(feature = "feature2-659") {
218 if v.pop() == None { // ok, functions
220 else if v.pop() == None {
223 if v.len() == 42 { // ok, functions
225 else if v.len() == 42 {