From 0cb8439aa3ce2b19b3965fdfa3b244004206bfe2 Mon Sep 17 00:00:00 2001 From: srdja Date: Mon, 8 Aug 2016 23:36:50 +0200 Subject: [PATCH 1/2] Update E0008 to new format --- src/librustc_const_eval/check_match.rs | 5 ++++- src/test/compile-fail/E0008.rs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 599e3ec871a83..b3485e6fe5be4 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1114,7 +1114,10 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, 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"); } 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"); diff --git a/src/test/compile-fail/E0008.rs b/src/test/compile-fail/E0008.rs index 97dd0f368bd12..20cc1cbd2232d 100644 --- a/src/test/compile-fail/E0008.rs +++ b/src/test/compile-fail/E0008.rs @@ -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 _ => {}, } } From aa40ec7f1155dc63bac19d218a56aec8109ac8e2 Mon Sep 17 00:00:00 2001 From: srdja Date: Tue, 9 Aug 2016 21:23:11 +0200 Subject: [PATCH 2/2] Update E0007 to new format --- src/librustc_const_eval/check_match.rs | 5 ++++- src/test/compile-fail/E0007.rs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index b3485e6fe5be4..3ca1b0cd6368f 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1112,7 +1112,10 @@ 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 { struct_span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard") diff --git a/src/test/compile-fail/E0007.rs b/src/test/compile-fail/E0007.rs index bfc0f1afe3ad3..4be115b8afdac 100644 --- a/src/test/compile-fail/E0007.rs +++ b/src/test/compile-fail/E0007.rs @@ -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 => {}, } }