-
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
cargo fix renames unused local variables from foo to _foo #54196
Comments
@MaikKlein To get a better understanding of your thought process, why do you feel |
For example
Now at one point you remove Now you have you might never find this in your code base. You really wanted to remove it, or maybe it was a bug in the first place that you are not using it anymore. Just renaming it for the sake of removing the warning seems wrong. Maybe it should also not rename parameters for free standing functions. I think that there are some cases in functions were you just want to rely on type inference and then the parameter should always be It seems reasonable to rename parameters for trait impls because you can't just change the function signature, and you might not always want to use the parameter.
|
I think I'm persuaded? Here's where the lint is issued: rust/src/librustc/middle/liveness.rs Lines 1546 to 1565 in f789b6b
We just need to change |
I think you are right, this is misleading in your use case. Just wondering: At which points in your workflow are you running cargo fix? I also think this is one of the cases where we need to differentiate between "cargo fix should fix it" and "get a lightbulb with auto-fix suggestions in your editor". Just because it might be auto-fixable doesn't mean we should automatically fix it. This is a discussion for a higher level issue, though. |
I only ran |
Is anyone against changing this suggestion to simply be Prepending an underscore to variable names is saying to the compiler "yes, I intentionally won't use this value", which should very much be a manual action. I'm hesitant to use |
Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
…rrors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
Rollup merge of rust-lang#120470 - estebank:issue-54196, r=compiler-errors Mark "unused binding" suggestion as maybe incorrect Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change. Fix rust-lang#54196.
For example:
I don't like that refactor because I might end up with local variables that do nothing. I think
cargo fix
should just ignore unused local variables all together. Ifcargo fix
just renames local variables to hide the warnings from the compiler, then the compiler lint is a bit pointless.Renaming unused function parameters seems fine.
The text was updated successfully, but these errors were encountered: