Skip to content

feat(build-std): Introduce opaque dependencies and builtin source - #17398

Open
adamgemmell wants to merge 10 commits into
rust-lang:masterfrom
adamgemmell:dev/adagem01/builtin-source
Open

feat(build-std): Introduce opaque dependencies and builtin source#17398
adamgemmell wants to merge 10 commits into
rust-lang:masterfrom
adamgemmell:dev/adagem01/builtin-source

Conversation

@adamgemmell

@adamgemmell adamgemmell commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

This PR, part of a stack split off from #16675, introduces:

  1. Opaque dependencies, as mentioned in the build-std=always RFC. An opaque dependency is one that cannot be fully resolved when encounted and is satisfied by an opaque Summary with no dependencies (which stops the resolver from recursing further). A future PR will handle the opaque summary by replacing it during unit generation with a package from a separate resolve, such as the standard library one.

  2. A new builtin source which discovers packages in the standard library source and generates opaque Summaries for them in order to satisfy dependencies which are specifically both opaque and Builtin. These concepts are intertwined at this stage to simplify implementation for build-std, but can be separated if Cargo decides to implement opaque dependencies more generally.

How to test and review this PR?

The PR introduces unit tests for all new behaviour and I recommend reading the commits in order. This PR cannot be manually tested.

There is a very large amount of context behind build-std. Please feel free to spam me with questions and I can link to relevant bits of this context than reviewers needing to reread this context every time you need to review a build-std PR if you prefer.

This PR is part of a stack:

@rustbot rustbot added A-crate-dependencies Area: [dependencies] of any kind A-dependency-resolution Area: dependency resolution and the resolver A-lockfile Area: Cargo.lock issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 27, 2026
@rustbot

rustbot commented Aug 27, 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: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo
  • Random selection from epage, weihanglo

@rustbot

This comment has been minimized.

@adamgemmell
adamgemmell force-pushed the dev/adagem01/builtin-source branch from 92fc1dd to 859aaf2 Compare September 1, 2026 17:10
@rustbot

This comment has been minimized.

@adamgemmell
adamgemmell force-pushed the dev/adagem01/builtin-source branch from 859aaf2 to b79ca52 Compare September 2, 2026 12:29
@rustbot

rustbot commented Sep 2, 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.

.url
.to_file_path()
.expect("builtin sources cannot be remote");
Ok(Box::new(BuiltinSource::new(&path, self, gctx)))

@adamgemmell adamgemmell Sep 2, 2026

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.

Existing concern from @epage regarding which source to use #16675 (comment)

Since then this patch now uses a BuiltinSource which wraps a RecursivePathSource.

View changes since the review

Comment thread src/workspace/summary.rs
/// The summary has no dependencies and is artificial - it is used purely guide the resolver
/// by satisfying opaque dependencies and is discarded during Unit generation. The real
/// packages that are converted into `Unit`s come from a different invocation of the resolver.
pub fn new_opaque(pkg_id: PackageId, sid: SourceId) -> Self {

@adamgemmell adamgemmell Sep 2, 2026

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.

Existing concern from @epage regarding the best way of constructing an opaque Summary #16675 (comment)

Since then I've split that logic into a function that looks much like the other Summary constructors.

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-crate-dependencies Area: [dependencies] of any kind A-dependency-resolution Area: dependency resolution and the resolver A-lockfile Area: Cargo.lock issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants