Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0297 to new error format #36389

Merged
merged 1 commit into from
Sep 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,13 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
},
_ => bug!(),
};
span_err!(cx.tcx.sess, sp, E0297,
let pattern_string = pat_to_string(witness);
struct_span_err!(cx.tcx.sess, sp, E0297,
"refutable pattern in `for` loop binding: \
`{}` not covered",
pat_to_string(witness));
pattern_string)
.span_label(sp, &format!("pattern `{}` not covered", pattern_string))
.emit();
},
_ => {
let pattern_strings: Vec<_> = witnesses.iter().map(|w| {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0297.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
fn main() {
let xs : Vec<Option<i32>> = vec!(Some(1), None);

for Some(x) in xs {} //~ ERROR E0297
for Some(x) in xs {}
//~^ ERROR E0297
//~| NOTE pattern `None` not covered
}