Skip to content

Commit

Permalink
refactor: flatten log_compare into caller
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Jan 29, 2024
1 parent bf0b156 commit a04f2b2
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,25 @@ fn compare_old_fingerprint(
}

let compare = _compare_old_fingerprint(old_hash_path, new_fingerprint);
log_compare(unit, &compare);

match compare.as_ref() {
Ok(None) => {}
Ok(Some(reason)) => {
info!(
"fingerprint dirty for {}/{:?}/{:?}",
unit.pkg, unit.mode, unit.target,
);
info!(" dirty: {reason:?}");
}
Err(e) => {
info!(
"fingerprint error for {}/{:?}/{:?}",
unit.pkg, unit.mode, unit.target,
);
info!(" err: {e:?}");
}
}

match compare {
Ok(None) if forced => Some(DirtyReason::Forced),
Ok(reason) => reason,
Expand Down Expand Up @@ -1784,29 +1802,6 @@ fn _compare_old_fingerprint(
Ok(Some(new_fingerprint.compare(&old_fingerprint)))
}

/// Logs the result of fingerprint comparison.
///
/// TODO: Obsolete and mostly superseded by [`DirtyReason`]. Could be removed.
fn log_compare(unit: &Unit, compare: &CargoResult<Option<DirtyReason>>) {
match compare {
Ok(None) => {}
Ok(Some(reason)) => {
info!(
"fingerprint dirty for {}/{:?}/{:?}",
unit.pkg, unit.mode, unit.target,
);
info!(" dirty: {reason:?}");
}
Err(e) => {
info!(
"fingerprint error for {}/{:?}/{:?}",
unit.pkg, unit.mode, unit.target,
);
info!(" err: {e:?}");
}
}
}

/// Parses Cargo's internal [`EncodedDepInfo`] structure that was previously
/// serialized to disk.
///
Expand Down

0 comments on commit a04f2b2

Please sign in to comment.