-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Missing suggestion to dereference LHS of assignment when LHS is invalid #93980
Comments
@rustbot claim The culprit is here: rust/compiler/rustc_typeck/src/check/demand.rs Lines 251 to 255 in b117335
I'm not quite sure how to solve this. After all, the comment is correct. Do we want to show both errors? Or just attach the help to the "invalid left-hand side of assignment" error? |
@ChayimFriedman2, amazing find! If we remove that delay-as-bug, do we see a lot of unnecessary new errors being emitted in the ui tests? On the other hand, it might be useful just to special case this logic and attach it to the "invalid left-hand side" error. |
Here's what the compiler emits if I comment the above code out:
Not so bad, but maybe it can become more verbose in other cases and not emitting redundant errors is always better. I'll try to update the logic so it'll just append the help. |
In the surrounding code to rust/compiler/rustc_typeck/src/check/expr.rs Line 1033 in a391d54
you have access to the types and the expr, so you might be able to easily call the code that provides the suggestion in E0308 from there. |
@estebank The problem is that this code is not self-contained; it's inside |
@rustbot release-assignment I don't have time for that now. If somebody wants to pick it and work on it, feel free. |
@rustbot claim |
Given the following code:
The current output is:
Ideally the output should look like:
The root cause seems to be the coersion error being suppressed, since there is already logic that suggest dereferencing the LHS of an assignment operator. In fact, this diagnostic code path is being hit, but somewhere along the way the diagnostic is being canceled (hence the fact that we only see this "invalid left-hand side of assignment" error being emitted and not an error about not being able to relate
&mut ()
and()
.)The text was updated successfully, but these errors were encountered: