diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-08-31 20:08:06 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-09-03 21:15:45 +0300 |
| commit | fa893a322570ea60cc8815b3dddb5311f0cb3b63 (patch) | |
| tree | e693cfd3e9ad5b53aba23bcfe17725afa749aa48 /src/doc | |
| parent | b3146549abf25818fecfc7555f35358a948e27ad (diff) | |
| download | rust-fa893a322570ea60cc8815b3dddb5311f0cb3b63.tar.gz rust-fa893a322570ea60cc8815b3dddb5311f0cb3b63.zip | |
use TokenStream rather than &[TokenTree] for built-in macros
That way, we don't loose the jointness info
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/plugin.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 53e8393ec52..68877b48433 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -57,12 +57,12 @@ extern crate rustc; extern crate rustc_driver; use syntax::parse::token::{self, Token}; -use syntax::tokenstream::TokenTree; +use syntax::tokenstream::{TokenTree, TokenStream}; use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; use syntax_pos::Span; use rustc_driver::plugin::Registry; -fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) +fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: TokenStream) -> Box<dyn MacResult + 'static> { static NUMERALS: &'static [(&'static str, usize)] = &[ @@ -78,7 +78,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) return DummyResult::any(sp); } - let text = match args[0] { + let text = match args.into_trees().next().unwrap() { TokenTree::Token(Token { kind: token::Ident(s, _), .. }) => s.to_string(), _ => { cx.span_err(sp, "argument should be a single identifier"); |
