diff options
| author | bors <bors@rust-lang.org> | 2017-05-28 16:47:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-05-28 16:47:17 +0000 |
| commit | d47cf08d57d881f34f9724edfb0b3b93209af202 (patch) | |
| tree | 970783ad9b7d4b3d6b591a42c5cda1eb68512cf3 /src/libsyntax | |
| parent | bcf95067e487e0bbaed7035296e05975b77eb981 (diff) | |
| parent | 21dd71f51460eb791dc5f938ad4b02b76c6c8520 (diff) | |
| download | rust-d47cf08d57d881f34f9724edfb0b3b93209af202.tar.gz rust-d47cf08d57d881f34f9724edfb0b3b93209af202.zip | |
Auto merge of #42175 - michaelwoerister:filemap-hashing-fix-1, r=nikomatsakis
incr.comp.: Track expanded spans instead of FileMaps. This PR removes explicit tracking of FileMaps in response to #42101. The reasoning behind being able to just *not* track access to FileMaps is similar to why we don't track access to the `DefId->DefPath` map: 1. One can only get ahold of a `Span` value by accessing the HIR (for local things) or a `metadata::schema::Entry` (for things from external crates). 2. For both of these things we compute a hash that incorporates the *expanded spans*, that is, what we hash is in the (FileMap independent) format `filename:line:col`. 3. Consequently, everything that emits a span should already be tracked via its dependency to something that has the span included in its hash and changes would be detected via that hash. One caveat here is that we have to be conservative when exporting things in metadata. A crate can be built without debuginfo and would thus by default not incorporate most spans into the metadata hashes. However, a downstream crate can make an inline copy of things in the upstream crate and span changes in the upstream crate would then go undetected, even if the downstream uses them (e.g. by emitting debuginfo for an inlined function). For this reason, we always incorporate spans into metadata hashes for now (there might be more efficient ways to handle this safely when red-green tracking is implemented). r? @nikomatsakis
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index d32c3ec5f46..bbe5bd4a10c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -103,18 +103,11 @@ impl FileLoader for RealFileLoader { // pub struct CodeMap { - // The `files` field should not be visible outside of libsyntax so that we - // can do proper dependency tracking. pub(super) files: RefCell<Vec<Rc<FileMap>>>, file_loader: Box<FileLoader>, // This is used to apply the file path remapping as specified via // -Zremap-path-prefix to all FileMaps allocated within this CodeMap. path_mapping: FilePathMapping, - // The CodeMap will invoke this callback whenever a specific FileMap is - // accessed. The callback starts out as a no-op but when the dependency - // graph becomes available later during the compilation process, it is - // be replaced with something that notifies the dep-tracking system. - dep_tracking_callback: RefCell<Box<Fn(&FileMap)>>, } impl CodeMap { @@ -123,7 +116,6 @@ impl CodeMap { files: RefCell::new(Vec::new()), file_loader: Box::new(RealFileLoader), path_mapping: path_mapping, - dep_tracking_callback: RefCell::new(Box::new(|_| {})), } } @@ -134,7 +126,6 @@ impl CodeMap { files: RefCell::new(Vec::new()), file_loader: file_loader, path_mapping: path_mapping, - dep_tracking_callback: RefCell::new(Box::new(|_| {})), } } @@ -142,10 +133,6 @@ impl CodeMap { &self.path_mapping } - pub fn set_dep_tracking_callback(&self, cb: Box<Fn(&FileMap)>) { - *self.dep_tracking_callback.borrow_mut() = cb; - } - pub fn file_exists(&self, path: &Path) -> bool { self.file_loader.file_exists(path) } @@ -156,15 +143,6 @@ impl CodeMap { } pub fn files(&self) -> Ref<Vec<Rc<FileMap>>> { - let files = self.files.borrow(); - for file in files.iter() { - (self.dep_tracking_callback.borrow())(file); - } - files - } - - /// Only use this if you do your own dependency tracking! - pub fn files_untracked(&self) -> Ref<Vec<Rc<FileMap>>> { self.files.borrow() } @@ -311,8 +289,6 @@ impl CodeMap { let files = self.files.borrow(); let f = (*files)[idx].clone(); - (self.dep_tracking_callback.borrow())(&f); - match f.lookup_line(pos) { Some(line) => Ok(FileMapAndLine { fm: f, line: line }), None => Err(f) @@ -502,7 +478,6 @@ impl CodeMap { pub fn get_filemap(&self, filename: &str) -> Option<Rc<FileMap>> { for fm in self.files.borrow().iter() { if filename == fm.name { - (self.dep_tracking_callback.borrow())(fm); return Some(fm.clone()); } } @@ -513,7 +488,6 @@ impl CodeMap { pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { let idx = self.lookup_filemap_idx(bpos); let fm = (*self.files.borrow())[idx].clone(); - (self.dep_tracking_callback.borrow())(&fm); let offset = bpos - fm.start_pos; FileMapAndBytePos {fm: fm, pos: offset} } @@ -524,8 +498,6 @@ impl CodeMap { let files = self.files.borrow(); let map = &(*files)[idx]; - (self.dep_tracking_callback.borrow())(map); - // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0; |
