summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorInokentiy Babushkin <twk@twki.de>2017-06-12 15:37:26 +0200
committerInokentiy Babushkin <twk@twki.de>2017-06-12 15:37:26 +0200
commit271133b03ee5da57334670f50cd8a6ebbc35d140 (patch)
tree4401cf452b68d5962427a0e1fb4057a590231e27 /src/librustc_errors
parentafe841587df0d20b344b576641d0a32d32b87f54 (diff)
downloadrust-271133b03ee5da57334670f50cd8a6ebbc35d140.tar.gz
rust-271133b03ee5da57334670f50cd8a6ebbc35d140.zip
External spans: address review.
* The lazy loading mechanism has been moved to a more appropriate place.
* Return values from the functions invoked there are properly used.
* Documentation has gotten some minor improvements.
* Possibly some larger restructuring will need to take place still.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs9
-rw-r--r--src/librustc_errors/lib.rs4
2 files changed, 5 insertions, 8 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 2099725c48a..b4b14328b3d 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -177,8 +177,6 @@ impl EmitterWriter {
                     continue;
                 }
 
-                cm.load_source_for_filemap(cm.span_to_filename(span_label.span));
-
                 let lo = cm.lookup_char_pos(span_label.span.lo);
                 let mut hi = cm.lookup_char_pos(span_label.span.hi);
 
@@ -891,10 +889,10 @@ impl EmitterWriter {
         let mut annotated_files = self.preprocess_annotations(msp);
 
         // Make sure our primary file comes first
-        let primary_lo = if let (Some(ref cm), Some(ref primary_span)) =
+        let (primary_lo, cm) = if let (Some(cm), Some(ref primary_span)) =
             (self.cm.as_ref(), msp.primary_span().as_ref()) {
             if primary_span != &&DUMMY_SP {
-                cm.lookup_char_pos(primary_span.lo)
+                (cm.lookup_char_pos(primary_span.lo), cm)
             } else {
                 emit_to_destination(&buffer.render(), level, &mut self.dst)?;
                 return Ok(());
@@ -912,8 +910,7 @@ impl EmitterWriter {
         // Print out the annotate source lines that correspond with the error
         for annotated_file in annotated_files {
             // we can't annotate anything if the source is unavailable.
-            if annotated_file.file.src.is_none()
-                    && annotated_file.file.external_src.borrow().is_absent() {
+            if !cm.ensure_filemap_source_present(annotated_file.file.clone()) {
                 continue;
             }
 
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 26ecbe724f8..975b720276e 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -50,7 +50,7 @@ pub mod registry;
 pub mod styled_buffer;
 mod lock;
 
-use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION};
+use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION};
 
 #[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
 pub enum RenderSpan {
@@ -104,7 +104,7 @@ pub trait CodeMapper {
     fn span_to_filename(&self, sp: Span) -> FileName;
     fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
     fn call_span_if_macro(&self, sp: Span) -> Span;
-    fn load_source_for_filemap(&self, file: FileName) -> bool;
+    fn ensure_filemap_source_present(&self, file_map: Rc<FileMap>) -> bool;
 }
 
 impl CodeSuggestion {