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

Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand #11170

Merged

Conversation

basile-henry
Copy link
Contributor

Fixes #11149

@rust-highfive
Copy link

r? @epage

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2022
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Looks great!

Could you add a test case under tests/testsuite/cargo_alias_config.rs to exercise this behaviour? Thank you!

@ehuss
Copy link
Contributor

ehuss commented Oct 2, 2022

My intent with the concern at #11099 (comment) is to just not warn at all for a built-in alias. Cargo doesn't warn about built-in commands shadowing a user-installed command. Why would a built-in alias be different? There isn't much the user can do to squelch the warning other than uninstall the command, which would prevent usage in older toolchains.

@weihanglo
Copy link
Member

Oops. That's my fault. I understood it wrong. I agree with ehuss, and we might follow what ehuss suggests.

@epage
Copy link
Contributor

epage commented Oct 4, 2022

My intent with the concern at #11099 (comment) is to just not warn at all for a built-in alias. Cargo doesn't warn about built-in commands shadowing a user-installed command. Why would a built-in alias be different? There isn't much the user can do to squelch the warning other than uninstall the command, which would prevent usage in older toolchains.

I thought we do warn when shadowing aliases

            (Some(_), Ok(Some(_))) => {
                // User alias conflicts with a built-in subcommand
                config.shell().warn(format!(
                    "user-defined alias `{}` is ignored, because it is shadowed by a built-in command",
                    cmd,
                ))?;
            }

@ehuss
Copy link
Contributor

ehuss commented Oct 4, 2022

The situation that doesn't warn today is when an installed third-party subcommand is being shadowed by a built-in command. The expected scenario where this happens is when cargo subsumes an existing command, and is more of a transition (like cargo-tree moving from external to internal).

That's a warning for a user alias (something configured in config.toml) being shadowed by a built-in command. The expected scenario there is that the user is trying to change the default behavior of an existing command, something we generally don't want them to do.

The scenario for this PR is a third-party subcommand being shadowed by a built-in alias. That's more like the former scenario, where cargo is internalizing that third-party command. There is nothing the user can do to remove that built-in alias, and from their perspective there isn't much difference from a "built-in command" and a "built-in alias" as they are mostly indistinguishable.

@epage
Copy link
Contributor

epage commented Oct 13, 2022

@basile-henry do you expect to have time to apply @ehuss feedback soon or would you be ok with someone else taking over? #11149 was deferred out of #11099 and I think we'd like to get all changes for #11099 committed before the beta branch that happens in November.

@basile-henry
Copy link
Contributor Author

Sorry @epage, I had forgotten about this PR. I have pushed a commit following @ehuss' suggestion.

There is nothing the user can do to remove that built-in alias

I think if you're the author of that third-party command that is being shadowed by a built-in alias, you might consider naming your third-party command something else. But I see your point, they would likely notice the issue fairly quickly anyway. 👍

@basile-henry
Copy link
Contributor Author

Should I squash/rebase the commits? What's the usual cargo policy?

@epage
Copy link
Contributor

epage commented Oct 13, 2022

@basile-henry I don't think we are too strict on commits, otherwise we'd have bors squash or we'd have a tool to help enforce commits were somewhat in shape.

For me personally, I clean up my commits so that they are atomic and clearly communicate the intended change. Let us know if you'd like to do that and I'll hold off on merging

@basile-henry basile-henry force-pushed the basile-henry/built-in-alias-shadow branch from 5fe8904 to 5cedfbb Compare October 13, 2022 20:05
@basile-henry
Copy link
Contributor Author

I'm not sure how to fix the failing tests. The two tests that are failing have nothing to do with this PR. It looks like the difference is around which type of quotes are emitted in an error message. And these tests pass on my machine 😅

@epage
Copy link
Contributor

epage commented Oct 13, 2022

#11235 fixed the failing test. A new release of clap came out and we have tests that are sensitive to text output but don't have a lock file to hold us to a specific version, so the tests failed.

@basile-henry
Copy link
Contributor Author

I can rebase and remove my workaround once #11235 goes in 👍

@epage
Copy link
Contributor

epage commented Oct 13, 2022

Its merged

@basile-henry basile-henry force-pushed the basile-henry/built-in-alias-shadow branch from 83e0c66 to 3ff6d9e Compare October 13, 2022 21:23
@epage
Copy link
Contributor

epage commented Oct 13, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 13, 2022

📌 Commit 3ff6d9e has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2022
@bors
Copy link
Collaborator

bors commented Oct 13, 2022

⌛ Testing commit 3ff6d9e with merge b332991...

@bors
Copy link
Collaborator

bors commented Oct 13, 2022

☀️ Test successful - checks-actions
Approved by: epage
Pushing b332991 to master...

@bors bors merged commit b332991 into rust-lang:master Oct 13, 2022
Dylan-DPC pushed a commit to Dylan-DPC/rust that referenced this pull request Oct 15, 2022
12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440
2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 15, 2022
Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440 2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 15, 2022
Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440 2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 15, 2022
Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440 2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
lyming2007 pushed a commit to lyming2007/rust that referenced this pull request Oct 21, 2022
12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440
2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
@ehuss ehuss added this to the 1.66.0 milestone Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

built-in alias is shadowing external subcommand but Cargo warns "user-defined alias is shadowing"
6 participants