about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorMatthew Russo <matthew@edapp.com>2018-12-04 15:18:03 -0500
committerMatthew Russo <matthew@edapp.com>2018-12-04 19:52:42 -0500
commitf0f8aa9e05726bfbc065fa2504daf3232f29bc03 (patch)
tree5027e1682248fb6e535546046f43dff45d6e2b50 /src/libsyntax_pos
parent88130f1796e98837dc6f58aea9b9a0f49b85f426 (diff)
downloadrust-f0f8aa9e05726bfbc065fa2504daf3232f29bc03.tar.gz
rust-f0f8aa9e05726bfbc065fa2504daf3232f29bc03.zip
adds DocTest filename variant, refactors doctest_offset out of source_map, fixes remaining test failures
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index ff3c1cf9f47..4d42b85ea75 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -103,6 +103,7 @@ pub enum FileName {
     CliCrateAttr(u64),
     /// Custom sources for explicit parser calls from plugins and drivers
     Custom(String),
+    DocTest(PathBuf, isize),
 }
 
 impl std::fmt::Display for FileName {
@@ -119,6 +120,7 @@ impl std::fmt::Display for FileName {
             CfgSpec(_) => write!(fmt, "<cfgspec>"),
             CliCrateAttr(_) => write!(fmt, "<crate attribute>"),
             Custom(ref s) => write!(fmt, "<{}>", s),
+            DocTest(ref path, _) => write!(fmt, "{}", path.display()),
         }
     }
 }
@@ -142,7 +144,8 @@ impl FileName {
             CfgSpec(_) |
             CliCrateAttr(_) |
             Custom(_) |
-            QuoteExpansion(_) => false,
+            QuoteExpansion(_) |
+            DocTest(_, _) => false,
         }
     }
 
@@ -156,7 +159,8 @@ impl FileName {
             CfgSpec(_) |
             CliCrateAttr(_) |
             Custom(_) |
-            QuoteExpansion(_) => false,
+            QuoteExpansion(_) |
+            DocTest(_, _) => false,
             Macros(_) => true,
         }
     }
@@ -196,6 +200,10 @@ impl FileName {
         src.hash(&mut hasher);
         FileName::CliCrateAttr(hasher.finish())
     }
+
+    pub fn doc_test_source_code(path: PathBuf, line: isize) -> FileName{
+        FileName::DocTest(path, line)
+    }
 }
 
 /// Spans represent a region of code, used for error reporting. Positions in spans