Skip to content
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

Restore nightly behavior of Span::start and Span::end #472

Merged
merged 1 commit into from
Oct 16, 2024
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
16 changes: 16 additions & 0 deletions build/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ pub fn byte_range(this: &Span) -> Range<usize> {
this.byte_range()
}

pub fn start(this: &Span) -> Span {
this.start()
}

pub fn end(this: &Span) -> Span {
this.end()
}

pub fn line(this: &Span) -> usize {
this.line()
}

pub fn column(this: &Span) -> usize {
this.column()
}

pub fn join(this: &Span, other: Span) -> Option<Span> {
this.join(other)
}
Expand Down
15 changes: 15 additions & 0 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ impl Span {
#[cfg(span_locations)]
pub fn start(&self) -> LineColumn {
match self {
#[cfg(proc_macro_span)]
Span::Compiler(s) => LineColumn {
line: s.line(),
column: s.column().saturating_sub(1),
},
#[cfg(not(proc_macro_span))]
Span::Compiler(_) => LineColumn { line: 0, column: 0 },
Span::Fallback(s) => s.start(),
}
Expand All @@ -485,6 +491,15 @@ impl Span {
#[cfg(span_locations)]
pub fn end(&self) -> LineColumn {
match self {
#[cfg(proc_macro_span)]
Span::Compiler(s) => {
let end = s.end();
LineColumn {
line: end.line(),
column: end.column().saturating_sub(1),
}
}
#[cfg(not(proc_macro_span))]
Span::Compiler(_) => LineColumn { line: 0, column: 0 },
Span::Fallback(s) => s.end(),
}
Expand Down
Loading