Skip to content

Commit

Permalink
Rollup merge of rust-lang#35530 - srdja:master, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0008 and E0007 to new format

Part of rust-lang#35233
A fix for rust-lang#35496

r? @jonathandturner
  • Loading branch information
Jonathan Turner authored Aug 10, 2016
2 parents 46af590 + aa40ec7 commit e7b0619
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,15 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,

// x @ Foo(..) is legal, but x @ Foo(y) isn't.
if sub.map_or(false, |p| pat_contains_bindings(&p)) {
span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings");
struct_span_err!(cx.tcx.sess, p.span, E0007,
"cannot bind by-move with sub-bindings")
.span_label(p.span, &format!("binds an already bound by-move value by moving it"))
.emit();
} else if has_guard {
span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard");
struct_span_err!(cx.tcx.sess, p.span, E0008,
"cannot bind by-move into a pattern guard")
.span_label(p.span, &format!("moves value into pattern guard"))
.emit();
} else if by_ref_span.is_some() {
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern");
Expand Down
6 changes: 4 additions & 2 deletions src/test/compile-fail/E0007.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
fn main() {
let x = Some("s".to_string());
match x {
op_string @ Some(s) => {}, //~ ERROR E0007
//~| ERROR E0303
op_string @ Some(s) => {},
//~^ ERROR E0007
//~| NOTE binds an already bound by-move value by moving it
//~| ERROR E0303
None => {},
}
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0008.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

fn main() {
match Some("hi".to_string()) {
Some(s) if s.len() == 0 => {}, //~ ERROR E0008
Some(s) if s.len() == 0 => {},
//~^ ERROR E0008
//~| NOTE moves value into pattern guard
_ => {},
}
}

0 comments on commit e7b0619

Please sign in to comment.