@@ -3980,6 +3980,39 @@ impl SpaceLlama for i32 {
39803980```
39813981"## ,
39823982
3983+ E0527 : r##"
3984+ The number of elements in an array or slice pattern differed from the number of
3985+ elements in the array being matched.
3986+
3987+ Example of erroneous code:
3988+
3989+ ```compile_fail,E0527
3990+ #![feature(slice_patterns)]
3991+
3992+ let r = &[1, 2, 3, 4];
3993+ match r {
3994+ &[a, b] => { // error: pattern requires 2 elements but array
3995+ // has 4
3996+ println!("a={}, b={}", a, b);
3997+ }
3998+ }
3999+ ```
4000+
4001+ Ensure that the pattern is consistent with the size of the matched
4002+ array. Additional elements can be matched with `..`:
4003+
4004+ ```
4005+ #![feature(slice_patterns)]
4006+
4007+ let r = &[1, 2, 3, 4];
4008+ match r {
4009+ &[a, b, ..] => { // ok!
4010+ println!("a={}, b={}", a, b);
4011+ }
4012+ }
4013+ ```
4014+ "## ,
4015+
39834016E0529 : r##"
39844017An array or slice pattern was matched against some other type.
39854018
@@ -4131,7 +4164,6 @@ register_diagnostics! {
41314164 E0436 , // functional record update requires a struct
41324165 E0513 , // no type for local variable ..
41334166 E0521 , // redundant default implementations of trait
4134- E0527 , // expected {} elements, found {}
41354167 E0528 , // expected at least {} elements, found {}
41364168 E0533 , // `{}` does not name a unit variant, unit struct or a constant
41374169}
0 commit comments