about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorZack M. Davis <code@zackmdavis.net>2016-06-16 23:15:06 -0700
committerZack M. Davis <code@zackmdavis.net>2016-07-31 15:09:25 -0700
commit65e3ff4df44effdfa60971cd7b66e4ce8a4c5bb9 (patch)
tree081cacdd0ead9a14db156dc390125932f5742e74 /src
parent2b87f031e79d870f6b148339e21e5c2a3112d4af (diff)
downloadrust-65e3ff4df44effdfa60971cd7b66e4ce8a4c5bb9.tar.gz
rust-65e3ff4df44effdfa60971cd7b66e4ce8a4c5bb9.zip
add extended information for E0529, slice pattern expects array or slice
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/diagnostics.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 500f624ea3f..3867ed5fa68 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -3980,6 +3980,37 @@ impl SpaceLlama for i32 {
 ```
 "##,
 
+E0529: r##"
+An array or slice pattern was matched against some other type.
+
+Example of erroneous code:
+
+```compile_fail,E0529
+#![feature(slice_patterns)]
+
+let r: f32 = 1.0;
+match r {
+    [a, b] => { // error: expected an array or slice, found `f32`
+        println!("a={}, b={}", a, b);
+    }
+}
+```
+
+Ensure that the pattern and the expression being matched on are of consistent
+types:
+
+```
+#![feature(slice_patterns)]
+
+let r = [1.0, 2.0];
+match r {
+    [a, b] => { // ok!
+        println!("a={}, b={}", a, b);
+    }
+}
+```
+"##,
+
 E0559: r##"
 An unknown field was specified into an enum's structure variant.
 
@@ -4102,6 +4133,5 @@ register_diagnostics! {
     E0521, // redundant default implementations of trait
     E0527, // expected {} elements, found {}
     E0528, // expected at least {} elements, found {}
-    E0529, // slice pattern expects array or slice, not `{}`
     E0533, // `{}` does not name a unit variant, unit struct or a constant
 }