]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_span/src/source_map.rs
Rollup merge of #98710 - mojave2:string, r=JohnTitor
[rust.git] / compiler / rustc_span / src / source_map.rs
index afbb88e92336049d30357fd4b322988a2d0177e0..b4a4424e876cdeb6e5178df20f6bb19d3831be88 100644 (file)
@@ -718,6 +718,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 {