Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

linyihai
Copy link
Contributor

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 for Available 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

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2025
[ERROR] "--bin" takes one argument.
Available binaries:
crate1
crate2
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linyihai maybe we should just split this PR so we can move forward the --bin foo case and deal with --bin separately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us focus on the --bin foo case case

@rustbot rustbot added the A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) label Feb 19, 2025
@linyihai linyihai force-pushed the available-packages branch 2 times, most recently from 3d78767 to 7735088 Compare February 21, 2025 14:37
Comment on lines 2842 to 2843
[ERROR] no bin target named `crate2`.
Available bin targets:
another
Available bin targets in crate2:
Copy link
Contributor

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:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the targets that it seems not nessary.

@linyihai linyihai force-pushed the available-packages branch 2 times, most recently from 2ae0f25 to c3aa679 Compare February 23, 2025 04:48
@@ -286,7 +286,7 @@ impl<'a> UnitGenerator<'a, '_> {
if !suggestion.is_empty() {
write!(
msg,
"no {} target {} `{}`{}{}",
"no {} target {} `{}` in default-run packages{}{}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're always saying in default-run packages even if the user explicitly said --package foo?

Comment on lines +251 to 259
let pattern = build_glob(target_name)?;
let filter = |t: &Target| {
if is_glob {
is_expected_kind(t) && pattern.matches(t.name())
} else {
is_expected_kind(t) && t.name() == target_name
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A refactor for pulling out the filter creation should probably be in its own refactor commit

Comment on lines 2808 to 2830
[HELP] a target with a similar name exists: `crate1`
Available bin in `crate2` package:
crate2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these have separate [HELP] prefixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cli Area: Command-line interface, option parsing, etc. A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workspace.default-members causes cargo run --bin from-other-crate to fail with an unhelpful error
4 participants