]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/query/mod.rs
bac69e282a521672ae81467f3ae72581e2aac37c
[rust.git] / compiler / rustc_middle / src / query / mod.rs
1 // Each of these queries corresponds to a function pointer field in the
2 // `Providers` struct for requesting a value of that type, and a method
3 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
4 // which memoizes and does dep-graph tracking, wrapping around the actual
5 // `Providers` that the driver creates (using several `rustc_*` crates).
6 //
7 // The result type of each query must implement `Clone`, and additionally
8 // `ty::query::values::Value`, which produces an appropriate placeholder
9 // (error) value if the query resulted in a query cycle.
10 // Queries marked with `fatal_cycle` do not need the latter implementation,
11 // as they will raise an fatal error on query cycles instead.
12 rustc_queries! {
13     query trigger_delay_span_bug(key: DefId) -> () {
14         desc { "trigger a delay span bug" }
15     }
16
17     /// Represents crate as a whole (as distinct from the top-level crate module).
18     /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
19     /// we will have to assume that any change means that you need to be recompiled.
20     /// This is because the `hir_crate` query gives you access to all other items.
21     /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
22     /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
23     query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> {
24         eval_always
25         no_hash
26         desc { "get the crate HIR" }
27     }
28
29     /// The indexed HIR. This can be conveniently accessed by `tcx.hir()`.
30     /// Avoid calling this query directly.
31     query index_hir(_: CrateNum) -> &'tcx map::IndexedHir<'tcx> {
32         eval_always
33         no_hash
34         desc { "index HIR" }
35     }
36
37     /// The items in a module.
38     ///
39     /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
40     /// Avoid calling this query directly.
41     query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems {
42         eval_always
43         desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
44     }
45
46     /// Gives access to the HIR node for the HIR owner `key`.
47     ///
48     /// This can be conveniently accessed by methods on `tcx.hir()`.
49     /// Avoid calling this query directly.
50     query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> {
51         eval_always
52         desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
53     }
54
55     /// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
56     ///
57     /// This can be conveniently accessed by methods on `tcx.hir()`.
58     /// Avoid calling this query directly.
59     query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> {
60         eval_always
61         desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
62     }
63
64     /// Gives access to the HIR attributes inside the HIR owner `key`.
65     ///
66     /// This can be conveniently accessed by methods on `tcx.hir()`.
67     /// Avoid calling this query directly.
68     query hir_attrs(key: LocalDefId) -> rustc_middle::hir::AttributeMap<'tcx> {
69         eval_always
70         desc { |tcx| "HIR owner attributes in `{}`", tcx.def_path_str(key.to_def_id()) }
71     }
72
73     /// Computes the `DefId` of the corresponding const parameter in case the `key` is a
74     /// const argument and returns `None` otherwise.
75     ///
76     /// ```ignore (incomplete)
77     /// let a = foo::<7>();
78     /// //            ^ Calling `opt_const_param_of` for this argument,
79     ///
80     /// fn foo<const N: usize>()
81     /// //           ^ returns this `DefId`.
82     ///
83     /// fn bar() {
84     /// // ^ While calling `opt_const_param_of` for other bodies returns `None`.
85     /// }
86     /// ```
87     // It looks like caching this query on disk actually slightly
88     // worsened performance in #74376.
89     //
90     // Once const generics are more prevalently used, we might want to
91     // consider only caching calls returning `Some`.
92     query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
93         desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
94     }
95
96     /// Given the def_id of a const-generic parameter, computes the associated default const
97     /// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
98     query const_param_default(param: DefId) -> &'tcx ty::Const<'tcx> {
99         desc { |tcx| "compute const default for a given parameter `{}`", tcx.def_path_str(param)  }
100     }
101
102     /// Records the type of every item.
103     query type_of(key: DefId) -> Ty<'tcx> {
104         desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) }
105         cache_on_disk_if { key.is_local() }
106     }
107
108     query analysis(key: CrateNum) -> Result<(), ErrorReported> {
109         eval_always
110         desc { "running analysis passes on this crate" }
111     }
112
113     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
114     /// associated generics.
115     query generics_of(key: DefId) -> ty::Generics {
116         desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
117         storage(ArenaCacheSelector<'tcx>)
118         cache_on_disk_if { key.is_local() }
119     }
120
121     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
122     /// predicates (where-clauses) that must be proven true in order
123     /// to reference it. This is almost always the "predicates query"
124     /// that you want.
125     ///
126     /// `predicates_of` builds on `predicates_defined_on` -- in fact,
127     /// it is almost always the same as that query, except for the
128     /// case of traits. For traits, `predicates_of` contains
129     /// an additional `Self: Trait<...>` predicate that users don't
130     /// actually write. This reflects the fact that to invoke the
131     /// trait (e.g., via `Default::default`) you must supply types
132     /// that actually implement the trait. (However, this extra
133     /// predicate gets in the way of some checks, which are intended
134     /// to operate over only the actual where-clauses written by the
135     /// user.)
136     query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
137         desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
138         cache_on_disk_if { key.is_local() }
139     }
140
141     /// Returns the list of bounds that can be used for
142     /// `SelectionCandidate::ProjectionCandidate(_)` and
143     /// `ProjectionTyCandidate::TraitDef`.
144     /// Specifically this is the bounds written on the trait's type
145     /// definition, or those after the `impl` keyword
146     ///
147     /// ```ignore (incomplete)
148     /// type X: Bound + 'lt
149     /// //      ^^^^^^^^^^^
150     /// impl Debug + Display
151     /// //   ^^^^^^^^^^^^^^^
152     /// ```
153     ///
154     /// `key` is the `DefId` of the associated type or opaque type.
155     ///
156     /// Bounds from the parent (e.g. with nested impl trait) are not included.
157     query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
158         desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
159     }
160
161     /// Elaborated version of the predicates from `explicit_item_bounds`.
162     ///
163     /// For example:
164     ///
165     /// ```
166     /// trait MyTrait {
167     ///     type MyAType: Eq + ?Sized;
168     /// }
169     /// ```
170     ///
171     /// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
172     /// and `item_bounds` returns
173     /// ```text
174     /// [
175     ///     <Self as Trait>::MyAType: Eq,
176     ///     <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
177     /// ]
178     /// ```
179     ///
180     /// Bounds from the parent (e.g. with nested impl trait) are not included.
181     query item_bounds(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> {
182         desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
183     }
184
185     query projection_ty_from_predicates(key: (DefId, DefId)) -> Option<ty::ProjectionTy<'tcx>> {
186         desc { |tcx| "finding projection type inside predicates of `{}`", tcx.def_path_str(key.0) }
187     }
188
189     query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> {
190         desc { "looking up the native libraries of a linked crate" }
191     }
192
193     query lint_levels(_: CrateNum) -> LintLevelMap {
194         storage(ArenaCacheSelector<'tcx>)
195         eval_always
196         desc { "computing the lint levels for items in this crate" }
197     }
198
199     query parent_module_from_def_id(key: LocalDefId) -> LocalDefId {
200         eval_always
201         desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) }
202     }
203
204     /// Internal helper query. Use `tcx.expansion_that_defined` instead
205     query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
206         desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) }
207     }
208
209     query is_panic_runtime(_: CrateNum) -> bool {
210         fatal_cycle
211         desc { "checking if the crate is_panic_runtime" }
212     }
213
214     /// Set of all the `DefId`s in this crate that have MIR associated with
215     /// them. This includes all the body owners, but also things like struct
216     /// constructors.
217     query mir_keys(_: CrateNum) -> FxHashSet<LocalDefId> {
218         storage(ArenaCacheSelector<'tcx>)
219         desc { "getting a list of all mir_keys" }
220     }
221
222     /// Maps DefId's that have an associated `mir::Body` to the result
223     /// of the MIR const-checking pass. This is the set of qualifs in
224     /// the final value of a `const`.
225     query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
226         desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
227         cache_on_disk_if { key.is_local() }
228     }
229     query mir_const_qualif_const_arg(
230         key: (LocalDefId, DefId)
231     ) -> mir::ConstQualifs {
232         desc {
233             |tcx| "const checking the const argument `{}`",
234             tcx.def_path_str(key.0.to_def_id())
235         }
236     }
237
238     /// Fetch the MIR for a given `DefId` right after it's built - this includes
239     /// unreachable code.
240     query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
241         desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
242     }
243
244     /// Fetch the MIR for a given `DefId` up till the point where it is
245     /// ready for const qualification.
246     ///
247     /// See the README for the `mir` module for details.
248     query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
249         desc {
250             |tcx| "processing MIR for {}`{}`",
251             if key.const_param_did.is_some() { "the const argument " } else { "" },
252             tcx.def_path_str(key.did.to_def_id()),
253         }
254         no_hash
255     }
256
257     /// Try to build an abstract representation of the given constant.
258     query mir_abstract_const(
259         key: DefId
260     ) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
261         desc {
262             |tcx| "building an abstract representation for {}", tcx.def_path_str(key),
263         }
264     }
265     /// Try to build an abstract representation of the given constant.
266     query mir_abstract_const_of_const_arg(
267         key: (LocalDefId, DefId)
268     ) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
269         desc {
270             |tcx|
271             "building an abstract representation for the const argument {}",
272             tcx.def_path_str(key.0.to_def_id()),
273         }
274     }
275
276     query try_unify_abstract_consts(key: (
277         (ty::WithOptConstParam<DefId>, SubstsRef<'tcx>),
278         (ty::WithOptConstParam<DefId>, SubstsRef<'tcx>)
279     )) -> bool {
280         desc {
281             |tcx| "trying to unify the generic constants {} and {}",
282             tcx.def_path_str(key.0.0.did), tcx.def_path_str(key.1.0.did)
283         }
284     }
285
286     query mir_drops_elaborated_and_const_checked(
287         key: ty::WithOptConstParam<LocalDefId>
288     ) -> &'tcx Steal<mir::Body<'tcx>> {
289         no_hash
290         desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
291     }
292
293     query mir_for_ctfe(
294         key: DefId
295     ) -> &'tcx mir::Body<'tcx> {
296         desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
297         cache_on_disk_if { key.is_local() }
298     }
299
300     query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> {
301         desc {
302             |tcx| "MIR for CTFE of the const argument `{}`",
303             tcx.def_path_str(key.0.to_def_id())
304         }
305     }
306
307     query mir_promoted(key: ty::WithOptConstParam<LocalDefId>) ->
308         (
309             &'tcx Steal<mir::Body<'tcx>>,
310             &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
311         ) {
312         no_hash
313         desc {
314             |tcx| "processing {}`{}`",
315             if key.const_param_did.is_some() { "the const argument " } else { "" },
316             tcx.def_path_str(key.did.to_def_id()),
317         }
318     }
319
320     /// MIR after our optimization passes have run. This is MIR that is ready
321     /// for codegen. This is also the only query that can fetch non-local MIR, at present.
322     query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
323         desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
324         cache_on_disk_if { key.is_local() }
325     }
326
327     /// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
328     /// MIR pass (assuming the -Zinstrument-coverage option is enabled).
329     query coverageinfo(key: DefId) -> mir::CoverageInfo {
330         desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key) }
331         storage(ArenaCacheSelector<'tcx>)
332         cache_on_disk_if { key.is_local() }
333     }
334
335     /// Returns the name of the file that contains the function body, if instrumented for coverage.
336     query covered_file_name(key: DefId) -> Option<Symbol> {
337         desc {
338             |tcx| "retrieving the covered file name, if instrumented, for `{}`",
339             tcx.def_path_str(key)
340         }
341         storage(ArenaCacheSelector<'tcx>)
342         cache_on_disk_if { key.is_local() }
343     }
344
345     /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
346     /// function was optimized out before codegen, and before being added to the Coverage Map.
347     query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> {
348         desc {
349             |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
350             tcx.def_path_str(key)
351         }
352         storage(ArenaCacheSelector<'tcx>)
353         cache_on_disk_if { key.is_local() }
354     }
355
356     /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
357     /// `DefId`. This function returns all promoteds in the specified body. The body references
358     /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
359     /// after inlining a body may refer to promoteds from other bodies. In that case you still
360     /// need to use the `DefId` of the original body.
361     query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
362         desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
363         cache_on_disk_if { key.is_local() }
364     }
365     query promoted_mir_of_const_arg(
366         key: (LocalDefId, DefId)
367     ) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
368         desc {
369             |tcx| "optimizing promoted MIR for the const argument `{}`",
370             tcx.def_path_str(key.0.to_def_id()),
371         }
372     }
373
374     /// Erases regions from `ty` to yield a new type.
375     /// Normally you would just use `tcx.erase_regions(value)`,
376     /// however, which uses this query as a kind of cache.
377     query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
378         // This query is not expected to have input -- as a result, it
379         // is not a good candidates for "replay" because it is essentially a
380         // pure function of its input (and hence the expectation is that
381         // no caller would be green **apart** from just these
382         // queries). Making it anonymous avoids hashing the result, which
383         // may save a bit of time.
384         anon
385         desc { "erasing regions from `{:?}`", ty }
386     }
387
388     query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
389         storage(ArenaCacheSelector<'tcx>)
390         desc { "wasm import module map" }
391     }
392
393     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
394     /// predicates (where-clauses) directly defined on it. This is
395     /// equal to the `explicit_predicates_of` predicates plus the
396     /// `inferred_outlives_of` predicates.
397     query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> {
398         desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
399     }
400
401     /// Returns everything that looks like a predicate written explicitly
402     /// by the user on a trait item.
403     ///
404     /// Traits are unusual, because predicates on associated types are
405     /// converted into bounds on that type for backwards compatibility:
406     ///
407     /// trait X where Self::U: Copy { type U; }
408     ///
409     /// becomes
410     ///
411     /// trait X { type U: Copy; }
412     ///
413     /// `explicit_predicates_of` and `explicit_item_bounds` will then take
414     /// the appropriate subsets of the predicates here.
415     query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
416         desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) }
417     }
418
419     /// Returns the predicates written explicitly by the user.
420     query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
421         desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
422     }
423
424     /// Returns the inferred outlives predicates (e.g., for `struct
425     /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
426     query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
427         desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) }
428     }
429
430     /// Maps from the `DefId` of a trait to the list of
431     /// super-predicates. This is a subset of the full list of
432     /// predicates. We store these in a separate map because we must
433     /// evaluate them even during type conversion, often before the
434     /// full predicates are available (note that supertraits have
435     /// additional acyclicity requirements).
436     query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
437         desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
438     }
439
440     /// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
441     /// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
442     /// subset of super-predicates that reference traits that define the given associated type.
443     /// This is used to avoid cycles in resolving types like `T::Item`.
444     query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
445         desc { |tcx| "computing the super traits of `{}`{}",
446             tcx.def_path_str(key.0),
447             if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
448         }
449     }
450
451     /// To avoid cycles within the predicates of a single item we compute
452     /// per-type-parameter predicates for resolving `T::AssocTy`.
453     query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
454         desc { |tcx| "computing the bounds for type parameter `{}`", {
455             let id = tcx.hir().local_def_id_to_hir_id(key.1);
456             tcx.hir().ty_param_name(id)
457         }}
458     }
459
460     query trait_def(key: DefId) -> ty::TraitDef {
461         desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
462         storage(ArenaCacheSelector<'tcx>)
463     }
464     query adt_def(key: DefId) -> &'tcx ty::AdtDef {
465         desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
466     }
467     query adt_destructor(key: DefId) -> Option<ty::Destructor> {
468         desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
469     }
470
471     // The cycle error here should be reported as an error by `check_representable`.
472     // We consider the type as Sized in the meanwhile to avoid
473     // further errors (done in impl Value for AdtSizedConstraint).
474     // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
475     // in case we accidentally otherwise don't emit an error.
476     query adt_sized_constraint(
477         key: DefId
478     ) -> AdtSizedConstraint<'tcx> {
479         desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
480         cycle_delay_bug
481     }
482
483     query adt_dtorck_constraint(
484         key: DefId
485     ) -> Result<DtorckConstraint<'tcx>, NoSolution> {
486         desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
487     }
488
489     /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
490     /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
491     /// not have the feature gate active).
492     ///
493     /// **Do not call this function manually.** It is only meant to cache the base data for the
494     /// `is_const_fn` function.
495     query is_const_fn_raw(key: DefId) -> bool {
496         desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
497     }
498
499     /// Returns `true` if this is a const `impl`. **Do not call this function manually.**
500     ///
501     /// This query caches the base data for the `is_const_impl` helper function, which also
502     /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`).
503     query is_const_impl_raw(key: DefId) -> bool {
504         desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) }
505     }
506
507     query asyncness(key: DefId) -> hir::IsAsync {
508         desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
509     }
510
511     /// Returns `true` if calls to the function may be promoted.
512     ///
513     /// This is either because the function is e.g., a tuple-struct or tuple-variant
514     /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
515     /// be removed in the future in favour of some form of check which figures out whether the
516     /// function does not inspect the bits of any of its arguments (so is essentially just a
517     /// constructor function).
518     query is_promotable_const_fn(key: DefId) -> bool {
519         desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
520     }
521
522     /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
523     query is_foreign_item(key: DefId) -> bool {
524         desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) }
525     }
526
527     /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
528     query static_mutability(def_id: DefId) -> Option<hir::Mutability> {
529         desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) }
530     }
531
532     /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
533     query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
534         desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
535     }
536
537     /// Gets a map with the variance of every item; use `item_variance` instead.
538     query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> {
539         storage(ArenaCacheSelector<'tcx>)
540         desc { "computing the variances for items in this crate" }
541     }
542
543     /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
544     query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
545         desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
546     }
547
548     /// Maps from thee `DefId` of a type to its (inferred) outlives.
549     query inferred_outlives_crate(_: CrateNum)
550         -> ty::CratePredicatesMap<'tcx> {
551         storage(ArenaCacheSelector<'tcx>)
552         desc { "computing the inferred outlives predicates for items in this crate" }
553     }
554
555     /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
556     query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
557         desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
558     }
559
560     /// Maps from a trait item to the trait item "descriptor".
561     query associated_item(key: DefId) -> ty::AssocItem {
562         desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
563         storage(ArenaCacheSelector<'tcx>)
564     }
565
566     /// Collects the associated items defined on a trait or impl.
567     query associated_items(key: DefId) -> ty::AssociatedItems<'tcx> {
568         storage(ArenaCacheSelector<'tcx>)
569         desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
570     }
571
572     /// Given an `impl_id`, return the trait it implements.
573     /// Return `None` if this is an inherent impl.
574     query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
575         desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
576     }
577     query impl_polarity(impl_id: DefId) -> ty::ImplPolarity {
578         desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) }
579     }
580
581     query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
582         desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
583     }
584
585     /// Maps a `DefId` of a type to a list of its inherent impls.
586     /// Contains implementations of methods that are inherent to a type.
587     /// Methods in these implementations don't need to be exported.
588     query inherent_impls(key: DefId) -> &'tcx [DefId] {
589         desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
590         eval_always
591     }
592
593     /// The result of unsafety-checking this `LocalDefId`.
594     query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
595         desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
596         cache_on_disk_if { true }
597     }
598     query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult {
599         desc {
600             |tcx| "unsafety-checking the const argument `{}`",
601             tcx.def_path_str(key.0.to_def_id())
602         }
603     }
604
605     /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error.
606     ///
607     /// Unsafety checking is executed for each method separately, but we only want
608     /// to emit this error once per derive. As there are some impls with multiple
609     /// methods, we use a query for deduplication.
610     query unsafe_derive_on_repr_packed(key: LocalDefId) -> () {
611         desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
612     }
613
614     /// The signature of functions.
615     query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> {
616         desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
617     }
618
619     query lint_mod(key: LocalDefId) -> () {
620         desc { |tcx| "linting {}", describe_as_module(key, tcx) }
621     }
622
623     /// Checks the attributes in the module.
624     query check_mod_attrs(key: LocalDefId) -> () {
625         desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
626     }
627
628     query check_mod_unstable_api_usage(key: LocalDefId) -> () {
629         desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
630     }
631
632     /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
633     query check_mod_const_bodies(key: LocalDefId) -> () {
634         desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
635     }
636
637     /// Checks the loops in the module.
638     query check_mod_loops(key: LocalDefId) -> () {
639         desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
640     }
641
642     query check_mod_naked_functions(key: LocalDefId) -> () {
643         desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
644     }
645
646     query check_mod_item_types(key: LocalDefId) -> () {
647         desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
648     }
649
650     query check_mod_privacy(key: LocalDefId) -> () {
651         desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
652     }
653
654     query check_mod_intrinsics(key: LocalDefId) -> () {
655         desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) }
656     }
657
658     query check_mod_liveness(key: LocalDefId) -> () {
659         desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) }
660     }
661
662     query check_mod_impl_wf(key: LocalDefId) -> () {
663         desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
664     }
665
666     query collect_mod_item_types(key: LocalDefId) -> () {
667         desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
668     }
669
670     /// Caches `CoerceUnsized` kinds for impls on custom types.
671     query coerce_unsized_info(key: DefId)
672         -> ty::adjustment::CoerceUnsizedInfo {
673             desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
674         }
675
676     query typeck_item_bodies(_: CrateNum) -> () {
677         desc { "type-checking all item bodies" }
678     }
679
680     query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
681         desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
682         cache_on_disk_if { true }
683     }
684     query typeck_const_arg(
685         key: (LocalDefId, DefId)
686     ) -> &'tcx ty::TypeckResults<'tcx> {
687         desc {
688             |tcx| "type-checking the const argument `{}`",
689             tcx.def_path_str(key.0.to_def_id()),
690         }
691     }
692     query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
693         desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
694         cache_on_disk_if { true }
695         load_cached(tcx, id) {
696             let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
697                 .on_disk_cache.as_ref()
698                 .and_then(|c| c.try_load_query_result(*tcx, id));
699
700             typeck_results.map(|x| &*tcx.arena.alloc(x))
701         }
702     }
703
704     query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet<LocalDefId> {
705         desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) }
706         cache_on_disk_if { true }
707     }
708
709     query has_typeck_results(def_id: DefId) -> bool {
710         desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
711     }
712
713     query coherent_trait(def_id: DefId) -> () {
714         desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
715     }
716
717     /// Borrow-checks the function body. If this is a closure, returns
718     /// additional requirements that the closure's creator must verify.
719     query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
720         desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
721         cache_on_disk_if(tcx, opt_result) {
722             tcx.is_closure(key.to_def_id())
723                 || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty())
724         }
725     }
726     query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> {
727         desc {
728             |tcx| "borrow-checking the const argument`{}`",
729             tcx.def_path_str(key.0.to_def_id())
730         }
731     }
732
733     /// Gets a complete map from all types to their inherent impls.
734     /// Not meant to be used directly outside of coherence.
735     /// (Defined only for `LOCAL_CRATE`.)
736     query crate_inherent_impls(k: CrateNum)
737         -> CrateInherentImpls {
738         storage(ArenaCacheSelector<'tcx>)
739         eval_always
740         desc { "all inherent impls defined in crate `{:?}`", k }
741     }
742
743     /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
744     /// Not meant to be used directly outside of coherence.
745     /// (Defined only for `LOCAL_CRATE`.)
746     query crate_inherent_impls_overlap_check(_: CrateNum)
747         -> () {
748         eval_always
749         desc { "check for overlap between inherent impls defined in this crate" }
750     }
751
752     /// Check whether the function has any recursion that could cause the inliner to trigger
753     /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
754     /// current function, just all intermediate functions.
755     query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
756         fatal_cycle
757         desc { |tcx|
758             "computing if `{}` (transitively) calls `{}`",
759             key.0,
760             tcx.def_path_str(key.1.to_def_id()),
761         }
762     }
763
764     /// Obtain all the calls into other local functions
765     query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] {
766         fatal_cycle
767         desc { |tcx|
768             "computing all local function calls in `{}`",
769             tcx.def_path_str(key.def_id()),
770         }
771     }
772
773     /// Evaluates a constant and returns the computed allocation.
774     ///
775     /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
776     query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
777         -> EvalToAllocationRawResult<'tcx> {
778         desc { |tcx|
779             "const-evaluating + checking `{}`",
780             key.value.display(tcx)
781         }
782         cache_on_disk_if { true }
783     }
784
785     /// Evaluates const items or anonymous constants
786     /// (such as enum variant explicit discriminants or array lengths)
787     /// into a representation suitable for the type system and const generics.
788     ///
789     /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
790     /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
791     query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
792         -> EvalToConstValueResult<'tcx> {
793         desc { |tcx|
794             "simplifying constant for the type system `{}`",
795             key.value.display(tcx)
796         }
797         cache_on_disk_if { true }
798     }
799
800     /// Convert an evaluated constant to a type level constant or
801     /// return `None` if that is not possible.
802     query const_to_valtree(
803         key: ty::ParamEnvAnd<'tcx, ConstAlloc<'tcx>>
804     ) -> Option<ty::ValTree<'tcx>> {
805         desc { "destructure constant" }
806     }
807
808     /// Destructure a constant ADT or array into its variant index and its
809     /// field values.
810     query destructure_const(
811         key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
812     ) -> mir::DestructuredConst<'tcx> {
813         desc { "destructure constant" }
814     }
815
816     /// Dereference a constant reference or raw pointer and turn the result into a constant
817     /// again.
818     query deref_const(
819         key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
820     ) -> &'tcx ty::Const<'tcx> {
821         desc { "deref constant" }
822     }
823
824     query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
825         desc { "get a &core::panic::Location referring to a span" }
826     }
827
828     query lit_to_const(
829         key: LitToConstInput<'tcx>
830     ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
831         desc { "converting literal to const" }
832     }
833
834     query check_match(key: DefId) {
835         desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
836         cache_on_disk_if { key.is_local() }
837     }
838
839     /// Performs part of the privacy check and computes "access levels".
840     query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
841         eval_always
842         desc { "privacy access levels" }
843     }
844     query check_private_in_public(_: CrateNum) -> () {
845         eval_always
846         desc { "checking for private elements in public interfaces" }
847     }
848
849     query reachable_set(_: CrateNum) -> FxHashSet<LocalDefId> {
850         storage(ArenaCacheSelector<'tcx>)
851         desc { "reachability" }
852     }
853
854     /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
855     /// in the case of closures, this will be redirected to the enclosing function.
856     query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree {
857         desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
858     }
859
860     query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
861         storage(ArenaCacheSelector<'tcx>)
862         desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
863     }
864
865     /// The `symbol_name` query provides the symbol name for calling a
866     /// given instance from the local crate. In particular, it will also
867     /// look up the correct symbol name of instances from upstream crates.
868     query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
869         desc { "computing the symbol for `{}`", key }
870         cache_on_disk_if { true }
871     }
872
873     query opt_def_kind(def_id: DefId) -> Option<DefKind> {
874         desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
875     }
876
877     query def_span(def_id: DefId) -> Span {
878         desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
879         // FIXME(mw): DefSpans are not really inputs since they are derived from
880         // HIR. But at the moment HIR hashing still contains some hacks that allow
881         // to make type debuginfo to be source location independent. Declaring
882         // DefSpan an input makes sure that changes to these are always detected
883         // regardless of HIR hashing.
884         eval_always
885     }
886
887     query def_ident_span(def_id: DefId) -> Option<Span> {
888         desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
889     }
890
891     query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> {
892         desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
893     }
894
895     query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> {
896         desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
897     }
898
899     query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
900         desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
901     }
902
903     query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
904         desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
905     }
906
907     query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
908         desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
909         storage(ArenaCacheSelector<'tcx>)
910         cache_on_disk_if { true }
911     }
912
913     query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
914         desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
915     }
916     /// Gets the rendered value of the specified constant or associated constant.
917     /// Used by rustdoc.
918     query rendered_const(def_id: DefId) -> String {
919         desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) }
920     }
921     query impl_parent(def_id: DefId) -> Option<DefId> {
922         desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
923     }
924
925     /// Given an `associated_item`, find the trait it belongs to.
926     /// Return `None` if the `DefId` is not an associated item.
927     query trait_of_item(associated_item: DefId) -> Option<DefId> {
928         desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) }
929     }
930
931     query is_ctfe_mir_available(key: DefId) -> bool {
932         desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) }
933     }
934     query is_mir_available(key: DefId) -> bool {
935         desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
936     }
937
938     query vtable_methods(key: ty::PolyTraitRef<'tcx>)
939                         -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
940         desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) }
941     }
942
943     query codegen_fulfill_obligation(
944         key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
945     ) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
946         cache_on_disk_if { true }
947         desc { |tcx|
948             "checking if `{}` fulfills its obligations",
949             tcx.def_path_str(key.1.def_id())
950         }
951     }
952
953     /// Return all `impl` blocks in the current crate.
954     ///
955     /// To allow caching this between crates, you must pass in [`LOCAL_CRATE`] as the crate number.
956     /// Passing in any other crate will cause an ICE.
957     ///
958     /// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE
959     query all_local_trait_impls(local_crate: CrateNum) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
960         desc { "local trait impls" }
961     }
962
963     /// Given a trait `trait_id`, return all known `impl` blocks.
964     query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
965         storage(ArenaCacheSelector<'tcx>)
966         desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) }
967     }
968
969     query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph {
970         storage(ArenaCacheSelector<'tcx>)
971         desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
972         cache_on_disk_if { true }
973     }
974     query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
975         desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) }
976     }
977
978     /// Gets the ParameterEnvironment for a given item; this environment
979     /// will be in "user-facing" mode, meaning that it is suitable for
980     /// type-checking etc, and it does not normalize specializable
981     /// associated types. This is almost always what you want,
982     /// unless you are doing MIR optimizations, in which case you
983     /// might want to use `reveal_all()` method to change modes.
984     query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
985         desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
986     }
987
988     /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
989     /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
990     /// as this method is more efficient.
991     query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
992         desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
993     }
994
995     /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
996     /// `ty.is_copy()`, etc, since that will prune the environment where possible.
997     query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
998         desc { "computing whether `{}` is `Copy`", env.value }
999     }
1000     /// Query backing `TyS::is_sized`.
1001     query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1002         desc { "computing whether `{}` is `Sized`", env.value }
1003     }
1004     /// Query backing `TyS::is_freeze`.
1005     query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1006         desc { "computing whether `{}` is freeze", env.value }
1007     }
1008     /// Query backing `TyS::is_unpin`.
1009     query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1010         desc { "computing whether `{}` is `Unpin`", env.value }
1011     }
1012     /// Query backing `TyS::needs_drop`.
1013     query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1014         desc { "computing whether `{}` needs drop", env.value }
1015     }
1016
1017     /// Query backing `TyS::is_structural_eq_shallow`.
1018     ///
1019     /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1020     /// correctly.
1021     query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1022         desc {
1023             "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`",
1024             ty
1025         }
1026     }
1027
1028     /// A list of types where the ADT requires drop if and only if any of
1029     /// those types require drop. If the ADT is known to always need drop
1030     /// then `Err(AlwaysRequiresDrop)` is returned.
1031     query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1032         desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1033         cache_on_disk_if { true }
1034     }
1035
1036     query layout_raw(
1037         env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1038     ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> {
1039         desc { "computing layout of `{}`", env.value }
1040     }
1041
1042     query dylib_dependency_formats(_: CrateNum)
1043                                     -> &'tcx [(CrateNum, LinkagePreference)] {
1044         desc { "dylib dependency formats of crate" }
1045     }
1046
1047     query dependency_formats(_: CrateNum)
1048         -> Lrc<crate::middle::dependency_format::Dependencies>
1049     {
1050         desc { "get the linkage format of all dependencies" }
1051     }
1052
1053     query is_compiler_builtins(_: CrateNum) -> bool {
1054         fatal_cycle
1055         desc { "checking if the crate is_compiler_builtins" }
1056     }
1057     query has_global_allocator(_: CrateNum) -> bool {
1058         fatal_cycle
1059         desc { "checking if the crate has_global_allocator" }
1060     }
1061     query has_panic_handler(_: CrateNum) -> bool {
1062         fatal_cycle
1063         desc { "checking if the crate has_panic_handler" }
1064     }
1065     query is_profiler_runtime(_: CrateNum) -> bool {
1066         fatal_cycle
1067         desc { "query a crate is `#![profiler_runtime]`" }
1068     }
1069     query panic_strategy(_: CrateNum) -> PanicStrategy {
1070         fatal_cycle
1071         desc { "query a crate's configured panic strategy" }
1072     }
1073     query is_no_builtins(_: CrateNum) -> bool {
1074         fatal_cycle
1075         desc { "test whether a crate has `#![no_builtins]`" }
1076     }
1077     query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1078         fatal_cycle
1079         desc { "query a crate's symbol mangling version" }
1080     }
1081
1082     query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1083         eval_always
1084         desc { "getting crate's ExternCrateData" }
1085     }
1086
1087     query specializes(_: (DefId, DefId)) -> bool {
1088         desc { "computing whether impls specialize one another" }
1089     }
1090     query in_scope_traits_map(_: LocalDefId)
1091         -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
1092         eval_always
1093         desc { "traits in scope at a block" }
1094     }
1095
1096     query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export<LocalDefId>]> {
1097         desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1098         eval_always
1099     }
1100
1101     query impl_defaultness(def_id: DefId) -> hir::Defaultness {
1102         desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
1103     }
1104
1105     query check_item_well_formed(key: LocalDefId) -> () {
1106         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1107     }
1108     query check_trait_item_well_formed(key: LocalDefId) -> () {
1109         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1110     }
1111     query check_impl_item_well_formed(key: LocalDefId) -> () {
1112         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1113     }
1114
1115     // The `DefId`s of all non-generic functions and statics in the given crate
1116     // that can be reached from outside the crate.
1117     //
1118     // We expect this items to be available for being linked to.
1119     //
1120     // This query can also be called for `LOCAL_CRATE`. In this case it will
1121     // compute which items will be reachable to other crates, taking into account
1122     // the kind of crate that is currently compiled. Crates with only a
1123     // C interface have fewer reachable things.
1124     //
1125     // Does not include external symbols that don't have a corresponding DefId,
1126     // like the compiler-generated `main` function and so on.
1127     query reachable_non_generics(_: CrateNum)
1128         -> DefIdMap<SymbolExportLevel> {
1129         storage(ArenaCacheSelector<'tcx>)
1130         desc { "looking up the exported symbols of a crate" }
1131     }
1132     query is_reachable_non_generic(def_id: DefId) -> bool {
1133         desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1134     }
1135     query is_unreachable_local_definition(def_id: DefId) -> bool {
1136         desc { |tcx|
1137             "checking whether `{}` is reachable from outside the crate",
1138             tcx.def_path_str(def_id),
1139         }
1140     }
1141
1142     /// The entire set of monomorphizations the local crate can safely link
1143     /// to because they are exported from upstream crates. Do not depend on
1144     /// this directly, as its value changes anytime a monomorphization gets
1145     /// added or removed in any upstream crate. Instead use the narrower
1146     /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1147     /// better, `Instance::upstream_monomorphization()`.
1148     query upstream_monomorphizations(
1149         k: CrateNum
1150     ) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1151         storage(ArenaCacheSelector<'tcx>)
1152         desc { "collecting available upstream monomorphizations `{:?}`", k }
1153     }
1154
1155     /// Returns the set of upstream monomorphizations available for the
1156     /// generic function identified by the given `def_id`. The query makes
1157     /// sure to make a stable selection if the same monomorphization is
1158     /// available in multiple upstream crates.
1159     ///
1160     /// You likely want to call `Instance::upstream_monomorphization()`
1161     /// instead of invoking this query directly.
1162     query upstream_monomorphizations_for(def_id: DefId)
1163         -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1164             desc { |tcx|
1165                 "collecting available upstream monomorphizations for `{}`",
1166                 tcx.def_path_str(def_id),
1167             }
1168         }
1169
1170     /// Returns the upstream crate that exports drop-glue for the given
1171     /// type (`substs` is expected to be a single-item list containing the
1172     /// type one wants drop-glue for).
1173     ///
1174     /// This is a subset of `upstream_monomorphizations_for` in order to
1175     /// increase dep-tracking granularity. Otherwise adding or removing any
1176     /// type with drop-glue in any upstream crate would invalidate all
1177     /// functions calling drop-glue of an upstream type.
1178     ///
1179     /// You likely want to call `Instance::upstream_monomorphization()`
1180     /// instead of invoking this query directly.
1181     ///
1182     /// NOTE: This query could easily be extended to also support other
1183     ///       common functions that have are large set of monomorphizations
1184     ///       (like `Clone::clone` for example).
1185     query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1186         desc { "available upstream drop-glue for `{:?}`", substs }
1187     }
1188
1189     query foreign_modules(_: CrateNum) -> Lrc<FxHashMap<DefId, ForeignModule>> {
1190         desc { "looking up the foreign modules of a linked crate" }
1191     }
1192
1193     /// Identifies the entry-point (e.g., the `main` function) for a given
1194     /// crate, returning `None` if there is no entry point (such as for library crates).
1195     query entry_fn(_: CrateNum) -> Option<(LocalDefId, EntryFnType)> {
1196         desc { "looking up the entry function of a crate" }
1197     }
1198     query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
1199         desc { "looking up the plugin registrar for a crate" }
1200     }
1201     query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
1202         desc { "looking up the derive registrar for a crate" }
1203     }
1204     query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
1205         eval_always
1206         desc { "looking up the disambiguator a crate" }
1207     }
1208     // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1209     // Changing the name should cause a compiler error, but in case that changes, be aware.
1210     query crate_hash(_: CrateNum) -> Svh {
1211         eval_always
1212         desc { "looking up the hash a crate" }
1213     }
1214     query crate_host_hash(_: CrateNum) -> Option<Svh> {
1215         eval_always
1216         desc { "looking up the hash of a host version of a crate" }
1217     }
1218     query original_crate_name(_: CrateNum) -> Symbol {
1219         eval_always
1220         desc { "looking up the original name a crate" }
1221     }
1222     query extra_filename(_: CrateNum) -> String {
1223         eval_always
1224         desc { "looking up the extra filename for a crate" }
1225     }
1226     query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
1227         eval_always
1228         desc { "looking up the paths for extern crates" }
1229     }
1230
1231     /// Given a crate and a trait, look up all impls of that trait in the crate.
1232     /// Return `(impl_id, self_ty)`.
1233     query implementations_of_trait(_: (CrateNum, DefId))
1234         -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1235         desc { "looking up implementations of a trait in a crate" }
1236     }
1237
1238     /// Given a crate, look up all trait impls in that crate.
1239     /// Return `(impl_id, self_ty)`.
1240     query all_trait_implementations(_: CrateNum)
1241         -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1242         desc { "looking up all (?) trait implementations" }
1243     }
1244
1245     query is_dllimport_foreign_item(def_id: DefId) -> bool {
1246         desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) }
1247     }
1248     query is_statically_included_foreign_item(def_id: DefId) -> bool {
1249         desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) }
1250     }
1251     query native_library_kind(def_id: DefId)
1252         -> Option<NativeLibKind> {
1253         desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) }
1254     }
1255
1256     /// Does lifetime resolution, but does not descend into trait items. This
1257     /// should only be used for resolving lifetimes of on trait definitions,
1258     /// and is used to avoid cycles. Importantly, `resolve_lifetimes` still visits
1259     /// the same lifetimes and is responsible for diagnostics.
1260     /// See `rustc_resolve::late::lifetimes for details.
1261     query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
1262         storage(ArenaCacheSelector<'tcx>)
1263         desc { "resolving lifetimes for a trait definition" }
1264     }
1265     /// Does lifetime resolution on items. Importantly, we can't resolve
1266     /// lifetimes directly on things like trait methods, because of trait params.
1267     /// See `rustc_resolve::late::lifetimes for details.
1268     query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
1269         storage(ArenaCacheSelector<'tcx>)
1270         desc { "resolving lifetimes" }
1271     }
1272     query named_region_map(_: LocalDefId) ->
1273         Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1274         desc { "looking up a named region" }
1275     }
1276     query is_late_bound_map(_: LocalDefId) ->
1277         Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1278         desc { "testing if a region is late bound" }
1279     }
1280     /// For a given item (like a struct), gets the default lifetimes to be used
1281     /// for each paramter if a trait object were to be passed for that parameter.
1282     /// For example, for `struct Foo<'a, T, U>`, this would be `['static, 'static]`.
1283     /// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
1284     query object_lifetime_defaults_map(_: LocalDefId)
1285         -> Option<Vec<ObjectLifetimeDefault>> {
1286         desc { "looking up lifetime defaults for a region on an item" }
1287     }
1288     query late_bound_vars_map(_: LocalDefId)
1289         -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1290         desc { "looking up late bound vars" }
1291     }
1292
1293     query visibility(def_id: DefId) -> ty::Visibility {
1294         eval_always
1295         desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
1296     }
1297
1298     /// Computes the set of modules from which this type is visibly uninhabited.
1299     /// To check whether a type is uninhabited at all (not just from a given module), you could
1300     /// check whether the forest is empty.
1301     query type_uninhabited_from(
1302         key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1303     ) -> ty::inhabitedness::DefIdForest {
1304         desc { "computing the inhabitedness of `{:?}`", key }
1305     }
1306
1307     query dep_kind(_: CrateNum) -> CrateDepKind {
1308         eval_always
1309         desc { "fetching what a dependency looks like" }
1310     }
1311     query crate_name(_: CrateNum) -> Symbol {
1312         eval_always
1313         desc { "fetching what a crate is named" }
1314     }
1315     query item_children(def_id: DefId) -> &'tcx [Export<hir::HirId>] {
1316         desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
1317     }
1318     query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
1319         // This depends on untracked global state (`tcx.extern_crate_map`)
1320         eval_always
1321         desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1322     }
1323
1324     query get_lib_features(_: CrateNum) -> LibFeatures {
1325         storage(ArenaCacheSelector<'tcx>)
1326         eval_always
1327         desc { "calculating the lib features map" }
1328     }
1329     query defined_lib_features(_: CrateNum)
1330         -> &'tcx [(Symbol, Option<Symbol>)] {
1331         desc { "calculating the lib features defined in a crate" }
1332     }
1333     /// Returns the lang items defined in another crate by loading it from metadata.
1334     // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
1335     // of that argument?
1336     query get_lang_items(_: CrateNum) -> LanguageItems {
1337         storage(ArenaCacheSelector<'tcx>)
1338         eval_always
1339         desc { "calculating the lang items map" }
1340     }
1341
1342     /// Returns all diagnostic items defined in all crates.
1343     query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
1344         storage(ArenaCacheSelector<'tcx>)
1345         eval_always
1346         desc { "calculating the diagnostic items map" }
1347     }
1348
1349     /// Returns the lang items defined in another crate by loading it from metadata.
1350     query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1351         desc { "calculating the lang items defined in a crate" }
1352     }
1353
1354     /// Returns the diagnostic items defined in a crate.
1355     query diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
1356         storage(ArenaCacheSelector<'tcx>)
1357         desc { "calculating the diagnostic items map in a crate" }
1358     }
1359
1360     query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1361         desc { "calculating the missing lang items in a crate" }
1362     }
1363     query visible_parent_map(_: CrateNum)
1364         -> DefIdMap<DefId> {
1365         storage(ArenaCacheSelector<'tcx>)
1366         desc { "calculating the visible parent map" }
1367     }
1368     query trimmed_def_paths(_: CrateNum)
1369         -> FxHashMap<DefId, Symbol> {
1370         storage(ArenaCacheSelector<'tcx>)
1371         desc { "calculating trimmed def paths" }
1372     }
1373     query missing_extern_crate_item(_: CrateNum) -> bool {
1374         eval_always
1375         desc { "seeing if we're missing an `extern crate` item for this crate" }
1376     }
1377     query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1378         eval_always
1379         desc { "looking at the source for a crate" }
1380     }
1381     query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] {
1382         eval_always
1383         desc { "generating a postorder list of CrateNums" }
1384     }
1385
1386     query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1387         desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
1388         eval_always
1389     }
1390     query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1391         eval_always
1392         desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1393     }
1394     query maybe_unused_extern_crates(_: CrateNum)
1395         -> &'tcx [(LocalDefId, Span)] {
1396         eval_always
1397         desc { "looking up all possibly unused extern crates" }
1398     }
1399     query names_imported_by_glob_use(def_id: LocalDefId)
1400         -> &'tcx FxHashSet<Symbol> {
1401         eval_always
1402         desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1403     }
1404
1405     query stability_index(_: CrateNum) -> stability::Index<'tcx> {
1406         storage(ArenaCacheSelector<'tcx>)
1407         eval_always
1408         desc { "calculating the stability index for the local crate" }
1409     }
1410     query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
1411         eval_always
1412         desc { "fetching all foreign CrateNum instances" }
1413     }
1414
1415     /// A vector of every trait accessible in the whole crate
1416     /// (i.e., including those from subcrates). This is used only for
1417     /// error reporting.
1418     query all_traits(_: CrateNum) -> &'tcx [DefId] {
1419         desc { "fetching all foreign and local traits" }
1420     }
1421
1422     /// The list of symbols exported from the given crate.
1423     ///
1424     /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1425     ///   correspond to a publicly visible symbol in `cnum` machine code.
1426     /// - The `exported_symbols` sets of different crates do not intersect.
1427     query exported_symbols(_: CrateNum)
1428         -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1429         desc { "exported_symbols" }
1430     }
1431
1432     query collect_and_partition_mono_items(_: CrateNum)
1433         -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1434         eval_always
1435         desc { "collect_and_partition_mono_items" }
1436     }
1437     query is_codegened_item(def_id: DefId) -> bool {
1438         desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
1439     }
1440
1441     /// All items participating in code generation together with items inlined into them.
1442     query codegened_and_inlined_items(_: CrateNum)
1443         -> &'tcx DefIdSet {
1444         eval_always
1445        desc { "codegened_and_inlined_items" }
1446     }
1447
1448     query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
1449         desc { "codegen_unit" }
1450     }
1451     query unused_generic_params(key: DefId) -> FiniteBitSet<u32> {
1452         cache_on_disk_if { key.is_local() }
1453         desc {
1454             |tcx| "determining which generic parameters are unused by `{}`",
1455                 tcx.def_path_str(key)
1456         }
1457     }
1458     query backend_optimization_level(_: CrateNum) -> OptLevel {
1459         desc { "optimization level used by backend" }
1460     }
1461
1462     query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
1463         eval_always
1464         desc { "output_filenames" }
1465     }
1466
1467     /// Do not call this query directly: invoke `normalize` instead.
1468     query normalize_projection_ty(
1469         goal: CanonicalProjectionGoal<'tcx>
1470     ) -> Result<
1471         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1472         NoSolution,
1473     > {
1474         desc { "normalizing `{:?}`", goal }
1475     }
1476
1477     /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1478     query normalize_generic_arg_after_erasing_regions(
1479         goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1480     ) -> GenericArg<'tcx> {
1481         desc { "normalizing `{}`", goal.value }
1482     }
1483
1484     /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1485     query normalize_mir_const_after_erasing_regions(
1486         goal: ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1487     ) -> mir::ConstantKind<'tcx> {
1488         desc { "normalizing `{}`", goal.value }
1489     }
1490
1491     query implied_outlives_bounds(
1492         goal: CanonicalTyGoal<'tcx>
1493     ) -> Result<
1494         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1495         NoSolution,
1496     > {
1497         desc { "computing implied outlives bounds for `{:?}`", goal }
1498     }
1499
1500     /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1501     query dropck_outlives(
1502         goal: CanonicalTyGoal<'tcx>
1503     ) -> Result<
1504         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1505         NoSolution,
1506     > {
1507         desc { "computing dropck types for `{:?}`", goal }
1508     }
1509
1510     /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1511     /// `infcx.predicate_must_hold()` instead.
1512     query evaluate_obligation(
1513         goal: CanonicalPredicateGoal<'tcx>
1514     ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1515         desc { "evaluating trait selection obligation `{}`", goal.value.value }
1516     }
1517
1518     query evaluate_goal(
1519         goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx>
1520     ) -> Result<
1521         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1522         NoSolution
1523     > {
1524         desc { "evaluating trait selection obligation `{}`", goal.value }
1525     }
1526
1527     query type_implements_trait(
1528         key: (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>, )
1529     ) -> bool {
1530         desc { "evaluating `type_implements_trait` `{:?}`", key }
1531     }
1532
1533     /// Do not call this query directly: part of the `Eq` type-op
1534     query type_op_ascribe_user_type(
1535         goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1536     ) -> Result<
1537         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1538         NoSolution,
1539     > {
1540         desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1541     }
1542
1543     /// Do not call this query directly: part of the `Eq` type-op
1544     query type_op_eq(
1545         goal: CanonicalTypeOpEqGoal<'tcx>
1546     ) -> Result<
1547         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1548         NoSolution,
1549     > {
1550         desc { "evaluating `type_op_eq` `{:?}`", goal }
1551     }
1552
1553     /// Do not call this query directly: part of the `Subtype` type-op
1554     query type_op_subtype(
1555         goal: CanonicalTypeOpSubtypeGoal<'tcx>
1556     ) -> Result<
1557         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1558         NoSolution,
1559     > {
1560         desc { "evaluating `type_op_subtype` `{:?}`", goal }
1561     }
1562
1563     /// Do not call this query directly: part of the `ProvePredicate` type-op
1564     query type_op_prove_predicate(
1565         goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1566     ) -> Result<
1567         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1568         NoSolution,
1569     > {
1570         desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1571     }
1572
1573     /// Do not call this query directly: part of the `Normalize` type-op
1574     query type_op_normalize_ty(
1575         goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1576     ) -> Result<
1577         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1578         NoSolution,
1579     > {
1580         desc { "normalizing `{:?}`", goal }
1581     }
1582
1583     /// Do not call this query directly: part of the `Normalize` type-op
1584     query type_op_normalize_predicate(
1585         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1586     ) -> Result<
1587         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1588         NoSolution,
1589     > {
1590         desc { "normalizing `{:?}`", goal }
1591     }
1592
1593     /// Do not call this query directly: part of the `Normalize` type-op
1594     query type_op_normalize_poly_fn_sig(
1595         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1596     ) -> Result<
1597         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1598         NoSolution,
1599     > {
1600         desc { "normalizing `{:?}`", goal }
1601     }
1602
1603     /// Do not call this query directly: part of the `Normalize` type-op
1604     query type_op_normalize_fn_sig(
1605         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1606     ) -> Result<
1607         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1608         NoSolution,
1609     > {
1610         desc { "normalizing `{:?}`", goal }
1611     }
1612
1613     query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1614         desc { |tcx|
1615             "impossible substituted predicates:`{}`",
1616             tcx.def_path_str(key.0)
1617         }
1618     }
1619
1620     query method_autoderef_steps(
1621         goal: CanonicalTyGoal<'tcx>
1622     ) -> MethodAutoderefStepsResult<'tcx> {
1623         desc { "computing autoderef types for `{:?}`", goal }
1624     }
1625
1626     query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
1627         storage(ArenaCacheSelector<'tcx>)
1628         eval_always
1629         desc { "looking up supported target features" }
1630     }
1631
1632     /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1633     query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1634         -> usize {
1635         desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1636     }
1637
1638     query features_query(_: CrateNum) -> &'tcx rustc_feature::Features {
1639         eval_always
1640         desc { "looking up enabled feature gates" }
1641     }
1642
1643     /// Attempt to resolve the given `DefId` to an `Instance`, for the
1644     /// given generics args (`SubstsRef`), returning one of:
1645     ///  * `Ok(Some(instance))` on success
1646     ///  * `Ok(None)` when the `SubstsRef` are still too generic,
1647     ///    and therefore don't allow finding the final `Instance`
1648     ///  * `Err(ErrorReported)` when the `Instance` resolution process
1649     ///    couldn't complete due to errors elsewhere - this is distinct
1650     ///    from `Ok(None)` to avoid misleading diagnostics when an error
1651     ///    has already been/will be emitted, for the original cause
1652     query resolve_instance(
1653         key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1654     ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1655         desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
1656     }
1657
1658     query resolve_instance_of_const_arg(
1659         key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
1660     ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1661         desc {
1662             "resolving instance of the const argument `{}`",
1663             ty::Instance::new(key.value.0.to_def_id(), key.value.2),
1664         }
1665     }
1666
1667     query normalize_opaque_types(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
1668         desc { "normalizing opaque types in {:?}", key }
1669     }
1670
1671     /// Checks whether a type is definitely uninhabited. This is
1672     /// conservative: for some types that are uninhabited we return `false`,
1673     /// but we only return `true` for types that are definitely uninhabited.
1674     /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty`
1675     /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
1676     /// size, to account for partial initialisation. See #49298 for details.)
1677     query conservative_is_privately_uninhabited(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1678         desc { "conservatively checking if {:?} is privately uninhabited", key }
1679     }
1680 }