diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 3e88dec8cb27a..0e56f351c77c3 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -1175,8 +1175,10 @@ impl<'a, 'gcx, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'gcx> { _: LoanCause) { match kind { MutBorrow => { - span_err!(self.cx.tcx.sess, span, E0301, + struct_span_err!(self.cx.tcx.sess, span, E0301, "cannot mutably borrow in a pattern guard") + .span_label(span, &format!("borrowed mutably in pattern guard")) + .emit(); } ImmBorrow | UniqueImmBorrow => {} } diff --git a/src/test/compile-fail/E0301.rs b/src/test/compile-fail/E0301.rs index 06e98289b0d57..b7872509f5408 100644 --- a/src/test/compile-fail/E0301.rs +++ b/src/test/compile-fail/E0301.rs @@ -12,6 +12,7 @@ fn main() { match Some(()) { None => { }, option if option.take().is_none() => {}, //~ ERROR E0301 + //~| NOTE borrowed mutably in pattern guard Some(_) => { } } }