Skip to content

Conversation

@spookyvision
Copy link
Contributor

@spookyvision spookyvision commented Dec 3, 2025

I created a Rust project and wrote scaffolding until the dependency resolver pseudocode compiled (using rust-analyzer helpers but no LLMs). I have not done any kind of plausibility analysis, this is a pure "make all compiler errors go away" hackjob. The scaffolding might be interesting to preserve ... somewhere?

#[derive(Copy, Clone)]
struct Package;
impl Package {
    fn lookup_versions(&self) -> Option<Vec<Version>> {
        todo!()
    }
}

struct Version {
    dependencies: Vec<Package>,
}

#[derive(Copy, Clone)]
struct Policy;
impl Policy {
    fn pick_next_dep(&self, dep_queue: &Queue) -> Option<Package> {
        todo!()
    }

    fn try_unify_version(&self, dep_spec: Package, clone: ResolveGraph) -> Option<ResolveGraph> {
        todo!()
    }

    fn filter_versions(&self, dep_spec: Package, dep_versions: Vec<Version>) -> Vec<Version> {
        todo!()
    }

    fn pick_next_version(&self, dep_versions: &[Version]) -> Option<Version> {
        todo!()
    }

    fn needs_version_unification(&self, dep_version: &Version, resolved: &ResolveGraph) -> bool {
        todo!()
    }
}

#[derive(Clone)]
struct ResolveGraph;

impl ResolveGraph {
    fn new() -> Self {
        Self
    }

    fn register(&self, dep_version: Version) {
        todo!()
    }
}
struct Workspace;

#[derive(Clone)]
struct Queue;
impl Queue {
    fn new(workspace: &[Package]) -> Self {
        Self
    }

    fn enqueue(&self, dependencies: &Vec<Package>) {
        todo!()
    }
}

Thanks for the pull request 🎉!
Please read the contribution guide: https://doc.crates.io/contrib/.

What does this PR try to resolve?

the dependency resolver is explained using pseudocode which almost compiles. This PR makes it compile completely.

How to test and review this PR?

  • create a new Rust project
  • copy the resolver pseudocode from the book into it
  • observe many compiler errors resulting from the lack of struct definitions
  • copy the scaffolding above into the Rust source file to make the resolver functions compile

I created a Rust project and wrote scaffolding until it compiled (using rust-analyzer helpers but no LLMs). I have not done any kind of plausibility analysis, this is a pure "make all compiler errors go away" hackjob. The scaffolding might be interesting to preserve ... somewhere?


```rust
#[derive(Copy, Clone)]
struct Package;
impl Package {
    fn lookup_versions(&self) -> Option<Vec<Version>> {
        todo!()
    }
}

struct Version {
    dependencies: Vec<Package>,
}

#[derive(Copy, Clone)]
struct Policy;
impl Policy {
    fn pick_next_dep(&self, dep_queue: &Queue) -> Option<Package> {
        todo!()
    }

    fn try_unify_version(&self, dep_spec: Package, clone: ResolveGraph) -> Option<ResolveGraph> {
        todo!()
    }

    fn filter_versions(&self, dep_spec: Package, dep_versions: Vec<Version>) -> Vec<Version> {
        todo!()
    }

    fn pick_next_version(&self, dep_versions: &[Version]) -> Option<Version> {
        todo!()
    }

    fn needs_version_unification(&self, dep_version: &Version, resolved: &ResolveGraph) -> bool {
        todo!()
    }
}

#[derive(Clone)]
struct ResolveGraph;

impl ResolveGraph {
    fn new() -> Self {
        Self
    }

    fn register(&self, dep_version: Version) {
        todo!()
    }
}
struct Workspace;

#[derive(Clone)]
struct Queue;
impl Queue {
    fn new(workspace: &[Package]) -> Self {
        Self
    }

    fn enqueue(&self, dependencies: &Vec<Package>) {
        todo!()
    }
}
```
@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 3, 2025

r? @ehuss

rustbot has assigned @ehuss.
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

@epage epage enabled auto-merge December 3, 2025 19:13
@epage epage added this pull request to the merge queue Dec 3, 2025
Merged via the queue into rust-lang:master with commit bbb5c5b Dec 3, 2025
26 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 3, 2025
bors added a commit to rust-lang/rust that referenced this pull request Dec 5, 2025
Update cargo submodule

9 commits in bd979347d814dfe03bba124165dbce9554d0b4d8..2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac
2025-12-02 16:03:50 +0000 to 2025-12-04 16:47:28 +0000
- fix(publish): Move `.crate` out of final artifact location (rust-lang/cargo#15915)
- Remove legacy tmpdir support (rust-lang/cargo#16342)
- Run clippy CI on more targets (rust-lang/cargo#16340)
- feat: support for rustdoc mergeable cross-crate info (rust-lang/cargo#16309)
- fix(timings): unlocked -&gt; unblocked (rust-lang/cargo#16337)
- fix(layout): Put examples in their unit dir in new layout (rust-lang/cargo#16335)
- fix(frontmatter): Restrict code fence length  (rust-lang/cargo#16334)
- Update resolver.md: fix compile errors in pseudocode (rust-lang/cargo#16333)
- fix(fingerprint): clean doc dirs for only requested targets (rust-lang/cargo#16331)

This is best being merged before beta cutoff because rust-lang/cargo#16337 is a nightly regression.
@rustbot rustbot added this to the 1.93.0 milestone Dec 5, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 5, 2025
Update cargo submodule

9 commits in bd979347d814dfe03bba124165dbce9554d0b4d8..2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac
2025-12-02 16:03:50 +0000 to 2025-12-04 16:47:28 +0000
- fix(publish): Move `.crate` out of final artifact location (rust-lang/cargo#15915)
- Remove legacy tmpdir support (rust-lang/cargo#16342)
- Run clippy CI on more targets (rust-lang/cargo#16340)
- feat: support for rustdoc mergeable cross-crate info (rust-lang/cargo#16309)
- fix(timings): unlocked -&gt; unblocked (rust-lang/cargo#16337)
- fix(layout): Put examples in their unit dir in new layout (rust-lang/cargo#16335)
- fix(frontmatter): Restrict code fence length  (rust-lang/cargo#16334)
- Update resolver.md: fix compile errors in pseudocode (rust-lang/cargo#16333)
- fix(fingerprint): clean doc dirs for only requested targets (rust-lang/cargo#16331)

This is best being merged before beta cutoff because rust-lang/cargo#16337 is a nightly regression.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants