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