2020-11-21 22:05:17 +00:00
|
|
|
//! Test for `||` in or-patterns
|
2019-08-18 14:52:49 +00:00
|
|
|
|
2018-01-06 17:34:19 +00:00
|
|
|
fn main() {
|
|
|
|
let x = 3;
|
2019-08-18 14:52:49 +00:00
|
|
|
|
2018-01-06 17:34:19 +00:00
|
|
|
match x {
|
2021-02-08 02:40:33 +00:00
|
|
|
1 | 2 || 3 => (), //~ ERROR unexpected token `||` in pattern
|
2018-01-06 17:34:19 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
2019-08-18 14:52:49 +00:00
|
|
|
|
|
|
|
match x {
|
2021-02-08 02:40:33 +00:00
|
|
|
(1 | 2 || 3) => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 14:52:49 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match (x,) {
|
2021-02-08 02:40:33 +00:00
|
|
|
(1 | 2 || 3,) => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 14:52:49 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TS(u8);
|
|
|
|
|
|
|
|
match TS(x) {
|
2021-02-08 02:40:33 +00:00
|
|
|
TS(1 | 2 || 3) => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 14:52:49 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NS { f: u8 }
|
|
|
|
|
|
|
|
match (NS { f: x }) {
|
2021-02-08 02:40:33 +00:00
|
|
|
NS { f: 1 | 2 || 3 } => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 14:52:49 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match [x] {
|
2021-02-08 02:40:33 +00:00
|
|
|
[1 | 2 || 3] => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 14:52:49 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
2019-08-18 16:34:35 +00:00
|
|
|
|
|
|
|
match x {
|
2021-02-08 02:40:33 +00:00
|
|
|
|| 1 | 2 | 3 => (), //~ ERROR unexpected token `||` in pattern
|
2019-08-18 16:34:35 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
2018-01-06 17:34:19 +00:00
|
|
|
}
|