From 3c46de653247040dfa28acfd94cfb6cc6aab2efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 10 Jun 2025 14:31:47 +0200 Subject: [PATCH] Only invoke the Clippy wrapper for the leaf crate --- collector/src/compile/execute/mod.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/collector/src/compile/execute/mod.rs b/collector/src/compile/execute/mod.rs index 9e94991c0..64892a2a4 100644 --- a/collector/src/compile/execute/mod.rs +++ b/collector/src/compile/execute/mod.rs @@ -330,17 +330,11 @@ impl<'a> CargoProcess<'a> { let mut cmd = self.base_command(self.cwd, cargo_subcommand); cmd.arg("-p").arg(self.get_pkgid(self.cwd)?); match self.profile { - Profile::Check => { + Profile::Check | Profile::Clippy => { cmd.arg("--profile").arg("check"); } Profile::Debug => {} Profile::Doc => {} - Profile::Clippy => { - cmd.arg("--profile").arg("check"); - // For Clippy, we still invoke `cargo rustc`, but we need to override the - // executed rustc to be clippy-fake. - cmd.env("RUSTC", &*FAKE_CLIPPY); - } Profile::Opt => { cmd.arg("--release"); } @@ -366,6 +360,15 @@ impl<'a> CargoProcess<'a> { // onto rustc for the final crate, which is exactly the crate for which // we want to wrap rustc. if needs_final { + if let Profile::Clippy = self.profile { + // For Clippy, we still invoke `cargo rustc`, but we need to override the + // executed rustc to be clippy-fake. + // We only do this for the final crate, otherwise clippy would be invoked by + // cargo also for building host code (build scripts/proc macros), which doesn't + // really work. + cmd.env("RUSTC", &*FAKE_CLIPPY); + } + let processor = self .processor_etc .as_mut()