Skip to content

Commit bc438da

Browse files
committed
Box Mod and ForeignMod
1 parent 443c0d8 commit bc438da

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,11 +2725,11 @@ pub enum ItemKind {
27252725
/// A module declaration (`mod`).
27262726
///
27272727
/// E.g., `mod foo;` or `mod foo { .. }`.
2728-
Mod(Mod),
2728+
Mod(Box<Mod>),
27292729
/// An external module (`extern`).
27302730
///
27312731
/// E.g., `extern {}` or `extern "C" {}`.
2732-
ForeignMod(ForeignMod),
2732+
ForeignMod(Box<ForeignMod>),
27332733
/// Module-level inline assembly (from `global_asm!()`).
27342734
GlobalAsm(Box<GlobalAsm>),
27352735
/// A type alias (`type`).
@@ -2770,7 +2770,7 @@ pub enum ItemKind {
27702770
}
27712771

27722772
#[cfg(target_arch = "x86_64")]
2773-
rustc_data_structures::static_assert_size!(ItemKind, 72);
2773+
rustc_data_structures::static_assert_size!(ItemKind, 24);
27742774

27752775
impl ItemKind {
27762776
pub fn article(&self) -> &str {

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
10161016
id: DUMMY_NODE_ID,
10171017
vis: item_vis,
10181018
span,
1019-
kind: ItemKind::Mod(module),
1019+
kind: ItemKind::Mod(box module),
10201020
tokens: None,
10211021
});
10221022
let items = vis.flat_map_item(item);
@@ -1028,7 +1028,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
10281028
} else if len == 1 {
10291029
let Item { attrs, span, kind, .. } = items.into_iter().next().unwrap().into_inner();
10301030
match kind {
1031-
ItemKind::Mod(module) => Crate { module, attrs, span, proc_macros },
1031+
ItemKind::Mod(box module) => Crate { module, attrs, span, proc_macros },
10321032
_ => panic!("visitor converted a module to not a module"),
10331033
}
10341034
} else {

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10061006
self.error_item_without_body(item.span, "function", msg, " { <body> }");
10071007
}
10081008
}
1009-
ItemKind::ForeignMod(ForeignMod { unsafety, .. }) => {
1009+
ItemKind::ForeignMod(box ForeignMod { unsafety, .. }) => {
10101010
let old_item = mem::replace(&mut self.extern_mod, Some(item));
10111011
self.invalid_visibility(
10121012
&item.vis,
@@ -1054,7 +1054,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10541054
walk_list!(self, visit_attribute, &item.attrs);
10551055
return;
10561056
}
1057-
ItemKind::Mod(Mod { inline, unsafety, .. }) => {
1057+
ItemKind::Mod(box Mod { inline, unsafety, .. }) => {
10581058
if let Unsafe::Yes(span) = unsafety {
10591059
self.err_handler().span_err(span, "module cannot be declared unsafe");
10601060
}

compiler/rustc_expand/src/expand.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
376376
let krate_item = AstFragment::Items(smallvec![P(ast::Item {
377377
attrs: krate.attrs,
378378
span: krate.span,
379-
kind: ast::ItemKind::Mod(krate.module),
379+
kind: ast::ItemKind::Mod(box krate.module),
380380
ident: Ident::invalid(),
381381
id: ast::DUMMY_NODE_ID,
382382
vis: ast::Visibility {
@@ -388,7 +388,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
388388
})]);
389389

390390
match self.fully_expand_fragment(krate_item).make_items().pop().map(P::into_inner) {
391-
Some(ast::Item { attrs, kind: ast::ItemKind::Mod(module), .. }) => {
391+
Some(ast::Item { attrs, kind: ast::ItemKind::Mod(box module), .. }) => {
392392
krate.attrs = attrs;
393393
krate.module = module;
394394
}
@@ -1379,7 +1379,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13791379
_ => unreachable!(),
13801380
})
13811381
}
1382-
ast::ItemKind::Mod(ref mut old_mod @ ast::Mod { .. }) if ident != Ident::invalid() => {
1382+
ast::ItemKind::Mod(ref mut old_mod @ box ast::Mod { .. })
1383+
if ident != Ident::invalid() =>
1384+
{
13831385
let sess = &self.cx.sess.parse_sess;
13841386
let orig_ownership = self.cx.current_expansion.directory_ownership;
13851387
let mut module = (*self.cx.current_expansion.module).clone();
@@ -1412,7 +1414,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14121414
extern_mod_loaded(&krate, ident);
14131415
}
14141416

1415-
*old_mod = krate.module;
1417+
*old_mod = box krate.module;
14161418
item.attrs = krate.attrs;
14171419
// File can have inline attributes, e.g., `#![cfg(...)]` & co. => Reconfigure.
14181420
item = match self.configure(item) {

compiler/rustc_parse/src/parser/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a> Parser<'a> {
4646
self.parse_mod(&token::CloseDelim(token::Brace), unsafety)?
4747
};
4848
attrs.append(&mut inner_attrs);
49-
Ok((id, ItemKind::Mod(module)))
49+
Ok((id, ItemKind::Mod(box module)))
5050
}
5151

5252
/// Parses the contents of a module (inner attributes followed by module items).
@@ -919,7 +919,7 @@ impl<'a> Parser<'a> {
919919
let abi = self.parse_abi(); // ABI?
920920
let items = self.parse_item_list(attrs, |p| p.parse_foreign_item())?;
921921
let module = ast::ForeignMod { unsafety, abi, items };
922-
Ok((Ident::invalid(), ItemKind::ForeignMod(module)))
922+
Ok((Ident::invalid(), ItemKind::ForeignMod(box module)))
923923
}
924924

925925
/// Parses a foreign item (one in an `extern { ... }` block).

0 commit comments

Comments
 (0)