rust-lang / rust-lang/rust-clippy

drop_non_drop triggers inside of macro generated code

Open
#16,753 3 comments 0 reactions 1 assignee View on GitHub

@evolo22 is already working on this.

Since Mar 25, 2026.

C-bug I-false-positive
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

I am using Salsa along with Rust Analyzer's query-group-macro.

Lint Name

drop_non_drop

Reproducer

I tried this code. Or at least that's a relatively minimal reproducer extracted from wgsl-analyzer:

[package]
name = "clippy-issue"
version = "0.1.0"
edition = "2024"

[dependencies]
query-group = { package = "query-group-macro", git = "https://github.com/rust-lang/rust-analyzer", rev = "a31e10a2fdc585e9d7ea0857cacfd322dd478070", version = "0.0.0" }
salsa = { version = "0.22.0", default-features = true, features = [
  "macros",
  "salsa_unstable"
] }
salsa-macros = "0.22.0"
// lib.rs

#![deny(clippy::drop_non_drop)]

#[salsa::input]
pub struct MyKey {
    pub value: u32,
}

#[derive(PartialEq, Eq, Hash, Clone, salsa_macros::Supertype)]
pub enum KeyWithoutDrop {
    Foo(MyKey),
}

#[query_group::query_group(DefDatabaseStorage)]
pub trait RootQueryDb: salsa::Database {
    #[salsa::invoke(parse)]
    fn parse(&self, key: MyKey) -> u32;

    #[salsa::invoke(query)]
    fn function_data(&self, key: KeyWithoutDrop) -> u32;
}

fn parse(database: &dyn RootQueryDb, key: MyKey) -> u32 {
    key.value(database)
}

#[allow(clippy::needless_pass_by_value)]
fn query(database: &dyn RootQueryDb, key: KeyWithoutDrop) -> u32 {
    match key {
        KeyWithoutDrop::Foo(editioned_file_id) => editioned_file_id.value(database),
    }
}

I saw this happen:

C:\git\graphics\clippy-issue> cargo clippy                                                                                                                                                               
    Checking clippy-issue v0.1.0 (C:\git\graphics\clippy-issue)
error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes
  --> src\lib.rs:13:1
   |
13 | #[query_group::query_group(DefDatabaseStorage)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: argument has type `KeyWithoutDrop`
  --> src\lib.rs:13:1
   |
13 | #[query_group::query_group(DefDatabaseStorage)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#drop_non_drop
note: the lint level is defined here
  --> src\lib.rs:1:9
   |
 1 | #![deny(clippy::drop_non_drop)]
   |         ^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `salsa::plumbing::unexpected_cycle_initial` which comes from the expansion of the attribute macro `salsa_macros::tracked` (in Nightly builds, run with -Z macro-backtrace for more info)

error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes
  --> src\lib.rs:13:1
   |
13 | #[query_group::query_group(DefDatabaseStorage)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: argument has type `KeyWithoutDrop`
  --> src\lib.rs:13:1
   |
13 | #[query_group::query_group(DefDatabaseStorage)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#drop_non_drop
   = note: this error originates in the macro `salsa::plumbing::unexpected_cycle_recovery` which comes from the expansion of the attribute macro `salsa_macros::tracked` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `clippy-issue` (lib) due to 2 previous errors

I expected to see no warnings. It's macro generated code, I don't know how I could possibly fix it.

Version
rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: x86_64-pc-windows-msvc
release: 1.94.0
LLVM version: 21.1.8
Additional Labels

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.