From ed98cab6b60df19d9ff0a6c12a8c72762d17329d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 27 Dec 2018 15:47:09 -0800 Subject: [PATCH] Fix fingerprint calculation for patched deps. --- src/cargo/core/compiler/fingerprint.rs | 6 +-- tests/testsuite/freshness.rs | 59 +++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 8dfa0edee74..62daeed05fa 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -236,7 +236,6 @@ impl Fingerprint { } fn update_local(&self, root: &Path) -> CargoResult<()> { - let mut hash_busted = false; for local in self.local.iter() { match *local { LocalFingerprint::MtimeBased(ref slot, ref path) => { @@ -246,12 +245,9 @@ impl Fingerprint { } LocalFingerprint::EnvBased(..) | LocalFingerprint::Precalculated(..) => continue, } - hash_busted = true; } - if hash_busted { - *self.memoized_hash.lock().unwrap() = None; - } + *self.memoized_hash.lock().unwrap() = None; Ok(()) } diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 74daba86518..be867678a9d 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -4,7 +4,7 @@ use std::io::prelude::*; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; use crate::support::sleep_ms; -use crate::support::{basic_manifest, project}; +use crate::support::{basic_manifest, is_coarse_mtime, project}; #[test] fn modifying_and_moving() { @@ -1246,3 +1246,60 @@ fn reuse_panic_pm() { ) .run(); } + +#[test] +fn bust_patched_dep() { + Package::new("registry1", "0.1.0").publish(); + Package::new("registry2", "0.1.0") + .dep("registry1", "0.1.0") + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + registry2 = "0.1.0" + + [patch.crates-io] + registry1 = { path = "reg1new" } + "#, + ) + .file("src/lib.rs", "") + .file("reg1new/Cargo.toml", &basic_manifest("registry1", "0.1.0")) + .file("reg1new/src/lib.rs", "") + .build(); + + p.cargo("build").run(); + + File::create(&p.root().join("reg1new/src/lib.rs")).unwrap(); + if is_coarse_mtime() { + sleep_ms(1000); + } + + p.cargo("build") + .with_stderr( + "\ +[COMPILING] registry1 v0.1.0 ([..]) +[COMPILING] registry2 v0.1.0 +[COMPILING] foo v0.0.1 ([..]) +[FINISHED] [..] +", + ) + .run(); + + p.cargo("build -v") + .with_stderr( + "\ +[FRESH] registry1 v0.1.0 ([..]) +[FRESH] registry2 v0.1.0 +[FRESH] foo v0.0.1 ([..]) +[FINISHED] [..] +", + ) + .run(); +}