From 1ecb6ce8c31e281906aa5c9529f754f0c3849139 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Sat, 30 Dec 2017 14:34:05 -0500 Subject: [PATCH] Wrap the LineColumn struct when re-exporting from proc-macro --- src/lib.rs | 13 ++++++++----- src/unstable.rs | 14 ++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b70cb4b..25f61f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,7 +141,10 @@ impl fmt::Debug for SourceFile { // NOTE: We can't easily wrap LineColumn right now, as the version in proc-macro // doesn't actually expose the internal `line` and `column` fields, making it // mostly useless. -pub use imp::LineColumn; +pub struct LineColumn { + pub line: usize, + pub column: usize, +} #[derive(Copy, Clone)] pub struct Span(imp::Span); @@ -167,13 +170,13 @@ impl Span { } pub fn start(&self) -> LineColumn { - // XXX(nika): We can't easily wrap LineColumn right now - self.0.start() + let imp::LineColumn{ line, column } = self.0.start(); + LineColumn { line, column } } pub fn end(&self) -> LineColumn { - // XXX(nika): We can't easily wrap LineColumn right now - self.0.end() + let imp::LineColumn{ line, column } = self.0.end(); + LineColumn { line, column } } pub fn join(&self, other: Span) -> Option { diff --git a/src/unstable.rs b/src/unstable.rs index 7d4e85c..3f4ef63 100644 --- a/src/unstable.rs +++ b/src/unstable.rs @@ -191,8 +191,10 @@ impl fmt::Debug for SourceFile { } } -// XXX(nika): We can't easily wrap LineColumn right now -pub use proc_macro::LineColumn; +pub struct LineColumn { + pub line: usize, + pub column: usize, +} #[derive(Copy, Clone)] pub struct Span(proc_macro::Span); @@ -211,13 +213,13 @@ impl Span { } pub fn start(&self) -> LineColumn { - // XXX(nika): We can't easily wrap LineColumn right now - self.0.start() + let proc_macro::LineColumn{ line, column } = self.0.start(); + LineColumn { line, column } } pub fn end(&self) -> LineColumn { - // XXX(nika): We can't easily wrap LineColumn right now - self.0.end() + let proc_macro::LineColumn{ line, column } = self.0.end(); + LineColumn { line, column } } pub fn join(&self, other: Span) -> Option {