Skip to content

fix(cargo-anvil): Force Anvil's cargo-check to fail on Warnings - #348

Open
Nikoloz Gamkrelidze (nikagamkrelidze) wants to merge 6 commits into
mainfrom
u/nikagamkrelidze/force-cargo-check-fail-on-warnings
Open

Nikoloz Gamkrelidze (nikagamkrelidze) wants to merge 6 commits into
mainfrom
u/nikagamkrelidze/force-cargo-check-fail-on-warnings

Conversation

@nikagamkrelidze

@nikagamkrelidze Nikoloz Gamkrelidze (nikagamkrelidze) commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

There is inconsistency between how Anvil's recipes for cargo-check and cargo-clippy treat warnings.

Because cargo-clippy only runs on codebase with all features turned on, it can miss dead code that is only dead when some features are turned off. Meanwhile, if such some downstream crate uses the problematic crate without those features, that particular Clippy run won't be ran with those features on in the upstream crate and will fail. The dead code warnings were intercepted in the runs for PR that introduced them, but because cargo-check (which caught them) doesn't fail on Warnings, they went unnoticed.

This PR is forcing cargo-check to fail on Warnings and ensures the consistency of checking a crate as the target with changes vs checking it as an upstream dependency.

@nikagamkrelidze
Nikoloz Gamkrelidze (nikagamkrelidze) marked this pull request as ready for review November 6, 2026 14:08
Copilot AI balanced review requested due to automatic review settings November 6, 2026 14:08
@nikagamkrelidze Nikoloz Gamkrelidze (nikagamkrelidze) added the human-review-required Requires human review before approval or merge. label Nov 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new test writes mutable fixtures and depends on installed external tools, allowing coverage to be silently skipped and violating the required in-process, immutable-input test strategy.

1 open issue
What changed in this PR

This PR makes Anvil’s package-isolated check-all-targets recipe reject warnings in both default and no-default-feature configurations, catching warnings that all-features Clippy checks can miss.

Changes:

  • Adds build.warnings="deny" without replacing existing compiler flags.
  • Adds regression coverage and updates generated recipe snapshots.
  • Documents the Cargo 1.97 requirement and bumps cargo-anvil to 0.26.0.
File Description
justfiles/​anvil/​checks/​check-all-targets.just Applies warning denial to the generated recipe.
crates/​cargo-anvil/​tests/​snapshots/​snapshots__local_only.snap Updates the local-backend recipe snapshot.
crates/​cargo-anvil/​tests/​snapshots/​snapshots__github_backend.snap Updates the GitHub-backend recipe snapshot.
crates/​cargo-anvil/​tests/​snapshots/​snapshots__ado_backend.snap Updates the Azure DevOps-backend recipe snapshot.
crates/​cargo-anvil/​tests/​recipe_contracts.rs Updates command expectations and adds warning-policy coverage.
crates/​cargo-anvil/​templates/​justfiles/​anvil/​checks/​check-all-targets.just Adds warning denial to the source template.
crates/​cargo-anvil/​README.md Refreshes generated version metadata and API links.
crates/​cargo-anvil/​docs/​design/​README.md Documents the check’s minimum Cargo version.
crates/​cargo-anvil/​docs/​design/​checks.md Describes warning denial and compiler-flag preservation.
crates/​cargo-anvil/​Cargo.toml Bumps cargo-anvil to 0.26.0.
Cargo.lock Synchronizes the cargo-anvil version.
.anvil.lock Updates the generator version and checksums.

Review effort: Balanced

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.5%. Comparing base (a093f71) to head (a3bf596).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #348   +/-   ##
=====================================
  Coverage   99.5%   99.5%           
=====================================
  Files        351     351           
  Lines      64349   64349           
=====================================
  Hits       64050   64050           
  Misses       299     299           
Flag Coverage Δ
linux 99.4% <ø> (ø)
linux-arm 99.4% <ø> (ø)
scheduled ?
windows 99.5% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The documented Cargo 1.97 minimum is not enforced, allowing older selected toolchains to reach the check without the required version gate and actionable upgrade guidance.

1 open issue
1 resolved since last review

Review effort: Balanced

Write-Host "anvil-check-all-targets: checking $($cfg.name) features"
$featureArgs = $cfg.flags
& cargo {{_anvil_stable_toolchain_args}} each @pkg --keep-going '--' cargo {{_anvil_stable_toolchain_args}} check --package '{cargo-spec}' --all-targets @featureArgs --locked
& cargo {{_anvil_stable_toolchain_args}} each @pkg --keep-going '--' cargo {{_anvil_stable_toolchain_args}} check --package '{cargo-spec}' --all-targets @featureArgs --locked --config "build.warnings='deny'"
adopter selects, including a declared MSRV. Recipes rely on its behaviour, such as
source-qualified package IDs in `cargo metadata`, and keep no workarounds for older Cargo.
The selected stable toolchain for `check-all-targets` requires Cargo 1.97 or newer
to enforce its warnings-as-errors policy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[copilot speaking] [non-blocking] Could we append “; older Cargo versions ignore this setting” to make the behavior below Cargo 1.97 explicit?

Copilot AI balanced review requested due to automatic review settings November 9, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Prerequisite validation does not enforce the documented Cargo 1.97 minimum, allowing older versions that cannot enforce the warning policy to pass unchecked.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 10, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The public setup instructions omit the separate Cargo 1.97+ stable-check requirement, allowing adopters following the documented 1.95+ minimum to select an incompatible Cargo version for that check.

2 open issues

Review effort: Balanced

Comment on lines +13 to +14
- The selected stable toolchain for `check-all-targets` requires **Cargo 1.97
or newer** to enforce its warnings-as-errors policy.
" @{ name = 'no-default'; flags = @('--no-default-features') }\n",
" )\n",
" foreach ($cfg in $configs) {\n",
" Write-Host \"anvil-check-all-targets: checking $($cfg.name) features\"\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖: Non-blocking — The test suite does not protect the intended exception for warnings explicitly allowed in source.

Add a recipe-level success case where an otherwise warning-producing item has #[allow(...)], and assert both feature passes succeed. Without that case, a future stricter warning policy could reject intentionally allowed code while the current source-string assertions remain green.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change enforcing compiler warnings as errors in default and no-default-feature checks.

2 open issues

Review effort: Balanced

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

Labels

human-review-required Requires human review before approval or merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants