Skip to content

Commit 6043ce9

Browse files
committed
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.
1 parent 15aa15b commit 6043ce9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libsyntax/json.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ impl DiagnosticSpan {
256256
});
257257
DiagnosticSpan {
258258
file_name: start.file.name.clone(),
259-
byte_start: span.lo.0,
260-
byte_end: span.hi.0,
259+
byte_start: span.lo.0 - start.file.start_pos.0,
260+
byte_end: span.hi.0 - start.file.start_pos.0,
261261
line_start: start.line,
262262
line_end: end.line,
263263
column_start: start.col.0 + 1,
@@ -362,4 +362,3 @@ impl JsonEmitter {
362362
suggestion.splice_lines(&*self.cm).iter().map(|line| line.0.to_owned()).collect()
363363
}
364364
}
365-

0 commit comments

Comments
 (0)