Skip to content

Commit 61e5927

Browse files
committed
remove all residual state from previous lock files
1 parent 8418a3a commit 61e5927

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/cargo/core/registry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ impl<'cfg> PackageRegistry<'cfg> {
195195
self.yanked_whitelist.extend(pkgs);
196196
}
197197

198+
/// remove all residual state from previous lock files.
199+
pub fn clear_lock(&mut self) {
200+
trace!("clear_lock");
201+
self.locked = HashMap::new();
202+
}
203+
198204
pub fn register_lock(&mut self, id: PackageId, deps: Vec<PackageId>) {
199205
trace!("register_lock: {}", id);
200206
for dep in deps.iter() {

src/cargo/ops/resolve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ fn register_previous_locks(
584584
// the registry as a locked dependency.
585585
let keep = |id: &PackageId| keep(id) && !avoid_locking.contains(id);
586586

587+
registry.clear_lock();
587588
for node in resolve.iter().filter(keep) {
588589
let deps = resolve
589590
.deps_not_replaced(node)

tests/testsuite/build.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4934,6 +4934,7 @@ use cargo_test_support::registry::Dependency;
49344934

49354935
#[cargo_test]
49364936
fn reduced_reproduction_8249() {
4937+
// https://github.com/rust-lang/cargo/issues/8249
49374938
Package::new("a-src", "0.1.0").links("a").publish();
49384939
Package::new("a-src", "0.2.0").links("a").publish();
49394940

@@ -4966,10 +4967,6 @@ fn reduced_reproduction_8249() {
49664967

49674968
p.cargo("generate-lockfile").run();
49684969
cargo::util::paths::append(&p.root().join("Cargo.toml"), b"c = \"*\"").unwrap();
4969-
p.cargo("check")
4970-
.with_status(101)
4971-
.with_stderr_contains("[..]links to the native library `a`[..]")
4972-
.run();
4973-
// This passes, what!?
4970+
p.cargo("check").run();
49744971
p.cargo("check").run();
49754972
}

0 commit comments

Comments
 (0)