Skip to content

Commit dfb69e6

Browse files
committed
Include lints.rust.unexpected_cfgs.check-cfg into the fingerprint
1 parent 3ca2120 commit dfb69e6

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
//! config settings[^5] | ✓ |
8181
//! is_std | | ✓
8282
//! `[lints]` table[^6] | ✓ |
83+
//! `[lints.rust.unexpected_cfgs.check-cfg]` | ✓ |
8384
//!
8485
//! [^1]: Build script and bin dependencies are not included.
8586
//!
@@ -1420,12 +1421,34 @@ fn calculate_normal(
14201421
}
14211422
.to_vec();
14221423

1424+
// Include all the args from `[lints.rust.unexpected_cfgs.check-cfg]`
1425+
//
1426+
// HACK(#13975): duplicating the lookup logic here until `--check-cfg` is supported
1427+
// on Cargo's MSRV and we can centralize the logic in `lints_to_rustflags`
1428+
let mut lint_check_cfg = Vec::new();
1429+
if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() {
1430+
if let Some(rust_lints) = lints.get("rust") {
1431+
if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") {
1432+
if let Some(config) = unexpected_cfgs.config() {
1433+
if let Some(check_cfg) = config.get("check-cfg") {
1434+
if let Ok(check_cfgs) =
1435+
toml::Value::try_into::<Vec<String>>(check_cfg.clone())
1436+
{
1437+
lint_check_cfg = check_cfgs;
1438+
}
1439+
}
1440+
}
1441+
}
1442+
}
1443+
}
1444+
14231445
let profile_hash = util::hash_u64((
14241446
&unit.profile,
14251447
unit.mode,
14261448
build_runner.bcx.extra_args_for(unit),
14271449
build_runner.lto[unit],
14281450
unit.pkg.manifest().lint_rustflags(),
1451+
lint_check_cfg,
14291452
));
14301453
// Include metadata since it is exposed as environment variables.
14311454
let m = unit.pkg.manifest().metadata();

tests/testsuite/check_cfg.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,7 @@ fn config_fingerprint() {
851851
.with_stderr_does_not_contain("[..]rustc[..]")
852852
.run();
853853

854-
// checking that changing the `-check-cfg` config does not invalid the fingerprint
855-
// FIXME: This should change the fingerprint
854+
// checking that changing the `check-cfg` config does invalid the fingerprint
856855
p.change_file(
857856
"Cargo.toml",
858857
r#"
@@ -867,6 +866,10 @@ fn config_fingerprint() {
867866
);
868867

869868
p.cargo("check -v")
870-
.with_stderr_does_not_contain("[..]rustc[..]")
869+
// we check that the fingerprint is indeed dirty
870+
.with_stderr_contains("[..]Dirty[..]the profile configuration changed")
871+
// that cause rustc to be called again with the new check-cfg args
872+
.with_stderr_contains(x!("rustc" => "cfg" of "bar"))
873+
.with_stderr_contains(x!("rustc" => "cfg" of "foo"))
871874
.run();
872875
}

0 commit comments

Comments
 (0)