-
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
Get all members as available targets
even though default-members was specified.
#15199
base: master
Are you sure you want to change the base?
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
[ERROR] "--bin" takes one argument. | ||
Available binaries: | ||
crate1 | ||
crate2 |
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.
Fixes #14544
If the fix only adds bins from all targets to this error theo it will lead to user frustration as they then add --bin crate2
and it fails without saying why.
The core problem in the Issue is the --bin crate2
error message. It only suggested touching this error message as an addendum and suggested it show what the needed package is. I agree with that with the caveat that we need to double check if our completion or fish's completion script uses the output from this. While this is meant for humans and can change, we still want to play nice with these.
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.
While the focus of #14544 is now included, two of the 3 improvements still require investigating their impact on cargo's and fish's completions and one still has the issue of showing values that can't be used.
3c409c9
to
ee13fd6
Compare
ee13fd6
to
d1ed4c8
Compare
d1ed4c8
to
7389aff
Compare
fn get_targets_from_other_packages( | ||
&self, | ||
filter_fn: impl Fn(&Target) -> bool, | ||
) -> CargoResult<Option<(String, String)>> { | ||
let packages = Packages::All(Vec::new()).get_packages(self.ws)?; | ||
let targets = packages.into_iter().find_map(|pkg| { | ||
if let Some(target) = pkg | ||
.manifest() | ||
.targets() | ||
.iter() | ||
.find(|target| filter_fn(target)) | ||
{ | ||
Some((pkg.name().to_string(), target.name().to_string())) | ||
} else { | ||
None | ||
} | ||
}); | ||
|
||
Ok(targets) | ||
} |
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.
The name implies this returns multiple but it only returns the first.
What should we do when there are multiple?
7389aff
to
3d78767
Compare
…ave the `Target`.
3d78767
to
7735088
Compare
[HELP] a target with a similar name exists: `a` | ||
|
||
|
||
"#]]) |
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.
This extra newline doesn't seem right
tests/testsuite/workspaces.rs
Outdated
[ERROR] no bin target named `crate2`. | ||
Available bin targets: | ||
another | ||
Available bin targets in crate2: |
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.
Should we say
no bin target named
crate2
in crate1 package.
or
no bin target named
crate2
in default-run packages
Without that extra context, I worry users might get confused because they know might know these targets come from other packages but not realize it
(this should probably be its own commit)
tests/testsuite/workspaces.rs
Outdated
[ERROR] no bin target named `crate2`. | ||
Available bin targets: | ||
another | ||
Available bin targets in crate2: |
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.
For cases like this where the bin and target name are redundant, should we clarify this
Available bin targets in package
crate2
:
What does this PR try to resolve?
The old behavior gets members from
default-members
if specified in a virtual workspace, this PR gets all workspace members forAvailable
target hints.Fixes #14544
How should we test and review this PR?
The first commit added the test, the second commit addressed the issue.
Additional information