Skip to content

Commit 53d8da5

Browse files
committed
fix(ci): deny warnings in 'features' step
fixes #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 <git@katelyn.world>
1 parent 8abd0b4 commit 53d8da5

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎.github/workflows/CI.yml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,12 @@ jobs:
181181
- uses: Swatinem/rust-cache@v2
182182

183183
- name: check --feature-powerset
184-
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --skip ffi,tracing
185-
env:
186-
RUSTFLAGS: "-D dead_code -D unused_imports"
184+
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features __deny_warnings --skip ffi,tracing
187185

188186
- name: check --feature-powerset with tracing feature
189-
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing --skip ffi
187+
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing,__deny_warnings --skip ffi
190188
env:
191-
RUSTFLAGS: "--cfg hyper_unstable_tracing -D dead_code -D unused_imports"
189+
RUSTFLAGS: "--cfg hyper_unstable_tracing"
192190

193191
ffi:
194192
name: Test C API (FFI)

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ capi = []
9696
tracing = ["dep:tracing"]
9797

9898
# internal features used in CI
99+
__deny_warnings = []
99100
nightly = []
100101

101102
[lints.rust.unexpected_cfgs]

‎src/lib.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![deny(missing_docs)]
22
#![deny(missing_debug_implementations)]
33
#![cfg_attr(test, deny(rust_2018_idioms))]
4-
#![cfg_attr(all(test, feature = "full"), deny(unreachable_pub))]
5-
#![cfg_attr(all(test, feature = "full"), deny(warnings))]
4+
#![cfg_attr(
5+
any(all(test, feature = "full"), feature = "__deny_warnings"),
6+
deny(warnings, unreachable_pub)
7+
)]
68
#![cfg_attr(all(test, feature = "nightly"), feature(test))]
79
#![cfg_attr(docsrs, feature(doc_cfg))]
810

0 commit comments

Comments
 (0)