rust-lang / rust-lang/rust-clippy

let_underscore_drop warns even when drop order is not affected

Open
#6,841 3 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.