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