Skip to content

Commit

Permalink
make JSON error byte position start at top of file
Browse files Browse the repository at this point in the history
The `hi` and `lo` offsets in a span are relative to a `CodeMap`, but this
doesn't seem to be terribly useful for tool consumers who don't have the
codemap, but might want the byte offset within an actual file?

Resolves #35164.
  • Loading branch information
zackmdavis committed Jul 21, 2017
1 parent 15aa15b commit 6043ce9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libsyntax/json.rs
Expand Up @@ -256,8 +256,8 @@ impl DiagnosticSpan {
});
DiagnosticSpan {
file_name: start.file.name.clone(),
byte_start: span.lo.0,
byte_end: span.hi.0,
byte_start: span.lo.0 - start.file.start_pos.0,
byte_end: span.hi.0 - start.file.start_pos.0,
line_start: start.line,
line_end: end.line,
column_start: start.col.0 + 1,
Expand Down Expand Up @@ -362,4 +362,3 @@ impl JsonEmitter {
suggestion.splice_lines(&*self.cm).iter().map(|line| line.0.to_owned()).collect()
}
}

0 comments on commit 6043ce9

Please sign in to comment.