Auto merge of #100564 - nnethercote:box-ast-MacCall, r=spastorino
Box the `MacCall` in various types. r? `@spastorino`
This commit is contained in:
commit
dd01122b5c
12 changed files with 94 additions and 94 deletions
|
@ -770,7 +770,7 @@ pub enum PatKind {
|
|||
Paren(P<Pat>),
|
||||
|
||||
/// A macro pattern; pre-expansion.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
|
||||
|
@ -980,7 +980,7 @@ pub enum StmtKind {
|
|||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct MacCallStmt {
|
||||
pub mac: MacCall,
|
||||
pub mac: P<MacCall>,
|
||||
pub style: MacStmtStyle,
|
||||
pub attrs: AttrVec,
|
||||
pub tokens: Option<LazyTokenStream>,
|
||||
|
@ -1437,7 +1437,7 @@ pub enum ExprKind {
|
|||
InlineAsm(P<InlineAsm>),
|
||||
|
||||
/// A macro invocation; pre-expansion.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
|
||||
/// A struct literal expression.
|
||||
///
|
||||
|
@ -2040,7 +2040,7 @@ pub enum TyKind {
|
|||
/// Inferred type of a `self` or `&self` argument in a method.
|
||||
ImplicitSelf,
|
||||
/// A macro in the type position.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
/// Placeholder for a kind that has failed to be defined.
|
||||
Err,
|
||||
/// Placeholder for a `va_list`.
|
||||
|
@ -2877,7 +2877,7 @@ pub enum ItemKind {
|
|||
/// A macro invocation.
|
||||
///
|
||||
/// E.g., `foo!(..)`.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
|
||||
/// A macro definition.
|
||||
MacroDef(MacroDef),
|
||||
|
@ -2951,7 +2951,7 @@ pub enum AssocItemKind {
|
|||
/// An associated type.
|
||||
TyAlias(Box<TyAlias>),
|
||||
/// A macro expanding to associated items.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
}
|
||||
|
||||
impl AssocItemKind {
|
||||
|
@ -3000,7 +3000,7 @@ pub enum ForeignItemKind {
|
|||
/// An foreign type.
|
||||
TyAlias(Box<TyAlias>),
|
||||
/// A macro expanding to foreign items.
|
||||
MacCall(MacCall),
|
||||
MacCall(P<MacCall>),
|
||||
}
|
||||
|
||||
impl From<ForeignItemKind> for ItemKind {
|
||||
|
@ -3036,15 +3036,15 @@ mod size_asserts {
|
|||
use super::*;
|
||||
use rustc_data_structures::static_assert_size;
|
||||
// These are in alphabetical order, which is easy to maintain.
|
||||
static_assert_size!(AssocItem, 160);
|
||||
static_assert_size!(AssocItemKind, 72);
|
||||
static_assert_size!(AssocItem, 120);
|
||||
static_assert_size!(AssocItemKind, 32);
|
||||
static_assert_size!(Attribute, 32);
|
||||
static_assert_size!(Block, 48);
|
||||
static_assert_size!(Expr, 104);
|
||||
static_assert_size!(ExprKind, 72);
|
||||
static_assert_size!(Fn, 192);
|
||||
static_assert_size!(ForeignItem, 160);
|
||||
static_assert_size!(ForeignItemKind, 72);
|
||||
static_assert_size!(ForeignItem, 112);
|
||||
static_assert_size!(ForeignItemKind, 24);
|
||||
static_assert_size!(GenericBound, 88);
|
||||
static_assert_size!(Generics, 72);
|
||||
static_assert_size!(Impl, 200);
|
||||
|
|
|
@ -52,7 +52,7 @@ pub fn expand_assert<'cx>(
|
|||
let expr = if let Some(tokens) = custom_message {
|
||||
let then = cx.expr(
|
||||
call_site_span,
|
||||
ExprKind::MacCall(MacCall {
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
path: panic_path(),
|
||||
args: P(MacArgs::Delimited(
|
||||
DelimSpan::from_single(call_site_span),
|
||||
|
@ -60,7 +60,7 @@ pub fn expand_assert<'cx>(
|
|||
tokens,
|
||||
)),
|
||||
prior_type_ascription: None,
|
||||
}),
|
||||
})),
|
||||
);
|
||||
expr_if_not(cx, call_site_span, cond_expr, then, None)
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
|||
});
|
||||
self.cx.expr(
|
||||
self.span,
|
||||
ExprKind::MacCall(MacCall {
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
path: panic_path,
|
||||
args: P(MacArgs::Delimited(
|
||||
DelimSpan::from_single(self.span),
|
||||
|
@ -185,7 +185,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
|||
initial.into_iter().chain(captures).collect::<TokenStream>(),
|
||||
)),
|
||||
prior_type_ascription: None,
|
||||
}),
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ fn expand<'cx>(
|
|||
MacEager::expr(
|
||||
cx.expr(
|
||||
sp,
|
||||
ExprKind::MacCall(MacCall {
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
path: Path {
|
||||
span: sp,
|
||||
segments: cx
|
||||
|
@ -64,7 +64,7 @@ fn expand<'cx>(
|
|||
tts,
|
||||
)),
|
||||
prior_type_ascription: None,
|
||||
}),
|
||||
})),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ pub struct Invocation {
|
|||
|
||||
pub enum InvocationKind {
|
||||
Bang {
|
||||
mac: ast::MacCall,
|
||||
mac: P<ast::MacCall>,
|
||||
span: Span,
|
||||
},
|
||||
Attr {
|
||||
|
@ -1017,7 +1017,7 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
unreachable!()
|
||||
}
|
||||
fn pre_flat_map_node_collect_attr(_cfg: &StripUnconfigured<'_>, _attr: &ast::Attribute) {}
|
||||
|
@ -1046,7 +1046,7 @@ impl InvocationCollectorNode for P<ast::Item> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ItemKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.into_inner();
|
||||
match node.kind {
|
||||
ItemKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
|
||||
|
@ -1154,7 +1154,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let item = self.wrapped.into_inner();
|
||||
match item.kind {
|
||||
AssocItemKind::MacCall(mac) => (mac, item.attrs, AddSemicolon::No),
|
||||
|
@ -1179,7 +1179,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let item = self.wrapped.into_inner();
|
||||
match item.kind {
|
||||
AssocItemKind::MacCall(mac) => (mac, item.attrs, AddSemicolon::No),
|
||||
|
@ -1202,7 +1202,7 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ForeignItemKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.into_inner();
|
||||
match node.kind {
|
||||
ForeignItemKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
|
||||
|
@ -1323,7 +1323,7 @@ impl InvocationCollectorNode for ast::Stmt {
|
|||
StmtKind::Local(..) | StmtKind::Empty => false,
|
||||
}
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
// We pull macro invocations (both attributes and fn-like macro calls) out of their
|
||||
// `StmtKind`s and treat them as statement macro invocations, not as items or expressions.
|
||||
let (add_semicolon, mac, attrs) = match self.kind {
|
||||
|
@ -1387,7 +1387,7 @@ impl InvocationCollectorNode for P<ast::Ty> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ast::TyKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.into_inner();
|
||||
match node.kind {
|
||||
TyKind::MacCall(mac) => (mac, Vec::new(), AddSemicolon::No),
|
||||
|
@ -1411,7 +1411,7 @@ impl InvocationCollectorNode for P<ast::Pat> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, PatKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.into_inner();
|
||||
match node.kind {
|
||||
PatKind::MacCall(mac) => (mac, Vec::new(), AddSemicolon::No),
|
||||
|
@ -1439,7 +1439,7 @@ impl InvocationCollectorNode for P<ast::Expr> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ExprKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.into_inner();
|
||||
match node.kind {
|
||||
ExprKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
|
||||
|
@ -1466,7 +1466,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
|
|||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, ast::ExprKind::MacCall(..))
|
||||
}
|
||||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
let node = self.wrapped.into_inner();
|
||||
match node.kind {
|
||||
ExprKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
|
||||
|
@ -1512,7 +1512,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
placeholder(fragment_kind, NodeId::placeholder_from_expn_id(expn_id), vis)
|
||||
}
|
||||
|
||||
fn collect_bang(&mut self, mac: ast::MacCall, kind: AstFragmentKind) -> AstFragment {
|
||||
fn collect_bang(&mut self, mac: P<ast::MacCall>, kind: AstFragmentKind) -> AstFragment {
|
||||
// cache the macro call span so that it can be
|
||||
// easily adjusted for incremental compilation
|
||||
let span = mac.span();
|
||||
|
|
|
@ -15,12 +15,12 @@ pub fn placeholder(
|
|||
id: ast::NodeId,
|
||||
vis: Option<ast::Visibility>,
|
||||
) -> AstFragment {
|
||||
fn mac_placeholder() -> ast::MacCall {
|
||||
ast::MacCall {
|
||||
fn mac_placeholder() -> P<ast::MacCall> {
|
||||
P(ast::MacCall {
|
||||
path: ast::Path { span: DUMMY_SP, segments: Vec::new(), tokens: None },
|
||||
args: P(ast::MacArgs::Empty),
|
||||
prior_type_ascription: None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let ident = Ident::empty();
|
||||
|
|
|
@ -1492,11 +1492,11 @@ impl<'a> Parser<'a> {
|
|||
self.struct_span_err(path.span, "macros cannot use qualified paths").emit();
|
||||
}
|
||||
let lo = path.span;
|
||||
let mac = MacCall {
|
||||
let mac = P(MacCall {
|
||||
path,
|
||||
args: self.parse_mac_args()?,
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
};
|
||||
});
|
||||
(lo.to(self.prev_token.span), ExprKind::MacCall(mac))
|
||||
} else if self.check(&token::OpenDelim(Delimiter::Brace)) &&
|
||||
let Some(expr) = self.maybe_parse_struct_expr(qself.as_ref(), &path) {
|
||||
|
|
|
@ -287,7 +287,7 @@ impl<'a> Parser<'a> {
|
|||
return Ok(None);
|
||||
} else if macros_allowed && self.check_path() {
|
||||
// MACRO INVOCATION ITEM
|
||||
(Ident::empty(), ItemKind::MacCall(self.parse_item_macro(vis)?))
|
||||
(Ident::empty(), ItemKind::MacCall(P(self.parse_item_macro(vis)?)))
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
|
|
@ -665,7 +665,7 @@ impl<'a> Parser<'a> {
|
|||
fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> {
|
||||
self.bump();
|
||||
let args = self.parse_mac_args()?;
|
||||
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
|
||||
let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription });
|
||||
Ok(PatKind::MacCall(mac))
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ impl<'a> Parser<'a> {
|
|||
None => unreachable!(),
|
||||
};
|
||||
|
||||
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
|
||||
let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription });
|
||||
|
||||
let kind = if (style == MacStmtStyle::Braces
|
||||
&& self.token != token::Dot
|
||||
|
|
|
@ -598,11 +598,11 @@ impl<'a> Parser<'a> {
|
|||
let path = self.parse_path_inner(PathStyle::Type, ty_generics)?;
|
||||
if self.eat(&token::Not) {
|
||||
// Macro invocation in type position
|
||||
Ok(TyKind::MacCall(MacCall {
|
||||
Ok(TyKind::MacCall(P(MacCall {
|
||||
path,
|
||||
args: self.parse_mac_args()?,
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
}))
|
||||
})))
|
||||
} else if allow_plus == AllowPlus::Yes && self.check_plus() {
|
||||
// `Trait1 + Trait2 + 'a`
|
||||
self.parse_remaining_bounds_path(Vec::new(), path, lo, true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue