Skip to content

Commit 65e3ff4

Browse files
committed
add extended information for E0529, slice pattern expects array or slice
1 parent 2b87f03 commit 65e3ff4

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3980,6 +3980,37 @@ impl SpaceLlama for i32 {
39803980
```
39813981
"##,
39823982

3983+
E0529: r##"
3984+
An array or slice pattern was matched against some other type.
3985+
3986+
Example of erroneous code:
3987+
3988+
```compile_fail,E0529
3989+
#![feature(slice_patterns)]
3990+
3991+
let r: f32 = 1.0;
3992+
match r {
3993+
[a, b] => { // error: expected an array or slice, found `f32`
3994+
println!("a={}, b={}", a, b);
3995+
}
3996+
}
3997+
```
3998+
3999+
Ensure that the pattern and the expression being matched on are of consistent
4000+
types:
4001+
4002+
```
4003+
#![feature(slice_patterns)]
4004+
4005+
let r = [1.0, 2.0];
4006+
match r {
4007+
[a, b] => { // ok!
4008+
println!("a={}, b={}", a, b);
4009+
}
4010+
}
4011+
```
4012+
"##,
4013+
39834014
E0559: r##"
39844015
An unknown field was specified into an enum's structure variant.
39854016
@@ -4102,6 +4133,5 @@ register_diagnostics! {
41024133
E0521, // redundant default implementations of trait
41034134
E0527, // expected {} elements, found {}
41044135
E0528, // expected at least {} elements, found {}
4105-
E0529, // slice pattern expects array or slice, not `{}`
41064136
E0533, // `{}` does not name a unit variant, unit struct or a constant
41074137
}

0 commit comments

Comments
 (0)