-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Lint unused_variables's "typoed pattern" suggestion still suggests invalid and unrelated paths #147595
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.L-unused_variablesLint: unused_variablesLint: unused_variablesT-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-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.L-unused_variablesLint: unused_variablesLint: unused_variablesT-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 just stumbled upon this organically. Since PR #145827 rustc suggests paths to underscore (!) constant items which is syntactically invalid. Consider:
Compiler Output
The suggested path
assertions::_is syntactically invalid and should never be a suggestion.Moreover, while rustc does seem to make sure that the type of the unused binding and the suggested constant / constructor match, it doesn't seem to filter out
Consider:
Compiler Output
The suggested path
enclosed::EXTRA_OFFSETis (1) inaccessible insidedemodue to privacy and (2) looks nothing like the unusedx, so it can't possibly be a typo.Finally, the suggestion doesn't properly qualify the path. Consider
Compiler Output
It suggests
enclosed::Xinsideseparated::demowhile it should suggestsuper::enclosed::Xorcrate::enclosed::Xotherwise it doesn't resolve.