Factor out StmtKind::MacCall fields into MacCallStmt
struct
In PR #76130, I add a fourth field, which makes using a tuple variant somewhat unwieldy.
This commit is contained in:
parent
85fbf49ce0
commit
090b16717a
8 changed files with 32 additions and 23 deletions
|
@ -13,7 +13,7 @@ use rustc_ast::token;
|
|||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::visit::{self, AssocCtxt, Visitor};
|
||||
use rustc_ast::{self as ast, AttrItem, Block, LitKind, NodeId, PatKind, Path};
|
||||
use rustc_ast::{ItemKind, MacArgs, MacStmtStyle, StmtKind};
|
||||
use rustc_ast::{ItemKind, MacArgs, MacCallStmt, MacStmtStyle, StmtKind};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr::{self as attr, is_builtin_attr, HasAttrs};
|
||||
use rustc_data_structures::map_in_place::MapInPlace;
|
||||
|
@ -1363,7 +1363,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||
}
|
||||
|
||||
if let StmtKind::MacCall(mac) = stmt.kind {
|
||||
let (mac, style, attrs) = mac.into_inner();
|
||||
let MacCallStmt { mac, style, attrs } = mac.into_inner();
|
||||
self.check_attributes(&attrs);
|
||||
let mut placeholder =
|
||||
self.collect_bang(mac, stmt.span, AstFragmentKind::Stmts).make_stmts();
|
||||
|
|
|
@ -92,7 +92,11 @@ pub fn placeholder(
|
|||
AstFragment::Ty(P(ast::Ty { id, span, kind: ast::TyKind::MacCall(mac_placeholder()) }))
|
||||
}
|
||||
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
|
||||
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new()));
|
||||
let mac = P(ast::MacCallStmt {
|
||||
mac: mac_placeholder(),
|
||||
style: ast::MacStmtStyle::Braces,
|
||||
attrs: ast::AttrVec::new(),
|
||||
});
|
||||
ast::Stmt { id, span, kind: ast::StmtKind::MacCall(mac) }
|
||||
}]),
|
||||
AstFragmentKind::Arms => AstFragment::Arms(smallvec![ast::Arm {
|
||||
|
@ -293,7 +297,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
|||
|
||||
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
|
||||
let (style, mut stmts) = match stmt.kind {
|
||||
ast::StmtKind::MacCall(mac) => (mac.1, self.remove(stmt.id).make_stmts()),
|
||||
ast::StmtKind::MacCall(mac) => (mac.style, self.remove(stmt.id).make_stmts()),
|
||||
_ => return noop_flat_map_stmt(stmt, self),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue