From 403089e199a90adf552c07ab25f7ff8d7d380bca Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 30 Mar 2021 01:22:02 -0400 Subject: [PATCH] Document behavior of Span::start/end outside of proc macro --- src/lib.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f476ba49..9575a9bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,8 +436,13 @@ impl Span { /// Get the starting line/column in the source file for this span. /// - /// This method requires the `"span-locations"` feature to be enabled and to be on `nightly`. On `stable` rust this - /// currently returns a mocked LineColumn (`LineColumn { line: 0, column: 0 }`). + /// This method requires the `"span-locations"` feature to be enabled. + /// + /// When executing in a procedural macro context, the returned line/column + /// are only meaningful if compiled with a nightly toolchain. The stable + /// toolchain does not have this information available. When executing + /// outside of a procedural macro, such as main.rs or build.rs, the + /// line/column are always meaningful regardless of toolchain. #[cfg(span_locations)] pub fn start(&self) -> LineColumn { let imp::LineColumn { line, column } = self.inner.start(); @@ -446,8 +451,13 @@ impl Span { /// Get the ending line/column in the source file for this span. /// - /// This method requires the `"span-locations"` feature to be enabled and to be on `nightly`. On `stable` rust this - /// currently returns a mocked LineColumn (`LineColumn { line: 0, column: 0 }`). + /// This method requires the `"span-locations"` feature to be enabled. + /// + /// When executing in a procedural macro context, the returned line/column + /// are only meaningful if compiled with a nightly toolchain. The stable + /// toolchain does not have this information available. When executing + /// outside of a procedural macro, such as main.rs or build.rs, the + /// line/column are always meaningful regardless of toolchain. #[cfg(span_locations)] pub fn end(&self) -> LineColumn { let imp::LineColumn { line, column } = self.inner.end();