]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0529.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0529.md
1 An array or slice pattern was matched against some other type.
2
3 Example of erroneous code:
4
5 ```compile_fail,E0529
6 let r: f32 = 1.0;
7 match r {
8     [a, b] => { // error: expected an array or slice, found `f32`
9         println!("a={}, b={}", a, b);
10     }
11 }
12 ```
13
14 Ensure that the pattern and the expression being matched on are of consistent
15 types:
16
17 ```
18 let r = [1.0, 2.0];
19 match r {
20     [a, b] => { // ok!
21         println!("a={}, b={}", a, b);
22     }
23 }
24 ```