about summary refs log tree commit diff
path: root/tests/ui/reachable/expr_if.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/reachable/expr_if.rs')
-rw-r--r--tests/ui/reachable/expr_if.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/reachable/expr_if.rs b/tests/ui/reachable/expr_if.rs
new file mode 100644
index 00000000000..3c04eaf480a
--- /dev/null
+++ b/tests/ui/reachable/expr_if.rs
@@ -0,0 +1,31 @@
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+#![allow(dead_code)]
+#![deny(unreachable_code)]
+
+fn foo() {
+    if {return} { //~ ERROR unreachable block in `if`
+        println!("Hello, world!");
+    }
+}
+
+fn bar() {
+    if {true} {
+        return;
+    }
+    println!("I am not dead.");
+}
+
+fn baz() {
+    if {true} {
+        return;
+    } else {
+        return;
+    }
+    // As the next action to be taken after the if arms, we should
+    // report the `println!` as unreachable:
+    println!("But I am.");
+    //~^ ERROR unreachable statement
+}
+
+fn main() { }