incorrect/useless lint warning [warn(dropping_references)]
Open
Nobody has claimed this yet.
A-diagnostics
A-lints
A-suggestion-diagnostics
C-enhancement
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
when compiling something like
let x = [0; 64];
let _ = drop(&x);
I see
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
--> src/main.rs:3:9
|
3 | let _ = drop(&x);
| ^^^^^--^
| |
| argument has type `&[i32; 64]`
|
= note: use `let _ = ...` to ignore the expression or result
= note: `#[warn(dropping_references)]` on by default
warning: `playground` (bin "playground") generated 1 warning
which gives me the note: use let _ = ... to ignore the expression or result. (the reason for the let _ = ... in the first place is because i listened to the suggestion)
Meta
$ rustc --version
rustc 1.95.0 (59807616e 2026-04-14)
this also happens on nightly
$ cargo +nightly --version
cargo 1.97.0-nightly (06ac0e7c0 2026-04-21)
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 issue with the Rust snippet in the report and inspect the compiler's dropping_references lint diagnostics. Trace how the warning and its let _ = ... note are selected; done means the diagnostic no longer gives guidance that conflicts with the code that triggered it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100