Skip to content

Commit 8f9114a

Browse files
committed
Fix fingerprint calculation for patched deps.
1 parent 1b6702f commit 8f9114a

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

src/cargo/core/compiler/fingerprint.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ struct MtimeSlot(Mutex<Option<FileTime>>);
228228

229229
impl Fingerprint {
230230
fn update_local(&self, root: &Path) -> CargoResult<()> {
231-
let mut hash_busted = false;
232231
for local in self.local.iter() {
233232
match *local {
234233
LocalFingerprint::MtimeBased(ref slot, ref path) => {
@@ -238,12 +237,9 @@ impl Fingerprint {
238237
}
239238
LocalFingerprint::EnvBased(..) | LocalFingerprint::Precalculated(..) => continue,
240239
}
241-
hash_busted = true;
242240
}
243241

244-
if hash_busted {
245-
*self.memoized_hash.lock().unwrap() = None;
246-
}
242+
*self.memoized_hash.lock().unwrap() = None;
247243
Ok(())
248244
}
249245

tests/testsuite/freshness.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::prelude::*;
44
use support::paths::CargoPathExt;
55
use support::registry::Package;
66
use support::sleep_ms;
7-
use support::{basic_manifest, project};
7+
use support::{basic_manifest, is_coarse_mtime, project};
88

99
#[test]
1010
fn modifying_and_moving() {
@@ -1177,3 +1177,60 @@ fn reuse_panic_pm() {
11771177
)
11781178
.run();
11791179
}
1180+
1181+
#[test]
1182+
fn bust_patched_dep() {
1183+
Package::new("registry1", "0.1.0").publish();
1184+
Package::new("registry2", "0.1.0")
1185+
.dep("registry1", "0.1.0")
1186+
.publish();
1187+
1188+
let p = project()
1189+
.file(
1190+
"Cargo.toml",
1191+
r#"
1192+
[package]
1193+
name = "foo"
1194+
version = "0.0.1"
1195+
1196+
[dependencies]
1197+
registry2 = "0.1.0"
1198+
1199+
[patch.crates-io]
1200+
registry1 = { path = "reg1new" }
1201+
"#,
1202+
)
1203+
.file("src/lib.rs", "")
1204+
.file("reg1new/Cargo.toml", &basic_manifest("registry1", "0.1.0"))
1205+
.file("reg1new/src/lib.rs", "")
1206+
.build();
1207+
1208+
p.cargo("build").run();
1209+
1210+
File::create(&p.root().join("reg1new/src/lib.rs")).unwrap();
1211+
if is_coarse_mtime() {
1212+
sleep_ms(1000);
1213+
}
1214+
1215+
p.cargo("build")
1216+
.with_stderr(
1217+
"\
1218+
[COMPILING] registry1 v0.1.0 ([..])
1219+
[COMPILING] registry2 v0.1.0
1220+
[COMPILING] foo v0.0.1 ([..])
1221+
[FINISHED] [..]
1222+
",
1223+
)
1224+
.run();
1225+
1226+
p.cargo("build -v")
1227+
.with_stderr(
1228+
"\
1229+
[FRESH] registry1 v0.1.0 ([..])
1230+
[FRESH] registry2 v0.1.0
1231+
[FRESH] foo v0.0.1 ([..])
1232+
[FINISHED] [..]
1233+
",
1234+
)
1235+
.run();
1236+
}

0 commit comments

Comments
 (0)