about summary refs log tree commit diff
path: root/tests/ui/loop-match/const-continue-to-block.rs
blob: a0f60aaec33804ef029bea8d3cd6374d3037aef2 (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
// Test that a `#[const_continue]` that breaks to a normal labeled block (that
// is not part of a `#[loop_match]`) produces an error.

#![allow(incomplete_features)]
#![feature(loop_match)]
#![crate_type = "lib"]

fn const_continue_to_block() -> u8 {
    let state = 0;
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                0 => {
                    #[const_continue]
                    break 'blk 1;
                }
                _ => 'b: {
                    #[const_continue]
                    break 'b 2;
                    //~^ ERROR `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
                }
            }
        }
    }
}

fn const_continue_to_shadowed_block() -> u8 {
    let state = 0;
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                0 => {
                    #[const_continue]
                    break 'blk 1;
                }
                _ => 'blk: {
                    //~^ WARN label name `'blk` shadows a label name that is already in scope
                    #[const_continue]
                    break 'blk 2;
                    //~^ ERROR `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
                }
            }
        }
    }
}