mirror of
https://github.com/rust-lang/rust
synced 2024-09-15 22:50:55 +00:00
rustc: Exclude stdin from codemap files when lookup_pos
Fixes issue #1362
This commit is contained in:
parent
085c813fe3
commit
1e4de33374
|
@ -35,15 +35,17 @@ fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
|
|||
|
||||
fn lookup_pos(map: codemap, pos: uint, lookup: lookup_fn) -> loc {
|
||||
let len = vec::len(map.files);
|
||||
if len > 1u && map.files[len - 1u].name == "-" {
|
||||
// the trailing "-" must be the core_macros inserted by expand_crate,
|
||||
// exclude it from the targets to lookup
|
||||
len = len - 1u;
|
||||
}
|
||||
let a = 0u;
|
||||
let b = len;
|
||||
while b - a > 1u {
|
||||
let m = (a + b) / 2u;
|
||||
if lookup(map.files[m].start_pos) > pos { b = m; } else { a = m; }
|
||||
}
|
||||
if (a >= len) {
|
||||
ret { filename: "-", line: 0u, col: 0u };
|
||||
}
|
||||
let f = map.files[a];
|
||||
a = 0u;
|
||||
b = vec::len(f.lines);
|
||||
|
|
Loading…
Reference in a new issue