Skip to content

Commit

Permalink
Update E0297 to new error format
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Sep 10, 2016
1 parent a5f4cc5 commit f647db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/librustc_const_eval/check_match.rs
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
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
}

0 comments on commit f647db4

Please sign in to comment.