@@ -3864,6 +3864,104 @@ impl SpaceLlama for i32 {
3864
3864
```
3865
3865
"## ,
3866
3866
3867
+ E0527 : r##"
3868
+ The number of elements in an array or slice pattern differed from the number of
3869
+ elements in the array being matched.
3870
+
3871
+ Example of erroneous code:
3872
+
3873
+ ```compile_fail,E0527
3874
+ #![feature(slice_patterns)]
3875
+
3876
+ let r = &[1, 2, 3, 4];
3877
+ match r {
3878
+ &[a, b] => { // error: pattern requires 2 elements but array
3879
+ // has 4
3880
+ println!("a={}, b={}", a, b);
3881
+ }
3882
+ }
3883
+ ```
3884
+
3885
+ Ensure that the pattern is consistent with the size of the matched
3886
+ array. Additional elements can be matched with `..`:
3887
+
3888
+ ```
3889
+ #![feature(slice_patterns)]
3890
+
3891
+ let r = &[1, 2, 3, 4];
3892
+ match r {
3893
+ &[a, b, ..] => { // ok!
3894
+ println!("a={}, b={}", a, b);
3895
+ }
3896
+ }
3897
+ ```
3898
+ "## ,
3899
+
3900
+ E0528 : r##"
3901
+ An array or slice pattern required more elements than were present in the
3902
+ matched array.
3903
+
3904
+ Example of erroneous code:
3905
+
3906
+ ```compile_fail,E0528
3907
+ #![feature(slice_patterns)]
3908
+
3909
+ let r = &[1, 2];
3910
+ match r {
3911
+ &[a, b, c, rest..] => { // error: pattern requires at least 3
3912
+ // elements but array has 2
3913
+ println!("a={}, b={}, c={} rest={:?}", a, b, c, rest);
3914
+ }
3915
+ }
3916
+ ```
3917
+
3918
+ Ensure that the matched array has at least as many elements as the pattern
3919
+ requires. You can match an arbitrary number of remaining elements with `..`:
3920
+
3921
+ ```
3922
+ #![feature(slice_patterns)]
3923
+
3924
+ let r = &[1, 2, 3, 4, 5];
3925
+ match r {
3926
+ &[a, b, c, rest..] => { // ok!
3927
+ // prints `a=1, b=2, c=3 rest=[4, 5]`
3928
+ println!("a={}, b={}, c={} rest={:?}", a, b, c, rest);
3929
+ }
3930
+ }
3931
+ ```
3932
+ "## ,
3933
+
3934
+ E0529 : r##"
3935
+ An array or slice pattern was matched against some other type.
3936
+
3937
+ Example of erroneous code:
3938
+
3939
+ ```compile_fail,E0529
3940
+ #![feature(slice_patterns)]
3941
+
3942
+ let r: f32 = 1.0;
3943
+ match r {
3944
+ [a, b] => { // error: expected an array or slice, found `f32`
3945
+ println!("a={}, b={}", a, b);
3946
+ }
3947
+ }
3948
+ ```
3949
+
3950
+ Ensure that the pattern and the expression being matched on are of consistent
3951
+ types:
3952
+
3953
+ ```
3954
+ #![feature(slice_patterns)]
3955
+
3956
+ let r = [1.0, 2.0];
3957
+ match r {
3958
+ [a, b] => { // ok!
3959
+ println!("a={}, b={}", a, b);
3960
+ }
3961
+ }
3962
+ ```
3963
+ "## ,
3964
+
3867
3965
E0559 : r##"
3868
3966
An unknown field was specified into an enum's structure variant.
3869
3967
@@ -3985,8 +4083,5 @@ register_diagnostics! {
3985
4083
E0436 , // functional record update requires a struct
3986
4084
E0513 , // no type for local variable ..
3987
4085
E0521 , // redundant default implementations of trait
3988
- E0527 , // expected {} elements, found {}
3989
- E0528 , // expected at least {} elements, found {}
3990
- E0529 , // slice pattern expects array or slice, not `{}`
3991
4086
E0533 , // `{}` does not name a unit variant, unit struct or a constant
3992
4087
}
0 commit comments