blob: 774e195c33c9699e00ae5a07ed638d9fdaa62a39 (
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
63
64
65
66
67
68
|
// skip-filecheck
#![allow(incomplete_features)]
#![feature(loop_match)]
#![crate_type = "lib"]
// Test that a #[loop_match] without an explicit break from the loop generates valid MIR.
enum State {
A,
B,
C,
}
// EMIT_MIR loop_match_diverges.simple.built.after.mir
fn simple(mut state: State) -> State {
#[loop_match]
'a: loop {
state = 'blk: {
match state {
State::A => {
#[const_continue]
break 'blk State::B;
}
State::B => {
if true {
#[const_continue]
break 'blk State::C;
} else {
#[const_continue]
break 'blk State::A;
}
}
State::C => break 'a,
}
};
}
state
}
// EMIT_MIR loop_match_diverges.break_to_block_unit.built.after.mir
#[unsafe(no_mangle)]
fn break_to_block_unit() -> u8 {
let mut state = 0;
#[loop_match]
loop {
state = 'blk: {
match state {
_ => 'b: {
break 'b 2;
}
}
}
}
}
// EMIT_MIR loop_match_diverges.infinite_a.built.after.mir
#[unsafe(no_mangle)]
fn infinite_a(mut state: u8) {
#[loop_match]
loop {
state = 'blk: {
match state {
a => a,
}
}
}
}
|