-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-dead
Don't delay invalid LHS bug unless it will be covered by an error in `check_overloaded_binop` Fixes #101376
- Loading branch information
Showing
3 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// issue #101376 | ||
|
||
use std::ops::AddAssign; | ||
struct Foo; | ||
|
||
impl AddAssign<()> for Foo { | ||
fn add_assign(&mut self, _: ()) {} | ||
} | ||
|
||
impl AddAssign<()> for &mut Foo { | ||
fn add_assign(&mut self, _: ()) {} | ||
} | ||
|
||
fn main() { | ||
(&mut Foo) += (); | ||
//~^ ERROR invalid left-hand side of assignment | ||
//~| NOTE cannot assign to this expression | ||
//~| HELP consider dereferencing the left-hand side of this operation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0067]: invalid left-hand side of assignment | ||
--> $DIR/assign-non-lval-needs-deref.rs:15:16 | ||
| | ||
LL | (&mut Foo) += (); | ||
| ---------- ^^ | ||
| | | ||
| cannot assign to this expression | ||
| | ||
help: consider dereferencing the left-hand side of this operation | ||
| | ||
LL | *(&mut Foo) += (); | ||
| + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0067`. |