rust-lang / rust-lang/rust

incorrect/useless lint warning [warn(dropping_references)]

Open
#155,895 4 comments 2 reactions 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.