Skip to content

Commit c7513d7

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35530 - srdja:master, r=jonathandturner
Update E0008 and E0007 to new format Part of rust-lang#35233 A fix for rust-lang#35496 r? @jonathandturner
2 parents 0283443 + aa40ec7 commit c7513d7

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/librustc_const_eval/check_match.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,15 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
11151115

11161116
// x @ Foo(..) is legal, but x @ Foo(y) isn't.
11171117
if sub.map_or(false, |p| pat_contains_bindings(&p)) {
1118-
span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings");
1118+
struct_span_err!(cx.tcx.sess, p.span, E0007,
1119+
"cannot bind by-move with sub-bindings")
1120+
.span_label(p.span, &format!("binds an already bound by-move value by moving it"))
1121+
.emit();
11191122
} else if has_guard {
1120-
span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard");
1123+
struct_span_err!(cx.tcx.sess, p.span, E0008,
1124+
"cannot bind by-move into a pattern guard")
1125+
.span_label(p.span, &format!("moves value into pattern guard"))
1126+
.emit();
11211127
} else if by_ref_span.is_some() {
11221128
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
11231129
"cannot bind by-move and by-ref in the same pattern");

src/test/compile-fail/E0007.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
fn main() {
1212
let x = Some("s".to_string());
1313
match x {
14-
op_string @ Some(s) => {}, //~ ERROR E0007
15-
//~| ERROR E0303
14+
op_string @ Some(s) => {},
15+
//~^ ERROR E0007
16+
//~| NOTE binds an already bound by-move value by moving it
17+
//~| ERROR E0303
1618
None => {},
1719
}
1820
}

src/test/compile-fail/E0008.rs

+3-1
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)