Skip to content

Commit 0cb8439

Browse files
author
srdja
committed
Update E0008 to new format
1 parent b42a384 commit 0cb8439

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/librustc_const_eval/check_match.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,10 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
11141114
if sub.map_or(false, |p| pat_contains_bindings(&p)) {
11151115
span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings");
11161116
} else if has_guard {
1117-
span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard");
1117+
struct_span_err!(cx.tcx.sess, p.span, E0008,
1118+
"cannot bind by-move into a pattern guard")
1119+
.span_label(p.span, &format!("moves value into pattern guard"))
1120+
.emit();
11181121
} else if by_ref_span.is_some() {
11191122
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
11201123
"cannot bind by-move and by-ref in the same pattern");

src/test/compile-fail/E0008.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
fn main() {
1212
match Some("hi".to_string()) {
13-
Some(s) if s.len() == 0 => {}, //~ ERROR E0008
13+
Some(s) if s.len() == 0 => {},
14+
//~^ ERROR E0008
15+
//~| NOTE moves value into pattern guard
1416
_ => {},
1517
}
1618
}

0 commit comments

Comments
 (0)