From 5d62e2079a2deb3546f178dee3c792bdf6d95a4c Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 06:53:35 -0800 Subject: [PATCH] Validation tests: bin_exe! takes CARGO_BIN_EXE_ through option_env! without unwrapping it, which clippy denies 56cf3dbd1b called .expect on option_env!(...), and clippy::option_env_unwrap ("this will panic at run-time if the environment variable doesn't exist at compile-time") is denied under -D warnings: m3-max-78487's run at 01d80f2d65 failed five of them. The compile-time path is now one more fallback after nextest's NEXTEST_BIN_EXE_, and a test that finds neither panics naming both. Verified: the next msi job runs clippy over the validation crate as CI does (CI=1, so scripts/rustc-wrapper runs the compiler itself, and a fresh target), at the old macro and at this one. --- .../tests/integration/main.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/metal2vulkan-validation/tests/integration/main.rs b/crates/metal2vulkan-validation/tests/integration/main.rs index 9efdea24f..248dec8bf 100644 --- a/crates/metal2vulkan-validation/tests/integration/main.rs +++ b/crates/metal2vulkan-validation/tests/integration/main.rs @@ -15,16 +15,17 @@ macro_rules! bin_exe { ($name:literal) => { std::env::var_os(concat!("NEXTEST_BIN_EXE_", $name)) + // `option_env!`, not `env!`: Cargo sets `CARGO_BIN_EXE_` for a build of the test, + // not for `cargo clippy --all-targets`, which only checks it. + .or_else(|| option_env!(concat!("CARGO_BIN_EXE_", $name)).map(std::ffi::OsString::from)) .map(std::path::PathBuf::from) .unwrap_or_else(|| { - // `option_env!`, not `env!`: Cargo sets `CARGO_BIN_EXE_` for a build of the - // test, but not for `cargo clippy --all-targets`, which only checks it. - std::path::PathBuf::from(option_env!(concat!("CARGO_BIN_EXE_", $name)).expect( - concat!( - "Cargo sets CARGO_BIN_EXE_", - $name, - " when it builds this test" - ), + panic!(concat!( + "neither NEXTEST_BIN_EXE_", + $name, + " nor CARGO_BIN_EXE_", + $name, + " is set" )) }) };