From 1fc18aab5d6c62633562729bff1435299b2c344d Mon Sep 17 00:00:00 2001 From: Dustin Bensing Date: Tue, 16 Aug 2016 23:50:32 +0200 Subject: [PATCH 1/2] Update E0005 to use a label --- src/librustc_const_eval/check_match.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index bf6ebcb5efefb..5db293f5bb016 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1073,11 +1073,12 @@ fn check_irrefutable(cx: &MatchCheckCtxt, pat: &Pat, is_fn_arg: bool) { }; is_refutable(cx, pat, |uncovered_pat| { - span_err!(cx.tcx.sess, pat.span, E0005, + let pattern_string = pat_to_string(uncovered_pat); + struct_span_err!(cx.tcx.sess, pat.span, E0005, "refutable pattern in {}: `{}` not covered", origin, - pat_to_string(uncovered_pat), - ); + pattern_string, + ).span_label(pat.span, &format!("pattern `{}` not covered", pattern_string)).emit(); }); } From 4cfdf634c18421e607779ad83c7e7bda642cc349 Mon Sep 17 00:00:00 2001 From: Dustin Bensing Date: Wed, 17 Aug 2016 00:40:08 +0200 Subject: [PATCH 2/2] Update E0005 Unit-Test --- src/test/compile-fail/E0005.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/compile-fail/E0005.rs b/src/test/compile-fail/E0005.rs index 0405bba81b585..809b3af3bea2a 100644 --- a/src/test/compile-fail/E0005.rs +++ b/src/test/compile-fail/E0005.rs @@ -11,4 +11,5 @@ fn main() { let x = Some(1); let Some(y) = x; //~ ERROR E0005 + //~| NOTE pattern `None` not covered }