Skip to content

Commit f647db4

Browse files
committed
Update E0297 to new error format
1 parent a5f4cc5 commit f647db4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/librustc_const_eval/check_match.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,13 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
410410
},
411411
_ => bug!(),
412412
};
413-
span_err!(cx.tcx.sess, sp, E0297,
413+
let pattern_string = pat_to_string(witness);
414+
struct_span_err!(cx.tcx.sess, sp, E0297,
414415
"refutable pattern in `for` loop binding: \
415416
`{}` not covered",
416-
pat_to_string(witness));
417+
pattern_string)
418+
.span_label(sp, &format!("pattern `{}` not covered", pattern_string))
419+
.emit();
417420
},
418421
_ => {
419422
let pattern_strings: Vec<_> = witnesses.iter().map(|w| {

src/test/compile-fail/E0297.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
fn main() {
1212
let xs : Vec<Option<i32>> = vec!(Some(1), None);
1313

14-
for Some(x) in xs {} //~ ERROR E0297
14+
for Some(x) in xs {}
15+
//~^ ERROR E0297
16+
//~| NOTE pattern `None` not covered
1517
}

0 commit comments

Comments
 (0)