summaryrefslogtreecommitdiffstats
path: root/src/test/ui/label/label_misspelled.rs
blob: e3180b06ecb2bfa33694e7c94c64efde0a8d801e (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#![warn(unused_labels)]

fn main() {
    'while_loop: while true { //~ WARN denote infinite loops with
        //~^ WARN unused label
        while_loop;
        //~^ ERROR cannot find value `while_loop` in this scope
    };
    'while_let: while let Some(_) = Some(()) {
        //~^ WARN unused label
        while_let;
        //~^ ERROR cannot find value `while_let` in this scope
    }
    'for_loop: for _ in 0..3 {
        //~^ WARN unused label
        for_loop;
        //~^ ERROR cannot find value `for_loop` in this scope
    };
    'LOOP: loop {
        //~^ WARN unused label
        LOOP;
        //~^ ERROR cannot find value `LOOP` in this scope
    };
}

fn foo() {
    'LOOP: loop {
        break LOOP;
        //~^ ERROR cannot find value `LOOP` in this scope
    };
    'while_loop: while true { //~ WARN denote infinite loops with
        break while_loop;
        //~^ ERROR cannot find value `while_loop` in this scope
    };
    'while_let: while let Some(_) = Some(()) {
        break while_let;
        //~^ ERROR cannot find value `while_let` in this scope
    }
    'for_loop: for _ in 0..3 {
        break for_loop;
        //~^ ERROR cannot find value `for_loop` in this scope
    };
}

fn bar() {
    let foo = ();
    'while_loop: while true { //~ WARN denote infinite loops with
        //~^ WARN unused label
        break foo;
        //~^ ERROR `break` with value from a `while` loop
    };
    'while_let: while let Some(_) = Some(()) {
        //~^ WARN unused label
        break foo;
        //~^ ERROR `break` with value from a `while` loop
    }
    'for_loop: for _ in 0..3 {
        //~^ WARN unused label
        break foo;
        //~^ ERROR `break` with value from a `for` loop
    };
}