]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/query/mod.rs
Rollup merge of #90155 - jsha:outdent-methods, r=GuillaumeGomez,camelid
[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) { tcx.is_closure(key.to_def_id()) }
769     }
770     query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> {
771         desc {
772             |tcx| "borrow-checking the const argument`{}`",
773             tcx.def_path_str(key.0.to_def_id())
774         }
775     }
776
777     /// Gets a complete map from all types to their inherent impls.
778     /// Not meant to be used directly outside of coherence.
779     query crate_inherent_impls(k: ()) -> CrateInherentImpls {
780         storage(ArenaCacheSelector<'tcx>)
781         eval_always
782         desc { "all inherent impls defined in crate" }
783     }
784
785     /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
786     /// Not meant to be used directly outside of coherence.
787     query crate_inherent_impls_overlap_check(_: ())
788         -> () {
789         eval_always
790         desc { "check for overlap between inherent impls defined in this crate" }
791     }
792
793     /// Check whether the function has any recursion that could cause the inliner to trigger
794     /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
795     /// current function, just all intermediate functions.
796     query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
797         fatal_cycle
798         desc { |tcx|
799             "computing if `{}` (transitively) calls `{}`",
800             key.0,
801             tcx.def_path_str(key.1.to_def_id()),
802         }
803     }
804
805     /// Obtain all the calls into other local functions
806     query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] {
807         fatal_cycle
808         desc { |tcx|
809             "computing all local function calls in `{}`",
810             tcx.def_path_str(key.def_id()),
811         }
812     }
813
814     /// Evaluates a constant and returns the computed allocation.
815     ///
816     /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
817     query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
818         -> EvalToAllocationRawResult<'tcx> {
819         desc { |tcx|
820             "const-evaluating + checking `{}`",
821             key.value.display(tcx)
822         }
823         cache_on_disk_if { true }
824     }
825
826     /// Evaluates const items or anonymous constants
827     /// (such as enum variant explicit discriminants or array lengths)
828     /// into a representation suitable for the type system and const generics.
829     ///
830     /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
831     /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
832     query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
833         -> EvalToConstValueResult<'tcx> {
834         desc { |tcx|
835             "simplifying constant for the type system `{}`",
836             key.value.display(tcx)
837         }
838         cache_on_disk_if { true }
839     }
840
841     /// Convert an evaluated constant to a type level constant or
842     /// return `None` if that is not possible.
843     query const_to_valtree(
844         key: ty::ParamEnvAnd<'tcx, ConstAlloc<'tcx>>
845     ) -> Option<ty::ValTree<'tcx>> {
846         desc { "destructure constant" }
847     }
848
849     /// Destructure a constant ADT or array into its variant index and its
850     /// field values.
851     query destructure_const(
852         key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
853     ) -> mir::DestructuredConst<'tcx> {
854         desc { "destructure constant" }
855     }
856
857     /// Dereference a constant reference or raw pointer and turn the result into a constant
858     /// again.
859     query deref_const(
860         key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
861     ) -> &'tcx ty::Const<'tcx> {
862         desc { "deref constant" }
863     }
864
865     query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
866         desc { "get a &core::panic::Location referring to a span" }
867     }
868
869     query lit_to_const(
870         key: LitToConstInput<'tcx>
871     ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
872         desc { "converting literal to const" }
873     }
874
875     query check_match(key: DefId) {
876         desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
877         cache_on_disk_if { key.is_local() }
878     }
879
880     /// Performs part of the privacy check and computes "access levels".
881     query privacy_access_levels(_: ()) -> &'tcx AccessLevels {
882         eval_always
883         desc { "privacy access levels" }
884     }
885     query check_private_in_public(_: ()) -> () {
886         eval_always
887         desc { "checking for private elements in public interfaces" }
888     }
889
890     query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
891         storage(ArenaCacheSelector<'tcx>)
892         desc { "reachability" }
893     }
894
895     /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
896     /// in the case of closures, this will be redirected to the enclosing function.
897     query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree {
898         desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
899     }
900
901     query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
902         storage(ArenaCacheSelector<'tcx>)
903         desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
904     }
905
906     /// The `symbol_name` query provides the symbol name for calling a
907     /// given instance from the local crate. In particular, it will also
908     /// look up the correct symbol name of instances from upstream crates.
909     query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
910         desc { "computing the symbol for `{}`", key }
911         cache_on_disk_if { true }
912     }
913
914     query opt_def_kind(def_id: DefId) -> Option<DefKind> {
915         desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
916     }
917
918     query def_span(def_id: DefId) -> Span {
919         desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
920     }
921
922     query def_ident_span(def_id: DefId) -> Option<Span> {
923         desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
924     }
925
926     query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> {
927         desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
928     }
929
930     query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> {
931         desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
932     }
933
934     query should_inherit_track_caller(def_id: DefId) -> bool {
935         desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
936     }
937
938     query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
939         desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
940     }
941
942     query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
943         desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
944     }
945
946     query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
947         desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
948         storage(ArenaCacheSelector<'tcx>)
949         cache_on_disk_if { true }
950     }
951
952     query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
953         desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
954     }
955     /// Gets the rendered value of the specified constant or associated constant.
956     /// Used by rustdoc.
957     query rendered_const(def_id: DefId) -> String {
958         desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) }
959     }
960     query impl_parent(def_id: DefId) -> Option<DefId> {
961         desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
962     }
963
964     /// Given an `associated_item`, find the trait it belongs to.
965     /// Return `None` if the `DefId` is not an associated item.
966     query trait_of_item(associated_item: DefId) -> Option<DefId> {
967         desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) }
968     }
969
970     query is_ctfe_mir_available(key: DefId) -> bool {
971         desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) }
972     }
973     query is_mir_available(key: DefId) -> bool {
974         desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
975     }
976
977     query own_existential_vtable_entries(
978         key: ty::PolyExistentialTraitRef<'tcx>
979     ) -> &'tcx [DefId] {
980         desc { |tcx| "finding all existential vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
981     }
982
983     query vtable_entries(key: ty::PolyTraitRef<'tcx>)
984                         -> &'tcx [ty::VtblEntry<'tcx>] {
985         desc { |tcx| "finding all vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
986     }
987
988     query vtable_trait_upcasting_coercion_new_vptr_slot(key: (ty::Ty<'tcx>, ty::Ty<'tcx>)) -> Option<usize> {
989         desc { |tcx| "finding the slot within vtable for trait object {} vtable ptr during trait upcasting coercion from {} vtable",
990             key.1, key.0 }
991     }
992
993     query vtable_allocation(key: (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
994         desc { |tcx| "vtable const allocation for <{} as {}>",
995             key.0,
996             key.1.map(|trait_ref| format!("{}", trait_ref)).unwrap_or("_".to_owned())
997         }
998     }
999
1000     query codegen_fulfill_obligation(
1001         key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
1002     ) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
1003         cache_on_disk_if { true }
1004         desc { |tcx|
1005             "checking if `{}` fulfills its obligations",
1006             tcx.def_path_str(key.1.def_id())
1007         }
1008     }
1009
1010     /// Return all `impl` blocks in the current crate.
1011     ///
1012     /// To allow caching this between crates, you must pass in [`LOCAL_CRATE`] as the crate number.
1013     /// Passing in any other crate will cause an ICE.
1014     ///
1015     /// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE
1016     query all_local_trait_impls(_: ()) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
1017         desc { "local trait impls" }
1018     }
1019
1020     /// Given a trait `trait_id`, return all known `impl` blocks.
1021     query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
1022         storage(ArenaCacheSelector<'tcx>)
1023         desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) }
1024     }
1025
1026     query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph {
1027         storage(ArenaCacheSelector<'tcx>)
1028         desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
1029         cache_on_disk_if { true }
1030     }
1031     query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
1032         desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) }
1033     }
1034
1035     /// Gets the ParameterEnvironment for a given item; this environment
1036     /// will be in "user-facing" mode, meaning that it is suitable for
1037     /// type-checking etc, and it does not normalize specializable
1038     /// associated types. This is almost always what you want,
1039     /// unless you are doing MIR optimizations, in which case you
1040     /// might want to use `reveal_all()` method to change modes.
1041     query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
1042         desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1043     }
1044
1045     /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
1046     /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
1047     /// as this method is more efficient.
1048     query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
1049         desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
1050     }
1051
1052     /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1053     /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1054     query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1055         desc { "computing whether `{}` is `Copy`", env.value }
1056     }
1057     /// Query backing `TyS::is_sized`.
1058     query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1059         desc { "computing whether `{}` is `Sized`", env.value }
1060     }
1061     /// Query backing `TyS::is_freeze`.
1062     query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1063         desc { "computing whether `{}` is freeze", env.value }
1064     }
1065     /// Query backing `TyS::is_unpin`.
1066     query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1067         desc { "computing whether `{}` is `Unpin`", env.value }
1068     }
1069     /// Query backing `TyS::needs_drop`.
1070     query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1071         desc { "computing whether `{}` needs drop", env.value }
1072     }
1073     /// Query backing `TyS::has_significant_drop_raw`.
1074     query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1075         desc { "computing whether `{}` has a significant drop", env.value }
1076     }
1077
1078     /// Query backing `TyS::is_structural_eq_shallow`.
1079     ///
1080     /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1081     /// correctly.
1082     query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1083         desc {
1084             "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`",
1085             ty
1086         }
1087     }
1088
1089     /// A list of types where the ADT requires drop if and only if any of
1090     /// those types require drop. If the ADT is known to always need drop
1091     /// then `Err(AlwaysRequiresDrop)` is returned.
1092     query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1093         desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1094         cache_on_disk_if { true }
1095     }
1096
1097     /// A list of types where the ADT requires drop if and only if any of those types
1098     /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1099     /// is considered to not be significant. A drop is significant if it is implemented
1100     /// by the user or does anything that will have any observable behavior (other than
1101     /// freeing up memory). If the ADT is known to have a significant destructor then
1102     /// `Err(AlwaysRequiresDrop)` is returned.
1103     query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1104         desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1105         cache_on_disk_if { false }
1106     }
1107
1108     /// Computes the layout of a type. Note that this implicitly
1109     /// executes in "reveal all" mode, and will normalize the input type.
1110     query layout_of(
1111         key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1112     ) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
1113         desc { "computing layout of `{}`", key.value }
1114     }
1115
1116     /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1117     ///
1118     /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1119     /// instead, where the instance is an `InstanceDef::Virtual`.
1120     query fn_abi_of_fn_ptr(
1121         key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1122     ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1123         desc { "computing call ABI of `{}` function pointers", key.value.0 }
1124     }
1125
1126     /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1127     /// direct calls to an `fn`.
1128     ///
1129     /// NB: that includes virtual calls, which are represented by "direct calls"
1130     /// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1131     query fn_abi_of_instance(
1132         key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1133     ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1134         desc { "computing call ABI of `{}`", key.value.0 }
1135     }
1136
1137     query dylib_dependency_formats(_: CrateNum)
1138                                     -> &'tcx [(CrateNum, LinkagePreference)] {
1139         desc { "dylib dependency formats of crate" }
1140     }
1141
1142     query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
1143         desc { "get the linkage format of all dependencies" }
1144     }
1145
1146     query is_compiler_builtins(_: CrateNum) -> bool {
1147         fatal_cycle
1148         desc { "checking if the crate is_compiler_builtins" }
1149     }
1150     query has_global_allocator(_: CrateNum) -> bool {
1151         // This query depends on untracked global state in CStore
1152         eval_always
1153         fatal_cycle
1154         desc { "checking if the crate has_global_allocator" }
1155     }
1156     query has_panic_handler(_: CrateNum) -> bool {
1157         fatal_cycle
1158         desc { "checking if the crate has_panic_handler" }
1159     }
1160     query is_profiler_runtime(_: CrateNum) -> bool {
1161         fatal_cycle
1162         desc { "query a crate is `#![profiler_runtime]`" }
1163     }
1164     query panic_strategy(_: CrateNum) -> PanicStrategy {
1165         fatal_cycle
1166         desc { "query a crate's configured panic strategy" }
1167     }
1168     query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1169         fatal_cycle
1170         desc { "query a crate's configured panic-in-drop strategy" }
1171     }
1172     query is_no_builtins(_: CrateNum) -> bool {
1173         fatal_cycle
1174         desc { "test whether a crate has `#![no_builtins]`" }
1175     }
1176     query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1177         fatal_cycle
1178         desc { "query a crate's symbol mangling version" }
1179     }
1180
1181     query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1182         eval_always
1183         desc { "getting crate's ExternCrateData" }
1184     }
1185
1186     query specializes(_: (DefId, DefId)) -> bool {
1187         desc { "computing whether impls specialize one another" }
1188     }
1189     query in_scope_traits_map(_: LocalDefId)
1190         -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
1191         desc { "traits in scope at a block" }
1192     }
1193
1194     query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> {
1195         desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1196     }
1197
1198     query impl_defaultness(def_id: DefId) -> hir::Defaultness {
1199         desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
1200     }
1201
1202     query impl_constness(def_id: DefId) -> hir::Constness {
1203         desc { |tcx| "looking up whether `{}` is a const impl", tcx.def_path_str(def_id) }
1204     }
1205
1206     query check_item_well_formed(key: LocalDefId) -> () {
1207         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1208     }
1209     query check_trait_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_impl_item_well_formed(key: LocalDefId) -> () {
1213         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1214     }
1215
1216     // The `DefId`s of all non-generic functions and statics in the given crate
1217     // that can be reached from outside the crate.
1218     //
1219     // We expect this items to be available for being linked to.
1220     //
1221     // This query can also be called for `LOCAL_CRATE`. In this case it will
1222     // compute which items will be reachable to other crates, taking into account
1223     // the kind of crate that is currently compiled. Crates with only a
1224     // C interface have fewer reachable things.
1225     //
1226     // Does not include external symbols that don't have a corresponding DefId,
1227     // like the compiler-generated `main` function and so on.
1228     query reachable_non_generics(_: CrateNum)
1229         -> DefIdMap<SymbolExportLevel> {
1230         storage(ArenaCacheSelector<'tcx>)
1231         desc { "looking up the exported symbols of a crate" }
1232     }
1233     query is_reachable_non_generic(def_id: DefId) -> bool {
1234         desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1235     }
1236     query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1237         desc { |tcx|
1238             "checking whether `{}` is reachable from outside the crate",
1239             tcx.def_path_str(def_id.to_def_id()),
1240         }
1241     }
1242
1243     /// The entire set of monomorphizations the local crate can safely link
1244     /// to because they are exported from upstream crates. Do not depend on
1245     /// this directly, as its value changes anytime a monomorphization gets
1246     /// added or removed in any upstream crate. Instead use the narrower
1247     /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1248     /// better, `Instance::upstream_monomorphization()`.
1249     query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1250         storage(ArenaCacheSelector<'tcx>)
1251         desc { "collecting available upstream monomorphizations" }
1252     }
1253
1254     /// Returns the set of upstream monomorphizations available for the
1255     /// generic function identified by the given `def_id`. The query makes
1256     /// sure to make a stable selection if the same monomorphization is
1257     /// available in multiple upstream crates.
1258     ///
1259     /// You likely want to call `Instance::upstream_monomorphization()`
1260     /// instead of invoking this query directly.
1261     query upstream_monomorphizations_for(def_id: DefId)
1262         -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1263             desc { |tcx|
1264                 "collecting available upstream monomorphizations for `{}`",
1265                 tcx.def_path_str(def_id),
1266             }
1267         }
1268
1269     /// Returns the upstream crate that exports drop-glue for the given
1270     /// type (`substs` is expected to be a single-item list containing the
1271     /// type one wants drop-glue for).
1272     ///
1273     /// This is a subset of `upstream_monomorphizations_for` in order to
1274     /// increase dep-tracking granularity. Otherwise adding or removing any
1275     /// type with drop-glue in any upstream crate would invalidate all
1276     /// functions calling drop-glue of an upstream type.
1277     ///
1278     /// You likely want to call `Instance::upstream_monomorphization()`
1279     /// instead of invoking this query directly.
1280     ///
1281     /// NOTE: This query could easily be extended to also support other
1282     ///       common functions that have are large set of monomorphizations
1283     ///       (like `Clone::clone` for example).
1284     query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1285         desc { "available upstream drop-glue for `{:?}`", substs }
1286     }
1287
1288     query foreign_modules(_: CrateNum) -> Lrc<FxHashMap<DefId, ForeignModule>> {
1289         desc { "looking up the foreign modules of a linked crate" }
1290     }
1291
1292     /// Identifies the entry-point (e.g., the `main` function) for a given
1293     /// crate, returning `None` if there is no entry point (such as for library crates).
1294     query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
1295         desc { "looking up the entry function of a crate" }
1296     }
1297     query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1298         desc { "looking up the derive registrar for a crate" }
1299     }
1300     // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1301     // Changing the name should cause a compiler error, but in case that changes, be aware.
1302     query crate_hash(_: CrateNum) -> Svh {
1303         eval_always
1304         desc { "looking up the hash a crate" }
1305     }
1306     query crate_host_hash(_: CrateNum) -> Option<Svh> {
1307         eval_always
1308         desc { "looking up the hash of a host version of a crate" }
1309     }
1310     query extra_filename(_: CrateNum) -> String {
1311         eval_always
1312         desc { "looking up the extra filename for a crate" }
1313     }
1314     query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
1315         eval_always
1316         desc { "looking up the paths for extern crates" }
1317     }
1318
1319     /// Given a crate and a trait, look up all impls of that trait in the crate.
1320     /// Return `(impl_id, self_ty)`.
1321     query implementations_of_trait(_: (CrateNum, DefId))
1322         -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1323         desc { "looking up implementations of a trait in a crate" }
1324     }
1325
1326     /// Given a crate, look up all trait impls in that crate.
1327     /// Return `(impl_id, self_ty)`.
1328     query all_trait_implementations(_: CrateNum)
1329         -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1330         desc { "looking up all (?) trait implementations" }
1331     }
1332
1333     query is_dllimport_foreign_item(def_id: DefId) -> bool {
1334         desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) }
1335     }
1336     query is_statically_included_foreign_item(def_id: DefId) -> bool {
1337         desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) }
1338     }
1339     query native_library_kind(def_id: DefId)
1340         -> Option<NativeLibKind> {
1341         desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) }
1342     }
1343
1344     /// Does lifetime resolution, but does not descend into trait items. This
1345     /// should only be used for resolving lifetimes of on trait definitions,
1346     /// and is used to avoid cycles. Importantly, `resolve_lifetimes` still visits
1347     /// the same lifetimes and is responsible for diagnostics.
1348     /// See `rustc_resolve::late::lifetimes for details.
1349     query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
1350         storage(ArenaCacheSelector<'tcx>)
1351         desc { "resolving lifetimes for a trait definition" }
1352     }
1353     /// Does lifetime resolution on items. Importantly, we can't resolve
1354     /// lifetimes directly on things like trait methods, because of trait params.
1355     /// See `rustc_resolve::late::lifetimes for details.
1356     query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
1357         storage(ArenaCacheSelector<'tcx>)
1358         desc { "resolving lifetimes" }
1359     }
1360     query named_region_map(_: LocalDefId) ->
1361         Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1362         desc { "looking up a named region" }
1363     }
1364     query is_late_bound_map(_: LocalDefId) ->
1365         Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1366         desc { "testing if a region is late bound" }
1367     }
1368     /// For a given item (like a struct), gets the default lifetimes to be used
1369     /// for each parameter if a trait object were to be passed for that parameter.
1370     /// For example, for `struct Foo<'a, T, U>`, this would be `['static, 'static]`.
1371     /// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
1372     query object_lifetime_defaults_map(_: LocalDefId)
1373         -> Option<Vec<ObjectLifetimeDefault>> {
1374         desc { "looking up lifetime defaults for a region on an item" }
1375     }
1376     query late_bound_vars_map(_: LocalDefId)
1377         -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1378         desc { "looking up late bound vars" }
1379     }
1380
1381     query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
1382         desc { "finds the lifetime scope for an HirId of a PathSegment" }
1383     }
1384
1385     query visibility(def_id: DefId) -> ty::Visibility {
1386         desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
1387     }
1388
1389     /// Computes the set of modules from which this type is visibly uninhabited.
1390     /// To check whether a type is uninhabited at all (not just from a given module), you could
1391     /// check whether the forest is empty.
1392     query type_uninhabited_from(
1393         key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1394     ) -> ty::inhabitedness::DefIdForest {
1395         desc { "computing the inhabitedness of `{:?}`", key }
1396     }
1397
1398     query dep_kind(_: CrateNum) -> CrateDepKind {
1399         eval_always
1400         desc { "fetching what a dependency looks like" }
1401     }
1402     query crate_name(_: CrateNum) -> Symbol {
1403         eval_always
1404         desc { "fetching what a crate is named" }
1405     }
1406     query item_children(def_id: DefId) -> &'tcx [Export] {
1407         desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
1408     }
1409     query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
1410         desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1411     }
1412
1413     query get_lib_features(_: ()) -> LibFeatures {
1414         storage(ArenaCacheSelector<'tcx>)
1415         eval_always
1416         desc { "calculating the lib features map" }
1417     }
1418     query defined_lib_features(_: CrateNum)
1419         -> &'tcx [(Symbol, Option<Symbol>)] {
1420         desc { "calculating the lib features defined in a crate" }
1421     }
1422     /// Returns the lang items defined in another crate by loading it from metadata.
1423     query get_lang_items(_: ()) -> LanguageItems {
1424         storage(ArenaCacheSelector<'tcx>)
1425         eval_always
1426         desc { "calculating the lang items map" }
1427     }
1428
1429     /// Returns all diagnostic items defined in all crates.
1430     query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
1431         storage(ArenaCacheSelector<'tcx>)
1432         eval_always
1433         desc { "calculating the diagnostic items map" }
1434     }
1435
1436     /// Returns the lang items defined in another crate by loading it from metadata.
1437     query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1438         desc { "calculating the lang items defined in a crate" }
1439     }
1440
1441     /// Returns the diagnostic items defined in a crate.
1442     query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
1443         storage(ArenaCacheSelector<'tcx>)
1444         desc { "calculating the diagnostic items map in a crate" }
1445     }
1446
1447     query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1448         desc { "calculating the missing lang items in a crate" }
1449     }
1450     query visible_parent_map(_: ()) -> DefIdMap<DefId> {
1451         storage(ArenaCacheSelector<'tcx>)
1452         desc { "calculating the visible parent map" }
1453     }
1454     query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
1455         storage(ArenaCacheSelector<'tcx>)
1456         desc { "calculating trimmed def paths" }
1457     }
1458     query missing_extern_crate_item(_: CrateNum) -> bool {
1459         eval_always
1460         desc { "seeing if we're missing an `extern crate` item for this crate" }
1461     }
1462     query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1463         eval_always
1464         desc { "looking at the source for a crate" }
1465     }
1466     query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
1467         eval_always
1468         desc { "generating a postorder list of CrateNums" }
1469     }
1470     /// Returns whether or not the crate with CrateNum 'cnum'
1471     /// is marked as a private dependency
1472     query is_private_dep(c: CrateNum) -> bool {
1473         eval_always
1474         desc { "check whether crate {} is a private dependency", c }
1475     }
1476     query allocator_kind(_: ()) -> Option<AllocatorKind> {
1477         eval_always
1478         desc { "allocator kind for the current crate" }
1479     }
1480
1481     query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1482         desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
1483         eval_always
1484     }
1485     query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1486         desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1487     }
1488     query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] {
1489         desc { "looking up all possibly unused extern crates" }
1490     }
1491     query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet<Symbol> {
1492         desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1493     }
1494
1495     query stability_index(_: ()) -> stability::Index<'tcx> {
1496         storage(ArenaCacheSelector<'tcx>)
1497         eval_always
1498         desc { "calculating the stability index for the local crate" }
1499     }
1500     query crates(_: ()) -> &'tcx [CrateNum] {
1501         eval_always
1502         desc { "fetching all foreign CrateNum instances" }
1503     }
1504
1505     /// A vector of every trait accessible in the whole crate
1506     /// (i.e., including those from subcrates). This is used only for
1507     /// error reporting.
1508     query all_traits(_: ()) -> &'tcx [DefId] {
1509         desc { "fetching all foreign and local traits" }
1510     }
1511
1512     /// The list of symbols exported from the given crate.
1513     ///
1514     /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1515     ///   correspond to a publicly visible symbol in `cnum` machine code.
1516     /// - The `exported_symbols` sets of different crates do not intersect.
1517     query exported_symbols(_: CrateNum)
1518         -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1519         desc { "exported_symbols" }
1520     }
1521
1522     query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1523         eval_always
1524         desc { "collect_and_partition_mono_items" }
1525     }
1526     query is_codegened_item(def_id: DefId) -> bool {
1527         desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
1528     }
1529
1530     /// All items participating in code generation together with items inlined into them.
1531     query codegened_and_inlined_items(_: ()) -> &'tcx DefIdSet {
1532         eval_always
1533        desc { "codegened_and_inlined_items" }
1534     }
1535
1536     query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
1537         desc { "codegen_unit" }
1538     }
1539     query unused_generic_params(key: ty::InstanceDef<'tcx>) -> FiniteBitSet<u32> {
1540         cache_on_disk_if { key.def_id().is_local() }
1541         desc {
1542             |tcx| "determining which generic parameters are unused by `{}`",
1543                 tcx.def_path_str(key.def_id())
1544         }
1545     }
1546     query backend_optimization_level(_: ()) -> OptLevel {
1547         desc { "optimization level used by backend" }
1548     }
1549
1550     query output_filenames(_: ()) -> Arc<OutputFilenames> {
1551         eval_always
1552         desc { "output_filenames" }
1553     }
1554
1555     /// Do not call this query directly: invoke `normalize` instead.
1556     query normalize_projection_ty(
1557         goal: CanonicalProjectionGoal<'tcx>
1558     ) -> Result<
1559         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1560         NoSolution,
1561     > {
1562         desc { "normalizing `{:?}`", goal }
1563     }
1564
1565     /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1566     query normalize_generic_arg_after_erasing_regions(
1567         goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1568     ) -> GenericArg<'tcx> {
1569         desc { "normalizing `{}`", goal.value }
1570     }
1571
1572     /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1573     query normalize_mir_const_after_erasing_regions(
1574         goal: ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1575     ) -> mir::ConstantKind<'tcx> {
1576         desc { "normalizing `{}`", goal.value }
1577     }
1578
1579     query implied_outlives_bounds(
1580         goal: CanonicalTyGoal<'tcx>
1581     ) -> Result<
1582         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1583         NoSolution,
1584     > {
1585         desc { "computing implied outlives bounds for `{:?}`", goal }
1586     }
1587
1588     /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1589     query dropck_outlives(
1590         goal: CanonicalTyGoal<'tcx>
1591     ) -> Result<
1592         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1593         NoSolution,
1594     > {
1595         desc { "computing dropck types for `{:?}`", goal }
1596     }
1597
1598     /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1599     /// `infcx.predicate_must_hold()` instead.
1600     query evaluate_obligation(
1601         goal: CanonicalPredicateGoal<'tcx>
1602     ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1603         desc { "evaluating trait selection obligation `{}`", goal.value.value }
1604     }
1605
1606     query evaluate_goal(
1607         goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx>
1608     ) -> Result<
1609         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1610         NoSolution
1611     > {
1612         desc { "evaluating trait selection obligation `{}`", goal.value }
1613     }
1614
1615     /// Do not call this query directly: part of the `Eq` type-op
1616     query type_op_ascribe_user_type(
1617         goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1618     ) -> Result<
1619         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1620         NoSolution,
1621     > {
1622         desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1623     }
1624
1625     /// Do not call this query directly: part of the `Eq` type-op
1626     query type_op_eq(
1627         goal: CanonicalTypeOpEqGoal<'tcx>
1628     ) -> Result<
1629         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1630         NoSolution,
1631     > {
1632         desc { "evaluating `type_op_eq` `{:?}`", goal }
1633     }
1634
1635     /// Do not call this query directly: part of the `Subtype` type-op
1636     query type_op_subtype(
1637         goal: CanonicalTypeOpSubtypeGoal<'tcx>
1638     ) -> Result<
1639         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1640         NoSolution,
1641     > {
1642         desc { "evaluating `type_op_subtype` `{:?}`", goal }
1643     }
1644
1645     /// Do not call this query directly: part of the `ProvePredicate` type-op
1646     query type_op_prove_predicate(
1647         goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1648     ) -> Result<
1649         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1650         NoSolution,
1651     > {
1652         desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1653     }
1654
1655     /// Do not call this query directly: part of the `Normalize` type-op
1656     query type_op_normalize_ty(
1657         goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1658     ) -> Result<
1659         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1660         NoSolution,
1661     > {
1662         desc { "normalizing `{:?}`", goal }
1663     }
1664
1665     /// Do not call this query directly: part of the `Normalize` type-op
1666     query type_op_normalize_predicate(
1667         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1668     ) -> Result<
1669         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1670         NoSolution,
1671     > {
1672         desc { "normalizing `{:?}`", goal }
1673     }
1674
1675     /// Do not call this query directly: part of the `Normalize` type-op
1676     query type_op_normalize_poly_fn_sig(
1677         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1678     ) -> Result<
1679         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1680         NoSolution,
1681     > {
1682         desc { "normalizing `{:?}`", goal }
1683     }
1684
1685     /// Do not call this query directly: part of the `Normalize` type-op
1686     query type_op_normalize_fn_sig(
1687         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1688     ) -> Result<
1689         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1690         NoSolution,
1691     > {
1692         desc { "normalizing `{:?}`", goal }
1693     }
1694
1695     query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1696         desc { |tcx|
1697             "impossible substituted predicates:`{}`",
1698             tcx.def_path_str(key.0)
1699         }
1700     }
1701
1702     query method_autoderef_steps(
1703         goal: CanonicalTyGoal<'tcx>
1704     ) -> MethodAutoderefStepsResult<'tcx> {
1705         desc { "computing autoderef types for `{:?}`", goal }
1706     }
1707
1708     query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
1709         storage(ArenaCacheSelector<'tcx>)
1710         eval_always
1711         desc { "looking up supported target features" }
1712     }
1713
1714     /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1715     query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1716         -> usize {
1717         desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1718     }
1719
1720     query features_query(_: ()) -> &'tcx rustc_feature::Features {
1721         eval_always
1722         desc { "looking up enabled feature gates" }
1723     }
1724
1725     /// Attempt to resolve the given `DefId` to an `Instance`, for the
1726     /// given generics args (`SubstsRef`), returning one of:
1727     ///  * `Ok(Some(instance))` on success
1728     ///  * `Ok(None)` when the `SubstsRef` are still too generic,
1729     ///    and therefore don't allow finding the final `Instance`
1730     ///  * `Err(ErrorReported)` when the `Instance` resolution process
1731     ///    couldn't complete due to errors elsewhere - this is distinct
1732     ///    from `Ok(None)` to avoid misleading diagnostics when an error
1733     ///    has already been/will be emitted, for the original cause
1734     query resolve_instance(
1735         key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1736     ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1737         desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
1738     }
1739
1740     query resolve_instance_of_const_arg(
1741         key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
1742     ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1743         desc {
1744             "resolving instance of the const argument `{}`",
1745             ty::Instance::new(key.value.0.to_def_id(), key.value.2),
1746         }
1747     }
1748
1749     query normalize_opaque_types(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
1750         desc { "normalizing opaque types in {:?}", key }
1751     }
1752
1753     /// Checks whether a type is definitely uninhabited. This is
1754     /// conservative: for some types that are uninhabited we return `false`,
1755     /// but we only return `true` for types that are definitely uninhabited.
1756     /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty`
1757     /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
1758     /// size, to account for partial initialisation. See #49298 for details.)
1759     query conservative_is_privately_uninhabited(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1760         desc { "conservatively checking if {:?} is privately uninhabited", key }
1761     }
1762
1763     query limits(key: ()) -> Limits {
1764         desc { "looking up limits" }
1765     }
1766
1767     /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
1768     /// we get an `Unimplemented` error that matches the provided `Predicate`, return
1769     /// the cause of the newly created obligation.
1770     ///
1771     /// This is only used by error-reporting code to get a better cause (in particular, a better
1772     /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
1773     /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
1774     /// because the `ty::Ty`-based wfcheck is always run.
1775     query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> {
1776         eval_always
1777         no_hash
1778         desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 }
1779     }
1780 }