-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(info): resolve underscore vs hyphen mismatch in schema lookup #16455
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(info): resolve underscore vs hyphen mismatch in schema lookup #16455
Conversation
|
i will add one more commit for the functionality change, before that please check this code if it is good or not? |
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 think the test looks good and does what we want. Though rustfmt is failing so you'll need to fix that.
otherwise I think you should be good to start implementing the change :)
b577f22 to
d371702
Compare
This comment has been minimized.
This comment has been minimized.
d371702 to
e590ced
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
From discussion in #general > writing test for cargo @ 💬
Currently Cargo will prioritize crates that match the current workspace's MSRV (ref) when selecting the package. Not sure how others feel about this behavior but I wanted to call this out during review. Edit: Apparently crates.io does not allow publishing crates with the same name as an existing crate with hyphens instead of underscores and vise versa. So my concern here might not be a problem in practice. Though unsure if we need to worry about 3rd party registries. I don't see this behavior specified in the Cargo registry API docs. |
ee9afc3 to
3e8367f
Compare
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 just renamed the PR title, as we usually only include one type in the Conventional Message. |
tests/testsuite/cargo_info/crate_name_normalization_from_hyphen_to_underscore/mod.rs
Show resolved
Hide resolved
11b9042 to
dea0635
Compare
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.
Thanks @dhruv-38 for implementing this and @ranger-ross for reviewing it!
Update cargo submodule 5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1 2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000 - fix: preserve `dep_name` for build script metadata (rust-lang/cargo#16494) - refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492) - Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490) - Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491) - fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455) --- An extra submodule update right after <#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
What does this PR try to resolve?
This PR makes
cargo infohandle crate names with underscores (_) the same way as cargo add, by translating underscores to hyphens (-) and emitting a warning and also the other way around.Currently,
cargo info my_packageandcargo info my-cratefails even when the actual crate name ismy-packageandmy_craterespectively, which is surprising and inconsistent with other Cargo commands. This change aligns cargo info withexisting behavior and improves usability.
Fixes #16442
How to test and review this PR?
Run the added tests:
cargo test --test testsuite -- cargo_info::crate_name_normalization_from_hyphen_to_underscorecargo test --test testsuite -- cargo_info::crate_name_normalization_from_underscore_to_hyphenManually verify behavior:
cargo info esp_printlncargo info big-sThis should succeed, show a warning about translating
_to-and also-to_, and display the crate info.The change includes a test that captures the previous failing behavior and verifies the new expected output.