make JSON error byte position start at top of file

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.
This commit is contained in:
Zack M. Davis 2017-06-29 12:07:30 -07:00
parent 15aa15b03f
commit 6043ce9f75

View File

@ -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,
@ -362,4 +362,3 @@ impl JsonEmitter {
suggestion.splice_lines(&*self.cm).iter().map(|line| line.0.to_owned()).collect()
}
}