We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
lookup_line
1 parent fe217c2 commit 0fd3bbeCopy full SHA for 0fd3bbe
compiler/rustc_span/src/lib.rs
@@ -1628,10 +1628,7 @@ impl SourceFile {
1628
/// number. If the source_file is empty or the position is located before the
1629
/// first line, `None` is returned.
1630
pub fn lookup_line(&self, pos: BytePos) -> Option<usize> {
1631
- self.lines(|lines| match lines.partition_point(|x| x <= &pos) {
1632
- 0 => None,
1633
- i => Some(i - 1),
1634
- })
+ self.lines(|lines| lines.partition_point(|x| x <= &pos).checked_sub(1))
1635
}
1636
1637
pub fn line_bounds(&self, line_index: usize) -> Range<BytePos> {
0 commit comments