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