]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/arena.rs
Serialize incr comp structures to file via fixed-size buffer
[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, $args:tt, $tcx:lifetime) => (
13         $macro!($args, [
14             [] layouts: rustc_target::abi::Layout,
15             // AdtDef are interned and compared by address
16             [] adt_def: rustc_middle::ty::AdtDef,
17             [] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
18             [decode] mir: rustc_middle::mir::Body<$tcx>,
19             [] steal_promoted:
20                 rustc_data_structures::steal::Steal<
21                     rustc_index::vec::IndexVec<
22                         rustc_middle::mir::Promoted,
23                         rustc_middle::mir::Body<$tcx>
24                     >
25                 >,
26             [decode] promoted:
27                 rustc_index::vec::IndexVec<
28                     rustc_middle::mir::Promoted,
29                     rustc_middle::mir::Body<$tcx>
30                 >,
31             [decode] typeck_results: rustc_middle::ty::TypeckResults<$tcx>,
32             [decode] borrowck_result:
33                 rustc_middle::mir::BorrowCheckResult<$tcx>,
34             [decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
35             [decode] code_region: rustc_middle::mir::coverage::CodeRegion,
36             [] const_allocs: rustc_middle::mir::interpret::Allocation,
37             // Required for the incremental on-disk cache
38             [few] mir_keys: rustc_hir::def_id::DefIdSet,
39             [] region_scope_tree: rustc_middle::middle::region::ScopeTree,
40             [] dropck_outlives:
41                 rustc_middle::infer::canonical::Canonical<'tcx,
42                     rustc_middle::infer::canonical::QueryResponse<'tcx,
43                         rustc_middle::traits::query::DropckOutlivesResult<'tcx>
44                     >
45                 >,
46             [] normalize_projection_ty:
47                 rustc_middle::infer::canonical::Canonical<'tcx,
48                     rustc_middle::infer::canonical::QueryResponse<'tcx,
49                         rustc_middle::traits::query::NormalizationResult<'tcx>
50                     >
51                 >,
52             [] implied_outlives_bounds:
53                 rustc_middle::infer::canonical::Canonical<'tcx,
54                     rustc_middle::infer::canonical::QueryResponse<'tcx,
55                         Vec<rustc_middle::traits::query::OutlivesBound<'tcx>>
56                     >
57                 >,
58             [] type_op_subtype:
59                 rustc_middle::infer::canonical::Canonical<'tcx,
60                     rustc_middle::infer::canonical::QueryResponse<'tcx, ()>
61                 >,
62             [] type_op_normalize_poly_fn_sig:
63                 rustc_middle::infer::canonical::Canonical<'tcx,
64                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::PolyFnSig<'tcx>>
65                 >,
66             [] type_op_normalize_fn_sig:
67                 rustc_middle::infer::canonical::Canonical<'tcx,
68                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::FnSig<'tcx>>
69                 >,
70             [] type_op_normalize_predicate:
71                 rustc_middle::infer::canonical::Canonical<'tcx,
72                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Predicate<'tcx>>
73                 >,
74             [] type_op_normalize_ty:
75                 rustc_middle::infer::canonical::Canonical<'tcx,
76                     rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Ty<'tcx>>
77                 >,
78             [few] all_traits: Vec<rustc_hir::def_id::DefId>,
79             [few] privacy_access_levels: rustc_middle::middle::privacy::AccessLevels,
80             [few] foreign_module: rustc_middle::middle::cstore::ForeignModule,
81             [few] foreign_modules: Vec<rustc_middle::middle::cstore::ForeignModule>,
82             [] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
83             [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
84             [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
85             [] attribute: rustc_ast::Attribute,
86             [] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
87             [] hir_id_set: rustc_hir::HirIdSet,
88
89             // Interned types
90             [] tys: rustc_middle::ty::TyS<$tcx>,
91             [] predicates: rustc_middle::ty::PredicateInner<$tcx>,
92
93             // HIR query types
94             [few] indexed_hir: rustc_middle::hir::map::IndexedHir<$tcx>,
95             [few] hir_definitions: rustc_hir::definitions::Definitions,
96             [] hir_owner: rustc_middle::hir::Owner<$tcx>,
97             [] hir_owner_nodes: rustc_middle::hir::OwnerNodes<$tcx>,
98
99             // Note that this deliberately duplicates items in the `rustc_hir::arena`,
100             // since we need to allocate this type on both the `rustc_hir` arena
101             // (during lowering) and the `librustc_middle` arena (for decoding MIR)
102             [decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
103
104             // This is used to decode the &'tcx [Span] for InlineAsm's line_spans.
105             [decode] span: rustc_span::Span,
106             [decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
107         ], $tcx);
108     )
109 }
110
111 arena_types!(rustc_arena::declare_arena, [], 'tcx);