use syntax::ptr::P;
use syntax_pos::Span;
use syntax_pos::symbol::Symbol;
-use syntax::tokenstream::TokenTree;
+use syntax::tokenstream::{TokenTree, TokenStream};
-pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt<'_>,
- sp: Span,
- tts: &[TokenTree])
- -> Box<dyn base::MacResult + 'cx> {
+pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>,
+ sp: Span,
+ tts: TokenStream)
+ -> Box<dyn base::MacResult + 'cx> {
if tts.is_empty() {
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
return DummyResult::any(sp);
}
let mut res_str = String::new();
- for (i, e) in tts.iter().enumerate() {
+ for (i, e) in tts.into_trees().enumerate() {
if i & 1 == 1 {
- match *e {
+ match e {
TokenTree::Token(Token { kind: token::Comma, .. }) => {}
_ => {
cx.span_err(sp, "concat_idents! expecting comma.");
}
}
} else {
- match *e {
+ match e {
TokenTree::Token(Token { kind: token::Ident(name, _), .. }) =>
res_str.push_str(&name.as_str()),
_ => {
}
}
- let ident = ast::Ident::new(Symbol::intern(&res_str), cx.with_legacy_ctxt(sp));
+ let ident = ast::Ident::new(Symbol::intern(&res_str), cx.with_call_site_ctxt(sp));
struct ConcatIdentsResult { ident: ast::Ident }