clippy::panic fires once instead of twice on duplicated macro input with CARGO_INCREMENTAL=0, leaving one #[expect] unfulfilled (regression)
Summary
Context: I have some code (involving a duplicated expect via macro) that lints successfully locally, but fails in CI.
If the same tokens are pasted into two places (with macro_rules! or a proc macro such as duplicate::duplicate_item), each copy gets its own #[expect(clippy::panic)].
With CARGO_INCREMENTAL=1 (when cargo is running locally), both expectations are fulfilled.
With CARGO_INCREMENTAL=0 (when cargo is running in CI), unfulfilled_lint_expectations fires for one of the copies.
This is a regression. nightly-2026-10-15 is fine and nightly-2026-10-16 is the first bad nightly. It still reproduces on nightly-2026-10-24. Stable 1.99.1 is fine.
(After stumbling over the bug, I used AI to create the MRE and bisect the first failing nightly. I verified the reproducer and the bisect manually)
Reproducer
Code:
rust-toolchain.toml
[toolchain]
channel = "nightly-2026-10-16"
Cargo.toml:
[package]
name = "repro"
version = "0.1.0"
edition = "2024"
[lints.clippy]
panic = "warn"
src/lib.rs:
macro_rules! twice {
($($t:tt)*) => {
pub mod a { $($t)* }
pub mod b { $($t)* }
};
}
twice! {
#[expect(clippy::panic)]
pub fn foo() {
panic!();
}
}
run
CARGO_INCREMENTAL=0 cargo clippy
Current output:
Checking repro v0.1.0 (/home/xyz)
warning: this lint expectation is unfulfilled
--> src/lib.rs:9:14
|
9 | #[expect(clippy::panic)]
| ^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
warning: `repro` (lib) generated 1 warning
Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.06s
Desired output:
Checking repro v0.1.0 (/home/xyz)
Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.07s
(Note that cargo clippy (default, CARGO_INCREMENTAL=1) already works as it should
Version
rustc 1.101.0-nightly (4ebd25825 2026-10-15)
binary: rustc
commit-hash: 4ebd258257737d5b7635c116fa7d281627a7e937
commit-date: 2026-10-15
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4
clippy 0.1.101 (4ebd258257 2026-10-15)
Additional Labels
No response
I’d like to investigate this regression. The reproducer and nightly bisect are really helpful. I’ll try to narrow down what changed between the October 15 and October 16 nightly builds and see whether the issue is in Clippy’s lint tracking or the compiler side.
@rustbot claim