← LeaderboardThe Skill Leaderboard

rust-cargo-feature-unification

Use when a Rust workspace builds but a package fails on its own, a dependency feature appears unexpectedly, or CI needs reliable Cargo feature checks.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: rust-cargo-feature-unificationdescription: "Use when a Rust workspace builds but a package fails on its own, a dependency feature appears unexpectedly, or CI needs reliable Cargo feature checks."category: developmentrisk: criticalsource: selfsource_type: selfdate_added: "2026-12-01"author: ShianMiketags: [rust, cargo, cargo-features, workspace, dependency-resolution, ci]

Rust Cargo Feature Unification

When to Use

  • cargo check --workspace succeeds while checking one workspace package fails on a feature-gated import.
  • A release build enables default features even though a dependency declaration uses default-features = false.
  • CI needs to verify a package, target, or feature selection that is built independently for shipping.

Prerequisites

  • Record cargo --version, rustc --version, the workspace resolver, and the exact package, target, and feature flags used when shipping.
  • Inspect the workspace manifest, the failing package's manifest, and the dependency's feature declarations for the locked version.
  • Use the documented fixture in a scratch directory. It uses only local Cargo packages.

1. Compare the combined and independent builds

  1. Reproduce the passing workspace command and the failing package command as separate invocations. Match the release target and feature flags when those differ from the host defaults.
  2. Find which selected package asks for the dependency feature. Cargo combines feature requests on shared normal dependencies when building multiple workspace packages in one invocation. Resolver 2 separates some target, build, and dev contexts while shared normal dependency features can still unify.
  3. Compare the inverse feature tree in both build scopes. If more than one dependency version matches, use a version-qualified package spec.
cargo tree --workspace -e features -i wire-codec
cargo tree -p worker -e features -i wire-codec
cargo check --workspace --locked
cargo check -p worker --locked

2. Declare the requirement where the API is used

  1. When a package always calls a feature-gated dependency API, request that feature on that package's dependency declaration. Keep workspace.dependencies settings aligned with requirements shared by every inheriting package.
  2. When the caller's capability is optional, forward its named feature to the dependency feature and gate the call sites. Test both with and without that capability.
  3. Interpret default-features = false as a choice on that dependency declaration. A different selected edge can still request the default feature. Follow the feature tree before changing dependency versions or resolver settings.

3. Verify the combinations CI actually ships

  1. Check each independently shipped package in a separate invocation. A workspace command, a multi-package command, or --all-features can enable features absent from a standalone build.
  2. Check a production build separately from tests when dev-dependencies could enable a missing feature. Add an explicit --no-default-features check for a configuration users can actually run.
  3. For automation, inspect --message-format=json compiler diagnostics and compiler-artifact features. Use Cargo.lock to pin versions and verify active build features with the selected invocation.

Example

Run the three-package workspace fixture. It verifies that a sibling's feature request masks a missing declaration and that the corrected worker checks and runs on its own.

Limitations

  • The fixture targets normal dependencies in one workspace on the host. It does not exercise target-specific dependencies, build scripts, multiple dependency versions, or cross-compilation.
  • cargo check verifies compilation without a final executable link. Use the actual build or run command to verify shipping artifacts.

Safety and Side Effects

  • Cargo checks write target files and can update Cargo.lock unless the command uses --locked. The fixture creates its lockfile and build output in a fresh temporary workspace and runs offline.
  • Manifest and CI changes alter the resolved or active feature set. Review build flags and verify every affected shipping command.

Related Skills and Documentation