]> git.lizzy.rs Git - rust.git/blob - src/librustc_middle/query/mod.rs
44db95c406449532a97a9a2fcce1646355fb83a7
[rust.git] / src / librustc_middle / query / mod.rs
1 use crate::dep_graph::SerializedDepNodeIndex;
2 use crate::mir;
3 use crate::mir::interpret::{GlobalId, LitToConstInput};
4 use crate::traits;
5 use crate::traits::query::{
6     CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
7     CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
8     CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
9 };
10 use crate::ty::query::queries;
11 use crate::ty::query::QueryDescription;
12 use crate::ty::subst::{GenericArg, SubstsRef};
13 use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
14 use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
15
16 use rustc_span::symbol::Symbol;
17 use std::borrow::Cow;
18
19 fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
20     if def_id.is_top_level_module() {
21         "top-level module".to_string()
22     } else {
23         format!("module `{}`", tcx.def_path_str(def_id))
24     }
25 }
26
27 // Each of these queries corresponds to a function pointer field in the
28 // `Providers` struct for requesting a value of that type, and a method
29 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
30 // which memoizes and does dep-graph tracking, wrapping around the actual
31 // `Providers` that the driver creates (using several `rustc_*` crates).
32 //
33 // The result type of each query must implement `Clone`, and additionally
34 // `ty::query::values::Value`, which produces an appropriate placeholder
35 // (error) value if the query resulted in a query cycle.
36 // Queries marked with `fatal_cycle` do not need the latter implementation,
37 // as they will raise an fatal error on query cycles instead.
38 rustc_queries! {
39     Other {
40         query trigger_delay_span_bug(key: DefId) -> () {
41             desc { "trigger a delay span bug" }
42         }
43     }
44
45     Other {
46         // Represents crate as a whole (as distinct from the top-level crate module).
47         // If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
48         // we will have to assume that any change means that you need to be recompiled.
49         // This is because the `hir_crate` query gives you access to all other items.
50         // To avoid this fate, do not call `tcx.hir().krate()`; instead,
51         // prefer wrappers like `tcx.visit_all_items_in_krate()`.
52         query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> {
53             eval_always
54             no_hash
55             desc { "get the crate HIR" }
56         }
57
58         // The indexed HIR. This can be conveniently accessed by `tcx.hir()`.
59         // Avoid calling this query directly.
60         query index_hir(_: CrateNum) -> &'tcx map::IndexedHir<'tcx> {
61             eval_always
62             no_hash
63             desc { "index HIR" }
64         }
65
66         // The items in a module.
67         //
68         // This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
69         // Avoid calling this query directly.
70         query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems {
71             eval_always
72             desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
73         }
74
75         // Gives access to the HIR node for the HIR owner `key`.
76         //
77         // This can be conveniently accessed by methods on `tcx.hir()`.
78         // Avoid calling this query directly.
79         query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> {
80             eval_always
81             desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
82         }
83
84         // Gives access to the HIR nodes and bodies inside the HIR owner `key`.
85         //
86         // This can be conveniently accessed by methods on `tcx.hir()`.
87         // Avoid calling this query directly.
88         query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> {
89             eval_always
90             desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
91         }
92
93         /// Records the type of every item.
94         query type_of(key: DefId) -> Ty<'tcx> {
95             cache_on_disk_if { key.is_local() }
96         }
97
98         query analysis(key: CrateNum) -> Result<(), ErrorReported> {
99             eval_always
100             desc { "running analysis passes on this crate" }
101         }
102
103         /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
104         /// associated generics.
105         query generics_of(key: DefId) -> ty::Generics {
106             storage(ArenaCacheSelector<'tcx>)
107             cache_on_disk_if { key.is_local() }
108             load_cached(tcx, id) {
109                 let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
110                                                         .try_load_query_result(tcx, id);
111                 generics
112             }
113         }
114
115         /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
116         /// predicates (where-clauses) that must be proven true in order
117         /// to reference it. This is almost always the "predicates query"
118         /// that you want.
119         ///
120         /// `predicates_of` builds on `predicates_defined_on` -- in fact,
121         /// it is almost always the same as that query, except for the
122         /// case of traits. For traits, `predicates_of` contains
123         /// an additional `Self: Trait<...>` predicate that users don't
124         /// actually write. This reflects the fact that to invoke the
125         /// trait (e.g., via `Default::default`) you must supply types
126         /// that actually implement the trait. (However, this extra
127         /// predicate gets in the way of some checks, which are intended
128         /// to operate over only the actual where-clauses written by the
129         /// user.)
130         query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
131             cache_on_disk_if { key.is_local() }
132         }
133
134         query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLibrary>> {
135             desc { "looking up the native libraries of a linked crate" }
136         }
137
138         query lint_levels(_: CrateNum) -> LintLevelMap {
139             storage(ArenaCacheSelector<'tcx>)
140             eval_always
141             desc { "computing the lint levels for items in this crate" }
142         }
143
144         query parent_module_from_def_id(key: LocalDefId) -> LocalDefId {
145             eval_always
146             desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) }
147         }
148     }
149
150     Codegen {
151         query is_panic_runtime(_: CrateNum) -> bool {
152             fatal_cycle
153             desc { "checking if the crate is_panic_runtime" }
154         }
155     }
156
157     Codegen {
158         /// Set of all the `DefId`s in this crate that have MIR associated with
159         /// them. This includes all the body owners, but also things like struct
160         /// constructors.
161         query mir_keys(_: CrateNum) -> FxHashSet<LocalDefId> {
162             storage(ArenaCacheSelector<'tcx>)
163             desc { "getting a list of all mir_keys" }
164         }
165
166         /// Maps DefId's that have an associated `mir::Body` to the result
167         /// of the MIR const-checking pass. This is the set of qualifs in
168         /// the final value of a `const`.
169         query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
170             desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
171             cache_on_disk_if { key.is_local() }
172         }
173
174         /// Fetch the MIR for a given `DefId` right after it's built - this includes
175         /// unreachable code.
176         query mir_built(_: LocalDefId) -> Steal<mir::Body<'tcx>> {
177             storage(ArenaCacheSelector<'tcx>)
178             desc { "building MIR for" }
179         }
180
181         /// Fetch the MIR for a given `DefId` up till the point where it is
182         /// ready for const evaluation.
183         ///
184         /// See the README for the `mir` module for details.
185         query mir_const(_: DefId) -> Steal<mir::Body<'tcx>> {
186             storage(ArenaCacheSelector<'tcx>)
187             no_hash
188         }
189
190         query mir_validated(key: LocalDefId) ->
191             (
192                 Steal<mir::Body<'tcx>>,
193                 Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
194             ) {
195             storage(ArenaCacheSelector<'tcx>)
196             no_hash
197             desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
198         }
199
200         /// MIR after our optimization passes have run. This is MIR that is ready
201         /// for codegen. This is also the only query that can fetch non-local MIR, at present.
202         query optimized_mir(key: DefId) -> mir::Body<'tcx> {
203             storage(ArenaCacheSelector<'tcx>)
204             cache_on_disk_if { key.is_local() }
205         }
206
207         query promoted_mir(key: DefId) -> IndexVec<mir::Promoted, mir::Body<'tcx>> {
208             storage(ArenaCacheSelector<'tcx>)
209             cache_on_disk_if { key.is_local() }
210         }
211     }
212
213     TypeChecking {
214         // Erases regions from `ty` to yield a new type.
215         // Normally you would just use `tcx.erase_regions(&value)`,
216         // however, which uses this query as a kind of cache.
217         query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
218             // This query is not expected to have input -- as a result, it
219             // is not a good candidates for "replay" because it is essentially a
220             // pure function of its input (and hence the expectation is that
221             // no caller would be green **apart** from just these
222             // queries). Making it anonymous avoids hashing the result, which
223             // may save a bit of time.
224             anon
225             desc { "erasing regions from `{:?}`", ty }
226         }
227
228         query program_clauses_for(_: DefId) -> Clauses<'tcx> {
229             desc { "generating chalk-style clauses" }
230         }
231
232         query program_clauses_for_env(_: traits::Environment<'tcx>) -> Clauses<'tcx> {
233             desc { "generating chalk-style clauses for environment" }
234         }
235
236         // Get the chalk-style environment of the given item.
237         query environment(_: DefId) -> traits::Environment<'tcx> {
238             desc { "return a chalk-style environment" }
239         }
240     }
241
242     Linking {
243         query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
244             storage(ArenaCacheSelector<'tcx>)
245             desc { "wasm import module map" }
246         }
247     }
248
249     Other {
250         /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
251         /// predicates (where-clauses) directly defined on it. This is
252         /// equal to the `explicit_predicates_of` predicates plus the
253         /// `inferred_outlives_of` predicates.
254         query predicates_defined_on(_: DefId) -> ty::GenericPredicates<'tcx> {}
255
256         /// Returns the predicates written explicitly by the user.
257         query explicit_predicates_of(_: DefId) -> ty::GenericPredicates<'tcx> {}
258
259         /// Returns the inferred outlives predicates (e.g., for `struct
260         /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
261         query inferred_outlives_of(_: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {}
262
263         /// Maps from the `DefId` of a trait to the list of
264         /// super-predicates. This is a subset of the full list of
265         /// predicates. We store these in a separate map because we must
266         /// evaluate them even during type conversion, often before the
267         /// full predicates are available (note that supertraits have
268         /// additional acyclicity requirements).
269         query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
270             desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
271         }
272
273         /// To avoid cycles within the predicates of a single item we compute
274         /// per-type-parameter predicates for resolving `T::AssocTy`.
275         query type_param_predicates(key: (DefId, LocalDefId)) -> ty::GenericPredicates<'tcx> {
276             desc { |tcx| "computing the bounds for type parameter `{}`", {
277                 let id = tcx.hir().as_local_hir_id(key.1);
278                 tcx.hir().ty_param_name(id)
279             }}
280         }
281
282         query trait_def(_: DefId) -> ty::TraitDef {
283             storage(ArenaCacheSelector<'tcx>)
284         }
285         query adt_def(_: DefId) -> ty::AdtDef {
286             storage(ArenaCacheSelector<'tcx>)
287         }
288         query adt_destructor(_: DefId) -> Option<ty::Destructor> {}
289
290         // The cycle error here should be reported as an error by `check_representable`.
291         // We consider the type as Sized in the meanwhile to avoid
292         // further errors (done in impl Value for AdtSizedConstraint).
293         // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
294         // in case we accidentally otherwise don't emit an error.
295         query adt_sized_constraint(
296             _: DefId
297         ) -> AdtSizedConstraint<'tcx> {
298             cycle_delay_bug
299         }
300
301         query adt_dtorck_constraint(
302             _: DefId
303         ) -> Result<DtorckConstraint<'tcx>, NoSolution> {}
304
305         /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
306         /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
307         /// not have the feature gate active).
308         ///
309         /// **Do not call this function manually.** It is only meant to cache the base data for the
310         /// `is_const_fn` function.
311         query is_const_fn_raw(key: DefId) -> bool {
312             desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
313         }
314
315         /// Returns `true` if this is a const `impl`. **Do not call this function manually.**
316         ///
317         /// This query caches the base data for the `is_const_impl` helper function, which also
318         /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`).
319         query is_const_impl_raw(key: DefId) -> bool {
320             desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) }
321         }
322
323         query asyncness(key: DefId) -> hir::IsAsync {
324             desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
325         }
326
327         /// Returns `true` if calls to the function may be promoted.
328         ///
329         /// This is either because the function is e.g., a tuple-struct or tuple-variant
330         /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
331         /// be removed in the future in favour of some form of check which figures out whether the
332         /// function does not inspect the bits of any of its arguments (so is essentially just a
333         /// constructor function).
334         query is_promotable_const_fn(_: DefId) -> bool {}
335
336         query const_fn_is_allowed_fn_ptr(_: DefId) -> bool {}
337
338         /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
339         query is_foreign_item(_: DefId) -> bool {}
340
341         /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
342         query static_mutability(_: DefId) -> Option<hir::Mutability> {}
343
344         /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
345         query generator_kind(_: DefId) -> Option<hir::GeneratorKind> {}
346
347         /// Gets a map with the variance of every item; use `item_variance` instead.
348         query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> {
349             storage(ArenaCacheSelector<'tcx>)
350             desc { "computing the variances for items in this crate" }
351         }
352
353         /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
354         query variances_of(_: DefId) -> &'tcx [ty::Variance] {}
355     }
356
357     TypeChecking {
358         /// Maps from thee `DefId` of a type to its (inferred) outlives.
359         query inferred_outlives_crate(_: CrateNum)
360             -> ty::CratePredicatesMap<'tcx> {
361             storage(ArenaCacheSelector<'tcx>)
362             desc { "computing the inferred outlives predicates for items in this crate" }
363         }
364     }
365
366     Other {
367         /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
368         query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}
369
370         /// Maps from a trait item to the trait item "descriptor".
371         query associated_item(_: DefId) -> ty::AssocItem {}
372
373         /// Collects the associated items defined on a trait or impl.
374         query associated_items(key: DefId) -> ty::AssociatedItems {
375             storage(ArenaCacheSelector<'tcx>)
376             desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
377         }
378
379         query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
380         query impl_polarity(_: DefId) -> ty::ImplPolarity {}
381
382         query issue33140_self_ty(_: DefId) -> Option<ty::Ty<'tcx>> {}
383     }
384
385     TypeChecking {
386         /// Maps a `DefId` of a type to a list of its inherent impls.
387         /// Contains implementations of methods that are inherent to a type.
388         /// Methods in these implementations don't need to be exported.
389         query inherent_impls(_: DefId) -> &'tcx [DefId] {
390             eval_always
391         }
392     }
393
394     TypeChecking {
395         /// The result of unsafety-checking this `DefId`.
396         query unsafety_check_result(key: LocalDefId) -> mir::UnsafetyCheckResult {
397             desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
398             cache_on_disk_if { true }
399         }
400
401         /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
402         query unsafe_derive_on_repr_packed(_: DefId) -> () {}
403
404         /// The signature of functions and closures.
405         query fn_sig(_: DefId) -> ty::PolyFnSig<'tcx> {}
406     }
407
408     Other {
409         query lint_mod(key: LocalDefId) -> () {
410             desc { |tcx| "linting {}", describe_as_module(key.to_def_id(), tcx) }
411         }
412
413         /// Checks the attributes in the module.
414         query check_mod_attrs(key: DefId) -> () {
415             desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
416         }
417
418         query check_mod_unstable_api_usage(key: DefId) -> () {
419             desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
420         }
421
422         /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
423         query check_mod_const_bodies(key: DefId) -> () {
424             desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
425         }
426
427         /// Checks the loops in the module.
428         query check_mod_loops(key: DefId) -> () {
429             desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
430         }
431
432         query check_mod_item_types(key: DefId) -> () {
433             desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
434         }
435
436         query check_mod_privacy(key: LocalDefId) -> () {
437             desc { |tcx| "checking privacy in {}", describe_as_module(key.to_def_id(), tcx) }
438         }
439
440         query check_mod_intrinsics(key: DefId) -> () {
441             desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) }
442         }
443
444         query check_mod_liveness(key: DefId) -> () {
445             desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) }
446         }
447
448         query check_mod_impl_wf(key: DefId) -> () {
449             desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
450         }
451
452         query collect_mod_item_types(key: DefId) -> () {
453             desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
454         }
455
456         /// Caches `CoerceUnsized` kinds for impls on custom types.
457         query coerce_unsized_info(_: DefId)
458             -> ty::adjustment::CoerceUnsizedInfo {}
459     }
460
461     TypeChecking {
462         query typeck_item_bodies(_: CrateNum) -> () {
463             desc { "type-checking all item bodies" }
464         }
465
466         query typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> {
467             desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
468             cache_on_disk_if { true }
469         }
470         query diagnostic_only_typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> {
471             desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
472             cache_on_disk_if { true }
473             load_cached(tcx, id) {
474                 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
475                     .queries.on_disk_cache
476                     .try_load_query_result(tcx, id);
477
478                 typeck_tables.map(|x| &*tcx.arena.alloc(x))
479             }
480         }
481     }
482
483     Other {
484         query used_trait_imports(key: LocalDefId) -> &'tcx DefIdSet {
485             desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) }
486             cache_on_disk_if { true }
487         }
488     }
489
490     TypeChecking {
491         query has_typeck_tables(_: DefId) -> bool {}
492
493         query coherent_trait(def_id: DefId) -> () {
494             desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
495         }
496     }
497
498     BorrowChecking {
499         /// Borrow-checks the function body. If this is a closure, returns
500         /// additional requirements that the closure's creator must verify.
501         query mir_borrowck(key: LocalDefId) -> mir::BorrowCheckResult<'tcx> {
502             storage(ArenaCacheSelector<'tcx>)
503             desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
504             cache_on_disk_if(tcx, opt_result) {
505                 tcx.is_closure(key.to_def_id())
506                     || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty())
507             }
508         }
509     }
510
511     TypeChecking {
512         /// Gets a complete map from all types to their inherent impls.
513         /// Not meant to be used directly outside of coherence.
514         /// (Defined only for `LOCAL_CRATE`.)
515         query crate_inherent_impls(k: CrateNum)
516             -> CrateInherentImpls {
517             storage(ArenaCacheSelector<'tcx>)
518             eval_always
519             desc { "all inherent impls defined in crate `{:?}`", k }
520         }
521
522         /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
523         /// Not meant to be used directly outside of coherence.
524         /// (Defined only for `LOCAL_CRATE`.)
525         query crate_inherent_impls_overlap_check(_: CrateNum)
526             -> () {
527             eval_always
528             desc { "check for overlap between inherent impls defined in this crate" }
529         }
530     }
531
532     Other {
533         /// Evaluates a constant without running sanity checks.
534         ///
535         /// **Do not use this** outside const eval. Const eval uses this to break query cycles
536         /// during validation. Please add a comment to every use site explaining why using
537         /// `const_eval_validated` isn't sufficient. The returned constant also isn't in a suitable
538         /// form to be used outside of const eval.
539         query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
540             -> ConstEvalRawResult<'tcx> {
541             desc { |tcx|
542                 "const-evaluating `{}`",
543                 tcx.def_path_str(key.value.instance.def.def_id())
544             }
545         }
546
547         /// Results of evaluating const items or constants embedded in
548         /// other items (such as enum variant explicit discriminants).
549         ///
550         /// In contrast to `const_eval_raw` this performs some validation on the constant, and
551         /// returns a proper constant that is usable by the rest of the compiler.
552         ///
553         /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
554         /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
555         query const_eval_validated(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
556             -> ConstEvalResult<'tcx> {
557             desc { |tcx|
558                 "const-evaluating + checking `{}`",
559                 tcx.def_path_str(key.value.instance.def.def_id())
560             }
561             cache_on_disk_if(_, opt_result) {
562                 // Only store results without errors
563                 opt_result.map_or(true, |r| r.is_ok())
564             }
565         }
566
567         /// Extracts a field of a (variant of a) const.
568         query const_field(
569             key: ty::ParamEnvAnd<'tcx, (&'tcx ty::Const<'tcx>, mir::Field)>
570         ) -> ConstValue<'tcx> {
571             desc { "extract field of const" }
572         }
573
574         /// Destructure a constant ADT or array into its variant index and its
575         /// field values.
576         query destructure_const(
577             key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
578         ) -> mir::DestructuredConst<'tcx> {
579             desc { "destructure constant" }
580         }
581
582         query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
583             desc { "get a &core::panic::Location referring to a span" }
584         }
585
586         query lit_to_const(
587             key: LitToConstInput<'tcx>
588         ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
589             desc { "converting literal to const" }
590         }
591     }
592
593     TypeChecking {
594         query check_match(key: DefId) {
595             cache_on_disk_if { key.is_local() }
596         }
597
598         /// Performs part of the privacy check and computes "access levels".
599         query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
600             eval_always
601             desc { "privacy access levels" }
602         }
603         query check_private_in_public(_: CrateNum) -> () {
604             eval_always
605             desc { "checking for private elements in public interfaces" }
606         }
607     }
608
609     Other {
610         query reachable_set(_: CrateNum) -> &'tcx HirIdSet {
611             desc { "reachability" }
612         }
613
614         /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
615         /// in the case of closures, this will be redirected to the enclosing function.
616         query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
617
618         query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
619             storage(ArenaCacheSelector<'tcx>)
620             desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
621         }
622
623         /// The `symbol_name` query provides the symbol name for calling a
624         /// given instance from the local crate. In particular, it will also
625         /// look up the correct symbol name of instances from upstream crates.
626         query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName {
627             desc { "computing the symbol for `{}`", key }
628             cache_on_disk_if { true }
629         }
630
631         query def_kind(_: DefId) -> DefKind {}
632         query def_span(_: DefId) -> Span {
633             // FIXME(mw): DefSpans are not really inputs since they are derived from
634             // HIR. But at the moment HIR hashing still contains some hacks that allow
635             // to make type debuginfo to be source location independent. Declaring
636             // DefSpan an input makes sure that changes to these are always detected
637             // regardless of HIR hashing.
638             eval_always
639         }
640         query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
641         query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {}
642         query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
643         query item_attrs(_: DefId) -> &'tcx [ast::Attribute] {}
644     }
645
646     Codegen {
647         query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {
648             cache_on_disk_if { true }
649         }
650     }
651
652     Other {
653         query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {}
654         /// Gets the rendered value of the specified constant or associated constant.
655         /// Used by rustdoc.
656         query rendered_const(_: DefId) -> String {}
657         query impl_parent(_: DefId) -> Option<DefId> {}
658     }
659
660     TypeChecking {
661         query trait_of_item(_: DefId) -> Option<DefId> {}
662     }
663
664     Codegen {
665         query is_mir_available(key: DefId) -> bool {
666             desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
667         }
668     }
669
670     Other {
671         query vtable_methods(key: ty::PolyTraitRef<'tcx>)
672                             -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
673             desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) }
674         }
675     }
676
677     Codegen {
678         query codegen_fulfill_obligation(
679             key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
680         ) -> Result<Vtable<'tcx, ()>, ErrorReported> {
681             cache_on_disk_if { true }
682             desc { |tcx|
683                 "checking if `{}` fulfills its obligations",
684                 tcx.def_path_str(key.1.def_id())
685             }
686         }
687     }
688
689     TypeChecking {
690         query all_local_trait_impls(key: CrateNum) -> &'tcx BTreeMap<DefId, Vec<hir::HirId>> {
691             desc { "local trait impls" }
692         }
693         query trait_impls_of(key: DefId) -> ty::trait_def::TraitImpls {
694             storage(ArenaCacheSelector<'tcx>)
695             desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
696         }
697         query specialization_graph_of(key: DefId) -> specialization_graph::Graph {
698             storage(ArenaCacheSelector<'tcx>)
699             desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
700             cache_on_disk_if { true }
701         }
702         query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
703             desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
704         }
705
706         /// Gets the ParameterEnvironment for a given item; this environment
707         /// will be in "user-facing" mode, meaning that it is suitabe for
708         /// type-checking etc, and it does not normalize specializable
709         /// associated types. This is almost always what you want,
710         /// unless you are doing MIR optimizations, in which case you
711         /// might want to use `reveal_all()` method to change modes.
712         query param_env(_: DefId) -> ty::ParamEnv<'tcx> {}
713
714         /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
715         /// `ty.is_copy()`, etc, since that will prune the environment where possible.
716         query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
717             desc { "computing whether `{}` is `Copy`", env.value }
718         }
719         /// Query backing `TyS::is_sized`.
720         query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
721             desc { "computing whether `{}` is `Sized`", env.value }
722         }
723         /// Query backing `TyS::is_freeze`.
724         query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
725             desc { "computing whether `{}` is freeze", env.value }
726         }
727         /// Query backing `TyS::needs_drop`.
728         query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
729             desc { "computing whether `{}` needs drop", env.value }
730         }
731
732         /// A list of types where the ADT requires drop if and only if any of
733         /// those types require drop. If the ADT is known to always need drop
734         /// then `Err(AlwaysRequiresDrop)` is returned.
735         query adt_drop_tys(_: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
736             cache_on_disk_if { true }
737         }
738
739         query layout_raw(
740             env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
741         ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> {
742             desc { "computing layout of `{}`", env.value }
743         }
744     }
745
746     Other {
747         query dylib_dependency_formats(_: CrateNum)
748                                         -> &'tcx [(CrateNum, LinkagePreference)] {
749             desc { "dylib dependency formats of crate" }
750         }
751
752         query dependency_formats(_: CrateNum)
753             -> Lrc<crate::middle::dependency_format::Dependencies>
754         {
755             desc { "get the linkage format of all dependencies" }
756         }
757     }
758
759     Codegen {
760         query is_compiler_builtins(_: CrateNum) -> bool {
761             fatal_cycle
762             desc { "checking if the crate is_compiler_builtins" }
763         }
764         query has_global_allocator(_: CrateNum) -> bool {
765             fatal_cycle
766             desc { "checking if the crate has_global_allocator" }
767         }
768         query has_panic_handler(_: CrateNum) -> bool {
769             fatal_cycle
770             desc { "checking if the crate has_panic_handler" }
771         }
772         query is_profiler_runtime(_: CrateNum) -> bool {
773             fatal_cycle
774             desc { "query a crate is `#![profiler_runtime]`" }
775         }
776         query panic_strategy(_: CrateNum) -> PanicStrategy {
777             fatal_cycle
778             desc { "query a crate's configured panic strategy" }
779         }
780         query is_no_builtins(_: CrateNum) -> bool {
781             fatal_cycle
782             desc { "test whether a crate has `#![no_builtins]`" }
783         }
784         query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
785             fatal_cycle
786             desc { "query a crate's symbol mangling version" }
787         }
788
789         query extern_crate(_: DefId) -> Option<&'tcx ExternCrate> {
790             eval_always
791             desc { "getting crate's ExternCrateData" }
792         }
793     }
794
795     TypeChecking {
796         query specializes(_: (DefId, DefId)) -> bool {
797             desc { "computing whether impls specialize one another" }
798         }
799         query in_scope_traits_map(_: LocalDefId)
800             -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
801             eval_always
802             desc { "traits in scope at a block" }
803         }
804     }
805
806     Other {
807         query module_exports(_: DefId) -> Option<&'tcx [Export<hir::HirId>]> {
808             eval_always
809         }
810     }
811
812     TypeChecking {
813         query impl_defaultness(_: DefId) -> hir::Defaultness {}
814
815         query check_item_well_formed(key: LocalDefId) -> () {
816             desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
817         }
818         query check_trait_item_well_formed(key: LocalDefId) -> () {
819             desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
820         }
821         query check_impl_item_well_formed(key: LocalDefId) -> () {
822             desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
823         }
824     }
825
826     Linking {
827         // The `DefId`s of all non-generic functions and statics in the given crate
828         // that can be reached from outside the crate.
829         //
830         // We expect this items to be available for being linked to.
831         //
832         // This query can also be called for `LOCAL_CRATE`. In this case it will
833         // compute which items will be reachable to other crates, taking into account
834         // the kind of crate that is currently compiled. Crates with only a
835         // C interface have fewer reachable things.
836         //
837         // Does not include external symbols that don't have a corresponding DefId,
838         // like the compiler-generated `main` function and so on.
839         query reachable_non_generics(_: CrateNum)
840             -> DefIdMap<SymbolExportLevel> {
841             storage(ArenaCacheSelector<'tcx>)
842             desc { "looking up the exported symbols of a crate" }
843         }
844         query is_reachable_non_generic(_: DefId) -> bool {}
845         query is_unreachable_local_definition(_: DefId) -> bool {}
846     }
847
848     Codegen {
849         /// The entire set of monomorphizations the local crate can safely link
850         /// to because they are exported from upstream crates. Do not depend on
851         /// this directly, as its value changes anytime a monomorphization gets
852         /// added or removed in any upstream crate. Instead use the narrower
853         /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
854         /// better, `Instance::upstream_monomorphization()`.
855         query upstream_monomorphizations(
856             k: CrateNum
857         ) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
858             storage(ArenaCacheSelector<'tcx>)
859             desc { "collecting available upstream monomorphizations `{:?}`", k }
860         }
861
862         /// Returns the set of upstream monomorphizations available for the
863         /// generic function identified by the given `def_id`. The query makes
864         /// sure to make a stable selection if the same monomorphization is
865         /// available in multiple upstream crates.
866         ///
867         /// You likely want to call `Instance::upstream_monomorphization()`
868         /// instead of invoking this query directly.
869         query upstream_monomorphizations_for(_: DefId)
870             -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {}
871
872         /// Returns the upstream crate that exports drop-glue for the given
873         /// type (`substs` is expected to be a single-item list containing the
874         /// type one wants drop-glue for).
875         ///
876         /// This is a subset of `upstream_monomorphizations_for` in order to
877         /// increase dep-tracking granularity. Otherwise adding or removing any
878         /// type with drop-glue in any upstream crate would invalidate all
879         /// functions calling drop-glue of an upstream type.
880         ///
881         /// You likely want to call `Instance::upstream_monomorphization()`
882         /// instead of invoking this query directly.
883         ///
884         /// NOTE: This query could easily be extended to also support other
885         ///       common functions that have are large set of monomorphizations
886         ///       (like `Clone::clone` for example).
887         query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
888             desc { "available upstream drop-glue for `{:?}`", substs }
889         }
890     }
891
892     Other {
893         query foreign_modules(_: CrateNum) -> &'tcx [ForeignModule] {
894             desc { "looking up the foreign modules of a linked crate" }
895         }
896
897         /// Identifies the entry-point (e.g., the `main` function) for a given
898         /// crate, returning `None` if there is no entry point (such as for library crates).
899         query entry_fn(_: CrateNum) -> Option<(LocalDefId, EntryFnType)> {
900             desc { "looking up the entry function of a crate" }
901         }
902         query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
903             desc { "looking up the plugin registrar for a crate" }
904         }
905         query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
906             desc { "looking up the derive registrar for a crate" }
907         }
908         query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
909             eval_always
910             desc { "looking up the disambiguator a crate" }
911         }
912         query crate_hash(_: CrateNum) -> Svh {
913             eval_always
914             desc { "looking up the hash a crate" }
915         }
916         query crate_host_hash(_: CrateNum) -> Option<Svh> {
917             eval_always
918             desc { "looking up the hash of a host version of a crate" }
919         }
920         query original_crate_name(_: CrateNum) -> Symbol {
921             eval_always
922             desc { "looking up the original name a crate" }
923         }
924         query extra_filename(_: CrateNum) -> String {
925             eval_always
926             desc { "looking up the extra filename for a crate" }
927         }
928     }
929
930     TypeChecking {
931         query implementations_of_trait(_: (CrateNum, DefId))
932             -> &'tcx [DefId] {
933             desc { "looking up implementations of a trait in a crate" }
934         }
935         query all_trait_implementations(_: CrateNum)
936             -> &'tcx [DefId] {
937             desc { "looking up all (?) trait implementations" }
938         }
939     }
940
941     Other {
942         query dllimport_foreign_items(_: CrateNum)
943             -> FxHashSet<DefId> {
944             storage(ArenaCacheSelector<'tcx>)
945             desc { "dllimport_foreign_items" }
946         }
947         query is_dllimport_foreign_item(_: DefId) -> bool {}
948         query is_statically_included_foreign_item(_: DefId) -> bool {}
949         query native_library_kind(_: DefId)
950             -> Option<NativeLibraryKind> {}
951     }
952
953     Linking {
954         query link_args(_: CrateNum) -> Lrc<Vec<String>> {
955             eval_always
956             desc { "looking up link arguments for a crate" }
957         }
958     }
959
960     BorrowChecking {
961         /// Lifetime resolution. See `middle::resolve_lifetimes`.
962         query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes {
963             storage(ArenaCacheSelector<'tcx>)
964             desc { "resolving lifetimes" }
965         }
966         query named_region_map(_: LocalDefId) ->
967             Option<&'tcx FxHashMap<ItemLocalId, Region>> {
968             desc { "looking up a named region" }
969         }
970         query is_late_bound_map(_: LocalDefId) ->
971             Option<&'tcx FxHashSet<ItemLocalId>> {
972             desc { "testing if a region is late bound" }
973         }
974         query object_lifetime_defaults_map(_: LocalDefId)
975             -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>> {
976             desc { "looking up lifetime defaults for a region" }
977         }
978     }
979
980     TypeChecking {
981         query visibility(_: DefId) -> ty::Visibility {}
982     }
983
984     Other {
985         query dep_kind(_: CrateNum) -> DepKind {
986             eval_always
987             desc { "fetching what a dependency looks like" }
988         }
989         query crate_name(_: CrateNum) -> Symbol {
990             eval_always
991             desc { "fetching what a crate is named" }
992         }
993         query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
994         query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
995
996         query get_lib_features(_: CrateNum) -> LibFeatures {
997             storage(ArenaCacheSelector<'tcx>)
998             eval_always
999             desc { "calculating the lib features map" }
1000         }
1001         query defined_lib_features(_: CrateNum)
1002             -> &'tcx [(Symbol, Option<Symbol>)] {
1003             desc { "calculating the lib features defined in a crate" }
1004         }
1005         /// Returns the lang items defined in another crate by loading it from metadata.
1006         // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
1007         // of that argument?
1008         query get_lang_items(_: CrateNum) -> LanguageItems {
1009             storage(ArenaCacheSelector<'tcx>)
1010             eval_always
1011             desc { "calculating the lang items map" }
1012         }
1013
1014         /// Returns all diagnostic items defined in all crates.
1015         query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
1016             storage(ArenaCacheSelector<'tcx>)
1017             eval_always
1018             desc { "calculating the diagnostic items map" }
1019         }
1020
1021         /// Returns the lang items defined in another crate by loading it from metadata.
1022         query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1023             desc { "calculating the lang items defined in a crate" }
1024         }
1025
1026         /// Returns the diagnostic items defined in a crate.
1027         query diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
1028             storage(ArenaCacheSelector<'tcx>)
1029             desc { "calculating the diagnostic items map in a crate" }
1030         }
1031
1032         query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1033             desc { "calculating the missing lang items in a crate" }
1034         }
1035         query visible_parent_map(_: CrateNum)
1036             -> DefIdMap<DefId> {
1037             storage(ArenaCacheSelector<'tcx>)
1038             desc { "calculating the visible parent map" }
1039         }
1040         query missing_extern_crate_item(_: CrateNum) -> bool {
1041             eval_always
1042             desc { "seeing if we're missing an `extern crate` item for this crate" }
1043         }
1044         query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1045             eval_always
1046             desc { "looking at the source for a crate" }
1047         }
1048         query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] {
1049             eval_always
1050             desc { "generating a postorder list of CrateNums" }
1051         }
1052
1053         query upvars(_: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1054             eval_always
1055         }
1056         query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1057             eval_always
1058             desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1059         }
1060         query maybe_unused_extern_crates(_: CrateNum)
1061             -> &'tcx [(DefId, Span)] {
1062             eval_always
1063             desc { "looking up all possibly unused extern crates" }
1064         }
1065         query names_imported_by_glob_use(def_id: LocalDefId)
1066             -> &'tcx FxHashSet<ast::Name> {
1067             eval_always
1068             desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1069         }
1070
1071         query stability_index(_: CrateNum) -> stability::Index<'tcx> {
1072             storage(ArenaCacheSelector<'tcx>)
1073             eval_always
1074             desc { "calculating the stability index for the local crate" }
1075         }
1076         query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
1077             eval_always
1078             desc { "fetching all foreign CrateNum instances" }
1079         }
1080
1081         /// A vector of every trait accessible in the whole crate
1082         /// (i.e., including those from subcrates). This is used only for
1083         /// error reporting.
1084         query all_traits(_: CrateNum) -> &'tcx [DefId] {
1085             desc { "fetching all foreign and local traits" }
1086         }
1087     }
1088
1089     Linking {
1090         /// The list of symbols exported from the given crate.
1091         ///
1092         /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1093         ///   correspond to a publicly visible symbol in `cnum` machine code.
1094         /// - The `exported_symbols` sets of different crates do not intersect.
1095         query exported_symbols(_: CrateNum)
1096             -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1097             desc { "exported_symbols" }
1098         }
1099     }
1100
1101     Codegen {
1102         query collect_and_partition_mono_items(_: CrateNum)
1103             -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1104             eval_always
1105             desc { "collect_and_partition_mono_items" }
1106         }
1107         query is_codegened_item(_: DefId) -> bool {}
1108         query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
1109             desc { "codegen_unit" }
1110         }
1111         query backend_optimization_level(_: CrateNum) -> OptLevel {
1112             desc { "optimization level used by backend" }
1113         }
1114     }
1115
1116     Other {
1117         query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
1118             eval_always
1119             desc { "output_filenames" }
1120         }
1121     }
1122
1123     TypeChecking {
1124         /// Do not call this query directly: invoke `normalize` instead.
1125         query normalize_projection_ty(
1126             goal: CanonicalProjectionGoal<'tcx>
1127         ) -> Result<
1128             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1129             NoSolution,
1130         > {
1131             desc { "normalizing `{:?}`", goal }
1132         }
1133
1134         /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1135         query normalize_generic_arg_after_erasing_regions(
1136             goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1137         ) -> GenericArg<'tcx> {
1138             desc { "normalizing `{}`", goal.value }
1139         }
1140
1141         query implied_outlives_bounds(
1142             goal: CanonicalTyGoal<'tcx>
1143         ) -> Result<
1144             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1145             NoSolution,
1146         > {
1147             desc { "computing implied outlives bounds for `{:?}`", goal }
1148         }
1149
1150         /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1151         query dropck_outlives(
1152             goal: CanonicalTyGoal<'tcx>
1153         ) -> Result<
1154             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1155             NoSolution,
1156         > {
1157             desc { "computing dropck types for `{:?}`", goal }
1158         }
1159
1160         /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1161         /// `infcx.predicate_must_hold()` instead.
1162         query evaluate_obligation(
1163             goal: CanonicalPredicateGoal<'tcx>
1164         ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1165             desc { "evaluating trait selection obligation `{}`", goal.value.value }
1166         }
1167
1168         /// Do not call this query directly: part of the `Eq` type-op
1169         query type_op_ascribe_user_type(
1170             goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1171         ) -> Result<
1172             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1173             NoSolution,
1174         > {
1175             desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1176         }
1177
1178         /// Do not call this query directly: part of the `Eq` type-op
1179         query type_op_eq(
1180             goal: CanonicalTypeOpEqGoal<'tcx>
1181         ) -> Result<
1182             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1183             NoSolution,
1184         > {
1185             desc { "evaluating `type_op_eq` `{:?}`", goal }
1186         }
1187
1188         /// Do not call this query directly: part of the `Subtype` type-op
1189         query type_op_subtype(
1190             goal: CanonicalTypeOpSubtypeGoal<'tcx>
1191         ) -> Result<
1192             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1193             NoSolution,
1194         > {
1195             desc { "evaluating `type_op_subtype` `{:?}`", goal }
1196         }
1197
1198         /// Do not call this query directly: part of the `ProvePredicate` type-op
1199         query type_op_prove_predicate(
1200             goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1201         ) -> Result<
1202             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1203             NoSolution,
1204         > {
1205             desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1206         }
1207
1208         /// Do not call this query directly: part of the `Normalize` type-op
1209         query type_op_normalize_ty(
1210             goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1211         ) -> Result<
1212             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1213             NoSolution,
1214         > {
1215             desc { "normalizing `{:?}`", goal }
1216         }
1217
1218         /// Do not call this query directly: part of the `Normalize` type-op
1219         query type_op_normalize_predicate(
1220             goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1221         ) -> Result<
1222             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1223             NoSolution,
1224         > {
1225             desc { "normalizing `{:?}`", goal }
1226         }
1227
1228         /// Do not call this query directly: part of the `Normalize` type-op
1229         query type_op_normalize_poly_fn_sig(
1230             goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1231         ) -> Result<
1232             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1233             NoSolution,
1234         > {
1235             desc { "normalizing `{:?}`", goal }
1236         }
1237
1238         /// Do not call this query directly: part of the `Normalize` type-op
1239         query type_op_normalize_fn_sig(
1240             goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1241         ) -> Result<
1242             &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1243             NoSolution,
1244         > {
1245             desc { "normalizing `{:?}`", goal }
1246         }
1247
1248         query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1249             desc { |tcx|
1250                 "testing substituted normalized predicates:`{}`",
1251                 tcx.def_path_str(key.0)
1252             }
1253         }
1254
1255         query method_autoderef_steps(
1256             goal: CanonicalTyGoal<'tcx>
1257         ) -> MethodAutoderefStepsResult<'tcx> {
1258             desc { "computing autoderef types for `{:?}`", goal }
1259         }
1260     }
1261
1262     Other {
1263         query target_features_whitelist(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
1264             storage(ArenaCacheSelector<'tcx>)
1265             eval_always
1266             desc { "looking up the whitelist of target features" }
1267         }
1268
1269         // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1270         query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1271             -> usize {
1272             desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1273         }
1274
1275         query features_query(_: CrateNum) -> &'tcx rustc_feature::Features {
1276             eval_always
1277             desc { "looking up enabled feature gates" }
1278         }
1279
1280         /// Attempt to resolve the given `DefId` to an `Instance`, for the
1281         /// given generics args (`SubstsRef`), returning one of:
1282         ///  * `Ok(Some(instance))` on success
1283         ///  * `Ok(None)` when the `SubstsRef` are still too generic,
1284         ///    and therefore don't allow finding the final `Instance`
1285         ///  * `Err(ErrorReported)` when the `Instance` resolution process
1286         ///    couldn't complete due to errors elsewhere - this is distinct
1287         ///    from `Ok(None)` to avoid misleading diagnostics when an error
1288         ///    has already been/will be emitted, for the original cause
1289         query resolve_instance(
1290             key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1291         ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1292             desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
1293         }
1294     }
1295 }