about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2023-12-22 21:42:49 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2023-12-23 14:10:28 -0500
commit6630d690859d882b2528a39317a701da64fe1203 (patch)
tree46b62bb8bc3550aba198ab860a866c8982ac7fbb /compiler/rustc_span/src
parentedcbcc768a484d52deb315e7c583fe4b2ab4f25b (diff)
downloadrust-6630d690859d882b2528a39317a701da64fe1203.tar.gz
rust-6630d690859d882b2528a39317a701da64fe1203.zip
Specialize DefPathHash table to skip crate IDs
Instead, we store just the local crate hash as a bare u64. On decoding,
we recombine it with the crate's stable crate ID stored separately in
metadata. The end result is that we save ~8 bytes/DefIndex in metadata
size.

One key detail here is that we no longer distinguish in encoded metadata
between present and non-present DefPathHashes. It used to be highly
likely we could distinguish as we used DefPathHash::default(), an
all-zero representation. However in theory even that is fallible as
nothing strictly prevents the StableCrateId from being zero.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/def_id.rs2
1 files changed, 0 insertions, 2 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index b2d51ac6c0d..e397fab5459 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -114,8 +114,6 @@ impl DefPathHash {
     }
 
     /// Returns the crate-local part of the [DefPathHash].
-    ///
-    /// Used for tests.
     #[inline]
     pub fn local_hash(&self) -> Hash64 {
         self.0.split().1