Reinstate single_match/single_match_else lints with comments#14420
Merged
Alexendoo merged 1 commit intorust-lang:masterfrom Mar 18, 2025
Merged
Reinstate single_match/single_match_else lints with comments#14420Alexendoo merged 1 commit intorust-lang:masterfrom
single_match/single_match_else lints with comments#14420Alexendoo merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
Member
Author
|
@GuillaumeGomez could you confirm that this is ok with running |
ojeda
pushed a commit
to ojeda/linux
that referenced
this pull request
Mar 16, 2025
Extend the Result documentation by some guidelines and examples how
to handle Result error cases gracefully. And how to not handle them.
While at it fix one missing `Result` link in the existing documentation.
[ Moved links out-of-line for improved readability. Fixed `srctree`
link. Sorted out-of-line links. Added newlines for consistency
with other docs. Applied paragraph break suggestion. Reworded
slightly the docs in a couple places. Added Markdown.
In addition, added `#[allow(clippy::single_match)` for the first
example. It cannot be an `expect` since due to a difference introduced
in Rust 1.85.0 when there are comments in the arms of the `match`.
Reported it upstream, but it was intended:
rust-lang/rust-clippy#14418
Perhaps Clippy will lint about it in the future, but without autofix:
rust-lang/rust-clippy#14420
- Miguel ]
Link: https://lore.kernel.org/rust-for-linux/CANiq72keOdXy0LFKk9SzYWwSjiD710v=hQO4xi+5E4xNALa6cA@mail.gmail.com/
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Link: https://lore.kernel.org/r/20250122054719.595878-1-dirk.behme@de.bosch.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
76 tasks
5a2d393 to
a84d84c
Compare
a84d84c to
c6bf42a
Compare
GuillaumeGomez
approved these changes
Mar 17, 2025
Member
|
Looks good to me, thanks! |
Alexendoo
reviewed
Mar 17, 2025
Commit efe3fe9 removed the ability for `single_match` and `single_match_else` to trigger if comments were present outside of the arms, as those comments would be lost while rewriting the `match` expression. This reinstates the lint, but prevents the suggestion from being applied automatically in the presence of comments by using the `MaybeIncorrect` applicability. Also, a note is added to the lint message to warn the user about the need to preserve the comments if acting upon the suggestion.
c6bf42a to
a1bdc19
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Commit efe3fe9 removed the ability for
single_matchandsingle_match_elseto trigger if comments were present outside of the arms, as those comments would be lost while rewriting thematchexpression.This reinstates the lint, but prevents the suggestion from being applied automatically in the presence of comments by using the
MaybeIncorrectapplicability. Also, a note is added to the lint message to warn the user about the need to preserve the comments if acting upon the suggestion.changelog: [
single_match,single_match_else]: reinstate lint when comments are inside thematchbut do not autofix the codeFix #14418