rust-lang / rust-lang/rust-clippy
allow_unwrap_types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
allow_unwrap_types configures unwrap_used to allow any type in a given list of types to be unwrapped.
Advantage
Avoids the need to #[allow] unwrap() various types.
A concrete example is to allow unwrap() of std::sync::LockResult which is produced by locking a Mutex.
Drawbacks
None.
Example
#[allow(clippy::unwrap_used)]
some_mutex
.lock()
.unwrap()
...;
Could be written as:
some_mutex
.lock()
.unwrap()
...;
with the following in Cargo.toml:
[lints.clippy]
allow_unwrap_types = [std::sync::LockResult]
Comparison with existing lints
When the unwrap_used lint is applied, the user is forced to pepper their code with #[allow(clippy::unwrap_used)] when, for example, Mutex lock results are unwrapped.
Additional Context
The reasonableness of unwrapping LockResult is discussed here: https://www.reddit.com/r/rust/comments/10f6328/is_this_a_reasonable_way_to_handle_unwrapping/.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start with Clippy's existing unwrap_used lint and the configuration shown in the issue, then trace how lint settings and type lists are handled. Done means allow_unwrap_types accepts the listed types and permits matching unwrap() calls without an explicit allow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100