Skip to content

fix(rust): inherit Cargo workspace dependency versions - #614

Open
vibgrate-team wants to merge 1 commit into
mainfrom
cursor/cargo-workspace-dep-inheritance-8f56
Open

vibgrate-team wants to merge 1 commit into
mainfrom
cursor/cargo-workspace-dep-inheritance-8f56

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Summary

parseCargoDepAttrs treated workspace = true as “no version,” so a member crate such as serde = { workspace = true } was reported with currentSpec * even when the workspace root pinned serde = "1.0" under [workspace.dependencies].

The scan now finds the nearest Cargo.toml at or above the member, and inside the scan root, that contains a [workspace] table. That file’s [workspace.dependencies] pins are applied when a dependency table sets workspace = true and does not set its own version:

  • A string pin (serde = "1.0") and a table pin (version = "…"), including [workspace.dependencies.<crate>], both supply the version.
  • A local version = "…" wins over the workspace pin.
  • features and optional are copied from the pin only when the local table does not set them. A local features list replaces the pin’s list. optional = false overrides a workspace optional = true.
  • Path-only and git-only tables, and path-only or git-only workspace pins, stay spec *. No version is invented.
  • Dev and build rows still stay devDependencies when the inherited pin sets optional = true.

Related issues

Closes #604

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed
  • Determinism preserved — identical input still produces identical
    graph.json / report output (content-hashed IDs, stable sorts; no time,
    randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)

Notes for reviewers

Docs were left unchanged. The Cargo notes in DOCS.md and docs/sbom-dependency-scope.md describe lockfile resolution and dependency sections, and they do not describe workspace inheritance.

The fixture under test/fixtures/cargo-workspace-member/ covers a member crate, a nearer nested workspace (so the scan root pin is not used), and a package that is itself the workspace root. pnpm test (5681 tests), pnpm lint, and pnpm typecheck passed locally. Lint still reports five existing unused-variable warnings outside this change.

Open in Web Open in Cursor 

Member crates that set workspace = true and omit version now use the
nearest workspace root [workspace.dependencies] pin. A local version,
features list, or optional flag still wins. Path-only and git-only
tables stay spec *.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
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: Cargo workspace = true dependencies stay at * instead of inheriting from [workspace.dependencies]

2 participants