Skip to content

fix(builtin-deps): Builtin dependencies manifest validation - #17499

Merged
weihanglo merged 10 commits into
rust-lang:masterfrom
adamgemmell:dev/builtins/deps-manifest-validation
Sep 23, 2026
Merged

weihanglo merged 10 commits into
rust-lang:masterfrom
adamgemmell:dev/builtins/deps-manifest-validation

Conversation

@adamgemmell

@adamgemmell adamgemmell commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

As part of #16960 this PR adds validation checks to reject invalid forms of the manifest including builtin dependencies, such as when they are present in the build-dependencies section or combined with other sources. The RFC specifies what forms of builtin dependencies are valid.

This PR is part of a chain:

How to test and review this PR?

The PR consists of commits which add a test demonstrating some undesired behaviour and then fixes that in the following commit. Cargo test passes on every commit.

🤖 LLM disclosure: I used Codex to help me understand the codebase and asked it to review my branch before sharing it upstream. I also used it in limited (pre-arranged) ways to generate code, including resolving merge conflicts and updating test assertions. All code was originally written by hand.

r? @weihanglo

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 21, 2026
@adamgemmell adamgemmell changed the title feat(builtin-deps): Builtin dependencies manifest validation fix(builtin-deps): Builtin dependencies manifest validation Sep 21, 2026
Comment thread tests/testsuite/builtin_dep.rs Outdated
}

#[cargo_test]
fn builtin_dependency_combined_with_sources() {

@epage epage Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I see more than one project in a test, it makes me wonder if this is more appropriate as multiple tests. Unsure where to draw the line,

View changes since the review

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.

For my self, I would either do this with a test helper function, or within a loop, so it makes obvious we are testing different combinations not a sequence of commands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most likely to make this work, the snapshot will need to be in the list or a parameter to the helper function.

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.

The error message is the same for all cases, so I've put this test in a simple loop 8abb7f7

Comment thread src/workspace/parser/mod.rs Outdated
Comment on lines 2447 to 2455
) {
(_, _, _, _, Some(true)) => {
(git, path, reg, reg_index, Some(true)) => {
if git.is_some() || path.is_some() || reg.is_some() || reg_index.is_some() {
bail!(
"dependency ({name_in_toml}) specification is ambiguous. \
`builtin = true` cannot be combined with any other dependency source"
)
}
todo!("SourceKind::Builtin");

@epage epage Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

side note: I wonder if there is a cleaner way for us to be structuring this whole match. This is bigger than just this change and not something to block it on

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.

I think the main issue is that there's some validation happening above this function as well as inside it, and the amount of combinations testable is enormous.

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.

Opened #17502 to improve this

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.

Closed #17502 and instead handled builtins separately to the match statement

Comment thread src/workspace/parser/mod.rs Outdated
Builtin dependencies are unversioned."
)
}

@epage epage Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

side note: that this is separate from the source match ties back to my comment at daaf847#r4064101205

View changes since the review

@epage

epage commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

I'm good with this once the parent PRs are merged

pull Bot pushed a commit to Little-Star888/cargo that referenced this pull request Sep 21, 2026
…-lang#17497)

### What does this PR try to resolve?

As part of rust-lang#16960, this PR adds
a new unstable feature which will be used to gate the `builtin = true`
syntax on builtin dependencies.

This PR is part of a chain:
- rust-lang#17497
- rust-lang#17498
- rust-lang#17499
- rust-lang#17500

### How to test and review this PR?

This PR adds a unit test to demonstrate that the allowed feature gate
works. It also adds documentation for the feature gate. `cargo test`
passes on all commits.

r? @Muscraft

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

Other than the tiny test suggestion, looks good!

View changes since this review

Comment thread tests/testsuite/builtin_dep.rs Outdated
}

