summaryrefslogtreecommitdiffstats
path: root/src/test/ui/reachable/expr_if.rs
blob: 3c04eaf480a2cab7a946fac7ffc694d71f581ba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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() { }