mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-06 03:52:53 +00:00
Improve test coverage of hir
comparison
This commit is contained in:
parent
e036a8145a
commit
6302e41ccb
@ -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) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user