]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_span/src/source_map.rs
Rollup merge of #99758 - WaffleLapkin:remove_useless_allow, r=Dylan-DPC
[rust.git] / compiler / rustc_span / src / source_map.rs
index afbb88e92336049d30357fd4b322988a2d0177e0..47159584afe3b3780f7113fa748e0a6a1ad7e36f 100644 (file)
@@ -586,17 +586,6 @@ fn span_to_source<F, T>(&self, sp: Span, extract_source: F) -> Result<T, SpanSni
         }
     }
 
-    /// Returns whether or not this span points into a file
-    /// in the current crate. This may be `false` for spans
-    /// produced by a macro expansion, or for spans associated
-    /// with the definition of an item in a foreign crate
-    pub fn is_local_span(&self, sp: Span) -> bool {
-        let local_begin = self.lookup_byte_offset(sp.lo());
-        let local_end = self.lookup_byte_offset(sp.hi());
-        // This might be a weird span that covers multiple files
-        local_begin.sf.src.is_some() && local_end.sf.src.is_some()
-    }
-
     pub fn is_span_accessible(&self, sp: Span) -> bool {
         self.span_to_source(sp, |src, start_index, end_index| {
             Ok(src.get(start_index..end_index).is_some())
@@ -718,6 +707,11 @@ pub fn span_extend_to_next_char(&self, sp: Span, c: char, accept_newlines: bool)
         sp
     }
 
+    /// Extends the given `Span` to contain the entire line it is on.
+    pub fn span_extend_to_line(&self, sp: Span) -> Span {
+        self.span_extend_to_prev_char(self.span_extend_to_next_char(sp, '\n', true), '\n', true)
+    }
+
     /// Given a `Span`, tries to get a shorter span ending before the first occurrence of `char`
     /// `c`.
     pub fn span_until_char(&self, sp: Span, c: char) -> Span {