Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
/// This integer is incremented with every breaking change to the API,
/// and is returned along with the JSON blob as [`Crate::format_version`].
/// Consuming code should assert that this value matches the format version(s) that it supports.
pub const FORMAT_VERSION: u32 = 44;
pub const FORMAT_VERSION: u32 = 45;

/// The root of the emitted JSON blob.
///
Expand Down Expand Up @@ -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),
}

Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-json/impls/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impl Foo {
}

// Testing spans, so all tests below code
//@ is "$.index[?(@.docs=='has span')].span.begin" "[13, 0]"
//@ is "$.index[?(@.docs=='has span')].span.end" "[15, 1]"
//@ is "$.index[?(@.docs=='has span')].span.begin" "[13, 1]"
//@ is "$.index[?(@.docs=='has span')].span.end" "[15, 2]"
// FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91
// is "$.index[?(@.inner.impl.is_synthetic==true)].span" null
pub struct Foo;
4 changes: 4 additions & 0 deletions tests/rustdoc-json/span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod bar {}
// This test ensures that spans are 1-indexed.
//@ is "$.index[?(@.name=='span')].span.begin" "[1, 1]"
//@ is "$.index[?(@.name=='bar')].span.begin" "[1, 1]"
Loading