From 83a87fb7b6378eb928d0fd3e38fbab3579dc520c Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sun, 10 Feb 2019 10:19:24 +0100 Subject: [PATCH] UI test cleanup: Extract match_same_arms tests --- tests/ui/copies.rs | 246 +--------------------------- tests/ui/copies.stderr | 256 +++-------------------------- tests/ui/if_same_then_else.rs | 262 ++++++++++++++++++++++++++++++ tests/ui/if_same_then_else.stderr | 214 ++++++++++++++++++++++++ 4 files changed, 499 insertions(+), 479 deletions(-) create mode 100644 tests/ui/if_same_then_else.rs create mode 100644 tests/ui/if_same_then_else.stderr diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index a78209bcce8..a1f15c0268b 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -5,7 +5,6 @@ clippy::eq_op, clippy::needless_continue, clippy::needless_return, - clippy::never_loop, clippy::no_effect, clippy::zero_divided_by_zero, clippy::unused_unit @@ -16,64 +15,15 @@ fn foo() -> bool { unimplemented!() } -struct Foo { - bar: u8, -} - pub enum Abc { A, B, C, } -#[warn(clippy::if_same_then_else)] #[warn(clippy::match_same_arms)] #[allow(clippy::unused_unit)] -fn if_same_then_else() -> Result<&'static str, ()> { - if true { - Foo { bar: 42 }; - 0..10; - ..; - 0..; - ..10; - 0..=10; - foo(); - } else { - //~ ERROR same body as `if` block - Foo { bar: 42 }; - 0..10; - ..; - 0..; - ..10; - 0..=10; - foo(); - } - - if true { - Foo { bar: 42 }; - } else { - Foo { bar: 43 }; - } - - if true { - (); - } else { - () - } - - if true { - 0..10; - } else { - 0..=10; - } - - if true { - foo(); - foo(); - } else { - foo(); - } - +fn match_same_arms() { let _ = match 42 { 42 => { foo(); @@ -102,129 +52,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { _ => 0, //~ ERROR match arms have same body }; - if true { - foo(); - } - - let _ = if true { - 42 - } else { - //~ ERROR same body as `if` block - 42 - }; - - if true { - for _ in &[42] { - let foo: &Option<_> = &Some::(42); - if true { - break; - } else { - continue; - } - } - } else { - //~ ERROR same body as `if` block - for _ in &[42] { - let foo: &Option<_> = &Some::(42); - if true { - break; - } else { - continue; - } - } - } - - if true { - let bar = if true { 42 } else { 43 }; - - while foo() { - break; - } - bar + 1; - } else { - //~ ERROR same body as `if` block - let bar = if true { 42 } else { 43 }; - - while foo() { - break; - } - bar + 1; - } - - if true { - let _ = match 42 { - 42 => 1, - a if a > 0 => 2, - 10..=15 => 3, - _ => 4, - }; - } else if false { - foo(); - } else if foo() { - let _ = match 42 { - 42 => 1, - a if a > 0 => 2, - 10..=15 => 3, - _ => 4, - }; - } - - if true { - if let Some(a) = Some(42) {} - } else { - //~ ERROR same body as `if` block - if let Some(a) = Some(42) {} - } - - if true { - if let (1, .., 3) = (1, 2, 3) {} - } else { - //~ ERROR same body as `if` block - if let (1, .., 3) = (1, 2, 3) {} - } - - if true { - if let (1, .., 3) = (1, 2, 3) {} - } else { - if let (.., 3) = (1, 2, 3) {} - } - - if true { - if let (1, .., 3) = (1, 2, 3) {} - } else { - if let (.., 4) = (1, 2, 3) {} - } - - if true { - if let (1, .., 3) = (1, 2, 3) {} - } else { - if let (.., 1, 3) = (1, 2, 3) {} - } - - if true { - if let Some(42) = None {} - } else { - if let Option::Some(42) = None {} - } - - if true { - if let Some(42) = None:: {} - } else { - if let Some(42) = None {} - } - - if true { - if let Some(42) = None:: {} - } else { - if let Some(42) = None:: {} - } - - if true { - if let Some(a) = Some(42) {} - } else { - if let Some(a) = Some(43) {} - } - let _ = match 42 { 42 => foo(), 51 => foo(), //~ ERROR match arms have same body @@ -271,33 +98,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { _ => 0, }; - let _ = if true { - 0.0 - } else { - //~ ERROR same body as `if` block - 0.0 - }; - - let _ = if true { - -0.0 - } else { - //~ ERROR same body as `if` block - -0.0 - }; - - let _ = if true { 0.0 } else { -0.0 }; - - // Different NaNs - let _ = if true { 0.0 / 0.0 } else { std::f32::NAN }; - - // Same NaNs - let _ = if true { - std::f32::NAN - } else { - //~ ERROR same body as `if` block - std::f32::NAN - }; - let _ = match Some(()) { Some(()) => 0.0, None => -0.0, @@ -308,50 +108,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { (None, Some(a)) => bar(a), // bindings have different types _ => (), } - - if true { - try!(Ok("foo")); - } else { - //~ ERROR same body as `if` block - try!(Ok("foo")); - } - - if true { - let foo = ""; - return Ok(&foo[0..]); - } else if false { - let foo = "bar"; - return Ok(&foo[0..]); - } else { - let foo = ""; - return Ok(&foo[0..]); - } - - // false positive if_same_then_else, let(x,y) vs let(y,x), see #3559 - if true { - let foo = ""; - let (x, y) = (1, 2); - return Ok(&foo[x..y]); - } else { - let foo = ""; - let (y, x) = (1, 2); - return Ok(&foo[x..y]); - } } fn main() {} - -// Issue #2423. This was causing an ICE -fn func() { - if true { - f(&[0; 62]); - f(&[0; 4]); - f(&[0; 3]); - } else { - f(&[0; 62]); - f(&[0; 6]); - f(&[0; 6]); - } -} - -fn f(val: &[u8]) {} diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index a0a5c3890ed..f04a7706846 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,32 +1,5 @@ -error: this `if` has identical blocks - --> $DIR/copies.rs:41:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | Foo { bar: 42 }; -LL | | 0..10; -... | -LL | | foo(); -LL | | } - | |_____^ - | - = note: `-D clippy::if-same-then-else` implied by `-D warnings` -note: same as this - --> $DIR/copies.rs:33:13 - | -LL | if true { - | _____________^ -LL | | Foo { bar: 42 }; -LL | | 0..10; -LL | | ..; -... | -LL | | foo(); -LL | | } else { - | |_____^ - error: this `match` has identical arm bodies - --> $DIR/copies.rs:87:14 + --> $DIR/copies.rs:37:14 | LL | _ => { | ______________^ @@ -40,7 +13,7 @@ LL | | }, | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:78:15 + --> $DIR/copies.rs:28:15 | LL | 42 => { | _______________^ @@ -52,7 +25,7 @@ LL | | a LL | | }, | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:78:15 + --> $DIR/copies.rs:28:15 | LL | 42 => { | _______________^ @@ -65,291 +38,106 @@ LL | | }, | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:102:14 + --> $DIR/copies.rs:52:14 | LL | _ => 0, //~ ERROR match arms have same body | ^ | note: same as this - --> $DIR/copies.rs:100:19 + --> $DIR/copies.rs:50:19 | LL | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:100:19 + --> $DIR/copies.rs:50:19 | LL | Abc::A => 0, | ^ -error: this `if` has identical blocks - --> $DIR/copies.rs:111:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | 42 -LL | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:109:21 - | -LL | let _ = if true { - | _____________________^ -LL | | 42 -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:125:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | for _ in &[42] { -LL | | let foo: &Option<_> = &Some::(42); -... | -LL | | } -LL | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:116:13 - | -LL | if true { - | _____________^ -LL | | for _ in &[42] { -LL | | let foo: &Option<_> = &Some::(42); -LL | | if true { -... | -LL | | } -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:144:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | let bar = if true { 42 } else { 43 }; -LL | | -... | -LL | | bar + 1; -LL | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:137:13 - | -LL | if true { - | _____________^ -LL | | let bar = if true { 42 } else { 43 }; -LL | | -LL | | while foo() { -... | -LL | | bar + 1; -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:174:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | if let Some(a) = Some(42) {} -LL | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:172:13 - | -LL | if true { - | _____________^ -LL | | if let Some(a) = Some(42) {} -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:181:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | if let (1, .., 3) = (1, 2, 3) {} -LL | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:179:13 - | -LL | if true { - | _____________^ -LL | | if let (1, .., 3) = (1, 2, 3) {} -LL | | } else { - | |_____^ - error: this `match` has identical arm bodies - --> $DIR/copies.rs:230:15 + --> $DIR/copies.rs:57:15 | LL | 51 => foo(), //~ ERROR match arms have same body | ^^^^^ | note: same as this - --> $DIR/copies.rs:229:15 + --> $DIR/copies.rs:56:15 | LL | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:229:15 + --> $DIR/copies.rs:56:15 | LL | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:236:17 + --> $DIR/copies.rs:63:17 | LL | None => 24, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:235:20 + --> $DIR/copies.rs:62:20 | LL | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:235:20 + --> $DIR/copies.rs:62:20 | LL | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:258:28 + --> $DIR/copies.rs:85:28 | LL | (None, Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:257:28 + --> $DIR/copies.rs:84:28 | LL | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:257:28 + --> $DIR/copies.rs:84:28 | LL | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:264:26 + --> $DIR/copies.rs:91:26 | LL | (.., Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:263:26 + --> $DIR/copies.rs:90:26 | LL | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:263:26 + --> $DIR/copies.rs:90:26 | LL | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:270:20 + --> $DIR/copies.rs:97:20 | LL | (.., 3) => 42, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:269:23 + --> $DIR/copies.rs:96:23 | LL | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:269:23 + --> $DIR/copies.rs:96:23 | LL | (1, .., 3) => 42, | ^^ -error: this `if` has identical blocks - --> $DIR/copies.rs:276:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | 0.0 -LL | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:274:21 - | -LL | let _ = if true { - | _____________________^ -LL | | 0.0 -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:283:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | -0.0 -LL | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:281:21 - | -LL | let _ = if true { - | _____________________^ -LL | | -0.0 -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:296:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | std::f32::NAN -LL | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:294:21 - | -LL | let _ = if true { - | _____________________^ -LL | | std::f32::NAN -LL | | } else { - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:314:12 - | -LL | } else { - | ____________^ -LL | | //~ ERROR same body as `if` block -LL | | try!(Ok("foo")); -LL | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:312:13 - | -LL | if true { - | _____________^ -LL | | try!(Ok("foo")); -LL | | } else { - | |_____^ - -error: aborting due to 17 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/if_same_then_else.rs b/tests/ui/if_same_then_else.rs new file mode 100644 index 00000000000..c054e39811c --- /dev/null +++ b/tests/ui/if_same_then_else.rs @@ -0,0 +1,262 @@ +#![warn(clippy::if_same_then_else)] +#![allow( + clippy::blacklisted_name, + clippy::collapsible_if, + clippy::cyclomatic_complexity, + clippy::eq_op, + clippy::needless_return, + clippy::never_loop, + clippy::no_effect, + clippy::zero_divided_by_zero, + clippy::unused_unit, +)] + +struct Foo { + bar: u8, +} + +fn foo() -> bool { + unimplemented!() +} + +fn if_same_then_else() -> Result<&'static str, ()> { + if true { + Foo { bar: 42 }; + 0..10; + ..; + 0..; + ..10; + 0..=10; + foo(); + } else { + //~ ERROR same body as `if` block + Foo { bar: 42 }; + 0..10; + ..; + 0..; + ..10; + 0..=10; + foo(); + } + + if true { + Foo { bar: 42 }; + } else { + Foo { bar: 43 }; + } + + if true { + (); + } else { + () + } + + if true { + 0..10; + } else { + 0..=10; + } + + if true { + foo(); + foo(); + } else { + foo(); + } + + let _ = if true { + 0.0 + } else { + //~ ERROR same body as `if` block + 0.0 + }; + + let _ = if true { + -0.0 + } else { + //~ ERROR same body as `if` block + -0.0 + }; + + let _ = if true { 0.0 } else { -0.0 }; + + // Different NaNs + let _ = if true { 0.0 / 0.0 } else { std::f32::NAN }; + + if true { + foo(); + } + + let _ = if true { + 42 + } else { + //~ ERROR same body as `if` block + 42 + }; + + if true { + for _ in &[42] { + let foo: &Option<_> = &Some::(42); + if true { + break; + } else { + continue; + } + } + } else { + //~ ERROR same body as `if` block + for _ in &[42] { + let foo: &Option<_> = &Some::(42); + if true { + break; + } else { + continue; + } + } + } + + if true { + let bar = if true { 42 } else { 43 }; + + while foo() { + break; + } + bar + 1; + } else { + //~ ERROR same body as `if` block + let bar = if true { 42 } else { 43 }; + + while foo() { + break; + } + bar + 1; + } + + if true { + let _ = match 42 { + 42 => 1, + a if a > 0 => 2, + 10..=15 => 3, + _ => 4, + }; + } else if false { + foo(); + } else if foo() { + let _ = match 42 { + 42 => 1, + a if a > 0 => 2, + 10..=15 => 3, + _ => 4, + }; + } + + if true { + if let Some(a) = Some(42) {} + } else { + //~ ERROR same body as `if` block + if let Some(a) = Some(42) {} + } + + if true { + if let (1, .., 3) = (1, 2, 3) {} + } else { + //~ ERROR same body as `if` block + if let (1, .., 3) = (1, 2, 3) {} + } + + if true { + if let (1, .., 3) = (1, 2, 3) {} + } else { + if let (.., 3) = (1, 2, 3) {} + } + + if true { + if let (1, .., 3) = (1, 2, 3) {} + } else { + if let (.., 4) = (1, 2, 3) {} + } + + if true { + if let (1, .., 3) = (1, 2, 3) {} + } else { + if let (.., 1, 3) = (1, 2, 3) {} + } + + if true { + if let Some(42) = None {} + } else { + if let Option::Some(42) = None {} + } + + if true { + if let Some(42) = None:: {} + } else { + if let Some(42) = None {} + } + + if true { + if let Some(42) = None:: {} + } else { + if let Some(42) = None:: {} + } + + if true { + if let Some(a) = Some(42) {} + } else { + if let Some(a) = Some(43) {} + } + + // Same NaNs + let _ = if true { + std::f32::NAN + } else { + //~ ERROR same body as `if` block + std::f32::NAN + }; + + if true { + try!(Ok("foo")); + } else { + //~ ERROR same body as `if` block + try!(Ok("foo")); + } + + if true { + let foo = ""; + return Ok(&foo[0..]); + } else if false { + let foo = "bar"; + return Ok(&foo[0..]); + } else { + let foo = ""; + return Ok(&foo[0..]); + } + + // false positive if_same_then_else, let(x,y) vs let(y,x), see #3559 + if true { + let foo = ""; + let (x, y) = (1, 2); + return Ok(&foo[x..y]); + } else { + let foo = ""; + let (y, x) = (1, 2); + return Ok(&foo[x..y]); + } +} + +// Issue #2423. This was causing an ICE +fn func() { + if true { + f(&[0; 62]); + f(&[0; 4]); + f(&[0; 3]); + } else { + f(&[0; 62]); + f(&[0; 6]); + f(&[0; 6]); + } +} + +fn f(val: &[u8]) {} + +fn main() {} diff --git a/tests/ui/if_same_then_else.stderr b/tests/ui/if_same_then_else.stderr new file mode 100644 index 00000000000..b170db31b85 --- /dev/null +++ b/tests/ui/if_same_then_else.stderr @@ -0,0 +1,214 @@ +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:31:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | Foo { bar: 42 }; +LL | | 0..10; +... | +LL | | foo(); +LL | | } + | |_____^ + | + = note: `-D clippy::if-same-then-else` implied by `-D warnings` +note: same as this + --> $DIR/if_same_then_else.rs:23:13 + | +LL | if true { + | _____________^ +LL | | Foo { bar: 42 }; +LL | | 0..10; +LL | | ..; +... | +LL | | foo(); +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:69:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | 0.0 +LL | | }; + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:67:21 + | +LL | let _ = if true { + | _____________________^ +LL | | 0.0 +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:76:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | -0.0 +LL | | }; + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:74:21 + | +LL | let _ = if true { + | _____________________^ +LL | | -0.0 +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:92:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | 42 +LL | | }; + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:90:21 + | +LL | let _ = if true { + | _____________________^ +LL | | 42 +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:106:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | for _ in &[42] { +LL | | let foo: &Option<_> = &Some::(42); +... | +LL | | } +LL | | } + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:97:13 + | +LL | if true { + | _____________^ +LL | | for _ in &[42] { +LL | | let foo: &Option<_> = &Some::(42); +LL | | if true { +... | +LL | | } +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:125:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | let bar = if true { 42 } else { 43 }; +LL | | +... | +LL | | bar + 1; +LL | | } + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:118:13 + | +LL | if true { + | _____________^ +LL | | let bar = if true { 42 } else { 43 }; +LL | | +LL | | while foo() { +... | +LL | | bar + 1; +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:155:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | if let Some(a) = Some(42) {} +LL | | } + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:153:13 + | +LL | if true { + | _____________^ +LL | | if let Some(a) = Some(42) {} +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:162:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | if let (1, .., 3) = (1, 2, 3) {} +LL | | } + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:160:13 + | +LL | if true { + | _____________^ +LL | | if let (1, .., 3) = (1, 2, 3) {} +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:212:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | std::f32::NAN +LL | | }; + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:210:21 + | +LL | let _ = if true { + | _____________________^ +LL | | std::f32::NAN +LL | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/if_same_then_else.rs:219:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | try!(Ok("foo")); +LL | | } + | |_____^ + | +note: same as this + --> $DIR/if_same_then_else.rs:217:13 + | +LL | if true { + | _____________^ +LL | | try!(Ok("foo")); +LL | | } else { + | |_____^ + +error: aborting due to 10 previous errors +