Skip to content

Commit

Permalink
Drop dependency on #![feature(proc_macro_span)]
Browse files Browse the repository at this point in the history
This unstable feature (rust-lang/rust#54725) is the last thing that we
require in Nightly. Removing it will cause a significant regression in
error messages, but that can be improved after switching to parsing the
grammar as tokens rather than as a string literal.
  • Loading branch information
kevinmehall committed Oct 28, 2018
1 parent 1a26964 commit 503b998
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions peg-syntax-ext/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#![feature(proc_macro_span)]

extern crate peg_codegen;
extern crate proc_macro;

use std::iter;

use proc_macro::{ TokenStream, TokenTree, Span };

#[proc_macro]
pub fn peg(input: TokenStream) -> TokenStream {
let (name, source, span) = parse_peg_args(input);

let line = span.start().line;
let fname = span.source_file().path().display().to_string();

// Make PEG line numbers match source line numbers
let source = iter::repeat('\n').take(line - 1).collect::<String>() + &source;
let (name, source, _) = parse_peg_args(input);

expand_peg(name, fname, source)
expand_peg(name, "<peg>".into(), source)
}

/// Parse a TokenStream of the form `name r#""#`
Expand Down

0 comments on commit 503b998

Please sign in to comment.