remove all residual state from previous lock files

This commit is contained in:
Eh2406 2020-05-23 11:31:05 -04:00
parent 8418a3ae58
commit 61e592788c
3 changed files with 9 additions and 5 deletions

View File

@ -195,6 +195,12 @@ impl<'cfg> PackageRegistry<'cfg> {
self.yanked_whitelist.extend(pkgs);
}
/// remove all residual state from previous lock files.
pub fn clear_lock(&mut self) {
trace!("clear_lock");
self.locked = HashMap::new();
}
pub fn register_lock(&mut self, id: PackageId, deps: Vec<PackageId>) {
trace!("register_lock: {}", id);
for dep in deps.iter() {

View File

@ -584,6 +584,7 @@ fn register_previous_locks(
// the registry as a locked dependency.
let keep = |id: &PackageId| keep(id) && !avoid_locking.contains(id);
registry.clear_lock();
for node in resolve.iter().filter(keep) {
let deps = resolve
.deps_not_replaced(node)

View File

@ -4934,6 +4934,7 @@ use cargo_test_support::registry::Dependency;
#[cargo_test]
fn reduced_reproduction_8249() {
// https://github.com/rust-lang/cargo/issues/8249
Package::new("a-src", "0.1.0").links("a").publish();
Package::new("a-src", "0.2.0").links("a").publish();
@ -4966,10 +4967,6 @@ fn reduced_reproduction_8249() {
p.cargo("generate-lockfile").run();
cargo::util::paths::append(&p.root().join("Cargo.toml"), b"c = \"*\"").unwrap();
p.cargo("check")
.with_status(101)
.with_stderr_contains("[..]links to the native library `a`[..]")
.run();
// This passes, what!?
p.cargo("check").run();
p.cargo("check").run();
}