Skip to content

Commit 74e31ec

Browse files
committed
Also arena-allocate ast::MacroDef to make Item: Copy
1 parent ed8d67d commit 74e31ec

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/rustc_ast_lowering/src/item.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
443443
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
444444
let body = P(self.lower_delim_args(body));
445445
let macro_kind = self.resolver.decl_macro_kind(self.local_def_id(id));
446-
hir::ItemKind::Macro(ast::MacroDef { body, macro_rules: *macro_rules }, macro_kind)
446+
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
447+
hir::ItemKind::Macro(macro_def, macro_kind)
447448
}
448449
ItemKind::MacCall(..) => {
449450
panic!("`TyMac` should have been expanded by now")

compiler/rustc_hir/src/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ macro_rules! arena_types {
88
[] hir_krate: rustc_hir::Crate<'tcx>,
99
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
1010
[] attribute: rustc_ast::Attribute,
11-
[] item: rustc_hir::Item<'tcx>,
1211
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
1312
[] use_path: rustc_hir::UsePath<'tcx>,
1413
[] lit: rustc_hir::Lit,
14+
[] macro_def: rustc_ast::MacroDef,
1515
]);
1616
)
1717
}

compiler/rustc_hir/src/hir.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,7 @@ impl ItemId {
30633063
/// An item
30643064
///
30653065
/// The name might be a dummy name in case of anonymous items
3066-
#[derive(Debug, HashStable_Generic)]
3066+
#[derive(Debug, Clone, Copy, HashStable_Generic)]
30673067
pub struct Item<'hir> {
30683068
pub ident: Ident,
30693069
pub owner_id: OwnerId,
@@ -3271,7 +3271,7 @@ impl FnHeader {
32713271
}
32723272
}
32733273

3274-
#[derive(Debug, HashStable_Generic)]
3274+
#[derive(Debug, Clone, Copy, HashStable_Generic)]
32753275
pub enum ItemKind<'hir> {
32763276
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.
32773277
///
@@ -3292,7 +3292,7 @@ pub enum ItemKind<'hir> {
32923292
/// A function declaration.
32933293
Fn(FnSig<'hir>, &'hir Generics<'hir>, BodyId),
32943294
/// A MBE macro definition (`macro_rules!` or `macro`).
3295-
Macro(ast::MacroDef, MacroKind),
3295+
Macro(&'hir ast::MacroDef, MacroKind),
32963296
/// A module.
32973297
Mod(&'hir Mod<'hir>),
32983298
/// An external module, e.g. `extern { .. }`.

0 commit comments

Comments
 (0)