mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Avoid fingerprint invalidation when reordering the declared features
This commit is contained in:
parent
7d1fc45a29
commit
f32f43d879
@ -1443,7 +1443,9 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
|
|||||||
allow_features.hash(&mut config);
|
allow_features.hash(&mut config);
|
||||||
}
|
}
|
||||||
let compile_kind = unit.kind.fingerprint_hash();
|
let compile_kind = unit.kind.fingerprint_hash();
|
||||||
let declared_features = unit.pkg.summary().features().keys().collect::<Vec<_>>();
|
let mut declared_features = unit.pkg.summary().features().keys().collect::<Vec<_>>();
|
||||||
|
declared_features.sort(); // to avoid useless rebuild if the user orders it's features
|
||||||
|
// differently
|
||||||
Ok(Fingerprint {
|
Ok(Fingerprint {
|
||||||
rustc: util::hash_u64(&cx.bcx.rustc().verbose_version),
|
rustc: util::hash_u64(&cx.bcx.rustc().verbose_version),
|
||||||
target: util::hash_u64(&unit.target),
|
target: util::hash_u64(&unit.target),
|
||||||
|
@ -165,6 +165,25 @@ fn features_fingerprint() {
|
|||||||
.with_stderr_does_not_contain("[..]unexpected_cfgs[..]")
|
.with_stderr_does_not_contain("[..]unexpected_cfgs[..]")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
p.cargo("check -v -Zcheck-cfg")
|
||||||
|
.masquerade_as_nightly_cargo(&["check-cfg"])
|
||||||
|
.with_stderr_does_not_contain("[..]rustc[..]")
|
||||||
|
.run();
|
||||||
|
|
||||||
|
// checking that re-ordering the features does not invalid the fingerprint
|
||||||
|
p.change_file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
f_b = []
|
||||||
|
f_a = []
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
|
||||||
p.cargo("check -v -Zcheck-cfg")
|
p.cargo("check -v -Zcheck-cfg")
|
||||||
.masquerade_as_nightly_cargo(&["check-cfg"])
|
.masquerade_as_nightly_cargo(&["check-cfg"])
|
||||||
.with_stderr_does_not_contain("[..]rustc[..]")
|
.with_stderr_does_not_contain("[..]rustc[..]")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user