refactor(parser): Refactor toml dependency validation - #17502
adamgemmell wants to merge 3 commits into
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| } | ||
| } | ||
| } | ||
| check_for_malformed_toml_dependency(orig, name_in_toml)?; |
There was a problem hiding this comment.
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 😞
There was a problem hiding this comment.
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?
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:
builtin-dependenciesfeature #17497How to test and review this PR?
Review commit-by-commit for simpler diffs.