Skip to content

Commit cb6230e

Browse files
committed
Box the MacCall in various types.
1 parent d665e9c commit cb6230e

File tree

11 files changed

+41
-41
lines changed

11 files changed

+41
-41
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ pub enum PatKind {
771771
Paren(P<Pat>),
772772

773773
/// A macro pattern; pre-expansion.
774-
MacCall(MacCall),
774+
MacCall(P<MacCall>),
775775
}
776776

777777
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
@@ -981,7 +981,7 @@ pub enum StmtKind {
981981

982982
#[derive(Clone, Encodable, Decodable, Debug)]
983983
pub struct MacCallStmt {
984-
pub mac: MacCall,
984+
pub mac: P<MacCall>,
985985
pub style: MacStmtStyle,
986986
pub attrs: AttrVec,
987987
pub tokens: Option<LazyTokenStream>,
@@ -1439,7 +1439,7 @@ pub enum ExprKind {
14391439
InlineAsm(P<InlineAsm>),
14401440

14411441
/// A macro invocation; pre-expansion.
1442-
MacCall(MacCall),
1442+
MacCall(P<MacCall>),
14431443

14441444
/// A struct literal expression.
14451445
///
@@ -2042,7 +2042,7 @@ pub enum TyKind {
20422042
/// Inferred type of a `self` or `&self` argument in a method.
20432043
ImplicitSelf,
20442044
/// A macro in the type position.
2045-
MacCall(MacCall),
2045+
MacCall(P<MacCall>),
20462046
/// Placeholder for a kind that has failed to be defined.
20472047
Err,
20482048
/// Placeholder for a `va_list`.
@@ -2873,7 +2873,7 @@ pub enum ItemKind {
28732873
/// A macro invocation.
28742874
///
28752875
/// E.g., `foo!(..)`.
2876-
MacCall(MacCall),
2876+
MacCall(P<MacCall>),
28772877

28782878
/// A macro definition.
28792879
MacroDef(MacroDef),
@@ -2947,7 +2947,7 @@ pub enum AssocItemKind {
29472947
/// An associated type.
29482948
TyAlias(Box<TyAlias>),
29492949
/// A macro expanding to associated items.
2950-
MacCall(MacCall),
2950+
MacCall(P<MacCall>),
29512951
}
29522952

29532953
impl AssocItemKind {
@@ -2996,7 +2996,7 @@ pub enum ForeignItemKind {
29962996
/// An foreign type.
29972997
TyAlias(Box<TyAlias>),
29982998
/// A macro expanding to foreign items.
2999-
MacCall(MacCall),
2999+
MacCall(P<MacCall>),
30003000
}
30013001

30023002
impl From<ForeignItemKind> for ItemKind {
@@ -3032,19 +3032,19 @@ mod size_asserts {
30323032
use super::*;
30333033
use rustc_data_structures::static_assert_size;
30343034
// These are in alphabetical order, which is easy to maintain.
3035-
static_assert_size!(AssocItem, 160);
3036-
static_assert_size!(AssocItemKind, 72);
3035+
static_assert_size!(AssocItem, 120);
3036+
static_assert_size!(AssocItemKind, 32);
30373037
static_assert_size!(Attribute, 152);
30383038
static_assert_size!(Block, 48);
30393039
static_assert_size!(Expr, 104);
30403040
static_assert_size!(Fn, 192);
3041-
static_assert_size!(ForeignItem, 160);
3042-
static_assert_size!(ForeignItemKind, 72);
3041+
static_assert_size!(ForeignItem, 112);
3042+
static_assert_size!(ForeignItemKind, 24);
30433043
static_assert_size!(GenericBound, 88);
30443044
static_assert_size!(Generics, 72);
30453045
static_assert_size!(Impl, 200);
3046-
static_assert_size!(Item, 160);
3047-
static_assert_size!(ItemKind, 72);
3046+
static_assert_size!(Item, 152);
3047+
static_assert_size!(ItemKind, 64);
30483048
static_assert_size!(Lit, 48);
30493049
static_assert_size!(Pat, 120);
30503050
static_assert_size!(Path, 40);

compiler/rustc_builtin_macros/src/assert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ pub fn expand_assert<'cx>(
5252
let expr = if let Some(tokens) = custom_message {
5353
let then = cx.expr(
5454
call_site_span,
55-
ExprKind::MacCall(MacCall {
55+
ExprKind::MacCall(P(MacCall {
5656
path: panic_path(),
5757
args: P(MacArgs::Delimited(
5858
DelimSpan::from_single(call_site_span),
5959
MacDelimiter::Parenthesis,
6060
tokens,
6161
)),
6262
prior_type_ascription: None,
63-
}),
63+
})),
6464
);
6565
expr_if_not(cx, call_site_span, cond_expr, then, None)
6666
}

compiler/rustc_builtin_macros/src/assert/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ impl<'cx, 'a> Context<'cx, 'a> {
177177
});
178178
self.cx.expr(
179179
self.span,
180-
ExprKind::MacCall(MacCall {
180+
ExprKind::MacCall(P(MacCall {
181181
path: panic_path,
182182
args: P(MacArgs::Delimited(
183183
DelimSpan::from_single(self.span),
184184
MacDelimiter::Parenthesis,
185185
initial.into_iter().chain(captures).collect::<TokenStream>(),
186186
)),
187187
prior_type_ascription: None,
188-
}),
188+
})),
189189
)
190190
}
191191

compiler/rustc_builtin_macros/src/edition_panic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn expand<'cx>(
4848
MacEager::expr(
4949
cx.expr(
5050
sp,
51-
ExprKind::MacCall(MacCall {
51+
ExprKind::MacCall(P(MacCall {
5252
path: Path {
5353
span: sp,
5454
segments: cx
@@ -64,7 +64,7 @@ fn expand<'cx>(
6464
tts,
6565
)),
6666
prior_type_ascription: None,
67-
}),
67+
})),
6868
),
6969
)
7070
}

compiler/rustc_expand/src/expand.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub struct Invocation {
306306

307307
pub enum InvocationKind {
308308
Bang {
309-
mac: ast::MacCall,
309+
mac: P<ast::MacCall>,
310310
span: Span,
311311
},
312312
Attr {
@@ -1017,7 +1017,7 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
10171017
fn is_mac_call(&self) -> bool {
10181018
false
10191019
}
1020-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1020+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
10211021
unreachable!()
10221022
}
10231023
fn pre_flat_map_node_collect_attr(_cfg: &StripUnconfigured<'_>, _attr: &ast::Attribute) {}
@@ -1046,7 +1046,7 @@ impl InvocationCollectorNode for P<ast::Item> {
10461046
fn is_mac_call(&self) -> bool {
10471047
matches!(self.kind, ItemKind::MacCall(..))
10481048
}
1049-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1049+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
10501050
let node = self.into_inner();
10511051
match node.kind {
10521052
ItemKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
@@ -1154,7 +1154,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
11541154
fn is_mac_call(&self) -> bool {
11551155
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
11561156
}
1157-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1157+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
11581158
let item = self.wrapped.into_inner();
11591159
match item.kind {
11601160
AssocItemKind::MacCall(mac) => (mac, item.attrs, AddSemicolon::No),
@@ -1179,7 +1179,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
11791179
fn is_mac_call(&self) -> bool {
11801180
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
11811181
}
1182-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1182+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
11831183
let item = self.wrapped.into_inner();
11841184
match item.kind {
11851185
AssocItemKind::MacCall(mac) => (mac, item.attrs, AddSemicolon::No),
@@ -1202,7 +1202,7 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
12021202
fn is_mac_call(&self) -> bool {
12031203
matches!(self.kind, ForeignItemKind::MacCall(..))
12041204
}
1205-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1205+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
12061206
let node = self.into_inner();
12071207
match node.kind {
12081208
ForeignItemKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
@@ -1323,7 +1323,7 @@ impl InvocationCollectorNode for ast::Stmt {
13231323
StmtKind::Local(..) | StmtKind::Empty => false,
13241324
}
13251325
}
1326-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1326+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
13271327
// We pull macro invocations (both attributes and fn-like macro calls) out of their
13281328
// `StmtKind`s and treat them as statement macro invocations, not as items or expressions.
13291329
let (add_semicolon, mac, attrs) = match self.kind {
@@ -1387,7 +1387,7 @@ impl InvocationCollectorNode for P<ast::Ty> {
13871387
fn is_mac_call(&self) -> bool {
13881388
matches!(self.kind, ast::TyKind::MacCall(..))
13891389
}
1390-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1390+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
13911391
let node = self.into_inner();
13921392
match node.kind {
13931393
TyKind::MacCall(mac) => (mac, Vec::new(), AddSemicolon::No),
@@ -1411,7 +1411,7 @@ impl InvocationCollectorNode for P<ast::Pat> {
14111411
fn is_mac_call(&self) -> bool {
14121412
matches!(self.kind, PatKind::MacCall(..))
14131413
}
1414-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1414+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
14151415
let node = self.into_inner();
14161416
match node.kind {
14171417
PatKind::MacCall(mac) => (mac, Vec::new(), AddSemicolon::No),
@@ -1439,7 +1439,7 @@ impl InvocationCollectorNode for P<ast::Expr> {
14391439
fn is_mac_call(&self) -> bool {
14401440
matches!(self.kind, ExprKind::MacCall(..))
14411441
}
1442-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1442+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
14431443
let node = self.into_inner();
14441444
match node.kind {
14451445
ExprKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
@@ -1466,7 +1466,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
14661466
fn is_mac_call(&self) -> bool {
14671467
matches!(self.wrapped.kind, ast::ExprKind::MacCall(..))
14681468
}
1469-
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, AddSemicolon) {
1469+
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
14701470
let node = self.wrapped.into_inner();
14711471
match node.kind {
14721472
ExprKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
@@ -1512,7 +1512,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
15121512
placeholder(fragment_kind, NodeId::placeholder_from_expn_id(expn_id), vis)
15131513
}
15141514

1515-
fn collect_bang(&mut self, mac: ast::MacCall, kind: AstFragmentKind) -> AstFragment {
1515+
fn collect_bang(&mut self, mac: P<ast::MacCall>, kind: AstFragmentKind) -> AstFragment {
15161516
// cache the macro call span so that it can be
15171517
// easily adjusted for incremental compilation
15181518
let span = mac.span();

compiler/rustc_expand/src/placeholders.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ pub fn placeholder(
1515
id: ast::NodeId,
1616
vis: Option<ast::Visibility>,
1717
) -> AstFragment {
18-
fn mac_placeholder() -> ast::MacCall {
19-
ast::MacCall {
18+
fn mac_placeholder() -> P<ast::MacCall> {
19+
P(ast::MacCall {
2020
path: ast::Path { span: DUMMY_SP, segments: Vec::new(), tokens: None },
2121
args: P(ast::MacArgs::Empty),
2222
prior_type_ascription: None,
23-
}
23+
})
2424
}
2525

2626
let ident = Ident::empty();

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,11 +1513,11 @@ impl<'a> Parser<'a> {
15131513
if qself.is_some() {
15141514
self.struct_span_err(path.span, "macros cannot use qualified paths").emit();
15151515
}
1516-
let mac = MacCall {
1516+
let mac = P(MacCall {
15171517
path,
15181518
args: self.parse_mac_args()?,
15191519
prior_type_ascription: self.last_type_ascription,
1520-
};
1520+
});
15211521
(self.prev_token.span, ExprKind::MacCall(mac))
15221522
} else if self.check(&token::OpenDelim(Delimiter::Brace)) {
15231523
if let Some(expr) = self.maybe_parse_struct_expr(qself.as_ref(), &path, &attrs) {

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a> Parser<'a> {
282282
return Ok(None);
283283
} else if macros_allowed && self.check_path() {
284284
// MACRO INVOCATION ITEM
285-
(Ident::empty(), ItemKind::MacCall(self.parse_item_macro(vis)?))
285+
(Ident::empty(), ItemKind::MacCall(P(self.parse_item_macro(vis)?)))
286286
} else {
287287
return Ok(None);
288288
};

compiler/rustc_parse/src/parser/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'a> Parser<'a> {
665665
fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> {
666666
self.bump();
667667
let args = self.parse_mac_args()?;
668-
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
668+
let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription });
669669
Ok(PatKind::MacCall(mac))
670670
}
671671

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a> Parser<'a> {
168168
None => unreachable!(),
169169
};
170170

171-
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
171+
let mac = P(MacCall { path, args, prior_type_ascription: self.last_type_ascription });
172172

173173
let kind = if (style == MacStmtStyle::Braces
174174
&& self.token != token::Dot

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,11 @@ impl<'a> Parser<'a> {
598598
let path = self.parse_path_inner(PathStyle::Type, ty_generics)?;
599599
if self.eat(&token::Not) {
600600
// Macro invocation in type position
601-
Ok(TyKind::MacCall(MacCall {
601+
Ok(TyKind::MacCall(P(MacCall {
602602
path,
603603
args: self.parse_mac_args()?,
604604
prior_type_ascription: self.last_type_ascription,
605-
}))
605+
})))
606606
} else if allow_plus == AllowPlus::Yes && self.check_plus() {
607607
// `Trait1 + Trait2 + 'a`
608608
self.parse_remaining_bounds_path(Vec::new(), path, lo, true)

0 commit comments

Comments
 (0)