about summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-12-15 16:50:07 -0600
committerMichael Woerister <michaelwoerister@posteo>2017-12-15 16:50:07 -0600
commitc7e5b703cd5c4926b477fe1ded13df42d31a62da (patch)
treef4ab0a465ecef6c8123307a14c40f8da486745ff /src/libsyntax/codemap.rs
parent77efd6800c57ba83923dddbbabf03c7afa6a34a4 (diff)
downloadrust-c7e5b703cd5c4926b477fe1ded13df42d31a62da.tar.gz
rust-c7e5b703cd5c4926b477fe1ded13df42d31a62da.zip
incr.comp.: Revert hashing optimization that caused regression.
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 07bba29ca4b..2c91d60ce9d 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -23,7 +23,9 @@ pub use syntax_pos::hygiene::{ExpnFormat, ExpnInfo, NameAndSpan};
 pub use self::ExpnFormat::*;
 
 use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::stable_hasher::StableHasher;
 use std::cell::{RefCell, Ref};
+use std::hash::Hash;
 use std::path::{Path, PathBuf};
 use std::rc::Rc;
 
@@ -100,6 +102,24 @@ impl FileLoader for RealFileLoader {
     }
 }
 
+// This is a FileMap identifier that is used to correlate FileMaps between
+// subsequent compilation sessions (which is something we need to do during
+// incremental compilation).
+#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
+pub struct StableFilemapId(u128);
+
+impl StableFilemapId {
+    pub fn new(filemap: &FileMap) -> StableFilemapId {
+        let mut hasher = StableHasher::new();
+
+        filemap.name.hash(&mut hasher);
+        filemap.name_was_remapped.hash(&mut hasher);
+        filemap.unmapped_path.hash(&mut hasher);
+
+        StableFilemapId(hasher.finish())
+    }
+}
+
 // _____________________________________________________________________________
 // CodeMap
 //
@@ -197,7 +217,7 @@ impl CodeMap {
 
         self.stable_id_to_filemap
             .borrow_mut()
-            .insert(filemap.stable_id, filemap.clone());
+            .insert(StableFilemapId::new(&filemap), filemap.clone());
 
         filemap
     }
@@ -226,7 +246,6 @@ impl CodeMap {
                                 name_was_remapped: bool,
                                 crate_of_origin: u32,
                                 src_hash: u128,
-                                stable_id: StableFilemapId,
                                 source_len: usize,
                                 mut file_local_lines: Vec<BytePos>,
                                 mut file_local_multibyte_chars: Vec<MultiByteChar>,
@@ -257,7 +276,6 @@ impl CodeMap {
             crate_of_origin,
             src: None,
             src_hash,
-            stable_id,
             external_src: RefCell::new(ExternalSource::AbsentOk),
             start_pos,
             end_pos,
@@ -270,7 +288,7 @@ impl CodeMap {
 
         self.stable_id_to_filemap
             .borrow_mut()
-            .insert(stable_id, filemap.clone());
+            .insert(StableFilemapId::new(&filemap), filemap.clone());
 
         filemap
     }