rust-lang / rust-lang/rust-clippy
unnecessary_wraps is too strict
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
The recently introduced unnecessary_wraps lint is quite strict, and sometimes the affected function cannot be refactored. An example is when the function is used for #[serde(default)]:
fn field_default() -> Option<i32> {
Some(42)
}
#[derive(serde::Deserialize)]
struct S {
#[serde(default = "field_default")]
field: Option<i32>,
}
It is a bit unfortunate having to allow the clippy lint explicitly. I was wondering if you would consider to add a function naming pattern that ignores the lint, such as an _opt suffix or a try_ prefix.
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
Review the existing unnecessary_wraps lint and the #[serde(default)] example first. Decide whether an _opt suffix or try_ prefix should be supported, then run the relevant lint checks to verify that the chosen naming pattern handles this case without weakening other diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100