fix: Avoid panic for package specs with an empty fragment#16754
Merged
0xPoe merged 2 commits intorust-lang:masterfrom Mar 15, 2026
Merged
fix: Avoid panic for package specs with an empty fragment#167540xPoe merged 2 commits intorust-lang:masterfrom
0xPoe merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
| r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
0xPoe approved these changes Mar 15, 2026
| MaybeFilePath { spec: String, maybe_url: String }, | ||
| | ||
| #[error("pkgid url cannot have an empty fragment")] | ||
| EmptyFragment, |
Member
There was a problem hiding this comment.
This is a non-public error kind, so I believe this is acceptable.
cc: @weihanglo Not sure if you have any thoughts on it.
Comment on lines 773 to +775
| err!("https://crates.io/1foo#1.2.3", ErrorKind::NameValidation(_)); | ||
| | ||
| err!("https://example.com/foo#", ErrorKind::EmptyFragment); |
Member
There was a problem hiding this comment.
Suggested change
| err!("https://crates.io/1foo#1.2.3", ErrorKind::NameValidation(_)); | |
| err!("https://example.com/foo#", ErrorKind::EmptyFragment); | |
| err!("https://crates.io/1foo#1.2.3", ErrorKind::NameValidation(_)); | |
| err!("https://example.com/foo#", ErrorKind::EmptyFragment); |
weihanglo approved these changes Mar 15, 2026
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 20, 2026
Update cargo submodule 13 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..d81735547e5f2844322f36380ab66f549cda11b9 2026-03-13 14:34:16 +0000 to 2026-03-20 13:20:51 +0000 - cargo clean: Validate that target_dir is not a file (rust-lang/cargo#16765) - fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768) - Update tar to 0.4.45 (rust-lang/cargo#16771) - chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762) - refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763) - fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760) - fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722) - refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757) - test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705) - fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754) - refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752) - refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749) - refactor(install): Remove dead code (rust-lang/cargo#16718) r? ghost
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 21, 2026
Update cargo submodule 14 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..e84cb639edfea2c42efd563b72a9be0cc5de6523 2026-03-13 14:34:16 +0000 to 2026-03-21 01:27:07 +0000 - Fix symlink_and_directory when running in a long target dir name (rust-lang/cargo#16775) - cargo clean: Validate that target_dir is not a file (rust-lang/cargo#16765) - fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768) - Update tar to 0.4.45 (rust-lang/cargo#16771) - chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762) - refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763) - fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760) - fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722) - refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757) - test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705) - fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754) - refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752) - refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749) - refactor(install): Remove dead code (rust-lang/cargo#16718)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
Fixes #16731
PackageIdSpec::parsepanics on URL package specs with an empty fragment (...#)This change would return
PackageIdSpecError(ErrorKind::EmptyFragment)instead of panicingHow to test and review this PR?
Earlier the following code would panic
but now it should return an error