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