-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Problem
cargo rustc
is inconsistent about when it will run.
-
cargo rustc
in a workspace with multiple members will not run, erroring witherror: manifest path './Cargo.toml' is a virtual manifest, but this command requires running against an actual package in this workspace
-
cargo rustc -p some-member --lib
will run, invoking rustc once if there's a lib target. -
cargo rustc -p some-member --all-targets
will run, invoking rustc multiple times if there are multiple targets within that member. -
cargo rustc -p some-member --lib -- -L/some/dir
will run, invoking rustc once with -L/some/dir as an argument -
cargo rustc -p some-member --all-targets -- -L/some/dir
will not run, erroring withextra arguments to rustc can only be passed to one target, consider filtering
It's not clear why 1. and 5. are prohibited, the behavior here seems somewhat arbitrary compared with other commands like cargo check
.
If we can already run rustc multiple times when a member has multiple targets, why can't we run it multiple times on multiple workspace members?
If we can already run rustc once with an additional flag when there is one target, why can't we run it with an additional flag when there are multiple targets?
Related: #2642. It's likely things have changed since then; it was raised in 2016.
Proposed Solution
- Teach
cargo rustc
to run on multiple members in a workspace. - Teach
cargo rustc
to pass additional flags even when multiple targets are selected.
I don't think either of these would be a breaking change.
Notes
No response