diff options
| author | est31 <MTest31@outlook.com> | 2021-08-03 00:46:10 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2021-08-03 03:10:10 +0200 |
| commit | 50fcd454c71084cb682f4d908b06cdd3eddacaf9 (patch) | |
| tree | f0144c0433bb73626cf5f38a6fb73adc1761b960 | |
| parent | b4a85dafda05adfb2eef3f13277ce3f52db4b23e (diff) | |
| download | rust-50fcd454c71084cb682f4d908b06cdd3eddacaf9.tar.gz rust-50fcd454c71084cb682f4d908b06cdd3eddacaf9.zip | |
Make columns 1 based
| -rw-r--r-- | library/proc_macro/src/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 8138c3882fc..793d35a28a2 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -348,13 +348,13 @@ impl Span { /// Gets the starting line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn start(&self) -> LineColumn { - self.0.start() + self.0.start().add_1_to_column() } /// Gets the ending line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn end(&self) -> LineColumn { - self.0.end() + self.0.end().add_1_to_column() } /// Creates a new span encompassing `self` and `other`. @@ -432,12 +432,18 @@ pub struct LineColumn { /// The 1-indexed line in the source file on which the span starts or ends (inclusive). #[unstable(feature = "proc_macro_span", issue = "54725")] pub line: usize, - /// The 0-indexed column (in UTF-8 characters) in the source file on which + /// The 1-indexed column (in UTF-8 characters) in the source file on which /// the span starts or ends (inclusive). #[unstable(feature = "proc_macro_span", issue = "54725")] pub column: usize, } +impl LineColumn { + fn add_1_to_column(self) -> Self { + LineColumn { line: self.line, column: self.column + 1 } + } +} + #[unstable(feature = "proc_macro_span", issue = "54725")] impl !Send for LineColumn {} #[unstable(feature = "proc_macro_span", issue = "54725")] |
