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