Skip to content

Commit

Permalink
Rollup merge of #111024 - saethlin:stringify-full-svh, r=oli-obk
Browse files Browse the repository at this point in the history
Use the full Fingerprint when stringifying Svh

Finally circling back, per #110367 (comment)

r? `@oli-obk`
  • Loading branch information
matthiaskrgr committed May 4, 2023
2 parents 1187ce7 + 3c6d9ec commit 3ce6dd2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_data_structures/src/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ impl Fingerprint {
)
}

#[inline]
pub(crate) fn as_u128(self) -> u128 {
u128::from(self.1) << 64 | u128::from(self.0)
}

// Combines two hashes in an order independent way. Make sure this is what
// you want.
#[inline]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_data_structures/src/svh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ impl Svh {
Svh { hash }
}

pub fn as_u64(&self) -> u64 {
self.hash.to_smaller_hash().as_u64()
pub fn as_u128(self) -> u128 {
self.hash.as_u128()
}

pub fn to_string(&self) -> String {
format!("{:016x}", self.hash.to_smaller_hash())
pub fn to_hex(self) -> String {
format!("{:032x}", self.hash.as_u128())
}
}

impl fmt::Display for Svh {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(&self.to_string())
f.pad(&self.to_hex())
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/src/persist/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
let mut new_sub_dir_name = String::from(&old_sub_dir_name[..=dash_indices[2]]);

// Append the svh
base_n::push_str(svh.as_u64() as u128, INT_ENCODE_BASE, &mut new_sub_dir_name);
base_n::push_str(svh.as_u128(), INT_ENCODE_BASE, &mut new_sub_dir_name);

// Create the full path
let new_path = incr_comp_session_dir.parent().unwrap().join(new_sub_dir_name);
Expand Down

0 comments on commit 3ce6dd2

Please sign in to comment.