From 5ed532f79c8586040c1f0de9edbf28273560a03e Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Thu, 5 Feb 2026 02:06:15 +0000 Subject: [PATCH] [cargo-zerocopy] Pass `RUSTDOCFLAGS` Pass the same set of flags to `RUSTFLAGS` and `RUSTDOCFLAGS`. Some of our tests - specifically `src/doctests.rs` - use `cfg`s which are set by `cargo-zerocopy`, but these were previously not passed when evaluating doc tests. This follows up on #2960, which introduced this bug. gherrit-pr-id: G413a86267ff4384a9806de9a784407f1f5be96aa --- tools/cargo-zerocopy/src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/cargo-zerocopy/src/main.rs b/tools/cargo-zerocopy/src/main.rs index fde52452ea..4256c42d63 100644 --- a/tools/cargo-zerocopy/src/main.rs +++ b/tools/cargo-zerocopy/src/main.rs @@ -239,7 +239,10 @@ fn delegate_cargo() -> Result<(), Error> { env_rustflags, ); + // Pass RUSTFLAGS to both Rust (via `RUSTFLAGS`) and Rustdoc + // (via `RUSTDOCFLAGS`). let mut cmd = rustup(["run", version, "cargo"], Some(("RUSTFLAGS", &rustflags))); + cmd.env("RUSTDOCFLAGS", &rustflags); if env::var("CARGO_TARGET_DIR").is_ok() { eprintln!("[cargo-zerocopy] WARNING: `CARGO_TARGET_DIR` is set - this may cause `cargo-zerocopy` to behave unexpectedly");