Skip to content

Conversation

secona
Copy link
Contributor

@secona secona commented Sep 18, 2025

What does this PR try to resolve?

As part of cargo plumbing commands, we're trying to make lockfiles more accessible to third-party uses. This change moves the lockfile schemas to cargo-util-schemas, where it is previously under cargo and are relatively hidden.

See also: crate-ci/cargo-plumbing#82

How to test and review this PR?

Commit by commit to see the changes made. My main concern is performance as the implementation repeatedly calls SourceId::from_url and I'm not sure if its negligible.

r? @epage

@rustbot rustbot added 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 Sep 18, 2025
Some of the fields are made public to make the moving phase easier. They
will be reverted back to private when its done moving over.
simplifies the moving over of the schemas
Manifests schemas use `TomlManifest`. To match, we rename the lockfile
schemas to `TomlLockfile`
Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

Thanks!

@epage epage added this pull request to the merge queue Sep 19, 2025
Merged via the queue into rust-lang:master with commit 24ef070 Sep 19, 2025
27 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2025
impl FromStr for TomlLockfilePackageId {
type Err = EncodablePackageIdError;

fn from_str(s: &str) -> Result<TomlLockfilePackageId, Self::Err> {
Copy link
Member

Choose a reason for hiding this comment

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

This parses the v1 lockfile representation for backfilling ckechsums purpose. Should we make it private and add comment around otherwise it gives a false sense if this is how we parse package id.

More like an documentation issue though.

}

impl TomlLockfileSourceId {
pub fn new(source: String) -> Result<Self, EncodableSourceIdError> {
Copy link
Member

Choose a reason for hiding this comment

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

Do we expect user to create SourceId from raw strings?

I know the API is pub because libcargo needs it, but I fee like this may expose an implicit dependency of the shape of source id string, which should be opaque according to our current documentation.

Changing the underlying implmemtation won't be SemVer breaking, but it may break tools relying on it and narrow their supported Rust toolchain versions if using this API.

Anyway, this is all hypothetical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In cargo plumbing, we use this to parse the source ID generated by cargo, i.e. from dependency resolution results and lockfiles. I imagine users would do the same.

@secona secona deleted the lockfile-schemas branch September 19, 2025 23:47
github-merge-queue bot pushed a commit that referenced this pull request Sep 20, 2025
### What does this PR try to resolve?

Add documentation efforts to the lockfile schemas.

Continuation of #15980

### How to test and review this PR?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver A-lockfile Area: Cargo.lock issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants