diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-01-19 15:49:34 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-01-20 08:35:47 -0800 |
| commit | 17294d98b915364f64a8a1cbc071aa6ee200a03b (patch) | |
| tree | 6a79c290e7f4ee37587b3b24fbd35a5f500a557b /src/libsyntax/print | |
| parent | dd5d85ea761e2d570682fccdb8608319d6bd2bf4 (diff) | |
| parent | 0b9e26f390403aa95620d3b813f046732b371fb1 (diff) | |
| download | rust-17294d98b915364f64a8a1cbc071aa6ee200a03b.tar.gz rust-17294d98b915364f64a8a1cbc071aa6ee200a03b.zip | |
Rollup merge of #39118 - jseyfried:token_tree_based_parser, r=nrc
Refactor the parser to consume token trees This is groundwork for efficiently parsing attribute proc macro invocations, bang macro invocations, and `TokenStream`-based attributes and fragment matchers. This improves parsing performance by 8-15% and expansion performance by 0-5% on a sampling of the compiler's crates. r? @nrc
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index baa3ebec854..061e871fe52 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -18,10 +18,9 @@ use util::parser::AssocOp; use attr; use codemap::{self, CodeMap}; use syntax_pos::{self, BytePos}; -use errors; use parse::token::{self, BinOpToken, Token}; use parse::lexer::comments; -use parse; +use parse::{self, ParseSess}; use print::pp::{self, break_offset, word, space, zerobreak, hardbreak}; use print::pp::{Breaks, eof}; use print::pp::Breaks::{Consistent, Inconsistent}; @@ -101,20 +100,15 @@ pub const DEFAULT_COLUMNS: usize = 78; /// it can scan the input text for comments and literals to /// copy forward. pub fn print_crate<'a>(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, krate: &ast::Crate, filename: String, input: &mut Read, out: Box<Write+'a>, ann: &'a PpAnn, is_expanded: bool) -> io::Result<()> { - let mut s = State::new_from_input(cm, - span_diagnostic, - filename, - input, - out, - ann, - is_expanded); + let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded); + if is_expanded && !std_inject::injected_crate_name(krate).is_none() { // We need to print `#![no_std]` (and its feature gate) so that // compiling pretty-printed source won't inject libstd again. @@ -140,16 +134,13 @@ pub fn print_crate<'a>(cm: &'a CodeMap, impl<'a> State<'a> { pub fn new_from_input(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, filename: String, input: &mut Read, out: Box<Write+'a>, ann: &'a PpAnn, is_expanded: bool) -> State<'a> { - let (cmnts, lits) = comments::gather_comments_and_literals( - span_diagnostic, - filename, - input); + let (cmnts, lits) = comments::gather_comments_and_literals(sess, filename, input); State::new( cm, |
