axum-extra: gate rejection test behind feature #3493
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
#3485 moved
WithRejectionbehind a feautre gate but this test was not gated.Why this wasn't caught in that PR's CI
cargo hackchecks just lib code, not tests, so the CI did not catch it there. Clippy is run with--all-targets --all-featuresand tests are run with--all-featuresso it wasn't caught there either.Solution
Compile the test only when the required feature is enabled.
We might also want to add a check to CI to catch this but I don't see it as necessary as this only prevents compilation of tests without all features, so users are not affected. However, developers may be surprised when they clone this repository and running
cargo test(as opposed tocargo test --all-features) fails.This does not happen regularly though so I'm not sure if running more stuff in CI is worth it. We could add
--all-targetsto thecargo hackinvocation but that might be problematic in itself because then I think it will be compiled with dev dependencies features as well as normal features. Or we can just also runcargo testandcargo test --no-default-featuresto test these two scenarios on top of what we're already testing. Or the same thing withcargo checkorcargo clippy.