Skip to content

Commit 5da3686

Browse files
authored
Merge pull request #278 from alexcrichton/linecolumn
Document behavior of Span::start/end outside of proc macro
2 parents 3571b0a + 403089e commit 5da3686

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,13 @@ impl Span {
436436

437437
/// Get the starting line/column in the source file for this span.
438438
///
439-
/// This method requires the `"span-locations"` feature to be enabled and to be on `nightly`. On `stable` rust this
440-
/// currently returns a mocked LineColumn (`LineColumn { line: 0, column: 0 }`).
439+
/// This method requires the `"span-locations"` feature to be enabled.
440+
///
441+
/// When executing in a procedural macro context, the returned line/column
442+
/// are only meaningful if compiled with a nightly toolchain. The stable
443+
/// toolchain does not have this information available. When executing
444+
/// outside of a procedural macro, such as main.rs or build.rs, the
445+
/// line/column are always meaningful regardless of toolchain.
441446
#[cfg(span_locations)]
442447
pub fn start(&self) -> LineColumn {
443448
let imp::LineColumn { line, column } = self.inner.start();
@@ -446,8 +451,13 @@ impl Span {
446451

447452
/// Get the ending line/column in the source file for this span.
448453
///
449-
/// This method requires the `"span-locations"` feature to be enabled and to be on `nightly`. On `stable` rust this
450-
/// currently returns a mocked LineColumn (`LineColumn { line: 0, column: 0 }`).
454+
/// This method requires the `"span-locations"` feature to be enabled.
455+
///
456+
/// When executing in a procedural macro context, the returned line/column
457+
/// are only meaningful if compiled with a nightly toolchain. The stable
458+
/// toolchain does not have this information available. When executing
459+
/// outside of a procedural macro, such as main.rs or build.rs, the
460+
/// line/column are always meaningful regardless of toolchain.
451461
#[cfg(span_locations)]
452462
pub fn end(&self) -> LineColumn {
453463
let imp::LineColumn { line, column } = self.inner.end();

0 commit comments

Comments
 (0)