Skip to content

refactor(parser): Refactor toml dependency validation - #17502

Closed
adamgemmell wants to merge 3 commits into
rust-lang:masterfrom
adamgemmell:dev/builtins/validation-refactor
Closed

adamgemmell wants to merge 3 commits into
rust-lang:masterfrom
adamgemmell:dev/builtins/validation-refactor

Conversation

@adamgemmell

@adamgemmell adamgemmell commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

The match statement in to_dependency_source_id() was too complex, especially when extended for builtin dependencies (#16960). This PR moves the checks for malformed toml dependencies to a helper function which allows simplifying the match statement considerably.

The PR should preserve the behaviour of the TOML parsing, even for non-intuitive cases like those tested for in alt_registry. The PR does not preserve the order in which errors are checked.

This PR is part of a chain:

How to test and review this PR?

Review commit-by-commit for simpler diffs.

@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 22, 2026
@rustbot

rustbot commented Sep 22, 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, epage, weihanglo

}
}
}
check_for_malformed_toml_dependency(orig, name_in_toml)?;

@weihanglo weihanglo Sep 22, 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.

Thanks for the refactor! It does improve a bit but not substantially. The nested if-else blocks are also not really readable.

I think we probably should leave the match statement there and move forward like what Ed has suggested. We can always come back later to fix this structurally.

Not a blocker really, and sorry that you've already spent time on this refactor 😞

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries, I was just trying something. I agree that ideally something more substantial should happen, but this PR does avoid adding an extra dimension to the match statement for builtins. I can't find Ed's suggestion for this, do you have a link?

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2026
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.

3 participants