Skip to content

Commit c759dea

Browse files
committed
refactor(fingerprint): Make the hasher name more specific
1 parent 4c46836 commit c759dea

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/cargo/core/compiler/build_runner/compilation_files.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -595,47 +595,47 @@ fn compute_metadata(
595595
.collect::<Vec<_>>();
596596
let use_extra_filename = use_extra_filename(bcx, unit);
597597

598-
let mut hasher = StableHasher::new();
598+
let mut shared_hasher = StableHasher::new();
599599

600-
METADATA_VERSION.hash(&mut hasher);
600+
METADATA_VERSION.hash(&mut shared_hasher);
601601

602602
// Unique metadata per (name, source, version) triple. This'll allow us
603603
// to pull crates from anywhere without worrying about conflicts.
604604
unit.pkg
605605
.package_id()
606606
.stable_hash(bcx.ws.root())
607-
.hash(&mut hasher);
607+
.hash(&mut shared_hasher);
608608

609609
// Also mix in enabled features to our metadata. This'll ensure that
610610
// when changing feature sets each lib is separately cached.
611-
unit.features.hash(&mut hasher);
611+
unit.features.hash(&mut shared_hasher);
612612

613613
// Throw in the profile we're compiling with. This helps caching
614614
// `panic=abort` and `panic=unwind` artifacts, additionally with various
615615
// settings like debuginfo and whatnot.
616-
unit.profile.hash(&mut hasher);
617-
unit.mode.hash(&mut hasher);
618-
build_runner.lto[unit].hash(&mut hasher);
616+
unit.profile.hash(&mut shared_hasher);
617+
unit.mode.hash(&mut shared_hasher);
618+
build_runner.lto[unit].hash(&mut shared_hasher);
619619

620620
// Artifacts compiled for the host should have a different
621621
// metadata piece than those compiled for the target, so make sure
622622
// we throw in the unit's `kind` as well. Use `fingerprint_hash`
623623
// so that the StableHash doesn't change based on the pathnames
624624
// of the custom target JSON spec files.
625-
unit.kind.fingerprint_hash().hash(&mut hasher);
625+
unit.kind.fingerprint_hash().hash(&mut shared_hasher);
626626

627627
// Finally throw in the target name/kind. This ensures that concurrent
628628
// compiles of targets in the same crate don't collide.
629-
unit.target.name().hash(&mut hasher);
630-
unit.target.kind().hash(&mut hasher);
629+
unit.target.name().hash(&mut shared_hasher);
630+
unit.target.kind().hash(&mut shared_hasher);
631631

632-
hash_rustc_version(bcx, &mut hasher, unit);
632+
hash_rustc_version(bcx, &mut shared_hasher, unit);
633633

634634
if build_runner.bcx.ws.is_member(&unit.pkg) {
635635
// This is primarily here for clippy. This ensures that the clippy
636636
// artifacts are separate from the `check` ones.
637637
if let Some(path) = &build_runner.bcx.rustc().workspace_wrapper {
638-
path.hash(&mut hasher);
638+
path.hash(&mut shared_hasher);
639639
}
640640
}
641641

@@ -646,7 +646,7 @@ fn compute_metadata(
646646
.gctx
647647
.get_env("__CARGO_DEFAULT_LIB_METADATA")
648648
{
649-
channel.hash(&mut hasher);
649+
channel.hash(&mut shared_hasher);
650650
}
651651

652652
// std units need to be kept separate from user dependencies. std crates
@@ -656,7 +656,7 @@ fn compute_metadata(
656656
// don't need unstable support. A future experiment might be to set
657657
// `is_std` to false for build dependencies so that they can be shared
658658
// with user dependencies.
659-
unit.is_std.hash(&mut hasher);
659+
unit.is_std.hash(&mut shared_hasher);
660660

661661
// While we don't hash RUSTFLAGS because it may contain absolute paths that
662662
// hurts reproducibility, we track whether a unit's RUSTFLAGS is from host
@@ -675,7 +675,7 @@ fn compute_metadata(
675675
.target_config(CompileKind::Host)
676676
.links_overrides
677677
!= unit.links_overrides;
678-
target_configs_are_different.hash(&mut hasher);
678+
target_configs_are_different.hash(&mut shared_hasher);
679679
}
680680

681681
// Mix in the target-metadata of all the dependencies of this target.
@@ -684,9 +684,9 @@ fn compute_metadata(
684684
.map(|m| m.meta_hash)
685685
.collect::<Vec<_>>();
686686
dep_hashes.sort();
687-
dep_hashes.hash(&mut hasher);
687+
dep_hashes.hash(&mut shared_hasher);
688688

689-
let meta_hash = UnitHash(hasher.finish());
689+
let meta_hash = UnitHash(shared_hasher.finish());
690690

691691
Metadata {
692692
meta_hash,

0 commit comments

Comments
 (0)