diff options
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 2bab958dced..26ab5d0a34b 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -971,6 +971,15 @@ impl FileMap { lines.push(pos); } + /// Return the BytePos of the beginning of the current line. + pub fn line_begin_pos(&self) -> BytePos { + let lines = self.lines.borrow(); + match lines.last() { + Some(&line_pos) => line_pos, + None => self.start_pos, + } + } + /// Add externally loaded source. /// If the hash of the input doesn't match or no input is supplied via None, /// it is interpreted as an error and the corresponding enum variant is set. |
