Repository navigation
Add ignored_result_err lint to detect discarded Result error variants - #17326
scuzzycheese wants to merge 1 commit into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @dswij (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
Lintcheck changes for 95c0e72
This comment will be updated if you push new changes |
|
r? clippy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
49263b1 to
714fead
Compare
714fead to
39df31c
Compare
|
Re-opening PR, I made mistake by resetting my origin. |
|
@rustbot ready |
|
Hi @flip1995 |
This comment has been minimized.
This comment has been minimized.
714fead to
efc87cd
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
efc87cd to
e2ccefa
Compare
3c48edf to
0b0e132
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0b0e132 to
bf50705
Compare
This comment has been minimized.
This comment has been minimized.
|
@flip1995 - Any movement on this? |
|
@flip1995 - ping! :D |
|
@flip1995 - Just a follow up on this. |
|
@flip1995 - ping |
|
r? clippy |
|
I don't think I'll have time to look at this either r? @Clippy I'm a bit busy with Rust security things right now |
|
Hello @scuzzycheese! Thanks for the contribution, being that you've been on this little 🏓 ping pong of reviewers (sometimes happens :/), I'll try to prioritize you. ❤️ |
|
Hmm, it seems that this lint is very similar to What do you think about this idea? |
|
I have to say, that i'm not convinced that match_wild_err_arm is similar in many ways. The purpose of this lint is to detect when the error variable is being discarded, which is what happens when there is no match being used. It actually doesn't try to detect match arms at all. Here are the patterns it detects:
I feel like match_wild_err_arm is a different use case, designed to catch a different thing. Can if I can't incorporate the above expressions into match_wild_err_arm, then it's not a particularly useful lint. I honestly feel like these are two different use cases. And they should be able to be used independently. |
|
The bad pattern here is discarding the error form, right? Good code does not discard errors, it handles them. So in the case of this lint, we're encountering an unhandled error. In the case of Even in this example: match expr {
Ok(x) => x,
Err(_) => {...}
} |
This comment has been minimized.
This comment has been minimized.
|
Ok, so are we saying we would take ALL the functionality into match_wild_err_arm? Because the whole reason I wrote this was to make sure that it captured the situations I think are dangerous. |
|
Indeed ❤️!
I know, and I understand that it can feel like we're valuing your work less just because we see that this two functionalities should go together. But looking at both these two helpful lints, we just don't see enough difference in user experience to warrant having to learn the two names and having two different documentation pages. You're very welcome to merge the logic from PR into |
|
Thanks for the reply. It's not a loss, I just didn't want to lose any of
the functionality in my checks. If they are captured completely in
match_wild_err_arm I'll be happy with that.
Let me get on that. I just need to deal with a merge conflict first which
I'll push, then I'll move them into match_wild_err_arm.
Thanks
…On Tue, 13 Oct 2026 at 14:33, Alejandra González ***@***.***> wrote:
*blyxyas* left a comment (rust-lang/rust-clippy#17326)
<#17326 (comment)>
Indeed ❤️!
Because the whole reason I wrote this was to make sure that it captured
the situations I think are dangerous.
I know, and I understand that it can feel like we're valuing your work
less just because we see that this two functionalities should go together.
But looking at both these two helpful lints, we just don't see enough
difference in user experience to warrant having to learn the two names and
having two different documentation pages.
You're very welcome to merge the logic from PR into match_wild_err_arm ,
and I'm sorry for the "lost" work.
—
Reply to this email directly, view it on GitHub
<#17326?email_source=notifications&email_token=AAPCF2AK6LCPUFPZYZWL7B35TYOIJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJUGU2TSNZTGMY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6145597331>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPCF2BT5GWMYTSD7TQZ6BT5TYOIJAVCNFSNUABEKJSXA33TNF2G64TZHMZDMOBVGA2DIMZ3JFZXG5LFHM2DOOBQGY2TAOJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAPCF2FKQXSH6ELQ27D2B435TYOIJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJUGU2TSNZTGMY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAPCF2D7HUP4BGH4NL76QIT5TYOIJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJUGU2TSNZTGMY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
bf50705 to
7fefdce
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Add a new restriction lint that warns when the Err variant of a Result
is implicitly discarded. The lint detects three patterns:
- `if let Ok(x) = expr` (with or without else)
- `while let Ok(x) = expr`
- `let Ok(x) = expr else { ... }`
In all these cases, the error value is lost, preventing detailed logging
and making error recovery impossible. The lint suggests using `match`
with an explicit `Err(e)` binding instead.
This is an opt-in restriction lint, enabled with:
#![warn(clippy::ignored_result_err)]
A configuration option `allow-ignored-result-err-in-tests = true` can be
set in clippy.toml to suppress the lint in `#[test]` functions and
`#[cfg(test)]` modules.
Tested via the compile-test UI test harness with cases covering all three
patterns, a negative case for `match` with bound Err, and a ui-toml test
verifying the allow-in-tests configuration works correctly.
7fefdce to
95c0e72
Compare
|
I have a.... query about putting this inside Is this acceptable? I'm not convinced it's... a good choice. What do you think? |
View all comments
changelog: new lint: [
ignored_result_err]: Addignored_result_errlint to detect discarded Result error variants. fixes #16107