Skip to content

Commit 12c7a91

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36205 - EugeneGonzalez:E0528, r=jonathandturner
Fixed E0528 label and unit test Fixes rust-lang#36194 part of rust-lang#35233. r? @jonathandturner
2 parents 8b0bb4e + 7cd4e7f commit 12c7a91

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Diff for: src/librustc_typeck/check/_match.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
248248
} else if let Some(rest) = size.checked_sub(min_len) {
249249
(inner_ty, tcx.mk_array(inner_ty, rest))
250250
} else {
251-
span_err!(tcx.sess, pat.span, E0528,
252-
"pattern requires at least {} elements but array has {}",
253-
min_len, size);
251+
struct_span_err!(tcx.sess, pat.span, E0528,
252+
"pattern requires at least {} elements but array has {}",
253+
min_len, size)
254+
.span_label(pat.span,
255+
&format!("pattern cannot match array of {} elements", size))
256+
.emit();
254257
(inner_ty, tcx.types.err)
255258
}
256259
}

Diff for: src/test/compile-fail/E0528.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
fn main() {
1414
let r = &[1, 2];
1515
match r {
16-
&[a, b, c, rest..] => { //~ ERROR E0528
16+
&[a, b, c, rest..] => {
17+
//~^ ERROR E0528
18+
//~| NOTE pattern cannot match array of 2 elements
1719
}
1820
}
1921
}

0 commit comments

Comments
 (0)