Skip to content

fix(ci): deny warnings in 'features' step - #4253

Open
cratelyn wants to merge 1 commit into
masterfrom
kate/enforce-warnings-in-cargo-features-step
Open

cratelyn wants to merge 1 commit into
masterfrom
kate/enforce-warnings-in-cargo-features-step

Conversation

@cratelyn

Copy link
Copy Markdown
Member

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:

 // 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:

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

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>
Comment thread src/lib.rs
Comment on lines +4 to +7
#![cfg_attr(
any(all(test, feature = "full"), feature = "__deny_warnings"),
deny(warnings, unreachable_pub)
)]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i preserved the existing all(test, feature = "full") predicate. i think that is probably worthwhile because it seems like a good ergonomic decision to have cargo test --features full continue to deny warnings, as a concise way to run tests and check for warnings when developing a feature.

Comment thread Cargo.toml
tracing = ["dep:tracing"]

# internal features used in CI
__deny_warnings = []

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i used two leading underscores in the name of this, following the convention set by previous feature flags like __internal_flaky_tests and __internal_happy_eyeballs_tests.

@cratelyn
cratelyn marked this pull request as ready for review October 30, 2026 21:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ci): some warnings are not enforced by features step

1 participant