summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser/lifetime_starts_expressions.rs
blob: 903b4de6ef47c3edfd44f5f984aca0e7030d1a22 (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
#![allow(unused, dead_code)]

fn foo() -> u32 {
    return 'label: loop { break 'label 42; };
}

fn bar() -> u32 {
    loop { break 'label: loop { break 'label 42; }; }
    //~^ ERROR: parentheses are required around this expression to avoid confusion
    //~| HELP: wrap the expression in parentheses
}

fn baz() -> u32 {
    'label: loop {
        break 'label
        //~^ WARNING: this labeled break expression is easy to confuse with an unlabeled break
            loop { break 42; };
            //~^ HELP: wrap this expression in parentheses
    };

    'label2: loop {
        break 'label2 'inner: loop { break 42; };
        // no warnings or errors here
    }
}

pub fn main() {
    // Regression test for issue #86948, as resolved in #87026:
    let a = 'first_loop: loop {
        break 'first_loop 1;
    };
    let b = loop {
        break 'inner_loop: loop {
        //~^ ERROR: parentheses are required around this expression to avoid confusion
        //~| HELP: wrap the expression in parentheses
            break 'inner_loop 1;
        };
    };
}