-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Reinstate single_match
/single_match_else
lints with comments
#14420
Conversation
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
@GuillaumeGomez could you confirm that this is ok with running |
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 <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
5a2d393
to
a84d84c
Compare
a84d84c
to
c6bf42a
Compare
Looks good to me, thanks! |
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
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.
Thanks!
Commit efe3fe9 removed the ability for
single_match
andsingle_match_else
to trigger if comments were present outside of the arms, as those comments would be lost while rewriting thematch
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.changelog: [
single_match
,single_match_else
]: reinstate lint when comments are inside thematch
but do not autofix the codeFix #14418