Skip to content

incorrect/useless lint warning [warn(dropping_references)] #155895

@cavemanloverboy

Description

@cavemanloverboy

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions