diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index a16d6d40331..03c38630e92 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -122,6 +122,26 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes } } + // Mirror `--workspace` and never avoid workspace members. + // Filtering them out here so the above processes them normally + // so their dependencies can be updated as requested + to_avoid = to_avoid + .into_iter() + .filter(|id| { + for package in ws.members() { + let member_id = package.package_id(); + // Skip checking the `version` because `previous_resolve` might have a stale + // value. + // When dealing with workspace members, the other fields should be a + // sufficiently unique match. + if id.name() == member_id.name() && id.source_id() == member_id.source_id() { + return false; + } + } + true + }) + .collect(); + registry.add_sources(sources)?; } diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index fb740052a67..40bc0b476a0 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -1091,11 +1091,8 @@ rustdns.workspace = true p.cargo("update -p rootcrate") .with_stderr(&format!( "\ -[UPDATING] git repository `{}` [UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81 -[UPDATING] rustdns v0.5.0 ([..]) -> [..] [UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81", - git_project.url(), )) .run(); } @@ -1182,11 +1179,8 @@ rustdns.workspace = true p.cargo("update -p crate2") .with_stderr(&format!( "\ -[UPDATING] git repository `{}` [UPDATING] crate1 v2.29.8 ([CWD]/crate1) -> v2.29.81 -[UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81 -[UPDATING] rustdns v0.5.0 ([..]) -> [..]", - git_project.url(), +[UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81", )) .run(); }