about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-16 15:12:05 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-18 20:32:40 +0200
commit59477a8ab21480a5c3da0313ef5a235091d8cbee (patch)
tree210a3a618b7a524481d6467d330916e7dc84926d
parent191df20fcad9331d3a948aa8e8556775ec3fe69d (diff)
downloadrust-59477a8ab21480a5c3da0313ef5a235091d8cbee.tar.gz
rust-59477a8ab21480a5c3da0313ef5a235091d8cbee.zip
Make rustdoc JSON Span column 1-based, just like line numbers
-rw-r--r--src/librustdoc/json/conversions.rs4
-rw-r--r--src/rustdoc-json-types/lib.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs
index dab23f8e42a..f446c9fbbd8 100644
--- a/src/librustdoc/json/conversions.rs
+++ b/src/librustdoc/json/conversions.rs
@@ -84,8 +84,8 @@ impl JsonRenderer<'_> {
                     let lo = span.lo(self.sess());
                     Some(Span {
                         filename: local_path,
-                        begin: (lo.line, lo.col.to_usize()),
-                        end: (hi.line, hi.col.to_usize()),
+                        begin: (lo.line, lo.col.to_usize() + 1),
+                        end: (hi.line, hi.col.to_usize() + 1),
                     })
                 } else {
                     None
diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
index 7247950545a..875857f9651 100644
--- a/src/rustdoc-json-types/lib.rs
+++ b/src/rustdoc-json-types/lib.rs
@@ -205,9 +205,9 @@ pub struct Item {
 pub struct Span {
     /// The path to the source file for this span relative to the path `rustdoc` was invoked with.
     pub filename: PathBuf,
-    /// Zero indexed Line and Column of the first character of the `Span`
+    /// One indexed Line and Column of the first character of the `Span`.
     pub begin: (usize, usize),
-    /// Zero indexed Line and Column of the last character of the `Span`
+    /// One indexed Line and Column of the last character of the `Span`.
     pub end: (usize, usize),
 }