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