about summary refs log tree commit diff
path: root/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
blob: fe7655c2c4e1ca00eb98b4501ff5a3cd9ef9f6ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    match &[1, 2, 3][..] {
        [1, rest..] => println!("{rest}"),
        //~^ ERROR cannot find value `rest` in this scope
        //~| ERROR cannot find value `rest` in this scope
        //~| ERROR `X..` patterns in slices are experimental
        _ => {}
    }
    match &[4, 5, 6][..] {
        [] => {}
        [_, ..tail] => println!("{tail}"),
        //~^ ERROR cannot find value `tail` in this scope
        //~| ERROR cannot find value `tail` in this scope
    }
    match &[7, 8, 9][..] {
        [] => {}
        [_, ...tail] => println!("{tail}"),
        //~^ ERROR cannot find value `tail` in this scope
        //~| ERROR cannot find value `tail` in this scope
        //~| ERROR range-to patterns with `...` are not allowed
    }
}