fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
                       -> CargoResult<Arc<Fingerprint>> {
    if let Some(s) = cx.fingerprints.get(unit) {
        return Ok(s.clone())
    }

    // First, calculate all statically known "salt data" such as the profile
    // information (compiler flags), the compiler version, activated features,
    // and target configuration.
    let features = cx.resolve.features(unit.pkg.package_id());
    let features = features.map(|s| {
        let mut v = s.iter().collect::<Vec<_>>();
        v.sort();
        v
    });

    // Next, recursively calculate the fingerprint for all of our dependencies.
    //
    // Skip the fingerprints of build scripts as they may not always be
    // available and the dirtiness propagation for modification is tracked
    // elsewhere. Also skip fingerprints of binaries because they don't actually
    // induce a recompile, they're just dependencies in the sense that they need
    // to be built.
    let deps = try!(cx.dep_targets(unit).iter().filter(|u| {
        !u.target.is_custom_build() && !u.target.is_bin()
    }).map(|unit| {
        calculate(cx, unit).map(|fingerprint| {
            (unit.pkg.package_id().to_string(), fingerprint)
        })
    }).collect::<CargoResult<Vec<_>>>());

    // And finally, calculate what our own local fingerprint is
    let local = if use_dep_info(unit) {
        let dep_info = dep_info_loc(cx, unit);
        let mtime = try!(dep_info_mtime_if_fresh(&dep_info));
        LocalFingerprint::MtimeBased(MtimeSlot(Mutex::new(mtime)), dep_info)
    } else {
        let fingerprint = try!(pkg_fingerprint(cx, unit.pkg));
        LocalFingerprint::Precalculated(fingerprint)
    };
    let mut deps = deps;
    deps.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));
    let fingerprint = Arc::new(Fingerprint {
        rustc: util::hash_u64(&cx.config.rustc_info().verbose_version),
        target: util::hash_u64(&unit.target),
        profile: util::hash_u64(&unit.profile),
        features: format!("{:?}", features),
        deps: deps,
        local: local,
        memoized_hash: Mutex::new(None),
    });
    cx.fingerprints.insert(*unit, fingerprint.clone());
    Ok(fingerprint)
}
/// Calculates the fingerprint for a package/target pair.
///
/// This fingerprint is used by Cargo to learn about when information such as:
///
/// * A non-path package changes (changes version, changes revision, etc).
/// * Any dependency changes
/// * The compiler changes
/// * The set of features a package is built with changes
/// * The profile a target is compiled with changes (e.g. opt-level changes)
///
/// Information like file modification time is only calculated for path
/// dependencies and is calculated in `calculate_target_fresh`.
Calculates the fingerprint for a package/target pair.
This fingerprint is used by Cargo to learn about when information such as.

A non-path package changes (changes version, changes revision, etc).
Any dependency changes
The compiler changes
The set of features a package is built with changes
The profile a target is compiled with changes

