#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)]
-#![feature(let_else)]
+#![cfg_attr(bootstrap, feature(let_else))]
#![feature(if_let_guard)]
#![feature(negative_impls)]
#![feature(min_specialization)]
/// number. If the source_file is empty or the position is located before the
/// first line, `None` is returned.
pub fn lookup_line(&self, pos: BytePos) -> Option<usize> {
- self.lines(|lines| match lines.binary_search(&pos) {
- Ok(idx) => Some(idx),
- Err(0) => None,
- Err(idx) => Some(idx - 1),
+ self.lines(|lines| match lines.partition_point(|x| x <= &pos) {
+ 0 => None,
+ i => Some(i - 1),
})
}