diff --git a/tests/compile-fail/copies.rs b/tests/compile-fail/copies.rs index 3c3e43931ed..c84c1062072 100644 --- a/tests/compile-fail/copies.rs +++ b/tests/compile-fail/copies.rs @@ -48,6 +48,13 @@ fn if_same_then_else() -> Result<&'static str, ()> { Foo { bar: 43 }; } + if true { + (); + } + else { + () + } + if true { 0..10; } @@ -66,11 +73,17 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = if true { //~^NOTE same as this foo(); - 42 + let mut a = 42 + [23].len() as i32; + a += 7; + a = -31-a; + a } else { //~ERROR this `if` has identical blocks foo(); - 42 + let mut a = 42 + [23].len() as i32; + a += 7; + a = -31-a; + a }; if true { @@ -85,6 +98,28 @@ fn if_same_then_else() -> Result<&'static str, ()> { 42 }; + if true { + //~^NOTE same as this + for _ in &[42] { + let foo: &Option<_> = &Some::(42); + if true { + break; + } else { + continue; + } + } + } + else { //~ERROR this `if` has identical blocks + for _ in &[42] { + let foo: &Option<_> = &Some::(42); + if true { + break; + } else { + continue; + } + } + } + if true { //~^NOTE same as this let bar = if true { @@ -167,6 +202,20 @@ fn if_same_then_else() -> Result<&'static str, ()> { 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(a) = Some(42) {} }