Skip to content

Commit f65615f

Browse files
committed
Auto merge of rust-lang#109590 - Nilstrieb:copy-hir, r=oli-obk
Impl `Copy` for most HIR types This simplifies the invocation of the `arena_types` macro and probably makes working with HIR nicer in general. Based on rust-lang#109588
2 parents 8991768 + 74e31ec commit f65615f

File tree

4 files changed

+72
-111
lines changed

4 files changed

+72
-111
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

+2-42
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,17 @@
11
/// This higher-order macro declares a list of types which can be allocated by `Arena`.
2-
///
3-
/// Specifying the `decode` modifier will add decode impls for `&T` and `&[T]`,
4-
/// where `T` is the type listed. These impls will appear in the implement_ty_decoder! macro.
2+
/// Note that all `Copy` types can be allocated by default and need not be specified here.
53
#[macro_export]
64
macro_rules! arena_types {
75
($macro:path) => (
86
$macro!([
97
// HIR types
108
[] hir_krate: rustc_hir::Crate<'tcx>,
11-
[] arm: rustc_hir::Arm<'tcx>,
12-
[] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, rustc_span::Span),
139
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
1410
[] attribute: rustc_ast::Attribute,
15-
[] closure: rustc_hir::Closure<'tcx>,
16-
[] block: rustc_hir::Block<'tcx>,
17-
[] bare_fn_ty: rustc_hir::BareFnTy<'tcx>,
18-
[] body: rustc_hir::Body<'tcx>,
19-
[] generics: rustc_hir::Generics<'tcx>,
20-
[] generic_arg: rustc_hir::GenericArg<'tcx>,
21-
[] generic_args: rustc_hir::GenericArgs<'tcx>,
22-
[] generic_bound: rustc_hir::GenericBound<'tcx>,
23-
[] generic_param: rustc_hir::GenericParam<'tcx>,
24-
[] expr: rustc_hir::Expr<'tcx>,
25-
[] impl_: rustc_hir::Impl<'tcx>,
26-
[] let_expr: rustc_hir::Let<'tcx>,
27-
[] expr_field: rustc_hir::ExprField<'tcx>,
28-
[] pat_field: rustc_hir::PatField<'tcx>,
29-
[] fn_decl: rustc_hir::FnDecl<'tcx>,
30-
[] foreign_item: rustc_hir::ForeignItem<'tcx>,
31-
[] foreign_item_ref: rustc_hir::ForeignItemRef,
32-
[] impl_item: rustc_hir::ImplItem<'tcx>,
33-
[] impl_item_ref: rustc_hir::ImplItemRef,
34-
[] item: rustc_hir::Item<'tcx>,
35-
[] inline_asm: rustc_hir::InlineAsm<'tcx>,
36-
[] local: rustc_hir::Local<'tcx>,
37-
[] mod_: rustc_hir::Mod<'tcx>,
3811
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
39-
[] param: rustc_hir::Param<'tcx>,
40-
[] pat: rustc_hir::Pat<'tcx>,
41-
[] path: rustc_hir::Path<'tcx>,
4212
[] use_path: rustc_hir::UsePath<'tcx>,
43-
[] path_segment: rustc_hir::PathSegment<'tcx>,
44-
[] poly_trait_ref: rustc_hir::PolyTraitRef<'tcx>,
45-
[] qpath: rustc_hir::QPath<'tcx>,
46-
[] stmt: rustc_hir::Stmt<'tcx>,
47-
[] field_def: rustc_hir::FieldDef<'tcx>,
48-
[] trait_item: rustc_hir::TraitItem<'tcx>,
49-
[] trait_item_ref: rustc_hir::TraitItemRef,
50-
[] ty: rustc_hir::Ty<'tcx>,
51-
[] type_binding: rustc_hir::TypeBinding<'tcx>,
52-
[] variant: rustc_hir::Variant<'tcx>,
53-
[] where_predicate: rustc_hir::WherePredicate<'tcx>,
5413
[] lit: rustc_hir::Lit,
14+
[] macro_def: rustc_ast::MacroDef,
5515
]);
5616
)
5717
}

0 commit comments

Comments
 (0)