rust-lang / rust-lang/rust-clippy
New lint: replace place statement with drop(place)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
As featured in this Twitter poll.
The statement <place>; causes a move from and drop of the value at place. For clarity of intent, this is better written as drop(<place>); to emphasize the destructor is what is being invoked.
> 65% of votes on the linked poll had intuition that this (var;) did not invoke the destructor, so this lint would definitely help avoid potentially misleading code. (rustc does already lint this as path_statements, so perhaps this should instead be an improvement to that lint. https://github.com/rust-lang/rust/issues/48852 is a 2018 issue to remove the lint (which is currently incorrect) for path statements that invoke a destructor.
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 reading Clippy's existing handling of rustc's path_statements lint and the linked discussion in rust-lang/rust#48852. The change is complete when place statements that move and drop a value are clearly diagnosed and drop(<place>); is recommended, without incorrectly covering cases where the behavior differs.
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