1
Fork 0

expand: Stop un-interpolating NtIdents before passing them to built-in macros

This was a big hack, and built-in macros should be able to deal with `NtIdents` in the input by themselves like any other parser code.
This commit is contained in:
Vadim Petrochenkov 2020-09-27 19:47:52 +03:00
parent d62d3f7fa9
commit 85ef265dbe
3 changed files with 10 additions and 33 deletions

View file

@ -368,7 +368,7 @@ fn parse_reg<'a>(
explicit_reg: &mut bool,
) -> Result<ast::InlineAsmRegOrRegClass, DiagnosticBuilder<'a>> {
p.expect(&token::OpenDelim(token::DelimToken::Paren))?;
let result = match p.token.kind {
let result = match p.token.uninterpolate().kind {
token::Ident(name, false) => ast::InlineAsmRegOrRegClass::RegClass(name),
token::Literal(token::Lit { kind: token::LitKind::Str, symbol, suffix: _ }) => {
*explicit_reg = true;

View file

@ -27,15 +27,15 @@ pub fn expand_concat_idents<'cx>(
}
}
} else {
match e {
TokenTree::Token(Token { kind: token::Ident(name, _), .. }) => {
res_str.push_str(&name.as_str())
}
_ => {
cx.span_err(sp, "concat_idents! requires ident args.");
return DummyResult::any(sp);
if let TokenTree::Token(token) = e {
if let Some((ident, _)) = token.ident() {
res_str.push_str(&ident.name.as_str());
continue;
}
}
cx.span_err(sp, "concat_idents! requires ident args.");
return DummyResult::any(sp);
}
}