Skip to content

Commit 50fcd45

Browse files
committed
Make columns 1 based
1 parent b4a85da commit 50fcd45

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

library/proc_macro/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ impl Span {
348348
/// Gets the starting line/column in the source file for this span.
349349
#[unstable(feature = "proc_macro_span", issue = "54725")]
350350
pub fn start(&self) -> LineColumn {
351-
self.0.start()
351+
self.0.start().add_1_to_column()
352352
}
353353

354354
/// Gets the ending line/column in the source file for this span.
355355
#[unstable(feature = "proc_macro_span", issue = "54725")]
356356
pub fn end(&self) -> LineColumn {
357-
self.0.end()
357+
self.0.end().add_1_to_column()
358358
}
359359

360360
/// Creates a new span encompassing `self` and `other`.
@@ -432,12 +432,18 @@ pub struct LineColumn {
432432
/// The 1-indexed line in the source file on which the span starts or ends (inclusive).
433433
#[unstable(feature = "proc_macro_span", issue = "54725")]
434434
pub line: usize,
435-
/// The 0-indexed column (in UTF-8 characters) in the source file on which
435+
/// The 1-indexed column (in UTF-8 characters) in the source file on which
436436
/// the span starts or ends (inclusive).
437437
#[unstable(feature = "proc_macro_span", issue = "54725")]
438438
pub column: usize,
439439
}
440440

441+
impl LineColumn {
442+
fn add_1_to_column(self) -> Self {
443+
LineColumn { line: self.line, column: self.column + 1 }
444+
}
445+
}
446+
441447
#[unstable(feature = "proc_macro_span", issue = "54725")]
442448
impl !Send for LineColumn {}
443449
#[unstable(feature = "proc_macro_span", issue = "54725")]

0 commit comments

Comments
 (0)