diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-05 12:11:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-05 12:11:11 +0200 |
| commit | fd46f6ed4158fe50e8eda731be749d99e1f47ff6 (patch) | |
| tree | 7257256e1e0bdd15c7d506edefdc96cbf9f6b8c6 /src/doc | |
| parent | 56491314235a30c9cda06bbde4e7381bb4509814 (diff) | |
| parent | 613649584a9571168c292f82156aee1c173337a8 (diff) | |
| download | rust-fd46f6ed4158fe50e8eda731be749d99e1f47ff6.tar.gz rust-fd46f6ed4158fe50e8eda731be749d99e1f47ff6.zip | |
Rollup merge of #64041 - matklad:token-stream-tt, r=petrochenkov
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"); |
