summaryrefslogtreecommitdiffstats
path: root/tests/ui/reachable/expr_block.rs
blob: 136bccce88104b2c06d98e0adb9941d60f61b41a (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 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() { }