about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/analyze_source_file.rs6
-rw-r--r--src/libsyntax_pos/hygiene.rs2
-rw-r--r--src/libsyntax_pos/lib.rs21
-rw-r--r--src/libsyntax_pos/symbol.rs14
4 files changed, 23 insertions, 20 deletions
diff --git a/src/libsyntax_pos/analyze_source_file.rs b/src/libsyntax_pos/analyze_source_file.rs
index e468aaac7a3..7bc9a1af62c 100644
--- a/src/libsyntax_pos/analyze_source_file.rs
+++ b/src/libsyntax_pos/analyze_source_file.rs
@@ -36,9 +36,9 @@ pub fn analyze_source_file(
     // it encounters. If that point is already outside the source_file, remove
     // it again.
     if let Some(&last_line_start) = lines.last() {
-        let file_map_end = source_file_start_pos + BytePos::from_usize(src.len());
-        assert!(file_map_end >= last_line_start);
-        if last_line_start == file_map_end {
+        let source_file_end = source_file_start_pos + BytePos::from_usize(src.len());
+        assert!(source_file_end >= last_line_start);
+        if last_line_start == source_file_end {
             lines.pop();
         }
     }
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs
index f053cb10d06..bc52a3e1c7c 100644
--- a/src/libsyntax_pos/hygiene.rs
+++ b/src/libsyntax_pos/hygiene.rs
@@ -156,7 +156,7 @@ impl Mark {
     pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark {
         HygieneData::with(|data| {
             // Compute the path from a to the root
-            let mut a_path = FxHashSet::<Mark>();
+            let mut a_path = FxHashSet::<Mark>::default();
             while a != Mark::root() {
                 a_path.insert(a);
                 a = data.marks[a.0 as usize].parent;
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 45eaf1d3190..a780a38ff96 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -612,6 +612,17 @@ impl MultiSpan {
         &self.primary_spans
     }
 
+    /// Returns `true` if this contains only a dummy primary span with any hygienic context.
+    pub fn is_dummy(&self) -> bool {
+        let mut is_dummy = true;
+        for span in &self.primary_spans {
+            if !span.is_dummy() {
+                is_dummy = false;
+            }
+        }
+        is_dummy
+    }
+
     /// Replaces all occurrences of one Span with another. Used to move Spans in areas that don't
     /// display well (like std macros). Returns true if replacements occurred.
     pub fn replace(&mut self, before: Span, after: Span) -> bool {
@@ -1255,9 +1266,9 @@ pub struct LocWithOpt {
 
 // used to be structural records. Better names, anyone?
 #[derive(Debug)]
-pub struct SourceFileAndLine { pub fm: Lrc<SourceFile>, pub line: usize }
+pub struct SourceFileAndLine { pub sf: Lrc<SourceFile>, pub line: usize }
 #[derive(Debug)]
-pub struct SourceFileAndBytePos { pub fm: Lrc<SourceFile>, pub pos: BytePos }
+pub struct SourceFileAndBytePos { pub sf: Lrc<SourceFile>, pub pos: BytePos }
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct LineInfo {
@@ -1292,7 +1303,7 @@ pub struct MacroBacktrace {
 }
 
 // _____________________________________________________________________________
-// SpanLinesError, SpanSnippetError, DistinctSources, MalformedCodemapPositions
+// SpanLinesError, SpanSnippetError, DistinctSources, MalformedSourceMapPositions
 //
 
 pub type FileLinesResult = Result<FileLines, SpanLinesError>;
@@ -1307,7 +1318,7 @@ pub enum SpanLinesError {
 pub enum SpanSnippetError {
     IllFormedSpan(Span),
     DistinctSources(DistinctSources),
-    MalformedForCodemap(MalformedCodemapPositions),
+    MalformedForSourcemap(MalformedSourceMapPositions),
     SourceNotAvailable { filename: FileName }
 }
 
@@ -1318,7 +1329,7 @@ pub struct DistinctSources {
 }
 
 #[derive(Clone, PartialEq, Eq, Debug)]
-pub struct MalformedCodemapPositions {
+pub struct MalformedSourceMapPositions {
     pub name: FileName,
     pub source_len: usize,
     pub begin_pos: BytePos,
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index d412412fc65..361353c82e2 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -224,6 +224,7 @@ impl<T: ::std::ops::Deref<Target=str>> PartialEq<T> for Symbol {
 }
 
 // The &'static strs in this type actually point into the arena
+#[derive(Default)]
 pub struct Interner {
     arena: DroplessArena,
     names: FxHashMap<&'static str, Symbol>,
@@ -232,17 +233,8 @@ pub struct Interner {
 }
 
 impl Interner {
-    pub fn new() -> Self {
-        Interner {
-            arena: DroplessArena::new(),
-            names: Default::default(),
-            strings: Default::default(),
-            gensyms: Default::default(),
-        }
-    }
-
     fn prefill(init: &[&str]) -> Self {
-        let mut this = Interner::new();
+        let mut this = Interner::default();
         for &string in init {
             if string == "" {
                 // We can't allocate empty strings in the arena, so handle this here
@@ -697,7 +689,7 @@ mod tests {
 
     #[test]
     fn interner_tests() {
-        let mut i: Interner = Interner::new();
+        let mut i: Interner = Interner::default();
         // first one is zero:
         assert_eq!(i.intern("dog"), Symbol(0));
         // re-use gets the same entry: