-
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
Conversation
…n check_overloaded_binop
r? @fee1-dead (rust-highfive has picked a reviewer for you, use r? to override) |
| | ||
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 comment
The 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 &mut Foo
is coming from a function argument or something.
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.
FWIW, it looks like a function with a return type of &mut Foo
can also trigger this ICE. foo() += ();
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 | ||
} |
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
| | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, it looks like a function with a return type of &mut Foo
can also trigger this ICE. foo() += ();
e5c238b
to
98f4b20
Compare
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#101322 (Fix internal doc link) - rust-lang#101385 (updated description of File struct in std::fs) - rust-lang#101388 (Don't delay invalid LHS bug unless it will be covered by an error in `check_overloaded_binop`) - rust-lang#101394 (Forbid mixing `System` with direct sytem allocator calls) - rust-lang#101397 (rustdoc: remove redundant mobile-sized `.source nav:not(.sidebar).sub`) - rust-lang#101401 (Make `char::is_lowercase` and `char::is_uppercase` const) - rust-lang#101407 (Remove duplicated test (superseeded by search-form-elements.goml)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #101376