Skip to content

Commit 97edb9f

Browse files
committed
span: add span_extend_to_line helper
Adds a simple helper function to the `SourceMap` for extending a `Span` to encompass the entire line it is on - useful for suggestions where removing a line is the suggested action. Signed-off-by: David Wood <[email protected]>
1 parent 224aec2 commit 97edb9f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_span/src/source_map.rs

+5
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,11 @@ impl SourceMap {
718718
sp
719719
}
720720

721+
/// Extends the given `Span` to contain the entire line it is on.
722+
pub fn span_extend_to_line(&self, sp: Span) -> Span {
723+
self.span_extend_to_prev_char(self.span_extend_to_next_char(sp, '\n', true), '\n', true)
724+
}
725+
721726
/// Given a `Span`, tries to get a shorter span ending before the first occurrence of `char`
722727
/// `c`.
723728
pub fn span_until_char(&self, sp: Span, c: char) -> Span {

0 commit comments

Comments
 (0)