| 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 | // Test that signed and unsigned integer patterns work with `#[loop_match]`.
//@ run-pass
#![allow(incomplete_features)]
#![feature(loop_match)]
fn main() {
    assert_eq!(integer(0), 2);
    assert_eq!(integer(-1), 2);
    assert_eq!(integer(2), 2);
    assert_eq!(boolean(true), false);
    assert_eq!(boolean(false), false);
    assert_eq!(character('a'), 'b');
    assert_eq!(character('b'), 'b');
    assert_eq!(character('c'), 'd');
    assert_eq!(character('d'), 'd');
    assert_eq!(test_f32(1.0), core::f32::consts::PI);
    assert_eq!(test_f32(2.5), core::f32::consts::PI);
    assert_eq!(test_f32(4.0), 4.0);
    assert_eq!(test_f64(1.0), core::f64::consts::PI);
    assert_eq!(test_f64(2.5), core::f64::consts::PI);
    assert_eq!(test_f64(4.0), 4.0);
}
fn integer(mut state: i32) -> i32 {
    #[loop_match]
    'a: loop {
        state = 'blk: {
            match state {
                -1 => {
                    #[const_continue]
                    break 'blk 2;
                }
                0 => {
                    #[const_continue]
                    break 'blk -1;
                }
                2 => break 'a,
                _ => unreachable!("weird value {:?}", state),
            }
        }
    }
    state
}
fn boolean(mut state: bool) -> bool {
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                true => {
                    #[const_continue]
                    break 'blk false;
                }
                false => return state,
            }
        }
    }
}
fn character(mut state: char) -> char {
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                'a' => {
                    #[const_continue]
                    break 'blk 'b';
                }
                'b' => return state,
                'c' => {
                    #[const_continue]
                    break 'blk 'd';
                }
                _ => return state,
            }
        }
    }
}
fn test_f32(mut state: f32) -> f32 {
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                1.0 => {
                    #[const_continue]
                    break 'blk 2.5;
                }
                2.0..3.0 => return core::f32::consts::PI,
                _ => return state,
            }
        }
    }
}
fn test_f64(mut state: f64) -> f64 {
    #[loop_match]
    loop {
        state = 'blk: {
            match state {
                1.0 => {
                    #[const_continue]
                    break 'blk 2.5;
                }
                2.0..3.0 => return core::f64::consts::PI,
                _ => return state,
            }
        }
    }
}
 |