mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-23 15:29:39 +00:00
Wrap the LineColumn struct when re-exporting from proc-macro
This commit is contained in:
parent
9cd13f742a
commit
1ecb6ce8c3
13
src/lib.rs
13
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<Span> {
|
||||
|
@ -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<Span> {
|
||||
|
Loading…
Reference in New Issue
Block a user