1
Fork 0

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 @@ impl<'hir> LoweringContext<'_, 'hir> {
ItemKind::MacroDef(MacroDef { body, macro_rules }) => { ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
let body = P(self.lower_delim_args(body)); let body = P(self.lower_delim_args(body));
let macro_kind = self.resolver.decl_macro_kind(self.local_def_id(id)); 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(..) => { ItemKind::MacCall(..) => {
panic!("`TyMac` should have been expanded by now") panic!("`TyMac` should have been expanded by now")

View file

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

View file

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