Repository navigation
chore: remove unused dependencies reported by cargo's unused_dependencies lint - #12165
Conversation
…cies lint Remove the dependencies that Cargo 1.100's `cargo::unused_dependencies` and `cargo::unused_workspace_dependencies` lints report and that are really unused, move the ones only integration tests use to `[dev-dependencies]`, and mirror the changes in the BUILD.bazel files and bazel/rust.MODULE.bazel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the dependency cleanup.
No open issues 🎉
What changed in this PR
Removes unused Rust dependencies identified by Cargo’s new lints, keeping Cargo and Bazel dependency declarations aligned while preserving integration-test and WebAssembly requirements.
Changes:
- Removes unused regular, build, and workspace dependencies and updates lockfiles.
- Moves four integration-test-only dependencies to development dependencies, adjusting Bazel test targets where needed.
- Restricts the dummy randomness dependency to WebAssembly and removes direct
ringandrustc-hashspecifications while retaining their transitive dependencies.
| File | Description |
|---|---|
rs/validator/ingress_message/test_canister/Cargo.toml |
Removes unused runtime build-info. |
rs/validator/ingress_message/test_canister/BUILD.bazel |
Removes the matching build-info dependency. |
rs/tests/consensus/vetkd/Cargo.toml |
Removes unused consensus system-test utilities. |
rs/tests/consensus/vetkd/BUILD.bazel |
Removes the matching test-utilities dependency. |
rs/tests/consensus/utils/Cargo.toml |
Removes unused ic-http-utils. |
rs/tests/consensus/utils/BUILD.bazel |
Removes the matching HTTP utilities dependency. |
rs/tests/boundary_nodes/performance_test_common/Cargo.toml |
Removes unused boundary-node test utilities. |
rs/tests/boundary_nodes/performance_test_common/BUILD.bazel |
Removes the matching test-utilities dependency. |
rs/sns/test_utils/Cargo.toml |
Removes unused NNS governance dependency. |
rs/sns/governance/Cargo.toml |
Removes two unused build dependencies. |
rs/sns/governance/BUILD.bazel |
Aligns build dependencies with Cargo. |
rs/sns/governance/api/Cargo.toml |
Removes four unused API dependencies. |
rs/rust_canisters/stable_memory_integrity/Cargo.toml |
Moves canister-test to development dependencies. |
rs/rust_canisters/dfn_http_metrics/Cargo.toml |
Removes unused dfn_http. |
rs/node_rewards/rewards_calculation/Cargo.toml |
Removes unused CDK and NNS constants dependencies. |
rs/node_rewards/canister/api/Cargo.toml |
Removes unused nervous-system protobuf dependency. |
rs/nns/test_utils/Cargo.toml |
Removes unused node-rewards API dependency. |
rs/nns/test_utils/BUILD.bazel |
Removes the matching node-rewards API dependency. |
rs/nns/integration_tests/Cargo.toml |
Removes unused dfn_json and rustc-hash. |
rs/nns/integration_tests/BUILD.bazel |
Mirrors the NNS integration-test dependency removals. |
rs/nervous_system/integration_tests/Cargo.toml |
Removes unused dependencies and makes SNS CLI test-only. |
rs/nervous_system/integration_tests/BUILD.bazel |
Removes unused dependencies and assigns SNS CLI to three tests. |
rs/cup_explorer/Cargo.toml |
Removes unused registry client dependency. |
rs/crypto/internal/crypto_lib/seed/Cargo.toml |
Moves hex to development dependencies. |
rs/consensus/Cargo.toml |
Moves certification to development dependencies. |
rs/consensus/BUILD.bazel |
Removes certification from the malicious-consensus library. |
packages/ic-dummy-getrandom-for-wasm/Cargo.toml |
Removes getrandom on non-canister targets. |
packages/ic-dummy-getrandom-for-wasm/BUILD.bazel |
Selects getrandom only for wasm32-unknown-unknown. |
Cargo.toml |
Removes workspace ring and rustc-hash entries. |
Cargo.lock |
Records removed workspace-member dependency edges. |
Cargo.Bazel.toml.lock |
Removes direct ring and rustc-hash dependencies. |
Cargo.Bazel.json.lock |
Updates direct dependencies, checksum, and ring features. |
bazel/rust.MODULE.bazel |
Removes direct ring and rustc-hash crate specifications. |
Review effort: Balanced
There was a problem hiding this comment.
This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):
-
Update
unreleased_changelog.md(if there are behavior changes, even if they are
non-breaking). -
Are there BREAKING changes?
-
Is a data migration needed?
-
Security review?
How to Satisfy This Automatic Review
-
Go to the bottom of the pull request page.
-
Look for where it says this bot is requesting changes.
-
Click the three dots to the right.
-
Select "Dismiss review".
-
In the text entry box, respond to each of the numbered items in the previous
section, declare one of the following:
-
Done.
-
$REASON_WHY_NO_NEED. E.g. for
unreleased_changelog.md, "No
canister behavior changes.", or for item 2, "Existing APIs
behave as before.".
Brief Guide to "Externally Visible" Changes
"Externally visible behavior change" is very often due to some NEW canister API.
Changes to EXISTING APIs are more likely to be "breaking".
If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.
If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.
Reference(s)
For a more comprehensive checklist, see here.
GOVERNANCE_CHECKLIST_REMINDER_DEDUP
|
✅ No security or compliance issues detected. Reviewed everything up to ea2155f. Security OverviewDetected Code Changes
|
|
✅ No security or compliance issues detected. Reviewed everything up to ea2155f. Security OverviewDetected Code Changes
|
No canister changes.
Rust 1.100.0 (#12143) brought Cargo's new
cargo::unused_dependenciesandcargo::unused_workspace_dependencieslints (warn by default). On master,reports 30 unused
[dependencies]/[build-dependencies]entries and one unused[workspace.dependencies]entry. A run with default features reports the same 31.This PR removes the ones that are really unused. Where Bazel listed the same dependency, the PR removes it from the
BUILD.bazelfile too; the "already absent" rows below needed no Bazel change. It also removes thecrate.specof each removed workspace dependency frombazel/rust.MODULE.bazel.The lint says nothing about a dependency while another dependency of the same crate still pulls it in, so the removals exposed four more, which this PR also removes:
rustc-hashinic-nns-integration-tests, previously also reachable through its dev-dependencyic-nervous-system-integration-tests;ic-typesandicp-ledgerinic-sns-governance-api, previously also reachable throughic-nns-common;rustc-hashentry, once no member inherited it.In total the PR removes 21
[dependencies], 2[build-dependencies]and 2[workspace.dependencies]entries, and moves 4 entries to[dev-dependencies]. After it, the command above reports only the six false positives listed at the end, with default features as well.A
[dependencies]entry only counts as used if the library or a binary (including their unit tests) uses it. The lint therefore also reports dependencies that only integration tests (tests/*.rs) use. Deleting those would break the tests, so they move to[dev-dependencies]instead; the lint doesn't check that table.Removed
consensus-vetkd-system-testsic_consensus_system_test_utilsic-boundary-nodes-performance-test-commonic-boundary-nodes-system-test-utilsic_consensus_system_test_utilsic-http-utilsic-cup-exploreric-registry-clientic-nervous-system-integration-testsic-nns-test-utils-macrosic-nervous-system-integration-testsic-test-utilities-load-wasm,rustc-hashic-nns-integration-testsdfn_json,rustc-hashic-nns-test-utilsic-node-rewards-canister-apiic-node-rewards-canister-apiic-nervous-system-protorewards-calculationic-cdk,ic-nns-constantsdfn_http_metricsdfn_httpic-sns-governance-apiic-nns-common,ic-types,icp-ledger,itertoolsic-sns-test-utilsic-nns-governanceic-validator-ingress-message-test-canisterbuild-infoic-sns-governanceic-base-typesandprost-build(build.rsonly callsbuild_info_build)BUILD_DEPENDENCIESic-dummy-getrandom-for-wasmgetrandomon targets other thanwasm32-unknown-unknown, where all of the crate's code is compiled outdepsbecame aselect()onwasm32-unknown-unknownring(no member has inherited it since #11669) andrustc-hash(no member inherits it after the removals above)crate.specs removedMoved to
[dev-dependencies](only integration tests use them)ic-consensusic-consensus-certification:malicious_consensus; the test targets already list itic-crypto-internal-seedhex:seed_integrationic_stable_memory_integritycanister-testrust_ic_testic-nervous-system-integration-testsic-sns-clirust_tests that use itringandrustc-hashBoth stay transitive dependencies in Cargo and in Bazel.
ringcomes in throughrcgen,x509-parserand, on wasm32,quinn-proto, so itscrate.annotationstays. The removedcrate.specwas the only thing enabling ring'sstdfeature in Bazel. Cargo already builds ring withoutstd(seecargo tree -e features -i ring --target all), so after the repin Bazel matches Cargo. In ring 0.17.14,stdonly addsstd::error::Errorimpls forerror::Unspecifiedanderror::KeyRejected.rustc-hash1.1.0 comes in throughbindgen. Itscrate.specenabled no features and it has nocrate.annotation, so the repin only drops it from the direct dependencies.Kept: false positives
The lint only sees code compiled for the host. These dependencies are only used when compiling for wasm, so they stay:
ic0incanlog(#[cfg(target_family = "wasm")]) andic-canister-profiler(#[cfg(target_arch = "wasm32")])ic-cdkinic-nervous-system-time-helpers(#[cfg(target_arch = "wasm32")])ic-dummy-getrandom-for-wasmincycles-minting-canister,ic-ckbtc-minterandxnet-test. Nothing references it in Rust code. It turns on getrandom 0.2'scustomfeature, whichrandneeds to compile forwasm32-unknown-unknownwith Cargo.🤖 Generated with Claude Code