-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Do not emit coerce_suggestions for expr from destructuring assignment desugaring #112476
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
ed0e2fd
to
43c8ea3
Compare
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.
I don't think this works for other kinds of destructuring patterns, like arrays:
fn main() {
let x: i32;
[x] = [&1];
}
Also, does this work to fix the nonsense suggestion for this example?
fn main() {
let x: &i32;
[x] = [1];
}
I think the problem here is that for destructuring assignments, the spans are wrong and don't really correspond correctly...
I don't know if fixing this one specific suggestion addresses the larger problem that other suggestions are still broken -- maybe we need a more thorough solution?
Maybe the best compromise here is to detect if the expression is from a destructuring assignment desugaring and just not offer any of the suggestions in That isn't perfect, but it should also help not suggesting nonsense like:
|
Yes, we need a better general solution if we want to suggest like this: help: consider dereferencing the borrow
|
17 | (a, b) = (123, *&mut 123);
| + we don't have expr for |
I don't think it's, in general, possible to suggest what you said above. You can do destructuring assignments where the expressions do not align, like:
so there's no way to in general pair |
43c8ea3
to
c79482a
Compare
Updated code to suppress the suggestions altogether. |
This comment has been minimized.
This comment has been minimized.
r=me after blessing tests and squashing the commits |
…pr from destructuring assignment desugaring
c79482a
to
33f73c2
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (3c5d71a): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 662.562s -> 663.05s (0.07%) |
Fixes #109991