Skip to content

Commit 3ce6dd2

Browse files
authored
Rollup merge of #111024 - saethlin:stringify-full-svh, r=oli-obk
Use the full Fingerprint when stringifying Svh Finally circling back, per #110367 (comment) r? `@oli-obk`
2 parents 1187ce7 + 3c6d9ec commit 3ce6dd2

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

compiler/rustc_data_structures/src/fingerprint.rs

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ impl Fingerprint {
6464
)
6565
}
6666

67+
#[inline]
68+
pub(crate) fn as_u128(self) -> u128 {
69+
u128::from(self.1) << 64 | u128::from(self.0)
70+
}
71+
6772
// Combines two hashes in an order independent way. Make sure this is what
6873
// you want.
6974
#[inline]

compiler/rustc_data_structures/src/svh.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ impl Svh {
2323
Svh { hash }
2424
}
2525

26-
pub fn as_u64(&self) -> u64 {
27-
self.hash.to_smaller_hash().as_u64()
26+
pub fn as_u128(self) -> u128 {
27+
self.hash.as_u128()
2828
}
2929

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

3535
impl fmt::Display for Svh {
3636
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37-
f.pad(&self.to_string())
37+
f.pad(&self.to_hex())
3838
}
3939
}
4040

compiler/rustc_incremental/src/persist/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
346346
let mut new_sub_dir_name = String::from(&old_sub_dir_name[..=dash_indices[2]]);
347347

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

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

0 commit comments

Comments
 (0)