Repository navigation
refactor(parser): Simplify dep source validation - #17506
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
CC @adamgemmell Because changes the order of evaluation, this is blocked on adding built-in sources. I also need to write a test for the bug I found with this but not bothering until this is unblocked and rebased.. |
|
I suspect there are other types of validation that could be consolidated into this, including
|
| orig.registry_index.as_ref(), | ||
| ) { | ||
| (Some(_git), Some(_path), _, _) => { | ||
| let git_source = if git.is_some() || branch.is_some() || tag.is_some() || rev.is_some() { |
There was a problem hiding this comment.
Yeah this looks nicer, and if growing too large, each source construction can be extracted separately.
This comment has been minimized.
This comment has been minimized.
2080b5f to
9b89531
Compare
This case is going to be generalized as an "unused field" warning but panics today because builtin sources panic.
5452a29 to
d1620e0
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. |
| let path_kind = if let Some(path) = path { | ||
| Some(path) | ||
| } else { | ||
| None | ||
| }; |
There was a problem hiding this comment.
nit: I guess you just wanted it to be symmetric so didn't do this?
| let path_kind = if let Some(path) = path { | |
| Some(path) | |
| } else { | |
| None | |
| }; | |
| let path_kind = path |
Update cargo submodule 12 commits in 3960fa69bb617e3d93c4ddc087c1b32bf12ad907..15be64aa0859b5c36f7a86d52f7aa0db44ba4d84 2026-10-12 19:29:05 +0000 to 2026-10-20 16:03:21 +0000 - feat(prerelease): support `[patch]` with `-Zprerelease` (rust-lang/cargo#17613) - chore(gh): Overhaul PR template (rust-lang/cargo#17612) - fix(util-schemas): compile out the file-path hint where url can't build it (rust-lang/cargo#17600) - feat(build-std): Add build.build-std.when and crates config keys (rust-lang/cargo#17602) - refactor(confg): Create a config abstraction (rust-lang/cargo#17606) - fix(config): Apply dotted tuple support for rustflags (rust-lang/cargo#17594) - Feat: Shell completion show all the packages having the feature (rust-lang/cargo#17574) - fix(config): Don't load registry config from credentials.toml (rust-lang/cargo#17599) - fix(fingerprint): choose a stable path when source mtimes tie (rust-lang/cargo#17521) - Update gix crates to address CVE-2026-82248, CVE-2026-82249, and CVE-2026-82250, and update git utils.rs to accommodate gix-url v0.38.0. (rust-lang/cargo#17484) - fix: check crate type when pruning `-L` paths (rust-lang/cargo#17589) - refactor(parser): Simplify dep source validation (rust-lang/cargo#17506) r? ghost
Update cargo submodule 12 commits in 3960fa69bb617e3d93c4ddc087c1b32bf12ad907..15be64aa0859b5c36f7a86d52f7aa0db44ba4d84 2026-10-12 19:29:05 +0000 to 2026-10-20 16:03:21 +0000 - feat(prerelease): support `[patch]` with `-Zprerelease` (rust-lang/cargo#17613) - chore(gh): Overhaul PR template (rust-lang/cargo#17612) - fix(util-schemas): compile out the file-path hint where url can't build it (rust-lang/cargo#17600) - feat(build-std): Add build.build-std.when and crates config keys (rust-lang/cargo#17602) - refactor(confg): Create a config abstraction (rust-lang/cargo#17606) - fix(config): Apply dotted tuple support for rustflags (rust-lang/cargo#17594) - Feat: Shell completion show all the packages having the feature (rust-lang/cargo#17574) - fix(config): Don't load registry config from credentials.toml (rust-lang/cargo#17599) - fix(fingerprint): choose a stable path when source mtimes tie (rust-lang/cargo#17521) - Update gix crates to address CVE-2026-82248, CVE-2026-82249, and CVE-2026-82250, and update git utils.rs to accommodate gix-url v0.38.0. (rust-lang/cargo#17484) - fix: check crate type when pruning `-L` paths (rust-lang/cargo#17589) - refactor(parser): Simplify dep source validation (rust-lang/cargo#17506) r? ghost
Update cargo submodule 12 commits in 3960fa69bb617e3d93c4ddc087c1b32bf12ad907..15be64aa0859b5c36f7a86d52f7aa0db44ba4d84 2026-10-12 19:29:05 +0000 to 2026-10-20 16:03:21 +0000 - feat(prerelease): support `[patch]` with `-Zprerelease` (rust-lang/cargo#17613) - chore(gh): Overhaul PR template (rust-lang/cargo#17612) - fix(util-schemas): compile out the file-path hint where url can't build it (rust-lang/cargo#17600) - feat(build-std): Add build.build-std.when and crates config keys (rust-lang/cargo#17602) - refactor(confg): Create a config abstraction (rust-lang/cargo#17606) - fix(config): Apply dotted tuple support for rustflags (rust-lang/cargo#17594) - Feat: Shell completion show all the packages having the feature (rust-lang/cargo#17574) - fix(config): Don't load registry config from credentials.toml (rust-lang/cargo#17599) - fix(fingerprint): choose a stable path when source mtimes tie (rust-lang/cargo#17521) - Update gix crates to address CVE-2026-82248, CVE-2026-82249, and CVE-2026-82250, and update git utils.rs to accommodate gix-url v0.38.0. (rust-lang/cargo#17484) - fix: check crate type when pruning `-L` paths (rust-lang/cargo#17589) - refactor(parser): Simplify dep source validation (rust-lang/cargo#17506) r? ghost
Update cargo submodule 12 commits in 3960fa69bb617e3d93c4ddc087c1b32bf12ad907..15be64aa0859b5c36f7a86d52f7aa0db44ba4d84 2026-10-12 19:29:05 +0000 to 2026-10-20 16:03:21 +0000 - feat(prerelease): support `[patch]` with `-Zprerelease` (rust-lang/cargo#17613) - chore(gh): Overhaul PR template (rust-lang/cargo#17612) - fix(util-schemas): compile out the file-path hint where url can't build it (rust-lang/cargo#17600) - feat(build-std): Add build.build-std.when and crates config keys (rust-lang/cargo#17602) - refactor(confg): Create a config abstraction (rust-lang/cargo#17606) - fix(config): Apply dotted tuple support for rustflags (rust-lang/cargo#17594) - Feat: Shell completion show all the packages having the feature (rust-lang/cargo#17574) - fix(config): Don't load registry config from credentials.toml (rust-lang/cargo#17599) - fix(fingerprint): choose a stable path when source mtimes tie (rust-lang/cargo#17521) - Update gix crates to address CVE-2026-82248, CVE-2026-82249, and CVE-2026-82250, and update git utils.rs to accommodate gix-url v0.38.0. (rust-lang/cargo#17484) - fix: check crate type when pruning `-L` paths (rust-lang/cargo#17589) - refactor(parser): Simplify dep source validation (rust-lang/cargo#17506) r? ghost
Update cargo submodule 12 commits in 3960fa69bb617e3d93c4ddc087c1b32bf12ad907..15be64aa0859b5c36f7a86d52f7aa0db44ba4d84 2026-10-12 19:29:05 +0000 to 2026-10-20 16:03:21 +0000 - feat(prerelease): support `[patch]` with `-Zprerelease` (rust-lang/cargo#17613) - chore(gh): Overhaul PR template (rust-lang/cargo#17612) - fix(util-schemas): compile out the file-path hint where url can't build it (rust-lang/cargo#17600) - feat(build-std): Add build.build-std.when and crates config keys (rust-lang/cargo#17602) - refactor(confg): Create a config abstraction (rust-lang/cargo#17606) - fix(config): Apply dotted tuple support for rustflags (rust-lang/cargo#17594) - Feat: Shell completion show all the packages having the feature (rust-lang/cargo#17574) - fix(config): Don't load registry config from credentials.toml (rust-lang/cargo#17599) - fix(fingerprint): choose a stable path when source mtimes tie (rust-lang/cargo#17521) - Update gix crates to address CVE-2026-82248, CVE-2026-82249, and CVE-2026-82250, and update git utils.rs to accommodate gix-url v0.38.0. (rust-lang/cargo#17484) - fix: check crate type when pruning `-L` paths (rust-lang/cargo#17589) - refactor(parser): Simplify dep source validation (rust-lang/cargo#17506) r? ghost
What does this PR try to resolve?
The logic for validating and creating a dependency source is getting a bit complicated as pointed out in #16960.
How to test and review this PR?
Originally, all source creation happened first and then we decided which to use.
The problem with this is it required a
registryto be configured even if it was unused.This is an alternative to #17502