Rollup merge of #36121 - Cobrand:master, r=jonathandturner

Updated E0527 to new error format

* Closes #36113
This commit is contained in:
Jonathan Turner 2016-09-06 09:38:01 -07:00 committed by GitHub
commit 613f35051f
2 changed files with 9 additions and 4 deletions

View File

@ -233,9 +233,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let min_len = before.len() + after.len();
if slice.is_none() {
if min_len != size {
span_err!(tcx.sess, pat.span, E0527,
"pattern requires {} elements but array has {}",
min_len, size);
struct_span_err!(
tcx.sess, pat.span, E0527,
"pattern requires {} elements but array has {}",
min_len, size)
.span_label(pat.span, &format!("expected {} elements",size))
.emit();
}
(inner_ty, tcx.types.err)
} else if let Some(rest) = size.checked_sub(min_len) {

View File

@ -13,7 +13,9 @@
fn main() {
let r = &[1, 2, 3, 4];
match r {
&[a, b] => { //~ ERROR E0527
&[a, b] => {
//~^ ERROR E0527
//~| NOTE expected 4 elements
println!("a={}, b={}", a, b);
}
}