Skip to content

Commit

Permalink
Rollup merge of rust-lang#35744 - DevShep:ds/update_E0009, r=jonathan…
Browse files Browse the repository at this point in the history
…dturner

Update E0009 to new format

Part of rust-lang#35233
Fixes rust-lang#35193

r? @jonathandturner
  • Loading branch information
eddyb authored Aug 18, 2016
2 parents 7a27444 + d01bfb1 commit 394c449
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
.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");
span_note!(&mut err, by_ref_span.unwrap(), "by-ref binding occurs here");
err.emit();
struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern")
.span_label(p.span, &format!("by-move pattern here"))
.span_label(by_ref_span.unwrap(), &format!("both by-ref and by-move used"))
.emit();
}
};

Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0009.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ fn main() {
struct X { x: (), }
let x = Some((X { x: () }, X { x: () }));
match x {
Some((y, ref z)) => {}, //~ ERROR E0009
Some((y, ref z)) => {},
//~^ ERROR E0009
//~| NOTE by-move pattern here
//~| NOTE both by-ref and by-move used
None => panic!()
}
}

0 comments on commit 394c449

Please sign in to comment.