rust-lang / rust-lang/rust-clippy
The lint docs misrepresent trait `Drop`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
The reason why Drop is a trait is because adding a drop method to a type is similar to implementing a trait on it.
Other than that, Drop does not really behave like a trait. If a type doesn’t implement Drop, then that doesn’t mean it lacks destructor code. For instance, String and HashMap currently don’t implement it.
Instead, core::mem::needs_drop::<T>() is used to check if dropping a T invokes a destructor.
drop_non_drop and forget_non_drop should ideally not mention the trait Drop in their name or documentation, it is misleading.
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 locating the definitions and documentation for the drop_non_drop and forget_non_drop lints. Compare their wording with core::mem::needs_drop::<T>() and determine how the lint names and documentation should avoid implying that only types implementing Drop have destructor code; done means the misleading references are corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100