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