-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-questionCategory: QuestionsCategory: QuestionsI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion
Description
There have been a couple of problems already with broken suggestions with macros.
The snippet
function does not deal with macros very well which is why we have snippet_with_macro_callsite
which uses the original macro unexpanded.
For example if we have some kind x.map(|_| vec![])
code, the redundant_closure
lint would suggest to replace vec![]
with $crate::vec::Vec::new
which should just be Vec::new()
.
cargo clippy --fix
fills in the suggestion and the crate no longer builds because what is x.map(|_| $crate::...
...
I'm wondering, what are valid cases where DO want to have an expanded macro inside a fix suggestion?
Can we fix this class of bugs once and for all by just making the snippet
fn not expand macros by default?
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-questionCategory: QuestionsCategory: QuestionsI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion