]> git.lizzy.rs Git - rust.git/blob - src/librustc/ty/maps/mod.rs
Make queries block and handle query cycles
[rust.git] / src / librustc / ty / maps / mod.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use dep_graph::{DepConstructor, DepNode};
12 use hir::def_id::{CrateNum, DefId, DefIndex};
13 use hir::def::{Def, Export};
14 use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
15 use hir::svh::Svh;
16 use infer::canonical::{self, Canonical};
17 use lint;
18 use middle::borrowck::BorrowCheckResult;
19 use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
20 use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
21 use middle::privacy::AccessLevels;
22 use middle::reachable::ReachableSet;
23 use middle::region;
24 use middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
25 use middle::stability::{self, DeprecationEntry};
26 use middle::lang_items::{LanguageItems, LangItem};
27 use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
28 use middle::const_val::EvalResult;
29 use mir::mono::{CodegenUnit, Stats};
30 use mir;
31 use mir::interpret::{GlobalId, Allocation, ConstValue};
32 use session::{CompileResult, CrateDisambiguator};
33 use session::config::OutputFilenames;
34 use traits::{self, Vtable};
35 use traits::query::{CanonicalPredicateGoal, CanonicalProjectionGoal,
36                     CanonicalTyGoal, NoSolution};
37 use traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
38 use traits::query::normalize::NormalizationResult;
39 use traits::specialization_graph;
40 use traits::Clauses;
41 use ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
42 use ty::steal::Steal;
43 use ty::subst::Substs;
44 use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
45 use util::common::{ErrorReported};
46
47 use rustc_data_structures::indexed_set::IdxSetBuf;
48 use rustc_target::spec::PanicStrategy;
49 use rustc_data_structures::indexed_vec::IndexVec;
50 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
51 use rustc_data_structures::stable_hasher::StableVec;
52
53 use std::ops::Deref;
54 use rustc_data_structures::sync::Lrc;
55 use std::sync::Arc;
56 use syntax_pos::{Span, DUMMY_SP};
57 use syntax_pos::symbol::InternedString;
58 use syntax::attr;
59 use syntax::ast;
60 use syntax::feature_gate;
61 use syntax::symbol::Symbol;
62
63 #[macro_use]
64 mod plumbing;
65 use self::plumbing::*;
66 pub use self::plumbing::{force_from_dep_node, CycleError};
67
68 mod job;
69 pub use self::job::{QueryJob, QueryInfo};
70 #[cfg(parallel_queries)]
71 pub use self::job::handle_deadlock;
72
73 mod keys;
74 pub use self::keys::Key;
75
76 mod values;
77 use self::values::Value;
78
79 mod config;
80 pub use self::config::QueryConfig;
81 use self::config::QueryDescription;
82
83 mod on_disk_cache;
84 pub use self::on_disk_cache::OnDiskCache;
85
86 // Each of these maps also corresponds to a method on a
87 // `Provider` trait for requesting a value of that type,
88 // and a method on `Maps` itself for doing that in a
89 // a way that memoizes and does dep-graph tracking,
90 // wrapping around the actual chain of providers that
91 // the driver creates (using several `rustc_*` crates).
92 //
93 // The result of query must implement Clone. They must also implement ty::maps::values::Value
94 // which produces an appropriate error value if the query resulted in a query cycle.
95 // Queries marked with `fatal_cycle` do not need that implementation
96 // as they will raise an fatal error on query cycles instead.
97 define_maps! { <'tcx>
98     /// Records the type of every item.
99     [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
100
101     /// Maps from the def-id of an item (trait/struct/enum/fn) to its
102     /// associated generics and predicates.
103     [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
104     [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
105     [] fn explicit_predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
106
107     /// Maps from the def-id of a trait to the list of
108     /// super-predicates. This is a subset of the full list of
109     /// predicates. We store these in a separate map because we must
110     /// evaluate them even during type conversion, often before the
111     /// full predicates are available (note that supertraits have
112     /// additional acyclicity requirements).
113     [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
114
115     /// To avoid cycles within the predicates of a single item we compute
116     /// per-type-parameter predicates for resolving `T::AssocTy`.
117     [] fn type_param_predicates: type_param_predicates((DefId, DefId))
118         -> ty::GenericPredicates<'tcx>,
119
120     [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
121     [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
122     [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
123     [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
124     [] fn adt_dtorck_constraint: DtorckConstraint(
125         DefId
126     ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
127
128     /// True if this is a const fn
129     [] fn is_const_fn: IsConstFn(DefId) -> bool,
130
131     /// True if this is a foreign item (i.e., linked via `extern { ... }`).
132     [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
133
134     /// Get a map with the variance of every item; use `item_variance`
135     /// instead.
136     [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
137
138     /// Maps from def-id of a type or region parameter to its
139     /// (inferred) variance.
140     [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
141
142     /// Maps from def-id of a type to its (inferred) outlives.
143     [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
144
145     /// Maps from def-id of a type to its (inferred) outlives.
146     [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
147         -> Lrc<ty::CratePredicatesMap<'tcx>>,
148
149     /// Maps from an impl/trait def-id to a list of the def-ids of its items
150     [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
151
152     /// Maps from a trait item to the trait item "descriptor"
153     [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
154
155     [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
156     [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
157
158     /// Maps a DefId of a type to a list of its inherent impls.
159     /// Contains implementations of methods that are inherent to a type.
160     /// Methods in these implementations don't need to be exported.
161     [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
162
163     /// Set of all the def-ids in this crate that have MIR associated with
164     /// them. This includes all the body owners, but also things like struct
165     /// constructors.
166     [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
167
168     /// Maps DefId's that have an associated Mir to the result
169     /// of the MIR qualify_consts pass. The actual meaning of
170     /// the value isn't known except to the pass itself.
171     [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<IdxSetBuf<mir::Local>>),
172
173     /// Fetch the MIR for a given def-id right after it's built - this includes
174     /// unreachable code.
175     [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
176
177     /// Fetch the MIR for a given def-id up till the point where it is
178     /// ready for const evaluation.
179     ///
180     /// See the README for the `mir` module for details.
181     [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
182
183     [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
184
185     /// MIR after our optimization passes have run. This is MIR that is ready
186     /// for codegen. This is also the only query that can fetch non-local MIR, at present.
187     [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
188
189     /// The result of unsafety-checking this def-id.
190     [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
191
192     /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
193     [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
194
195     /// The signature of functions and closures.
196     [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
197
198     /// Caches CoerceUnsized kinds for impls on custom types.
199     [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
200         -> ty::adjustment::CoerceUnsizedInfo,
201
202     [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
203
204     [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
205
206     [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
207
208     [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
209
210     [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
211
212     [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
213
214     /// Borrow checks the function body. If this is a closure, returns
215     /// additional requirements that the closure's creator must verify.
216     [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
217
218     /// Gets a complete map from all types to their inherent impls.
219     /// Not meant to be used directly outside of coherence.
220     /// (Defined only for LOCAL_CRATE)
221     [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
222
223     /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
224     /// Not meant to be used directly outside of coherence.
225     /// (Defined only for LOCAL_CRATE)
226     [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
227
228     /// Results of evaluating const items or constants embedded in
229     /// other items (such as enum variant explicit discriminants).
230     [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
231         -> EvalResult<'tcx>,
232
233     /// Converts a constant value to an constant allocation
234     [] fn const_value_to_allocation: const_value_to_allocation(
235         (ConstValue<'tcx>, Ty<'tcx>)
236     ) -> &'tcx Allocation,
237
238     [] fn check_match: CheckMatch(DefId)
239         -> Result<(), ErrorReported>,
240
241     /// Performs the privacy check and computes "access levels".
242     [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
243
244     [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
245
246     /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
247     /// in the case of closures, this will be redirected to the enclosing function.
248     [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
249
250     [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
251
252     [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
253     [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
254
255     [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
256     [] fn def_span: DefSpan(DefId) -> Span,
257     [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
258     [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
259     [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
260     [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
261     [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
262     /// Gets the rendered value of the specified constant or associated constant.
263     /// Used by rustdoc.
264     [] fn rendered_const: RenderedConst(DefId) -> String,
265     [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
266     [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
267     [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
268     [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
269     [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
270     [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
271                           -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
272
273     [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
274         (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
275     [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
276     [] fn specialization_graph_of: SpecializationGraph(DefId) -> Lrc<specialization_graph::Graph>,
277     [] fn is_object_safe: ObjectSafety(DefId) -> bool,
278
279     // Get the ParameterEnvironment for a given item; this environment
280     // will be in "user-facing" mode, meaning that it is suitabe for
281     // type-checking etc, and it does not normalize specializable
282     // associated types. This is almost always what you want,
283     // unless you are doing MIR optimizations, in which case you
284     // might want to use `reveal_all()` method to change modes.
285     [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
286
287     // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
288     // `ty.is_copy()`, etc, since that will prune the environment where possible.
289     [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
290     [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
291     [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
292     [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
293     [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
294                                   -> Result<&'tcx ty::layout::LayoutDetails,
295                                             ty::layout::LayoutError<'tcx>>,
296
297     [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
298                                     -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
299
300     [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
301     [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
302     [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
303     [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
304     [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
305     [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
306     [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
307
308     [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
309
310     [] fn specializes: specializes_node((DefId, DefId)) -> bool,
311     [] fn in_scope_traits_map: InScopeTraits(DefIndex)
312         -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
313     [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
314     [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
315
316     [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
317
318     [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
319     [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
320     [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
321
322     // The DefIds of all non-generic functions and statics in the given crate
323     // that can be reached from outside the crate.
324     //
325     // We expect this items to be available for being linked to.
326     //
327     // This query can also be called for LOCAL_CRATE. In this case it will
328     // compute which items will be reachable to other crates, taking into account
329     // the kind of crate that is currently compiled. Crates with only a
330     // C interface have fewer reachable things.
331     //
332     // Does not include external symbols that don't have a corresponding DefId,
333     // like the compiler-generated `main` function and so on.
334     [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
335         -> Lrc<DefIdMap<SymbolExportLevel>>,
336     [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
337     [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
338
339     [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
340         -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
341     [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
342         -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
343
344     [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
345
346     [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
347
348     [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
349     [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
350     [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
351     [] fn crate_hash: CrateHash(CrateNum) -> Svh,
352     [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
353     [] fn extra_filename: ExtraFileName(CrateNum) -> String,
354
355     [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
356         -> Lrc<Vec<DefId>>,
357     [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
358         -> Lrc<Vec<DefId>>,
359
360     [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
361         -> Lrc<FxHashSet<DefId>>,
362     [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
363     [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
364     [] fn native_library_kind: NativeLibraryKind(DefId)
365         -> Option<NativeLibraryKind>,
366     [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
367
368     // Lifetime resolution. See `middle::resolve_lifetimes`.
369     [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
370     [] fn named_region_map: NamedRegion(DefIndex) ->
371         Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
372     [] fn is_late_bound_map: IsLateBound(DefIndex) ->
373         Option<Lrc<FxHashSet<ItemLocalId>>>,
374     [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
375         -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
376
377     [] fn visibility: Visibility(DefId) -> ty::Visibility,
378     [] fn dep_kind: DepKind(CrateNum) -> DepKind,
379     [] fn crate_name: CrateName(CrateNum) -> Symbol,
380     [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
381     [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
382
383     [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
384     [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
385     [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
386     [] fn visible_parent_map: visible_parent_map_node(CrateNum)
387         -> Lrc<DefIdMap<DefId>>,
388     [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
389     [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
390     [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
391
392     [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
393     [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
394     [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
395         -> Lrc<Vec<(DefId, Span)>>,
396
397     [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
398     [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
399
400     /// A vector of every trait accessible in the whole crate
401     /// (i.e. including those from subcrates). This is used only for
402     /// error reporting.
403     [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
404
405     [] fn exported_symbols: ExportedSymbols(CrateNum)
406         -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
407     [] fn collect_and_partition_mono_items:
408         collect_and_partition_mono_items_node(CrateNum)
409         -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
410     [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
411     [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
412     [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
413     [] fn output_filenames: output_filenames_node(CrateNum)
414         -> Arc<OutputFilenames>,
415
416     // Erases regions from `ty` to yield a new type.
417     // Normally you would just use `tcx.erase_regions(&value)`,
418     // however, which uses this query as a kind of cache.
419     [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
420
421     /// Do not call this query directly: invoke `normalize` instead.
422     [] fn normalize_projection_ty: NormalizeProjectionTy(
423         CanonicalProjectionGoal<'tcx>
424     ) -> Result<
425         Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, NormalizationResult<'tcx>>>>,
426         NoSolution,
427     >,
428
429     /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
430     [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
431         ParamEnvAnd<'tcx, Ty<'tcx>>
432     ) -> Ty<'tcx>,
433
434     /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
435     [] fn dropck_outlives: DropckOutlives(
436         CanonicalTyGoal<'tcx>
437     ) -> Result<
438         Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>,
439         NoSolution,
440     >,
441
442     /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
443     /// `infcx.predicate_must_hold()` instead.
444     [] fn evaluate_obligation: EvaluateObligation(
445         CanonicalPredicateGoal<'tcx>
446     ) -> Result<traits::EvaluationResult, traits::OverflowError>,
447
448     [] fn substitute_normalize_and_test_predicates:
449         substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
450
451     [] fn target_features_whitelist:
452         target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
453
454     // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
455     [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
456         -> usize,
457
458     [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
459
460     [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>,
461
462     [] fn program_clauses_for_env: ProgramClausesForEnv(
463         ty::ParamEnv<'tcx>
464     ) -> Clauses<'tcx>,
465
466     [] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc<Vec<DefId>>,
467     [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
468         -> Lrc<FxHashMap<DefId, String>>,
469 }
470
471 //////////////////////////////////////////////////////////////////////
472 // These functions are little shims used to find the dep-node for a
473 // given query when there is not a *direct* mapping:
474
475
476 fn features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
477     DepConstructor::Features
478 }
479
480 fn codegen_fn_attrs<'tcx>(id: DefId) -> DepConstructor<'tcx> {
481     DepConstructor::CodegenFnAttrs { 0: id }
482 }
483
484 fn erase_regions_ty<'tcx>(ty: Ty<'tcx>) -> DepConstructor<'tcx> {
485     DepConstructor::EraseRegionsTy { ty }
486 }
487
488 fn const_value_to_allocation<'tcx>(
489     (val, ty): (ConstValue<'tcx>, Ty<'tcx>)
490 ) -> DepConstructor<'tcx> {
491     DepConstructor::ConstValueToAllocation { val, ty }
492 }
493
494 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
495     DepConstructor::TypeParamPredicates {
496         item_id,
497         param_id
498     }
499 }
500
501 fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
502     (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> DepConstructor<'tcx> {
503     DepConstructor::FulfillObligation {
504         param_env,
505         trait_ref
506     }
507 }
508
509 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
510     DepConstructor::Coherence
511 }
512
513 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
514     DepConstructor::CoherenceInherentImplOverlapCheck
515 }
516
517 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
518     DepConstructor::Reachability
519 }
520
521 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
522     DepConstructor::MirShim {
523         instance_def
524     }
525 }
526
527 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
528     DepConstructor::InstanceSymbolName { instance }
529 }
530
531 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
532     DepConstructor::TypeckBodiesKrate
533 }
534
535 fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
536                              -> DepConstructor<'tcx> {
537     DepConstructor::ConstEval { param_env }
538 }
539
540 fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
541     DepConstructor::MirKeys
542 }
543
544 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
545     DepConstructor::CrateVariances
546 }
547
548 fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
549     DepConstructor::IsCopy { param_env }
550 }
551
552 fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
553     DepConstructor::IsSized { param_env }
554 }
555
556 fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
557     DepConstructor::IsFreeze { param_env }
558 }
559
560 fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
561     DepConstructor::NeedsDrop { param_env }
562 }
563
564 fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
565     DepConstructor::Layout { param_env }
566 }
567
568 fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
569     DepConstructor::LintLevels
570 }
571
572 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
573     DepConstructor::Specializes { impl1: a, impl2: b }
574 }
575
576 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
577     -> DepConstructor<'tcx>
578 {
579     DepConstructor::ImplementationsOfTrait { krate, trait_id }
580 }
581
582 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
583     DepConstructor::LinkArgs
584 }
585
586 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
587     DepConstructor::GetLangItems
588 }
589
590 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
591     DepConstructor::VisibleParentMap
592 }
593
594 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
595     DepConstructor::PostorderCnums
596 }
597
598 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
599     DepConstructor::MaybeUnusedExternCrates
600 }
601
602 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
603     DepConstructor::StabilityIndex
604 }
605
606 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
607     DepConstructor::AllCrateNums
608 }
609
610 fn all_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
611     DepConstructor::AllTraits
612 }
613
614 fn collect_and_partition_mono_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
615     DepConstructor::CollectAndPartitionMonoItems
616 }
617
618 fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
619     DepConstructor::OutputFilenames
620 }
621
622 fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> {
623     DepConstructor::VtableMethods{ trait_ref }
624 }
625
626 fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>))
627                                             -> DepConstructor<'tcx> {
628     DepConstructor::SubstituteNormalizeAndTestPredicates { key }
629 }
630
631 fn target_features_whitelist_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
632     DepConstructor::TargetFeaturesWhitelist
633 }
634
635 fn instance_def_size_estimate_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>)
636                                               -> DepConstructor<'tcx> {
637     DepConstructor::InstanceDefSizeEstimate {
638         instance_def
639     }
640 }