Skip to content

Add ignored_result_err lint to detect discarded Result error variants#17326

Open
scuzzycheese wants to merge 1 commit into
rust-lang:masterfrom
scuzzycheese:ignored_result_err
Open

Add ignored_result_err lint to detect discarded Result error variants#17326
scuzzycheese wants to merge 1 commit into
rust-lang:masterfrom
scuzzycheese:ignored_result_err

Conversation

@scuzzycheese

@scuzzycheese scuzzycheese commented Jun 30, 2026

Copy link
Copy Markdown

changelog: new lint: [ignored_result_err]: Add ignored_result_err lint to detect discarded Result error variants. fixes #16107

@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 30, 2026
@rustbot

rustbot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 8 candidates
  • 8 candidates expanded to 8 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

Lintcheck changes for 714fead

Lint Added Removed Changed
clippy::ignored_result_err 302 0 0

This comment will be updated if you push new changes

@dswij

dswij commented Jul 2, 2026

Copy link
Copy Markdown
Member

r? clippy

@rustbot rustbot assigned flip1995 and unassigned dswij Jul 2, 2026
@rustbot

This comment has been minimized.

@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jul 6, 2026
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.
@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jul 6, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 6, 2026
@scuzzycheese

Copy link
Copy Markdown
Author

Re-opening PR, I made mistake by resetting my origin.

@scuzzycheese scuzzycheese reopened this Jul 6, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 6, 2026
@scuzzycheese

Copy link
Copy Markdown
Author

@rustbot ready

@scuzzycheese

Copy link
Copy Markdown
Author

Hi @flip1995
Just bumping this since I accidentally closed and reopened it a few days ago, which threw off the bot status.
Whenever you have some free time, I’d love to get your feedback on the implementation!

@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #15000) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A lint to check the ignoring of Err

4 participants