incr.comp.: Revert hashing optimization that caused regression.

This commit is contained in:
Michael Woerister 2017-12-15 16:50:07 -06:00
parent 77efd6800c
commit c7e5b703cd
6 changed files with 24 additions and 43 deletions

View file

@ -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
}