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