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