-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't delay invalid LHS bug unless it will be covered by an error in check_overloaded_binop
#101388
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
} | ||
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) += (); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This suggestion may be a bit strange here in this minimized example, but it makes sense if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, it looks like a function with a return type of |
||
| + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0067`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please link this to #101376?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done