Skip to content

Commit caec498

Browse files
Make rustdoc JSON Span column 1-based, just like line numbers
1 parent afa859f commit caec498

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: src/librustdoc/json/conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl JsonRenderer<'_> {
8484
let lo = span.lo(self.sess());
8585
Some(Span {
8686
filename: local_path,
87-
begin: (lo.line, lo.col.to_usize()),
88-
end: (hi.line, hi.col.to_usize()),
87+
begin: (lo.line, lo.col.to_usize() + 1),
88+
end: (hi.line, hi.col.to_usize() + 1),
8989
})
9090
} else {
9191
None

Diff for: src/rustdoc-json-types/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ pub struct Item {
149149
pub struct Span {
150150
/// The path to the source file for this span relative to the path `rustdoc` was invoked with.
151151
pub filename: PathBuf,
152-
/// Zero indexed Line and Column of the first character of the `Span`
152+
/// One indexed Line and Column of the first character of the `Span`.
153153
pub begin: (usize, usize),
154-
/// Zero indexed Line and Column of the last character of the `Span`
154+
/// One indexed Line and Column of the last character of the `Span`.
155155
pub end: (usize, usize),
156156
}
157157

0 commit comments

Comments
 (0)