#[cargo_test]
fn builtin_dependency_combined_with_sources() {

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.

For my self, I would either do this with a test helper function, or within a loop, so it makes obvious we are testing different combinations not a sequence of commands.

@adamgemmell
adamgemmell force-pushed the dev/builtins/deps-manifest-validation branch from 3d06fae to 8339dd8 Compare September 23, 2026 12:48
@rustbot

This comment has been minimized.

@adamgemmell
adamgemmell force-pushed the dev/builtins/deps-manifest-validation branch 4 times, most recently from d82b9cf to 8338c86 Compare September 23, 2026 14:26

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

Thanks. Will merge this when it is rebased.

View changes since this review

adamgemmell pushed a commit to adamgemmell/cargo that referenced this pull request Sep 23, 2026
…ng#17498)

*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/cargo/pull/17498)*

### What does this PR try to resolve?

As part of rust-lang#16960, this PR adds
the required syntax to the manifest to specify builtin dependencies. The
main validation present in this PR is that `builtin = true` being
present anywhere requires the `builtin-dependencies` feature in order to
avoid accidentally introducing any new stable behaviour in later PRs.
Invalid forms of builtin dependencies are rejected in a later PR. For
now builtin dependencies panic with a `todo!()` as there is no
`SourceKind` variant to represent them.

This PR is part of a chain:
- rust-lang#17497
- rust-lang#17502
- rust-lang#17498
- rust-lang#17499
- rust-lang#17500

### How to test and review this PR?

The PR first introduces the manifest syntax, then builds on that by
adding various tests that `builtin = true` requires an unstable feature.
Cargo test passes on every commit.

🤖 LLM disclosure: I used Codex to help me understand the codebase and
asked it to review my branch before sharing it upstream. I also used it
in limited (pre-arranged) ways to generate code, including resolving
merge conflicts and updating test assertions. All code was originally
written by hand.

r? @weihanglo
@adamgemmell
adamgemmell force-pushed the dev/builtins/deps-manifest-validation branch from 8338c86 to 4416d04 Compare September 23, 2026 14:54
@rustbot

rustbot commented Sep 23, 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 enabled auto-merge September 23, 2026 14:56
@weihanglo
weihanglo added this pull request to the merge queue Sep 23, 2026
Merged via the queue into rust-lang:master with commit e2f915c Sep 23, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2026
@adamgemmell
adamgemmell deleted the dev/builtins/deps-manifest-validation branch September 23, 2026 16:16
pull Bot pushed a commit to linyihai/cargo that referenced this pull request Sep 23, 2026
…7500)

### What does this PR try to resolve?

As part of rust-lang#16960 this PR adds
a series of tests that already pass, confirming existing behaviour and
preventing any future regressions.

This PR is part of a chain:
- rust-lang#17497
- rust-lang#17502
- rust-lang#17498
- rust-lang#17499
- rust-lang#17500

### How to test and review this PR?

Review all at once or commit-by-commit, there's no overlap between
commits. Cargo test passes on every commit.

🤖 LLM disclosure: I used Codex to help me understand the codebase and
asked it to review my branch before sharing it upstream. I also used it
in limited (pre-arranged) ways to generate code, including resolving
merge conflicts and updating test assertions. All code was originally
written by hand.

r? @weihanglo
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Sep 25, 2026
Update cargo submodule

5 commits in 98a09e7e7d62850f14e5b6132101fc1edd19a16f..3d7cf6e937d6127d0f49881bf689c560b36d35c4
2026-09-21 19:03:16 +0000 to 2026-09-25 01:47:29 +0000
- fix(package): preserve feature metadata in normalized manifests (rust-lang/cargo#17509)
- fix(diag): Don't report unused normal deps when static libs are skipped  (rust-lang/cargo#17515)
- test(builtin-deps): Additional manifest regression tests (rust-lang/cargo#17500)
- fix(builtin-deps): Builtin dependencies manifest validation (rust-lang/cargo#17499)
- feat(builtin-deps): Add builtin dependencies manifest syntax (rust-lang/cargo#17498)

r? ghost
@rustbot rustbot added this to the 1.100.0 milestone Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants