Skip to content

Commit dbef510

Browse files
Rollup merge of #35350 - birryree:E0368_update, r=jonathandturner
Fix for issue #35336 - updating error message for for E0368 to includ… …e a span_label. This fixes #35336 as part of #35233 r? @jonathandturner
2 parents 0339904 + 1ca95ae commit dbef510

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustc_typeck/check/op.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
176176
// error types are considered "builtin"
177177
if !lhs_ty.references_error() {
178178
if let IsAssign::Yes = is_assign {
179-
span_err!(self.tcx.sess, lhs_expr.span, E0368,
180-
"binary assignment operation `{}=` \
181-
cannot be applied to type `{}`",
182-
op.node.as_str(),
183-
lhs_ty);
179+
struct_span_err!(self.tcx.sess, lhs_expr.span, E0368,
180+
"binary assignment operation `{}=` \
181+
cannot be applied to type `{}`",
182+
op.node.as_str(),
183+
lhs_ty)
184+
.span_label(lhs_expr.span,
185+
&format!("cannot use `{}=` on type `{}`",
186+
op.node.as_str(), lhs_ty))
187+
.emit();
184188
} else {
185189
let mut err = struct_span_err!(self.tcx.sess, lhs_expr.span, E0369,
186190
"binary operation `{}` cannot be applied to type `{}`",

src/test/compile-fail/issue-5239-1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
fn main() {
1414
let x = |ref x: isize| -> isize { x += 1; };
1515
//~^ ERROR E0368
16+
//~| NOTE cannot use `+=` on type `&isize`
1617
}

0 commit comments

Comments
 (0)