rust-lang / rust-lang/rust-clippy
let_underscore_drop warns even when drop order is not affected
Open
Nobody has claimed this yet.
C-bug
I-false-positive
S-needs-discussion
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Lint name: clippy::let_underscore_drop
In this context, the semantics of _ do not alter drop order (which is the reason the lint exists, I think?) but the lint fires anyway:
struct FlushOnDrop<T: std::io::Write>(T);
impl<T: std::io::Write> Drop for FlushOnDrop<T> {
fn drop(&mut self) {
let _ = self.0.flush();
}
}
Meta
cargo clippy -V: clippy 0.1.52 (476acbf 2021-03-03)rustc -Vv:rustc 1.52.0-nightly (476acbf1e 2021-03-03) binary: rustc commit-hash: 476acbf1e9965b5e95c90f0d7d658709812b7003 commit-date: 2021-03-03 host: x86_64-unknown-linux-gnu release: 1.52.0-nightly LLVM version: 11.0.1
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 with the clippy::let_underscore_drop lint entry point and reproduce the supplied FlushOnDrop example using the reported Rust and Clippy versions. Add or update a regression case for this context; done means the example no longer warns when _ does not affect drop order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100