Uplift clippy::for_loops_over_fallibles lint into rustc#99696
Merged
bors merged 19 commits intorust-lang:masterfrom Oct 10, 2022
Merged
Uplift clippy::for_loops_over_fallibles lint into rustc#99696bors merged 19 commits intorust-lang:masterfrom
clippy::for_loops_over_fallibles lint into rustc#99696bors merged 19 commits intorust-lang:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR, as the title suggests, uplifts
clippy::for_loops_over_fallibleslint into rustc. This lint warns for code like this:i.e. directly iterating over
OptionandResultusingforloop.There are a number of suggestions that this PR adds (on top of what clippy suggested):
forloop is a.next()call, then we can suggest removing it (or rather replacing with.by_ref()to allow iterator being used later)while let, this is useful for non-iterator, iterator-like things like [async] channelsResult<impl IntoIterator, _>and the body has aResult<_, _>type, we can suggest using?if let(P.S.
SomeandOkare interchangeable depending on the type)I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)!
Resolves #99272