-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix confusing error and docs wrt. virtual manifests #4492
Merged
+35
−24
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8139a5d
Clarify docs on workspace members
RalfJung 4e5bfc9
update --help text for new implicit --all behavior
RalfJung 56274af
fix confusing error for virtual manifest with no member
RalfJung 682af71
get rid of Workspace::current() usage in cargo_{compile,doc}
RalfJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be surprised if only a single tests needs to be fixed after this change. However, if this is the case, that probably means that
current
function is almost not used anymore, and it might be a good idea to try to get rid of it altogether: probably all commands should work with virtual manifests just fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo test
says this is the only one that needs fixing.The code flow is a little spaghetti-esque currently, but I didn't want to change that as I have no idea how this is all architectured. Before #4335, when calling
cargo build
, what happens is thatPackages::from_flags
returnsPackages::Packages(&Vec::new())
, which then leads incompile_ws
(atcargo/src/cargo/ops/cargo_compile.rs
Line 234 in bf0b81a
current()
, which errored on virtual manifests. However, it seems we can also end up in that branch of there is a workspace but it is empty.With #4335 merged, that's in fact the only way to end up there, as
all
will always be set (unless-p
is given). I have no idea if there are other ways to havecompile_ws
callcurrent
, or if other places callcurrent
; grepping for such calls is doesn't really work due to the rather generic name of the function.Looking at
into_package_id_specs
(which has to return an empty list to end up in this branch ofcompile_ws
), the only way it can return empty is ifws.members()
is empty or if there was no-p
flag and this is not a workspace -- so, it seems actually that incompile_ws
, that branch will always trigger an error. If you want I can change that, and then see if there are other users ofcurrent
remaining, but notice that I have no idea what I am doing here. The question is do you trust the test suite coverage enough to let me still do such changes.^^There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out my analysis is incorrect. For non-virtual packages, we can still get
Packages::Packages(&[])
, and then it still uses that other path.current
will however of course always succeed, then.I suppose one could change
from_flags
to not ever returnPackages::Packages(&[])
, but instead fill in the current package name there or so; not sure how that would look.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So turns out there are a handful usages left:
Originally,
ws.current()
appeared as a stop gap to make workspace implementation feasible: with.current()
, it was possible to make Cargo workspace aware incrementally. So it would be great to get rid of it altogether some time in the future, but probably not right now.It seems to me that
cargo publish
still may hit this function from virtual manifest, and so this error message might be wrong in that case (and presumably this is not tested :( ).So... I think we definitely should update the documentation, however, I am not sure that updating this particular error message is correct for all cases... The simplest tactical fix would be to add a
if ws.members().is_empty()
check, and emit either old or new error message.The strategic fix (which should not be part of this PR) would be to look at the usages of
current
and try to get rid of them: I think those insidecargo_package
are unnecessary because it seems to me that we'll have a current package higher in the call stack anyway, and those in cargo_compile, cargo_run and cargo_doc should probably be folded intointo_package_id_specs
function.