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