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