summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0527.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0527.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0527.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0527.md b/compiler/rustc_error_codes/src/error_codes/E0527.md
new file mode 100644
index 000000000..97ea31269
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0527.md
@@ -0,0 +1,26 @@
+The number of elements in an array or slice pattern differed from the number of
+elements in the array being matched.
+
+Example of erroneous code:
+
+```compile_fail,E0527
+let r = &[1, 2, 3, 4];
+match r {
+ &[a, b] => { // error: pattern requires 2 elements but array
+ // has 4
+ println!("a={}, b={}", a, b);
+ }
+}
+```
+
+Ensure that the pattern is consistent with the size of the matched
+array. Additional elements can be matched with `..`:
+
+```
+let r = &[1, 2, 3, 4];
+match r {
+ &[a, b, ..] => { // ok!
+ println!("a={}, b={}", a, b);
+ }
+}
+```