about summary refs log tree commit diff
path: root/src/librustc/ich
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-12-08 17:07:48 +0100
committerMichael Woerister <michaelwoerister@posteo>2017-12-14 10:29:16 -0600
commit0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3 (patch)
tree1762e549160fe7c4e8da05530fc7b06ad8ea691a /src/librustc/ich
parent9faa31612fb7a847a1c85836996846b9a6f20116 (diff)
downloadrust-0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3.tar.gz
rust-0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3.zip
incr.comp.: Do less hashing per Span.
Diffstat (limited to 'src/librustc/ich')
-rw-r--r--src/librustc/ich/hcx.rs15
-rw-r--r--src/librustc/ich/impls_syntax.rs2
2 files changed, 11 insertions, 6 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 2d20836814c..f9fb668110b 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -338,13 +338,16 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for Span {
             return std_hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
         }
 
-        let len = span.hi - span.lo;
-
         std_hash::Hash::hash(&TAG_VALID_SPAN, hasher);
-        std_hash::Hash::hash(&file_lo.name, hasher);
-        std_hash::Hash::hash(&line_lo, hasher);
-        std_hash::Hash::hash(&col_lo, hasher);
-        std_hash::Hash::hash(&len, hasher);
+        // We truncate the stable_id hash and line and col numbers. The chances
+        // of causing a collision this way should be minimal.
+        std_hash::Hash::hash(&(file_lo.stable_id.0 as u64), hasher);
+
+        let col = (col_lo.0 as u64) & 0xFF;
+        let line = ((line_lo as u64) & 0xFF_FF_FF) << 8;
+        let len = ((span.hi - span.lo).0 as u64) << 32;
+        let line_col_len = col | line | len;
+        std_hash::Hash::hash(&line_col_len, hasher);
 
         if span.ctxt == SyntaxContext::empty() {
             TAG_NO_EXPANSION.hash_stable(hcx, hasher);
diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs
index c25aa10eb1e..dfb90a5d27f 100644
--- a/src/librustc/ich/impls_syntax.rs
+++ b/src/librustc/ich/impls_syntax.rs
@@ -394,6 +394,8 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for FileMap {
             // Do not hash the source as it is not encoded
             src: _,
             src_hash,
+            // The stable id is just a hash of other fields
+            stable_id: _,
             external_src: _,
             start_pos,
             end_pos: _,