about summary refs log tree commit diff
path: root/tests/ui/reachable/expr_block.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/reachable/expr_block.rs')
-rw-r--r--tests/ui/reachable/expr_block.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/reachable/expr_block.rs b/tests/ui/reachable/expr_block.rs
new file mode 100644
index 00000000000..136bccce881
--- /dev/null
+++ b/tests/ui/reachable/expr_block.rs
@@ -0,0 +1,31 @@
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+#![allow(dead_code)]
+#![deny(unreachable_code)]
+
+fn a() {
+    // Here the tail expression is considered unreachable:
+    let x = {
+        return;
+        22 //~ ERROR unreachable
+    };
+}
+
+fn b() {
+    // Here the `x` assignment is considered unreachable, not the block:
+    let x = {
+        return;
+    };
+}
+
+fn c() {
+    // Here the `println!` is unreachable:
+    let x = {
+        return;
+        println!("foo");
+        //~^ ERROR unreachable statement
+        22
+    };
+}
+
+fn main() { }