summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/unreachable.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/mir-opt/unreachable.rs49
1 files changed, 47 insertions, 2 deletions
diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs
index 23fad4737..5b96681d9 100644
--- a/tests/mir-opt/unreachable.rs
+++ b/tests/mir-opt/unreachable.rs
@@ -1,12 +1,31 @@
+// unit-test: UnreachablePropagation
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
enum Empty {}
fn empty() -> Option<Empty> {
None
}
-// EMIT_MIR unreachable.main.UnreachablePropagation.diff
-fn main() {
+// EMIT_MIR unreachable.if_let.UnreachablePropagation.diff
+fn if_let() {
+ // CHECK-LABEL: fn if_let(
+ // CHECK: bb0: {
+ // CHECK: {{_.*}} = empty()
+ // CHECK: bb1: {
+ // CHECK: [[ne:_.*]] = Ne({{.*}}, const 1_isize);
+ // CHECK-NEXT: assume(move [[ne]]);
+ // CHECK-NEXT: goto -> bb6;
+ // CHECK: bb2: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb3: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb4: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb5: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb6: {
+ // CHECK: return;
if let Some(_x) = empty() {
let mut _y;
@@ -19,3 +38,29 @@ fn main() {
match _x { }
}
}
+
+// EMIT_MIR unreachable.as_match.UnreachablePropagation.diff
+fn as_match() {
+ // CHECK-LABEL: fn as_match(
+ // CHECK: bb0: {
+ // CHECK: {{_.*}} = empty()
+ // CHECK: bb1: {
+ // CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize);
+ // CHECK-NEXT: assume(move [[eq]]);
+ // CHECK-NEXT: goto -> bb4;
+ // CHECK: bb2: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb3: {
+ // CHECK-NEXT: unreachable;
+ // CHECK: bb4: {
+ // CHECK: return;
+ match empty() {
+ None => {}
+ Some(_x) => match _x {}
+ }
+}
+
+fn main() {
+ if_let();
+ as_match();
+}