diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-02-21 05:05:59 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-03-03 02:15:37 +0000 |
| commit | f6eaaf350ea683ae8b33b4a79422ad1a10ea0987 (patch) | |
| tree | 06ec138259c84d8ec6d46b33402d6470263a8880 /src/libsyntax/ext/base.rs | |
| parent | 8cd0c0885f841c9bfd0c330e3da21363427010e4 (diff) | |
| download | rust-f6eaaf350ea683ae8b33b4a79422ad1a10ea0987.tar.gz rust-f6eaaf350ea683ae8b33b4a79422ad1a10ea0987.zip | |
Integrate `TokenStream`.
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index c7d2f0cd31d..e242cf2777f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -188,10 +188,7 @@ impl<F> AttrProcMacro for F /// Represents a thing that maps token trees to Macro Results pub trait TTMacroExpander { - fn expand<'cx>(&self, - ecx: &'cx mut ExtCtxt, - span: Span, - token_tree: &[tokenstream::TokenTree]) + fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream) -> Box<MacResult+'cx>; } @@ -200,15 +197,11 @@ pub type MacroExpanderFn = -> Box<MacResult+'cx>; impl<F> TTMacroExpander for F - where F : for<'cx> Fn(&'cx mut ExtCtxt, Span, &[tokenstream::TokenTree]) - -> Box<MacResult+'cx> + where F: for<'cx> Fn(&'cx mut ExtCtxt, Span, &[tokenstream::TokenTree]) -> Box<MacResult+'cx> { - fn expand<'cx>(&self, - ecx: &'cx mut ExtCtxt, - span: Span, - token_tree: &[tokenstream::TokenTree]) + fn expand<'cx>(&self, ecx: &'cx mut ExtCtxt, span: Span, input: TokenStream) -> Box<MacResult+'cx> { - (*self)(ecx, span, token_tree) + (*self)(ecx, span, &input.trees().collect::<Vec<_>>()) } } @@ -654,9 +647,8 @@ impl<'a> ExtCtxt<'a> { expand::MacroExpander::new(self, true) } - pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) - -> parser::Parser<'a> { - parse::tts_to_parser(self.parse_sess, tts.to_vec()) + pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) -> parser::Parser<'a> { + parse::stream_to_parser(self.parse_sess, tts.iter().cloned().collect()) } pub fn codemap(&self) -> &'a CodeMap { self.parse_sess.codemap() } pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess } |
