summaryrefslogtreecommitdiffstats
path: root/src/test/ui/reachable/expr_if.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/reachable/expr_if.rs')
-rw-r--r--src/test/ui/reachable/expr_if.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/reachable/expr_if.rs b/src/test/ui/reachable/expr_if.rs
new file mode 100644
index 000000000..3c04eaf48
--- /dev/null
+++ b/src/test/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() { }