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