expand: Stop un-interpolating NtIdent
s 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:
parent
d62d3f7fa9
commit
85ef265dbe
3 changed files with 10 additions and 33 deletions
|
@ -1,10 +1,9 @@
|
|||
use crate::expand::{self, AstFragment, Invocation};
|
||||
use crate::module::DirectoryOwnership;
|
||||
|
||||
use rustc_ast::mut_visit::{self, MutVisitor};
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::{self, TokenStream};
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::visit::{AssocCtxt, Visitor};
|
||||
use rustc_ast::{self as ast, Attribute, NodeId, PatKind};
|
||||
use rustc_attr::{self as attr, Deprecation, HasAttrs, Stability};
|
||||
|
@ -364,30 +363,8 @@ where
|
|||
&self,
|
||||
ecx: &'cx mut ExtCtxt<'_>,
|
||||
span: Span,
|
||||
mut input: TokenStream,
|
||||
input: TokenStream,
|
||||
) -> Box<dyn MacResult + 'cx> {
|
||||
struct AvoidInterpolatedIdents;
|
||||
|
||||
impl MutVisitor for AvoidInterpolatedIdents {
|
||||
fn visit_tt(&mut self, tt: &mut tokenstream::TokenTree) {
|
||||
if let tokenstream::TokenTree::Token(token) = tt {
|
||||
if let token::Interpolated(nt) = &token.kind {
|
||||
if let token::NtIdent(ident, is_raw) = **nt {
|
||||
*tt = tokenstream::TokenTree::token(
|
||||
token::Ident(ident.name, is_raw),
|
||||
ident.span,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
mut_visit::noop_visit_tt(tt, self)
|
||||
}
|
||||
|
||||
fn visit_mac(&mut self, mac: &mut ast::MacCall) {
|
||||
mut_visit::noop_visit_mac(mac, self)
|
||||
}
|
||||
}
|
||||
AvoidInterpolatedIdents.visit_tts(&mut input);
|
||||
(*self)(ecx, span, input)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue