about summary refs log tree commit diff
path: root/tests/ui/loop-match/const-continue-to-loop.rs
blob: c363e617cfb7c540382d8aa68067045f1b159d30 (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
// Test that a `#[const_continue]` that breaks to the label of the loop itself
// rather than to the label of the block within the `#[loop_match]` produces an
// error.

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

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