Skip to content

Commit 59477a8

Browse files
Make rustdoc JSON Span column 1-based, just like line numbers
1 parent 191df20 commit 59477a8

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
@@ -205,9 +205,9 @@ pub struct Item {
205205
pub struct Span {
206206
/// The path to the source file for this span relative to the path `rustdoc` was invoked with.
207207
pub filename: PathBuf,
208-
/// Zero indexed Line and Column of the first character of the `Span`
208+
/// One indexed Line and Column of the first character of the `Span`.
209209
pub begin: (usize, usize),
210-
/// Zero indexed Line and Column of the last character of the `Span`
210+
/// One indexed Line and Column of the last character of the `Span`.
211211
pub end: (usize, usize),
212212
}
213213

0 commit comments

Comments
 (0)