Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
new lint: and_then_then_some #12981
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
base: master
Are you sure you want to change the base?
new lint: and_then_then_some #12981
Changes from all commits
1d78783
4bb4f13
5b520b6
37e7058
3b9bba4
7a0adc4
88ec537
5654d30
7ea79c0
2a6f6d0
360cf82
2ccce8d
b528cb7
da89528
8e9fa96
13c7361
2f343a0
4e8fe6c
1090186
de9881f
015822d
be39ee0
016653f
6c0607d
f03e8d6
bb0e265
c842e4b
122cd11
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 assume this comment is saying this is a false negative in this case...? Not sure, can you elaborate?
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.
yes, the current code will fail if the offending lambda has a multi-stmt block as its body. unfortunately fixing this would either mean shuffling around HIR (and possibly messing up the spans in the process), or modeling the problem in a more complex way.
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.
Can't you use
peel_blocks_with_stmt
? And we thankfully don't need the spans ifBody
is usedThere 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.
Consider that change optional tbh as it'd require you to modify the suggestion to include those statements as well, otherwise it may cause the code to break, you can do it though if you want
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.
looks like
clippy_utils::path_to_local
, but I'm not sure if this can be replacedThere 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'm much more familiar with the hir and mir types than all the clippy utils, and yeah, you can't use function calls in patterns.
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.
It could be extracted from the
match
expression then in the_
case you put that in the other branch. It'd be cleaner imo tooThere 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.
Actually, one step further, rather than doing an
if let
as I suggested above, do smth withOption::map_or_else
thenis_some_and(identity)
since thetrue
case is only whenpath_to_local
would returnSome
.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.
Same here. Let's match the type's diagnostic item to
bool
then check the method name