Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false

matrix:
include:
- rust: 1.18.0
- rust: 1.15.0
- rust: stable
- rust: beta
- rust: nightly
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ impl Span {
#[cfg(procmacro2_unstable)]
pub fn start(&self) -> LineColumn {
let imp::LineColumn{ line, column } = self.0.start();
LineColumn { line, column }
LineColumn { line: line, column: column }
}

#[cfg(procmacro2_unstable)]
pub fn end(&self) -> LineColumn {
let imp::LineColumn{ line, column } = self.0.end();
LineColumn { line, column }
LineColumn { line: line, column: column }
}

#[cfg(procmacro2_unstable)]
Expand Down
26 changes: 23 additions & 3 deletions src/stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fn get_cursor(src: &str) -> Cursor {
fn get_cursor(src: &str) -> Cursor {
Cursor {
rest: src,
off: 0,
}
}

Expand Down Expand Up @@ -313,15 +312,26 @@ impl Codemap {
}

#[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 {
#[cfg(not(procmacro2_unstable))]
pub fn call_site() -> Span {
Span {}
}

#[cfg(procmacro2_unstable)]
pub fn call_site() -> Span {
Span { lo: 0, hi: 0 }
}

pub fn def_site() -> Span {
Span { lo: 0, hi: 0 }
Span::call_site()
}

#[cfg(procmacro2_unstable)]
Expand Down Expand Up @@ -568,6 +578,16 @@ named!(token_stream -> ::TokenStream, map!(
|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;
Expand Down
8 changes: 8 additions & 0 deletions src/strnom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ use imp::LexError;
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cursor<'a> {
pub rest: &'a str,
#[cfg(procmacro2_unstable)]
pub off: u32,
}

impl<'a> Cursor<'a> {
#[cfg(not(procmacro2_unstable))]
pub fn advance(&self, amt: usize) -> Cursor<'a> {
Cursor {
rest: &self.rest[amt..],
}
}
#[cfg(procmacro2_unstable)]
pub fn advance(&self, amt: usize) -> Cursor<'a> {
Cursor {
rest: &self.rest[amt..],
Expand Down
9 changes: 8 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
extern crate proc_macro2;

use proc_macro2::{Term, Literal, TokenStream, TokenNode, Span};
use proc_macro2::{Term, Literal, TokenStream};

#[cfg(procmacro2_unstable)]
use proc_macro2::TokenNode;

#[cfg(procmacro2_unstable)]
#[cfg(not(feature = "unstable"))]
use proc_macro2::Span;

#[test]
fn symbols() {
Expand Down