Skip to content

Document behavior of Span::start/end outside of proc macro #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2021
Merged
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
18 changes: 14 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down