-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Message suggesting prefixing with underscore is unhelpful #66636
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I believe that in the vast majority of cases when an unused variable is present, the author of the code intended to use it, but forgot. Thus the message suggesting to effectively turn off the warning is unhelpful.
I suggest changing it to something like:
While this doesn't concern me much personally, I believe it'd be much more helpful to novice programmers. To put it in extreme, imagine this kind of lint message: "Reference outlives borrowed value. Consider putting
#![allow(undefined_behavior)]at the top of your module."And I must admit the current warning feels a bit strange to me too. ("Dear compiler, the content of your message is completely useless, but its presence saved my ass twice today, so thank you for that!")
Disclaimer: this is entirely based on my personal experience and may not be true in general. Feel free to close if there's a good evidence that I'm broken, not the compiler. :)
This issue has been assigned to @loris-intergalactique via this comment.