Function cargo::ops::resolve::register_previous_locks

source ·
fn register_previous_locks(
    ws: &Workspace<'_>,
    registry: &mut PackageRegistry<'_>,
    resolve: &Resolve,
    keep: &'_ dyn Fn(&PackageId) -> bool,
    dev_deps: bool,
)
Expand description

In this function we’re responsible for informing the registry of all locked dependencies from the previous lock file we had, resolve.

This gets particularly tricky for a couple of reasons. The first is that we want all updates to be conservative, so we actually want to take the resolve into account (and avoid unnecessary registry updates and such). the second, however, is that we want to be resilient to updates of manifests. For example if a dependency is added or a version is changed we want to make sure that we properly re-resolve (conservatively) instead of providing an opaque error.

The logic here is somewhat subtle, but there should be more comments below to clarify things.

Note that this function, at the time of this writing, is basically the entire fix for issue #4127.