Skip to content

refactor(parser): Simplify dep source validation - #17506

Merged
weihanglo merged 9 commits into
rust-lang:masterfrom
epage:validation
Oct 14, 2026
Merged

weihanglo merged 9 commits into
rust-lang:masterfrom
epage:validation

Conversation

@epage

@epage epage commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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 registry to be configured even if it was unused.

This is an alternative to #17502

@rustbot rustbot added A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 24, 2026
@rustbot

rustbot commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Muscraft, @epage, @weihanglo
  • @Muscraft, @epage, @weihanglo expanded to Muscraft, epage, weihanglo
  • Random selection from Muscraft, weihanglo

@epage

epage commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

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..

@epage
epage marked this pull request as draft September 24, 2026 01:06
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 24, 2026
@epage

epage commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

I suspect there are other types of validation that could be consolidated into this, including

  • builtin and version
  • source-less dep

Comment thread src/workspace/parser/mod.rs Outdated
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() {

@weihanglo weihanglo Sep 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah this looks nicer, and if growing too large, each source construction can be extracted separately.

View changes since the review

@adamgemmell

Copy link
Copy Markdown
Contributor

@epage thanks, this makes a lot of sense. Posted a PR for SourceKind::Builtin here which I think unblocks this? #17513

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Sep 25, 2026
@epage
epage force-pushed the validation branch 2 times, most recently from 2080b5f to 9b89531 Compare September 30, 2026 20:02
Comment thread src/workspace/parser/mod.rs Resolved
Comment thread src/workspace/parser/mod.rs Resolved
@epage
epage force-pushed the validation branch 2 times, most recently from 5452a29 to d1620e0 Compare September 30, 2026 21:35
@epage
epage marked this pull request as ready for review October 1, 2026 17:16
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 1, 2026
@epage epage removed the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Oct 8, 2026
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

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.

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment on lines +2458 to +2462
let path_kind = if let Some(path) = path {
Some(path)
} else {
None
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I guess you just wanted it to be symmetric so didn't do this?

Suggested change
let path_kind = if let Some(path) = path {
Some(path)
} else {
None
};
let path_kind = path

@weihanglo
weihanglo added this pull request to the merge queue Oct 14, 2026
Merged via the queue into rust-lang:master with commit 3773409 Oct 14, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 21, 2026
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
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 22, 2026
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
@rustbot rustbot added this to the 1.101.0 milestone Oct 22, 2026
WhySoBad pushed a commit to WhySoBad/miri that referenced this pull request Oct 23, 2026
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
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Oct 25, 2026
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
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Oct 26, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-manifest Area: Cargo.toml issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants