Track 'public/private' depenendecy status in fingerprint

This commit is contained in:
Aaron Hill 2019-04-23 00:46:05 -04:00
parent 715d6ace02
commit 8185564a53
No known key found for this signature in database
GPG key ID: B4087E510E98B164

View file

@ -315,11 +315,13 @@ pub fn prepare_target<'a, 'cfg>(
/// A compilation unit dependency has a fingerprint that is comprised of:
/// * its package ID
/// * its extern crate name
/// * its public/private status
/// * its calculated fingerprint for the dependency
#[derive(Clone)]
struct DepFingerprint {
pkg_id: u64,
name: String,
public: bool,
fingerprint: Arc<Fingerprint>,
}
@ -429,10 +431,11 @@ impl<'de> Deserialize<'de> for DepFingerprint {
where
D: de::Deserializer<'de>,
{
let (pkg_id, name, hash) = <(u64, String, u64)>::deserialize(d)?;
let (pkg_id, name, public, hash) = <(u64, String, bool, u64)>::deserialize(d)?;
Ok(DepFingerprint {
pkg_id,
name,
public,
fingerprint: Arc::new(Fingerprint {
memoized_hash: Mutex::new(Some(hash)),
..Fingerprint::new()
@ -850,11 +853,13 @@ impl hash::Hash for Fingerprint {
for DepFingerprint {
pkg_id,
name,
public,
fingerprint,
} in deps
{
pkg_id.hash(h);
name.hash(h);
public.hash(h);
// use memoized dep hashes to avoid exponential blowup
h.write_u64(Fingerprint::hash(fingerprint));
}
@ -900,6 +905,7 @@ impl DepFingerprint {
) -> CargoResult<DepFingerprint> {
let fingerprint = calculate(cx, dep)?;
let name = cx.bcx.extern_crate_name(parent, dep)?;
let public = cx.bcx.is_public_dependency(parent, dep);
// We need to be careful about what we hash here. We have a goal of
// supporting renaming a project directory and not rebuilding
@ -920,6 +926,7 @@ impl DepFingerprint {
Ok(DepFingerprint {
pkg_id,
name,
public,
fingerprint,
})
}