Skip to content

Commit

Permalink
Use relative positions inside a SourceFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 3, 2023
1 parent 65d75fd commit 61a0b77
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/debuginfo/line_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,9 @@ impl DebugContext {
match tcx.sess.source_map().lookup_line(span.lo()) {
Ok(SourceFileAndLine { sf: file, line }) => {
let line_pos = file.lines(|lines| lines[line]);
let col = file.relative_position(span.lo()) - line_pos;

(
file,
u64::try_from(line).unwrap() + 1,
u64::from((span.lo() - line_pos).to_u32()) + 1,
)
(file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1)
}
Err(file) => (file, 0, 0),
}
Expand Down

0 comments on commit 61a0b77

Please sign in to comment.