diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index ac29b0d15d9..0b3a2db50f1 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1531,7 +1531,18 @@ fn calculate_normal( )); // Include metadata since it is exposed as environment variables. let m = unit.pkg.manifest().metadata(); - let metadata = util::hash_u64((&m.authors, &m.description, &m.homepage, &m.repository)); + let metadata = util::hash_u64(( + &m.authors, + &m.description, + &m.homepage, + &m.repository, + &m.readme, + &m.license, + &m.license_file, + &m.documentation, + &m.categories, + &m.keywords, + )); let mut config = StableHasher::new(); if let Some(linker) = build_runner.compilation.target_linker(unit.kind) { linker.hash(&mut config); diff --git a/tests/testsuite/freshness_checksum.rs b/tests/testsuite/freshness_checksum.rs index 5c4b88fdbc3..e51793aa97f 100644 --- a/tests/testsuite/freshness_checksum.rs +++ b/tests/testsuite/freshness_checksum.rs @@ -2018,11 +2018,33 @@ fn metadata_change_invalidates() { "description = \"desc\"", "homepage = \"https://example.com\"", "repository =\"https://example.com\"", + "readme =\"README.md\"", + "license =\"MIT\"", + "license-file =\"foo.txt\"", + "categories = [\"foo\"]", + "keywords = [\"foo\"]", + "documentation =\"https://example.com\"", ] { + let cargo_toml = p.root().join("Cargo.toml"); + + // license and license-file together will emit a warning, so remove license since we + // already tested it. Also rebuild it so that when we add license-file, we validate the + // fingerprint was updated. + if attr.starts_with("license-file") { + let contents = fs::read_to_string(&cargo_toml) + .unwrap() + .replace("license =\"MIT\"\n", ""); + fs::write(&cargo_toml, &contents).unwrap(); + + p.cargo("build -Zchecksum-freshness") + .masquerade_as_nightly_cargo(&["checksum-freshness"]) + .run(); + } + let mut file = OpenOptions::new() .write(true) .append(true) - .open(p.root().join("Cargo.toml")) + .open(cargo_toml) .unwrap(); writeln!(file, "{}", attr).unwrap(); p.cargo("build -Zchecksum-freshness")