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

fix(run): Disambiguate bins from different packages that share a name #15298

Merged
merged 12 commits into from
Mar 13, 2025

Conversation

epage
Copy link
Contributor

@epage epage commented Mar 11, 2025

What does this PR try to resolve?

This builds on the work done in #15199 to improve target selection errors to also disambiguate when the same binary name is used in multiple packages.

This also makes the errors from #15199 more consistent with the rustc style guide and reduces code duplication.

Fixes #13312

How should we test and review this PR?

This is a first pass and does not do the full --package foo --bin bar syntax. I wanted to focus on the basic functionality before we iterated on it, e.g. investigating how well we can predict the CLI flags, how much noise they might add, etc.

Additional information

@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 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-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) Command-run S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 11, 2025
Comment on lines 1023 to 1024
bin a in package foo
example b in package foo
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to quote the names? Unsure if it is more readable

Suggested change
bin a in package foo
example b in package foo
bin `a` in package foo
example `b` in package foo

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 expect we're very inconsistent about our quoting and would be good to decide when we should and try to clean things up.

@weihanglo weihanglo enabled auto-merge March 13, 2025 14:30
@weihanglo weihanglo added this pull request to the merge queue Mar 13, 2025
Merged via the queue into rust-lang:master with commit bc577dc Mar 13, 2025
21 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Update cargo

15 commits in ab1463d632528e39daf35f263e10c14cbe590ce8..6cf8267012570f63d6b86e85a2ae5627de52df9e
2025-03-08 01:45:05 +0000 to 2025-03-14 15:25:36 +0000
- feat(package): add --exclude-lockfile flag (rust-lang/cargo#15234)
- Redox OS is part of the unix family (rust-lang/cargo#15307)
- docs(ref): Mention `x.y.*` as a kind of version requirement to avoid. (rust-lang/cargo#15310)
- fix(run): Disambiguate bins from different packages that share a name (rust-lang/cargo#15298)
- cargo vendor: Add context which workspace failed to resolve (rust-lang/cargo#15297)
- docs(ref): Note that target-edition is deprecated (rust-lang/cargo#15292)
- refactor(toml): Centralize target descriptions (rust-lang/cargo#15291)
- docs(refs): Add `unsafe` to `extern` while using build scripts in Cargo Book (rust-lang/cargo#15294)
- Replace unmaintained humantime crate with jiff (rust-lang/cargo#15290)
- Add terminal integration via ANSI OSC 9;4 sequences (rust-lang/cargo#14615)
- feat: add completions for add --path (rust-lang/cargo#15288)
- Allow `term.progress.when` to default (rust-lang/cargo#15287)
- docs: spelling and grammar fixes (rust-lang/cargo#15284)
- chore(deps): update cargo-semver-checks to v0.40.0 (rust-lang/cargo#15282)
- Typo fixes (rust-lang/cargo#15280)

r? ghost
@rustbot rustbot added this to the 1.87.0 milestone Mar 15, 2025
@epage epage deleted the duplicate branch March 17, 2025 18:26
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) Command-run 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.

Error for cargo run --bin {name} should notice multiple packages have the same binary name
3 participants