workplace.default-members
and workspace.exclude
don't always work well together.
#8460
Labels
A-workspaces
Area: workspaces
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
One of the listed use cases for
workspace.exclude
in the documentation is for when you are "using a glob pattern and you want to remove a directory".This is very handy, and lets
workspace.members
stay pretty clean if your project structure is mostly consistent. Unfortunately it isn't similarly supported byworkspace.default-members
, which must be a strict subset ofworkspace.members
.To see what I mean, here's an example I hit recently (this is based on the project layout of https://github.com/mozilla/application-services -- but simplified).
Essentially, I think something like the following code should work:
However, if you try this, you get errors like "
<project>/components/support/android
is listed in workspace’s default-members but is not a member", because "When specified, default-members must expand to a subset of members."Possible solution
I think that rule makes sense, and can help catch bugs, so I'm not saying it should be removed or weakened. I think my issue can be fixed by just tweaking the way that rule is implemented rather than removing it:
Instead of checking that
workspace.default-members
is a subset of(workspace.members - workspace.exclude)
(which is what cargo does now), cargo should check thatdefault-members
is a subset ofmembers
.Conceptually, I think this is really just a change of when the check happens -- e.g. IMO it should happen prior to applying exclude to members, as opposed to afterwards.
(Of course, I think you will also need to apply
workspace.exclude
toworkspace.default-members
to produce the computed set of default members, but that's easy and if the above holds, it shouldn't remove anything from it except what was removed fromworkspace.members
)Anyway, thanks for your time.
P.S. Sorry that this doesn't fit an issue template. I wrote it out in a text editor first to make sure it made sense, but now it's hard to adapt and I don't really have time to rewrite it. Let me know if you need any clarification.
Also, since it's kinda halfway between bug and feature request, the template didn't really made tons of sense, I think.
I'm also sorry that the issue title is not very descriptive.
The text was updated successfully, but these errors were encountered: