Revert "Change fold_tt and fold_tts to take token trees by value (instead of by reference)"

This reverts commit 5bf7970ac7.
This commit is contained in:
Jeffrey Seyfried
2016-07-04 10:25:50 +00:00
parent c2b56fb7a0
commit 547a930835
8 changed files with 72 additions and 53 deletions

View File

@@ -21,6 +21,8 @@ use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
use parse::lexer;
use parse::token;
use std::rc::Rc;
/// A delimited sequence of token trees
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Delimited {
@@ -94,13 +96,13 @@ pub enum TokenTree {
/// A single token
Token(Span, token::Token),
/// A delimited sequence of token trees
Delimited(Span, Delimited),
Delimited(Span, Rc<Delimited>),
// This only makes sense in MBE macros.
/// A kleene-style repetition sequence with a span
// FIXME(eddyb) #12938 Use DST.
Sequence(Span, SequenceRepetition),
Sequence(Span, Rc<SequenceRepetition>),
}
impl TokenTree {
@@ -149,7 +151,7 @@ impl TokenTree {
Some(*cnt)
}).max().unwrap_or(0);
TokenTree::Delimited(sp, Delimited {
TokenTree::Delimited(sp, Rc::new(Delimited {
delim: token::Bracket,
open_span: sp,
tts: vec![TokenTree::Token(sp, token::Ident(token::str_to_ident("doc"))),
@@ -157,7 +159,7 @@ impl TokenTree {
TokenTree::Token(sp, token::Literal(
token::StrRaw(token::intern(&stripped), num_of_hashes), None))],
close_span: sp,
})
}))
}
(&TokenTree::Delimited(_, ref delimed), _) => {
if index == 0 {