Fix the start/end byte positions in the compiler JSON output

This commit is contained in:
Mikko Rantanen
2019-10-03 03:55:31 +03:00
parent 2748a9fd93
commit ff1860ad76
14 changed files with 543 additions and 22 deletions

View File

@@ -25,6 +25,9 @@ use std::sync::{Arc, Mutex};
use rustc_serialize::json::{as_json, as_pretty_json};
#[cfg(test)]
mod tests;
pub struct JsonEmitter {
dst: Box<dyn Write + Send>,
registry: Option<Registry>,
@@ -332,8 +335,8 @@ impl DiagnosticSpan {
DiagnosticSpan {
file_name: start.file.name.to_string(),
byte_start: span.lo().0 - start.file.start_pos.0,
byte_end: span.hi().0 - start.file.start_pos.0,
byte_start: start.file.original_relative_byte_pos(span.lo()).0,
byte_end: start.file.original_relative_byte_pos(span.hi()).0,
line_start: start.line,
line_end: end.line,
column_start: start.col.0 + 1,