Skip to content

Commit ed98cab

Browse files
committed
Fix fingerprint calculation for patched deps.
1 parent fef7802 commit ed98cab

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

src/cargo/core/compiler/fingerprint.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ impl Fingerprint {
236236
}
237237

238238
fn update_local(&self, root: &Path) -> CargoResult<()> {
239-
let mut hash_busted = false;
240239
for local in self.local.iter() {
241240
match *local {
242241
LocalFingerprint::MtimeBased(ref slot, ref path) => {
@@ -246,12 +245,9 @@ impl Fingerprint {
246245
}
247246
LocalFingerprint::EnvBased(..) | LocalFingerprint::Precalculated(..) => continue,
248247
}
249-
hash_busted = true;
250248
}
251249

252-
if hash_busted {
253-
*self.memoized_hash.lock().unwrap() = None;
254-
}
250+
*self.memoized_hash.lock().unwrap() = None;
255251
Ok(())
256252
}
257253

tests/testsuite/freshness.rs

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

99
#[test]
1010
fn modifying_and_moving() {
@@ -1246,3 +1246,60 @@ fn reuse_panic_pm() {
12461246
)
12471247
.run();
12481248
}
1249+
1250+
#[test]
1251+
fn bust_patched_dep() {
1252+
Package::new("registry1", "0.1.0").publish();
1253+
Package::new("registry2", "0.1.0")
1254+
.dep("registry1", "0.1.0")
1255+
.publish();
1256+
1257+
let p = project()
1258+
.file(
1259+
"Cargo.toml",
1260+
r#"
1261+
[package]
1262+
name = "foo"
1263+
version = "0.0.1"
1264+
1265+
[dependencies]
1266+
registry2 = "0.1.0"
1267+
1268+
[patch.crates-io]
1269+
registry1 = { path = "reg1new" }
1270+
"#,
1271+
)
1272+
.file("src/lib.rs", "")
1273+
.file("reg1new/Cargo.toml", &basic_manifest("registry1", "0.1.0"))
1274+
.file("reg1new/src/lib.rs", "")
1275+
.build();
1276+
1277+
p.cargo("build").run();
1278+
1279+
File::create(&p.root().join("reg1new/src/lib.rs")).unwrap();
1280+
if is_coarse_mtime() {
1281+
sleep_ms(1000);
1282+
}
1283+
1284+
p.cargo("build")
1285+
.with_stderr(
1286+
"\
1287+
[COMPILING] registry1 v0.1.0 ([..])
1288+
[COMPILING] registry2 v0.1.0
1289+
[COMPILING] foo v0.0.1 ([..])
1290+
[FINISHED] [..]
1291+
",
1292+
)
1293+
.run();
1294+
1295+
p.cargo("build -v")
1296+
.with_stderr(
1297+
"\
1298+
[FRESH] registry1 v0.1.0 ([..])
1299+
[FRESH] registry2 v0.1.0
1300+
[FRESH] foo v0.0.1 ([..])
1301+
[FINISHED] [..]
1302+
",
1303+
)
1304+
.run();
1305+
}

0 commit comments

Comments
 (0)