From 53d8da515009d3d0c9bdb609b9b552a79f0e4dac Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Fri, 30 Oct 2026 00:00:00 +0000 Subject: [PATCH] fix(ci): deny warnings in 'features' step fixes https://github.com/hyperium/hyper/issues/4232. in #4231, we found that we don't deny warnings when running cargo hack, because of the predicate that conditionally gates a crate-level `#![deny(warnings)]` attribute in `lib.rs`: ```rust // src/lib.rs #![cfg_attr(all(test, feature = "full"), deny(unreachable_pub))] #![cfg_attr(all(test, feature = "full"), deny(warnings))] #![cfg_attr(all(test, feature = "nightly"), feature(test))] ``` while this prevents warnings from existing when running `cargo test --features full`, it does not affect other builds. so, this would not be active in the commands run by the `features` step in CI, which runs the following two `cargo-hack` commands: ```sh RUSTFLAGS="-D dead_code -D unused_imports" \ cargo hack --no-dev-deps check \ --feature-powerset --depth 2 --skip ffi,tracing RUSTFLAGS="--cfg hyper_unstable_tracing -D dead_code -D unused_imports" \ cargo hack --no-dev-deps check \ --feature-powerset --depth 2 --features tracing --skip ffi ``` this commit introduces a new feature, intended for internal use in CI, called `__deny_warnings`. this provides another mechanism to deny warnings when building hyper. `cargo hack` invocations run in CI are updated to enable this flag. because `-D dead_code -D unused_imports` are now redundant, the `RUSTFLAGS` values passed to these steps are also accordingly simplified. Signed-off-by: katelyn martin --- .github/workflows/CI.yml | 8 +++----- Cargo.toml | 1 + src/lib.rs | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5d625ae140..1f8568549f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -181,14 +181,12 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: check --feature-powerset - run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --skip ffi,tracing - env: - RUSTFLAGS: "-D dead_code -D unused_imports" + run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features __deny_warnings --skip ffi,tracing - name: check --feature-powerset with tracing feature - run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing --skip ffi + run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing,__deny_warnings --skip ffi env: - RUSTFLAGS: "--cfg hyper_unstable_tracing -D dead_code -D unused_imports" + RUSTFLAGS: "--cfg hyper_unstable_tracing" ffi: name: Test C API (FFI) diff --git a/Cargo.toml b/Cargo.toml index 7f372a27ed..947e34c04f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,7 @@ capi = [] tracing = ["dep:tracing"] # internal features used in CI +__deny_warnings = [] nightly = [] [lints.rust.unexpected_cfgs] diff --git a/src/lib.rs b/src/lib.rs index 8d6e2d2d5a..c7894a608a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,10 @@ #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![cfg_attr(test, deny(rust_2018_idioms))] -#![cfg_attr(all(test, feature = "full"), deny(unreachable_pub))] -#![cfg_attr(all(test, feature = "full"), deny(warnings))] +#![cfg_attr( + any(all(test, feature = "full"), feature = "__deny_warnings"), + deny(warnings, unreachable_pub) +)] #![cfg_attr(all(test, feature = "nightly"), feature(test))] #![cfg_attr(docsrs, feature(doc_cfg))]