]> git.lizzy.rs Git - rust.git/blob - tests/ui/half-open-range-patterns/range_pat_interactions1.rs
Rollup merge of #106648 - Nilstrieb:poly-cleanup, r=compiler-errors
[rust.git] / tests / ui / half-open-range-patterns / range_pat_interactions1.rs
1 fn main() {
2     let mut if_lettable = Vec::<i32>::new();
3     let mut first_or = Vec::<i32>::new();
4     let mut or_two = Vec::<i32>::new();
5     let mut range_from = Vec::<i32>::new();
6     let mut bottom = Vec::<i32>::new();
7     let mut errors_only = Vec::<i32>::new();
8
9     for x in -9 + 1..=(9 - 2) {
10         if let n @ 2..3|4 = x {
11             //~^ error: variable `n` is not bound in all patterns
12             //~| exclusive range pattern syntax is experimental
13             errors_only.push(x);
14         } else if let 2..3 | 4 = x {
15             //~^ exclusive range pattern syntax is experimental
16             if_lettable.push(x);
17         }
18         match x as i32 {
19             0..5+1 => errors_only.push(x),
20             //~^ error: expected one of `=>`, `if`, or `|`, found `+`
21             1 | -3..0 => first_or.push(x),
22             y @ (0..5 | 6) => or_two.push(y),
23             y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
24             y @ -5.. => range_from.push(y),
25             y @ ..-7 => assert_eq!(y, -8),
26             y => bottom.push(y),
27         }
28     }
29 }