rust-lang / rust-lang/rust-clippy

Making `try_err` warn-by-default

Open
#10,145 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Description

try_err is currently an allow-by-default restriction lint.
I think it should be moved into a warn-by-default lint. First, I consider it bad style and unidiomatic. This is arguably subjective.
But the bigger problem is that people keep being confused by the limitations of this pattern. They often think that Err(err)? should be considered a diverging expression, when it is indeed not. If we started linting against the pattern (possibly even with an explanation that it is not diverging) then it should hopefully reduce confusion.
I think we should even uplift it at some point, but first clippy should start making it warn-by-default to collect feedback.

Here are some recent examples of issues opened on rust-lang/rust because of this: #106377 #106357

For reference, here's the lint page: https://rust-lang.github.io/rust-clippy/master/#try_err

Version

No response

Additional Labels

@rustbot label C-enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the try_err lint page linked in the issue and review the referenced Rust issues (#106377 and #106357) to understand the reported confusion. Locate the lint's default-level configuration in rust-clippy, change it to warn-by-default, and verify that the lint page and relevant behavior reflect the new level.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.