Information like file modification time is only calculated for path
dependencies and is calculated in `calculate_target_fresh`.
Calculates the fingerprint for a package / target pair . This fingerprint is used by Cargo to learn about when information such as . A non - path package changes ( changes version changes revision etc ) . Any dependency changes The compiler changes The set of features a package is built with changes The profile a target is compiled with changes Information like file modification time is only calculated for path dependencies and is calculated in ` calculate_target_fresh ` .
fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>)
                       -> CargoResult<Arc<Fingerprint>> {
    if let Some(s) = cx.fingerprints.get(unit) {
        return Ok(s.clone())
    }
    // First, calculate all statically known "salt data" such as the profile
    // information (compiler flags), the compiler version, activated features,
    // and target configuration.
    let features = cx.resolve.features(unit.pkg.package_id());
    let features = features.map(|s| {
        let mut v = s.iter().collect::<Vec<_>>();
        v.sort();
        v
    });
    // Next, recursively calculate the fingerprint for all of our dependencies.
    //
    // Skip the fingerprints of build scripts as they may not always be
    // available and the dirtiness propagation for modification is tracked
    // elsewhere. Also skip fingerprints of binaries because they don't actually
    // induce a recompile, they're just dependencies in the sense that they need
    // to be built.
    let deps = try!(cx.dep_targets(unit).iter().filter(|u| {
        !u.target.is_custom_build() && !u.target.is_bin()
    }).map(|unit| {
        calculate(cx, unit).map(|fingerprint| {
            (unit.pkg.package_id().to_string(), fingerprint)
        })
    }).collect::<CargoResult<Vec<_>>>());
    // And finally, calculate what our own local fingerprint is
    let local = if use_dep_info(unit) {
        let dep_info = dep_info_loc(cx, unit);
        let mtime = try!(dep_info_mtime_if_fresh(&dep_info));
        LocalFingerprint::MtimeBased(MtimeSlot(Mutex::new(mtime)), dep_info)
    } else {
        let fingerprint = try!(pkg_fingerprint(cx, unit.pkg));
        LocalFingerprint::Precalculated(fingerprint)
    };
    let mut deps = deps;
    deps.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));
    let fingerprint = Arc::new(Fingerprint {
        rustc: util::hash_u64(&cx.config.rustc_info().verbose_version),
        target: util::hash_u64(&unit.target),
        profile: util::hash_u64(&unit.profile),
        features: format!("{:?}", features),
        deps: deps,
        local: local,
        memoized_hash: Mutex::new(None),
    });
    cx.fingerprints.insert(*unit, fingerprint.clone());
    Ok(fingerprint)
}
fn calculate < ' a , ' cfg > ( cx : & mut Context < ' a , ' cfg > , unit : & Unit < ' a > ) -> CargoResult < Arc < Fingerprint > > { if let Some ( s ) = cx . fingerprints . get ( unit ) { return Ok ( s . clone ( ) ) } // First, calculate all statically known "salt data" such as the profile // information (compiler flags), the compiler version, activated features, // and target configuration. let features = cx . resolve . features ( unit . pkg . package_id ( ) ) ; let features = features . map ( | s | { let mut v = s . iter ( ) . collect :: < Vec < _ > > ( ) ; v . sort ( ) ; v } ) ; // Next, recursively calculate the fingerprint for all of our dependencies. // // Skip the fingerprints of build scripts as they may not always be // available and the dirtiness propagation for modification is tracked // elsewhere. Also skip fingerprints of binaries because they don't actually // induce a recompile, they're just dependencies in the sense that they need // to be built. let deps = try ! ( cx dep_targets ( unit ) iter ( ) filter ( u { u target is_custom_build ( ) u target is_bin ( ) } ) map ( unit { calculate ( cx unit ) map ( fingerprint { ( unit pkg package_id ( ) to_string ( ) fingerprint ) } ) } ) collect CargoResult Vec ( ) ) ; // And finally, calculate what our own local fingerprint is let local = if use_dep_info ( unit ) { let dep_info = dep_info_loc ( cx , unit ) ; let mtime = try ! ( dep_info_mtime_if_fresh ( dep_info ) ) ; LocalFingerprint :: MtimeBased ( MtimeSlot ( Mutex :: new ( mtime ) ) , dep_info ) } else { let fingerprint = try ! ( pkg_fingerprint ( cx unit pkg ) ) ; LocalFingerprint :: Precalculated ( fingerprint ) } ; let mut deps = deps ; deps . sort_by ( | & ( ref a , _ ) , & ( ref b , _ ) | a . cmp ( b ) ) ; let fingerprint = Arc :: new ( Fingerprint { rustc : util :: hash_u64 ( & cx . config . rustc_info ( ) . verbose_version ) , target : util :: hash_u64 ( & unit . target ) , profile : util :: hash_u64 ( & unit . profile ) , features : format ! ( " " features ) , deps : deps , local : local , memoized_hash : Mutex :: new ( None ) , } ) ; cx . fingerprints . insert ( * unit , fingerprint . clone ( ) ) ; Ok ( fingerprint ) }
Calculates the fingerprint for a package/target pair.
Calculates the fingerprint for a package / target pair .
cx
&mut Context<'a, 'cfg>
unit
&Unit<'a>
cx
&mut Context<'a, 'cfg>
unit
&Unit<'a>