about summary refs log tree commit diff
path: root/src/source_map.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-03-30 12:36:28 -0700
committerGitHub <noreply@github.com>2020-03-30 12:36:28 -0700
commit5ca3d023ff6c970e7dcd6cee3c83672dff14dc15 (patch)
tree2cc8d28e47d2d970c06829e3a5eb01ed48bde0ea /src/source_map.rs
parent9f53665f91be16c9aa7afd83f7c79357fec9152b (diff)
parent9714a140c99a8968b0becb5cf9227b1787768088 (diff)
Merge pull request #4100 from calebcartwright/rustfmt1x-rustc-v650
bump rustfmt 1x to rustc-ap v651
Diffstat (limited to 'src/source_map.rs')
-rw-r--r--src/source_map.rs29
1 files changed, 2 insertions, 27 deletions
diff --git a/src/source_map.rs b/src/source_map.rs
index c3a549d3b84..76e0d24cf1e 100644
--- a/src/source_map.rs
+++ b/src/source_map.rs
@@ -1,11 +1,10 @@
 //! This module contains utilities that work with the `SourceMap` from `libsyntax`/`syntex_syntax`.
 //! This includes extension traits and methods for looking up spans and line ranges for AST nodes.
 
-use rustc_span::{source_map::SourceMap, BytePos, Span};
+use rustc_span::{BytePos, Span};
 
 use crate::comment::FindUncommented;
 use crate::config::file_lines::LineRange;
-use crate::utils::starts_with_newline;
 use crate::visitor::SnippetProvider;
 
 pub(crate) trait SpanUtils {
@@ -26,7 +25,7 @@ pub(crate) trait LineRangeUtils {
     fn lookup_line_range(&self, span: Span) -> LineRange;
 }
 
-impl<'a> SpanUtils for SnippetProvider<'a> {
+impl SpanUtils for SnippetProvider {
     fn span_after(&self, original: Span, needle: &str) -> BytePos {
         self.opt_span_after(original, needle).unwrap_or_else(|| {
             panic!(
@@ -81,27 +80,3 @@ impl<'a> SpanUtils for SnippetProvider<'a> {
         Some(original.lo() + BytePos(offset as u32))
     }
 }
-
-impl LineRangeUtils for SourceMap {
-    fn lookup_line_range(&self, span: Span) -> LineRange {
-        let snippet = self.span_to_snippet(span).unwrap_or_default();
-        let lo = self.lookup_line(span.lo()).unwrap();
-        let hi = self.lookup_line(span.hi()).unwrap();
-
-        debug_assert_eq!(
-            lo.sf.name, hi.sf.name,
-            "span crossed file boundary: lo: {:?}, hi: {:?}",
-            lo, hi
-        );
-
-        // in case the span starts with a newline, the line range is off by 1 without the
-        // adjustment below
-        let offset = 1 + if starts_with_newline(&snippet) { 1 } else { 0 };
-        // Line numbers start at 1
-        LineRange {
-            file: lo.sf.clone(),
-            lo: lo.line + offset,
-            hi: hi.line + offset,
-        }
-    }
-}