We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 98ad6a5 commit 40b3726Copy full SHA for 40b3726
compiler/rustc_span/src/lib.rs
@@ -1631,10 +1631,9 @@ impl SourceFile {
1631
/// number. If the source_file is empty or the position is located before the
1632
/// first line, `None` is returned.
1633
pub fn lookup_line(&self, pos: BytePos) -> Option<usize> {
1634
- self.lines(|lines| match lines.binary_search(&pos) {
1635
- Ok(idx) => Some(idx),
1636
- Err(0) => None,
1637
- Err(idx) => Some(idx - 1),
+ self.lines(|lines| match lines.partition_point(|x| x <= &pos) {
+ 0 => None,
+ i => Some(i - 1),
1638
})
1639
}
1640
0 commit comments