1
Fork 0

box a bunch of large types

This commit is contained in:
Oli Scherer 2023-03-29 12:34:05 +00:00
parent ec74653652
commit 4bebdd7104
16 changed files with 83 additions and 79 deletions

View file

@ -2917,11 +2917,11 @@ pub enum ItemKind {
/// A static item (`static`).
///
/// E.g., `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`.
Static(Static),
Static(Box<Static>),
/// A constant item (`const`).
///
/// E.g., `const FOO: i32 = 42;`.
Const(ConstItem),
Const(Box<ConstItem>),
/// A function declaration (`fn`).
///
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
@ -3037,7 +3037,7 @@ pub type AssocItem = Item<AssocItemKind>;
pub enum AssocItemKind {
/// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
/// If `def` is parsed, then the constant is provided, and otherwise required.
Const(ConstItem),
Const(Box<ConstItem>),
/// An associated function.
Fn(Box<Fn>),
/// An associated type.
@ -3049,7 +3049,7 @@ pub enum AssocItemKind {
impl AssocItemKind {
pub fn defaultness(&self) -> Defaultness {
match *self {
Self::Const(ConstItem { defaultness, .. })
Self::Const(box ConstItem { defaultness, .. })
| Self::Fn(box Fn { defaultness, .. })
| Self::Type(box TyAlias { defaultness, .. }) => defaultness,
Self::MacCall(..) => Defaultness::Final,
@ -3099,7 +3099,7 @@ impl From<ForeignItemKind> for ItemKind {
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
match foreign_item_kind {
ForeignItemKind::Static(a, b, c) => {
ItemKind::Static(Static { ty: a, mutability: b, expr: c })
ItemKind::Static(Static { ty: a, mutability: b, expr: c }.into())
}
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@ -3113,7 +3113,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
Ok(match item_kind {
ItemKind::Static(Static { ty: a, mutability: b, expr: c }) => {
ItemKind::Static(box Static { ty: a, mutability: b, expr: c }) => {
ForeignItemKind::Static(a, b, c)
}
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
@ -3132,8 +3132,8 @@ mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
// tidy-alphabetical-start
static_assert_size!(AssocItem, 104);
static_assert_size!(AssocItemKind, 32);
static_assert_size!(AssocItem, 88);
static_assert_size!(AssocItemKind, 16);
static_assert_size!(Attribute, 32);
static_assert_size!(Block, 32);
static_assert_size!(Expr, 72);

View file

@ -1030,7 +1030,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
match kind {
ItemKind::ExternCrate(_orig_name) => {}
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
ItemKind::Static(Static { ty, mutability: _, expr }) => {
ItemKind::Static(box Static { ty, mutability: _, expr }) => {
vis.visit_ty(ty);
visit_opt(expr, |expr| vis.visit_expr(expr));
}

View file

@ -305,8 +305,8 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
match &item.kind {
ItemKind::ExternCrate(_) => {}
ItemKind::Use(use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
ItemKind::Static(Static { ty, mutability: _, expr })
| ItemKind::Const(ConstItem { ty, expr, .. }) => {
ItemKind::Static(box Static { ty, mutability: _, expr })
| ItemKind::Const(box ConstItem { ty, expr, .. }) => {
visitor.visit_ty(ty);
walk_list!(visitor, visit_expr, expr);
}
@ -675,7 +675,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
visitor.visit_ident(ident);
walk_list!(visitor, visit_attribute, attrs);
match kind {
AssocItemKind::Const(ConstItem { ty, expr, .. }) => {
AssocItemKind::Const(box ConstItem { ty, expr, .. }) => {
visitor.visit_ty(ty);
walk_list!(visitor, visit_expr, expr);
}