Also arena-allocate ast::MacroDef to make Item: Copy

This commit is contained in:
Nilstrieb 2023-03-25 21:09:11 +01:00
parent ed8d67d8ba
commit 74e31ec64c
3 changed files with 6 additions and 5 deletions

View File

@ -443,7 +443,8 @@ fn lower_item_kind(
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
let body = P(self.lower_delim_args(body));
let macro_kind = self.resolver.decl_macro_kind(self.local_def_id(id));
hir::ItemKind::Macro(ast::MacroDef { body, macro_rules: *macro_rules }, macro_kind)
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
hir::ItemKind::Macro(macro_def, macro_kind)
}
ItemKind::MacCall(..) => {
panic!("`TyMac` should have been expanded by now")

View File

@ -8,10 +8,10 @@ macro_rules! arena_types {
[] hir_krate: rustc_hir::Crate<'tcx>,
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
[] attribute: rustc_ast::Attribute,
[] item: rustc_hir::Item<'tcx>,
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
[] use_path: rustc_hir::UsePath<'tcx>,
[] lit: rustc_hir::Lit,
[] macro_def: rustc_ast::MacroDef,
]);
)
}

View File

@ -3063,7 +3063,7 @@ pub fn hir_id(&self) -> HirId {
/// An item
///
/// The name might be a dummy name in case of anonymous items
#[derive(Debug, HashStable_Generic)]
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub struct Item<'hir> {
pub ident: Ident,
pub owner_id: OwnerId,
@ -3271,7 +3271,7 @@ pub fn is_unsafe(&self) -> bool {
}
}
#[derive(Debug, HashStable_Generic)]
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub enum ItemKind<'hir> {
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.
///
@ -3292,7 +3292,7 @@ pub enum ItemKind<'hir> {
/// A function declaration.
Fn(FnSig<'hir>, &'hir Generics<'hir>, BodyId),
/// A MBE macro definition (`macro_rules!` or `macro`).
Macro(ast::MacroDef, MacroKind),
Macro(&'hir ast::MacroDef, MacroKind),
/// A module.
Mod(&'hir Mod<'hir>),
/// An external module, e.g. `extern { .. }`.