Skip to content

Commit 7714562

Browse files
Don't delay invalid lhs bug unless we know it'll be replaced by one in check_overloaded_binop
1 parent ae0030b commit 7714562

File tree

1 file changed

+14
-3
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+14
-3
lines changed

compiler/rustc_typeck/src/check/op.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5757
)
5858
.is_ok()
5959
{
60-
// Suppress this error, since we already emitted
61-
// a deref suggestion in check_overloaded_binop
62-
err.downgrade_to_delayed_bug();
60+
// If LHS += RHS is an error, but *LHS += RHS is successful, then we will have
61+
// emitted a better suggestion during error handling in check_overloaded_binop.
62+
if self
63+
.lookup_op_method(
64+
lhs_ty,
65+
Some(rhs_ty),
66+
Some(rhs),
67+
Op::Binary(op, IsAssign::Yes),
68+
expected,
69+
)
70+
.is_err()
71+
{
72+
err.downgrade_to_delayed_bug();
73+
}
6374
}
6475
}
6576
});

0 commit comments

Comments
 (0)