Fix for issue #35336 - updating error message for for E0368 to include a span_label

This commit is contained in:
William Lee 2016-08-04 23:43:56 -04:00
parent e804a3cf25
commit 1ca95ae5ba
2 changed files with 10 additions and 5 deletions

View File

@ -176,11 +176,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// error types are considered "builtin"
if !lhs_ty.references_error() {
if let IsAssign::Yes = is_assign {
span_err!(self.tcx.sess, lhs_expr.span, E0368,
"binary assignment operation `{}=` \
cannot be applied to type `{}`",
op.node.as_str(),
lhs_ty);
struct_span_err!(self.tcx.sess, lhs_expr.span, E0368,
"binary assignment operation `{}=` \
cannot be applied to type `{}`",
op.node.as_str(),
lhs_ty)
.span_label(lhs_expr.span,
&format!("cannot use `{}=` on type `{}`",
op.node.as_str(), lhs_ty))
.emit();
} else {
let mut err = struct_span_err!(self.tcx.sess, lhs_expr.span, E0369,
"binary operation `{}` cannot be applied to type `{}`",

View File

@ -13,4 +13,5 @@
fn main() {
let x = |ref x: isize| -> isize { x += 1; };
//~^ ERROR E0368
//~| NOTE cannot use `+=` on type `&isize`
}