]> git.lizzy.rs Git - rust.git/blob - tests/ui/array-slice-vec/slice-pat-type-mismatches.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / array-slice-vec / slice-pat-type-mismatches.rs
1 fn main() {
2     match "foo".to_string() {
3         ['f', 'o', ..] => {}
4         //~^ ERROR expected an array or slice, found `String`
5         _ => { }
6     };
7
8     // Note that this one works with default binding modes.
9     match &[0, 1, 2] {
10         [..] => {}
11     };
12
13     match &[0, 1, 2] {
14         &[..] => {} // ok
15     };
16
17     match [0, 1, 2] {
18         [0] => {}, //~ ERROR pattern requires
19
20         [0, 1, x @ ..] => {
21             let a: [_; 1] = x;
22         }
23         [0, 1, 2, 3, x @ ..] => {} //~ ERROR pattern requires
24     };
25
26     match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope
27         [] => {}
28     };
29 }
30
31 fn another_fn_to_avoid_suppression() {
32     match Default::default()
33     {
34         [] => {}  //~ ERROR type annotations needed
35     };
36 }