Omit Span::lo/hi when not using procmacro2_unstable
Token![...] being 24 bytes is a large number.
diff --git a/src/stable.rs b/src/stable.rs
index 9e69791..56c0dd2 100644
--- a/src/stable.rs
+++ b/src/stable.rs
@@ -54,7 +54,6 @@
fn get_cursor(src: &str) -> Cursor {
Cursor {
rest: src,
- off: 0,
}
}
@@ -313,15 +312,30 @@
}
#[derive(Clone, Copy, Debug)]
-pub struct Span { lo: u32, hi: u32 }
+pub struct Span {
+ #[cfg(procmacro2_unstable)]
+ lo: u32,
+ #[cfg(procmacro2_unstable)]
+ hi: u32,
+}
impl Span {
pub fn call_site() -> Span {
- Span { lo: 0, hi: 0 }
+ Span {
+ #[cfg(procmacro2_unstable)]
+ lo: 0,
+ #[cfg(procmacro2_unstable)]
+ hi: 0,
+ }
}
pub fn def_site() -> Span {
- Span { lo: 0, hi: 0 }
+ Span {
+ #[cfg(procmacro2_unstable)]
+ lo: 0,
+ #[cfg(procmacro2_unstable)]
+ hi: 0,
+ }
}
#[cfg(procmacro2_unstable)]
@@ -568,6 +582,16 @@
|trees| ::TokenStream(TokenStream { inner: trees })
));
+#[cfg(not(procmacro2_unstable))]
+fn token_tree(input: Cursor) -> PResult<TokenTree> {
+ let (input, kind) = token_kind(input)?;
+ Ok((input, TokenTree {
+ span: ::Span(Span {}),
+ kind: kind,
+ }))
+}
+
+#[cfg(procmacro2_unstable)]
fn token_tree(input: Cursor) -> PResult<TokenTree> {
let input = skip_whitespace(input);
let lo = input.off;
diff --git a/src/strnom.rs b/src/strnom.rs
index 558be8e..5f23803 100644
--- a/src/strnom.rs
+++ b/src/strnom.rs
@@ -9,6 +9,7 @@
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cursor<'a> {
pub rest: &'a str,
+ #[cfg(procmacro2_unstable)]
pub off: u32,
}
@@ -16,6 +17,7 @@
pub fn advance(&self, amt: usize) -> Cursor<'a> {
Cursor {
rest: &self.rest[amt..],
+ #[cfg(procmacro2_unstable)]
off: self.off + (amt as u32),
}
}