]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/arena.rs
Rollup merge of #88202 - azdavis:master, r=jyn514
[rust.git] / compiler / rustc_middle / src / arena.rs
1 /// This declares a list of types which can be allocated by `Arena`.
2 ///
3 /// The `few` modifier will cause allocation to use the shared arena and recording the destructor.
4 /// This is faster and more memory efficient if there's only a few allocations of the type.
5 /// Leaving `few` out will cause the type to get its own dedicated `TypedArena` which is
6 /// faster and more memory efficient if there is lots of allocations.
7 ///
8 /// Specifying the `decode` modifier will add decode impls for `&T` and `&[T]` where `T` is the type
9 /// listed. These impls will appear in the implement_ty_decoder! macro.
10 #[macro_export]
11 macro_rules! arena_types {
12     ($macro:path, $tcx:lifetime) => (
13         $macro!([
14             [] layouts: rustc_target::abi::Layout,
15             // AdtDef are interned and compared by address
16             [] adt_def: rustc_middle::ty::AdtDef,
17             [] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<$tcx>>,
18             [] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
19             [decode] mir: rustc_middle::mir::Body<$tcx>,
20             [] steal_promoted:
21                 rustc_data_structures::steal::Steal<
22                     rustc_index::vec::IndexVec<
23                         rustc_middle::mir::Promoted,
24                         rustc_middle::mir::Body<$tcx>
25                     >
26                 >,
27             [decode] promoted:
28                 rustc_index::vec::IndexVec<
29                     rustc_middle::mir::Promoted,
30                     rustc_middle::mir::Body<$tcx>
31                 >,
32             [decode] typeck_results: rustc_middle::ty::TypeckResults<$tcx>,
33             [decode] borrowck_result:
34                 rustc_middle::mir::BorrowCheckResult<$tcx>,
35             [decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
36             [decode] code_region: rustc_middle::mir::coverage::CodeRegion,
37             [] const_allocs: rustc_middle::mir::interpret::Allocation,
38             // Required for the incremental on-disk cache
39             [few] mir_keys: rustc_hir::def_id::DefIdSet,
40             [] region_scope_tree: rustc_middle::middle::region::ScopeTree,
41             [] dropck_outlives:
42                 rustc_middle::infer::canonical::Canonical<'tcx,
43                     rustc_middle::infer::canonical::QueryResponse<'tcx,
44                         rustc_middle::traits::query::DropckOutlivesResult<'tcx>
45                     >
46                 >,
47             [] normalize_projection_ty:
48                 rustc_middle::infer::canonical::Canonical<'tcx,
49                     rustc_middle::infer::canonical::QueryResponse<'tcx,
50                         rustc_middle::traits::query::NormalizationResult<'tcx>
51                     >
52                 >,
53             [] implied_outlives_bounds:
54                 rustc_middle::infer::canonical::Canonical<'tcx,
55                     rustc_middle::infer::canonical::QueryResponse<'tcx,
56                         Vec<rustc_middle::traits::query::OutlivesBound<'tcx>>
57                     >
58                 >,
59             [] type_op_subtype:
60                 rustc_middle::infer::canonical::Canonical<'tcx,
61                     rustc_middle::infer::canonical::QueryResponse<'tcx, ()>
62                 >,
63             [] type_op_normalize_poly_fn_sig:
64                 rustc_middle::infer::canonical::Canonical<'tcx,
65                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::PolyFnSig<'tcx>>
66                 >,
67             [] type_op_normalize_fn_sig:
68                 rustc_middle::infer::canonical::Canonical<'tcx,
69                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::FnSig<'tcx>>
70                 >,
71             [] type_op_normalize_predicate:
72                 rustc_middle::infer::canonical::Canonical<'tcx,
73                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Predicate<'tcx>>
74                 >,
75             [] type_op_normalize_ty:
76                 rustc_middle::infer::canonical::Canonical<'tcx,
77                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Ty<'tcx>>
78                 >,
79             [few] all_traits: Vec<rustc_hir::def_id::DefId>,
80             [few] privacy_access_levels: rustc_middle::middle::privacy::AccessLevels,
81             [few] foreign_module: rustc_middle::middle::cstore::ForeignModule,
82             [few] foreign_modules: Vec<rustc_middle::middle::cstore::ForeignModule>,
83             [] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
84             [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
85             [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
86             [] attribute: rustc_ast::Attribute,
87             [] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
88             [] hir_id_set: rustc_hir::HirIdSet,
89
90             // Interned types
91             [] tys: rustc_middle::ty::TyS<$tcx>,
92             [] predicates: rustc_middle::ty::PredicateInner<$tcx>,
93
94             // HIR query types
95             [few] indexed_hir: rustc_middle::hir::IndexedHir<$tcx>,
96             [few] hir_definitions: rustc_hir::definitions::Definitions,
97             [] hir_owner: rustc_middle::hir::Owner<$tcx>,
98             [] hir_owner_nodes: rustc_middle::hir::OwnerNodes<$tcx>,
99
100             // Note that this deliberately duplicates items in the `rustc_hir::arena`,
101             // since we need to allocate this type on both the `rustc_hir` arena
102             // (during lowering) and the `librustc_middle` arena (for decoding MIR)
103             [decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
104
105             // This is used to decode the &'tcx [Span] for InlineAsm's line_spans.
106             [decode] span: rustc_span::Span,
107             [decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
108         ], $tcx);
109     )
110 }
111
112 arena_types!(rustc_arena::declare_arena, 'tcx);