about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorInokentiy Babushkin <twk@twki.de>2017-06-11 10:19:46 +0200
committerInokentiy Babushkin <twk@twki.de>2017-06-11 11:47:00 +0200
commitc04aa4ed0ce61d257ab10b4dbdaa64fa5cad37b1 (patch)
treef354bf43f9c4a8fd86cdbe29e9b847f22424a768 /src/libsyntax_pos
parentc2c31b2db33e0d0b5356a0c9e032269034cdc70a (diff)
downloadrust-c04aa4ed0ce61d257ab10b4dbdaa64fa5cad37b1.tar.gz
rust-c04aa4ed0ce61d257ab10b4dbdaa64fa5cad37b1.zip
Improved lazy external source loading and inserted calls.
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index d6adf45e68a..9e545b81390 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -374,14 +374,35 @@ pub struct MultiByteChar {
     pub bytes: usize,
 }
 
+/// The state of the lazy external source loading mechanism of a FileMap.
 #[derive(PartialEq, Eq, Clone)]
 pub enum ExternalSource {
+    /// The external source has been loaded already.
     Present(String),
+    /// No attempt has been made to load the external source.
     AbsentOk,
+    /// A failed attempt has been made to load the external source.
     AbsentErr,
+    /// No external source has to be loaded, since the FileMap represents a local crate.
     Unneeded,
 }
 
+impl ExternalSource {
+    pub fn is_absent(&self) -> bool {
+        match *self {
+            ExternalSource::Present(_) => false,
+            _ => true,
+        }
+    }
+
+    pub fn get_source(&self) -> Option<&str> {
+        match *self {
+            ExternalSource::Present(ref src) => Some(src),
+            _ => None,
+        }
+    }
+}
+
 /// A single source in the CodeMap.
 #[derive(Clone)]
 pub struct FileMap {
@@ -620,7 +641,7 @@ impl FileMap {
     }
 
     pub fn is_imported(&self) -> bool {
-        self.src.is_none()
+        self.src.is_none() // TODO: change to something more sensible
     }
 
     pub fn byte_length(&self) -> u32 {