Skip to content

Commit

Permalink
Rollup merge of rust-lang#36205 - EugeneGonzalez:E0528, r=jonathandtu…
Browse files Browse the repository at this point in the history
…rner

Fixed E0528 label and unit test

Fixes rust-lang#36194 part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
Jonathan Turner authored Sep 2, 2016
2 parents 9e60445 + 7cd4e7f commit 5a1661a
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 @@ -248,9 +248,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else if let Some(rest) = size.checked_sub(min_len) {
(inner_ty, tcx.mk_array(inner_ty, rest))
} else {
span_err!(tcx.sess, pat.span, E0528,
"pattern requires at least {} elements but array has {}",
min_len, size);
struct_span_err!(tcx.sess, pat.span, E0528,
"pattern requires at least {} elements but array has {}",
min_len, size)
.span_label(pat.span,
&format!("pattern cannot match array of {} elements", size))
.emit();
(inner_ty, tcx.types.err)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0528.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
fn main() {
let r = &[1, 2];
match r {
&[a, b, c, rest..] => { //~ ERROR E0528
&[a, b, c, rest..] => {
//~^ ERROR E0528
//~| NOTE pattern cannot match array of 2 elements
}
}
}

0 comments on commit 5a1661a

Please sign in to comment.