Repository navigation
Copy only inherited workspace dependencies into generated manifest - #344
Merged
dtolnay merged 1 commit intoOct 7, 2026
Conversation
Cargo 1.100 warns about every [workspace.dependencies] entry that no workspace member inherits (cargo::unused_workspace_dependencies). The generated manifest copied the whole table, but the generated package inherits only the entries that the crate under test uses, so every Cargo invocation by trybuild warned about all the others. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tamaro-skaljic
deleted the
fix/issue-343-unused-workspace-dependency-warnings
branch
October 8, 2026 03:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Issue
Fixes #343.
Cargo's new warn-by-default lint
cargo::unused_workspace_dependencies, in beta 1.100 and nightly, warns about every[workspace.dependencies]entry that no workspace member inherits.trybuild copies the whole table into the generated manifest, but the generated package inherits only the entries that the crate under test uses. So every Cargo invocation by trybuild warns once for each of the other entries. The warnings appear while the dependencies build, and again in the STDERR block of every
passtest.The Solution
With this PR trybuild copies only the entries that the generated package inherits with
workspace = true, from its[dependencies], which include the dev-dependencies, or from any[target.*.dependencies].Dropping the other entries can't change resolution, because Cargo only uses a workspace dependency through a member that inherits it.
Considered Alternatives
Allowing the lint instead doesn't work:
[lints.cargo]in the generated package doesn't affect this workspace-level lint.[workspace.lints.cargo]silences it, but Cargo without stable cargo lints, such as 1.98.1 and 1.93.0, then warnsunused manifest key `lints.cargo`on every invocation.Verification / Testing
The test writes a fixture workspace into
CARGO_TARGET_TMPDIR. There, the crate under test inherits workspace dependencies through[dependencies],[dev-dependencies](withtrybuilditself),[build-dependencies],[target.'cfg(unix)'.dependencies]and[target.'cfg(windows)'.dev-dependencies]. A second member inherits the crate under test and an entry of its own.The test runs
cargo testthere, over apass+compile_failsuite and acompile_fail-only suite, and asserts three things:the run succeeds;
nothing prints
unused workspace dependency;the generated
[workspace.dependencies]holds exactly the four inherited entries.Building the fixture compiles trybuild a second time, which took about 16 seconds on a cold cache here and 7 seconds warm.
On Windows, it also needs a checkout path shorter than about 118 characters, because link.exe can't write the deeper paths of the fixture's binaries.
Results on Windows 11, with
RUSTFLAGS=-Dwarnings:build-dep,memberandother-depbuild-dep,memberandother-depWith the fix, trybuild's own
cargo testpasses on nightly with CI'sRUSTFLAGS="-Dwarnings -Zrandomize-layout", and on 1.98.1 and 1.93.0.cargo clippy --tests -- -Dclippy::all -Dclippy::pedanticis clean, and so is rustfmt.Before the fix: the STDERR block of the fixture's
passtest on nightlypr-343-test-results.md
🤖 Generated with Claude Code