rust-lang / rust-lang/rust-clippy
new_without_default could include blanket impls
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
The existing new_without_default lint could be expanded to catch smart pointers that have a blanket impl Default, such as Arc, Mutex, etc.
Advantage
Expands on the advantages of the existing new_without_default lint.
Drawbacks
No response
Example
pub struct Bar;
impl Bar {
#[expect(clippy::new_without_default)]
pub fn new() -> std::sync::Arc<Self> { Arc::new(Self) }
}
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
Start by reproducing the Playground example and reading the existing new_without_default lint and its tests. Identify how the lint recognizes return types, then verify the desired behavior for Arc, Mutex, and other smart pointers with blanket Default implementations. Done means suitable cases are reported without false positives and the test suite covers the expanded behavior.
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
- 52/100