Improve test coverage of hir comparison

This commit is contained in:
mcarton 2016-10-01 22:27:10 +02:00
parent e036a8145a
commit 6302e41ccb
No known key found for this signature in database
GPG key ID: 5E427C794CBA45E8

View file

@ -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::<u8>(42);
if true {
break;
} else {
continue;
}
}
}
else { //~ERROR this `if` has identical blocks
for _ in &[42] {
let foo: &Option<_> = &Some::<u8>(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::<u8> {}
}
else {
if let Some(42) = None {}
}
if true {
if let Some(a) = Some(42) {}
}