Skip to content

Commit

Permalink
Updated E0527 to new error format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cobrand committed Sep 5, 2016
1 parent 58dc448 commit e8c5dc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0527.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit e8c5dc4

Please sign in to comment.