]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/query/mod.rs
Change `arena_cache` to not alter the declared query result
[rust.git] / compiler / rustc_middle / src / query / mod.rs
1 //! Defines the various compiler queries.
2 //!
3 //! For more information on the query system, see
4 //! ["Queries: demand-driven compilation"](https://rustc-dev-guide.rust-lang.org/query.html).
5 //! This chapter includes instructions for adding new queries.
6
7 use crate::ty::{self, print::describe_as_module, TyCtxt};
8 use rustc_span::def_id::LOCAL_CRATE;
9
10 mod keys;
11 pub use keys::Key;
12
13 // Each of these queries corresponds to a function pointer field in the
14 // `Providers` struct for requesting a value of that type, and a method
15 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
16 // which memoizes and does dep-graph tracking, wrapping around the actual
17 // `Providers` that the driver creates (using several `rustc_*` crates).
18 //
19 // The result type of each query must implement `Clone`, and additionally
20 // `ty::query::values::Value`, which produces an appropriate placeholder
21 // (error) value if the query resulted in a query cycle.
22 // Queries marked with `fatal_cycle` do not need the latter implementation,
23 // as they will raise an fatal error on query cycles instead.
24 rustc_queries! {
25     query trigger_delay_span_bug(key: DefId) -> () {
26         desc { "triggering a delay span bug" }
27     }
28
29     query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
30         feedable
31         no_hash
32         desc { "getting the resolver outputs" }
33     }
34
35     query resolver_for_lowering(_: ()) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
36         feedable
37         no_hash
38         desc { "getting the resolver for lowering" }
39     }
40
41     /// Return the span for a definition.
42     /// Contrary to `def_span` below, this query returns the full absolute span of the definition.
43     /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
44     /// of rustc_middle::hir::source_map.
45     query source_span(key: LocalDefId) -> Span {
46         // Accesses untracked data
47         eval_always
48         desc { "getting the source span" }
49     }
50
51     /// Represents crate as a whole (as distinct from the top-level crate module).
52     /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
53     /// we will have to assume that any change means that you need to be recompiled.
54     /// This is because the `hir_crate` query gives you access to all other items.
55     /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
56     /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
57     query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
58         arena_cache
59         eval_always
60         desc { "getting the crate HIR" }
61     }
62
63     /// All items in the crate.
64     query hir_crate_items(_: ()) -> &'tcx rustc_middle::hir::ModuleItems {
65         arena_cache
66         eval_always
67         desc { "getting HIR crate items" }
68     }
69
70     /// The items in a module.
71     ///
72     /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
73     /// Avoid calling this query directly.
74     query hir_module_items(key: LocalDefId) -> &'tcx rustc_middle::hir::ModuleItems {
75         arena_cache
76         desc { |tcx| "getting HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
77         cache_on_disk_if { true }
78     }
79
80     /// Gives access to the HIR node for the HIR owner `key`.
81     ///
82     /// This can be conveniently accessed by methods on `tcx.hir()`.
83     /// Avoid calling this query directly.
84     query hir_owner(key: hir::OwnerId) -> Option<crate::hir::Owner<'tcx>> {
85         desc { |tcx| "getting HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
86     }
87
88     /// Gives access to the HIR ID for the given `LocalDefId` owner `key`.
89     ///
90     /// This can be conveniently accessed by methods on `tcx.hir()`.
91     /// Avoid calling this query directly.
92     query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
93         desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key.to_def_id()) }
94     }
95
96     /// Gives access to the HIR node's parent for the HIR owner `key`.
97     ///
98     /// This can be conveniently accessed by methods on `tcx.hir()`.
99     /// Avoid calling this query directly.
100     query hir_owner_parent(key: hir::OwnerId) -> hir::HirId {
101         desc { |tcx| "getting HIR parent of `{}`", tcx.def_path_str(key.to_def_id()) }
102     }
103
104     /// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
105     ///
106     /// This can be conveniently accessed by methods on `tcx.hir()`.
107     /// Avoid calling this query directly.
108     query hir_owner_nodes(key: hir::OwnerId) -> hir::MaybeOwner<&'tcx hir::OwnerNodes<'tcx>> {
109         desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
110     }
111
112     /// Gives access to the HIR attributes inside the HIR owner `key`.
113     ///
114     /// This can be conveniently accessed by methods on `tcx.hir()`.
115     /// Avoid calling this query directly.
116     query hir_attrs(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
117         desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key.to_def_id()) }
118     }
119
120     /// Computes the `DefId` of the corresponding const parameter in case the `key` is a
121     /// const argument and returns `None` otherwise.
122     ///
123     /// ```ignore (incomplete)
124     /// let a = foo::<7>();
125     /// //            ^ Calling `opt_const_param_of` for this argument,
126     ///
127     /// fn foo<const N: usize>()
128     /// //           ^ returns this `DefId`.
129     ///
130     /// fn bar() {
131     /// // ^ While calling `opt_const_param_of` for other bodies returns `None`.
132     /// }
133     /// ```
134     // It looks like caching this query on disk actually slightly
135     // worsened performance in #74376.
136     //
137     // Once const generics are more prevalently used, we might want to
138     // consider only caching calls returning `Some`.
139     query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
140         desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
141     }
142
143     /// Given the def_id of a const-generic parameter, computes the associated default const
144     /// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
145     query const_param_default(param: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
146         desc { |tcx| "computing const default for a given parameter `{}`", tcx.def_path_str(param)  }
147         cache_on_disk_if { param.is_local() }
148         separate_provide_extern
149     }
150
151     /// Returns the [`Ty`][rustc_middle::ty::Ty] of the given [`DefId`]. If the [`DefId`] points
152     /// to an alias, it will "skip" this alias to return the aliased type.
153     ///
154     /// [`DefId`]: rustc_hir::def_id::DefId
155     query type_of(key: DefId) -> Ty<'tcx> {
156         desc { |tcx|
157             "{action} `{path}`",
158             action = {
159                 use rustc_hir::def::DefKind;
160                 match tcx.def_kind(key) {
161                     DefKind::TyAlias => "expanding type alias",
162                     DefKind::TraitAlias => "expanding trait alias",
163                     _ => "computing type of",
164                 }
165             },
166             path = tcx.def_path_str(key),
167         }
168         cache_on_disk_if { key.is_local() }
169         separate_provide_extern
170     }
171
172     query collect_return_position_impl_trait_in_trait_tys(key: DefId)
173         -> Result<&'tcx FxHashMap<DefId, Ty<'tcx>>, ErrorGuaranteed>
174     {
175         desc { "comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process" }
176         cache_on_disk_if { key.is_local() }
177         separate_provide_extern
178     }
179
180     query is_type_alias_impl_trait(key: DefId) -> bool
181     {
182         desc { "determine whether the opaque is a type-alias impl trait" }
183         separate_provide_extern
184     }
185
186     query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32>
187     {
188         arena_cache
189         desc { |tcx|
190             "determining what parameters of `{}` can participate in unsizing",
191             tcx.def_path_str(key),
192         }
193     }
194
195     query analysis(key: ()) -> Result<(), ErrorGuaranteed> {
196         eval_always
197         desc { "running analysis passes on this crate" }
198     }
199
200     /// This query checks the fulfillment of collected lint expectations.
201     /// All lint emitting queries have to be done before this is executed
202     /// to ensure that all expectations can be fulfilled.
203     ///
204     /// This is an extra query to enable other drivers (like rustdoc) to
205     /// only execute a small subset of the `analysis` query, while allowing
206     /// lints to be expected. In rustc, this query will be executed as part of
207     /// the `analysis` query and doesn't have to be called a second time.
208     ///
209     /// Tools can additionally pass in a tool filter. That will restrict the
210     /// expectations to only trigger for lints starting with the listed tool
211     /// name. This is useful for cases were not all linting code from rustc
212     /// was called. With the default `None` all registered lints will also
213     /// be checked for expectation fulfillment.
214     query check_expectations(key: Option<Symbol>) -> () {
215         eval_always
216         desc { "checking lint expectations (RFC 2383)" }
217     }
218
219     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
220     /// associated generics.
221     query generics_of(key: DefId) -> &'tcx ty::Generics {
222         desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
223         arena_cache
224         cache_on_disk_if { key.is_local() }
225         separate_provide_extern
226     }
227
228     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
229     /// predicates (where-clauses) that must be proven true in order
230     /// to reference it. This is almost always the "predicates query"
231     /// that you want.
232     ///
233     /// `predicates_of` builds on `predicates_defined_on` -- in fact,
234     /// it is almost always the same as that query, except for the
235     /// case of traits. For traits, `predicates_of` contains
236     /// an additional `Self: Trait<...>` predicate that users don't
237     /// actually write. This reflects the fact that to invoke the
238     /// trait (e.g., via `Default::default`) you must supply types
239     /// that actually implement the trait. (However, this extra
240     /// predicate gets in the way of some checks, which are intended
241     /// to operate over only the actual where-clauses written by the
242     /// user.)
243     query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
244         desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
245         cache_on_disk_if { key.is_local() }
246     }
247
248     /// Returns the list of bounds that can be used for
249     /// `SelectionCandidate::ProjectionCandidate(_)` and
250     /// `ProjectionTyCandidate::TraitDef`.
251     /// Specifically this is the bounds written on the trait's type
252     /// definition, or those after the `impl` keyword
253     ///
254     /// ```ignore (incomplete)
255     /// type X: Bound + 'lt
256     /// //      ^^^^^^^^^^^
257     /// impl Debug + Display
258     /// //   ^^^^^^^^^^^^^^^
259     /// ```
260     ///
261     /// `key` is the `DefId` of the associated type or opaque type.
262     ///
263     /// Bounds from the parent (e.g. with nested impl trait) are not included.
264     query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
265         desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
266         cache_on_disk_if { key.is_local() }
267         separate_provide_extern
268     }
269
270     /// Elaborated version of the predicates from `explicit_item_bounds`.
271     ///
272     /// For example:
273     ///
274     /// ```
275     /// trait MyTrait {
276     ///     type MyAType: Eq + ?Sized;
277     /// }
278     /// ```
279     ///
280     /// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
281     /// and `item_bounds` returns
282     /// ```text
283     /// [
284     ///     <Self as Trait>::MyAType: Eq,
285     ///     <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
286     /// ]
287     /// ```
288     ///
289     /// Bounds from the parent (e.g. with nested impl trait) are not included.
290     query item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Predicate<'tcx>>> {
291         desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
292     }
293
294     /// Look up all native libraries this crate depends on.
295     /// These are assembled from the following places:
296     /// - `extern` blocks (depending on their `link` attributes)
297     /// - the `libs` (`-l`) option
298     query native_libraries(_: CrateNum) -> &'tcx Vec<NativeLib> {
299         arena_cache
300         desc { "looking up the native libraries of a linked crate" }
301         separate_provide_extern
302     }
303
304     query shallow_lint_levels_on(key: hir::OwnerId) -> &'tcx rustc_middle::lint::ShallowLintLevelMap {
305         eval_always // fetches `resolutions`
306         arena_cache
307         desc { |tcx| "looking up lint levels for `{}`", tcx.def_path_str(key.to_def_id()) }
308     }
309
310     query lint_expectations(_: ()) -> &'tcx Vec<(LintExpectationId, LintExpectation)> {
311         arena_cache
312         desc { "computing `#[expect]`ed lints in this crate" }
313     }
314
315     query parent_module_from_def_id(key: LocalDefId) -> LocalDefId {
316         eval_always
317         desc { |tcx| "getting the parent module of `{}`", tcx.def_path_str(key.to_def_id()) }
318     }
319
320     query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
321         desc { |tcx| "getting the expansion that defined `{}`", tcx.def_path_str(key) }
322         separate_provide_extern
323     }
324
325     query is_panic_runtime(_: CrateNum) -> bool {
326         fatal_cycle
327         desc { "checking if the crate is_panic_runtime" }
328         separate_provide_extern
329     }
330
331     /// Checks whether a type is representable or infinitely sized
332     query representability(_: LocalDefId) -> rustc_middle::ty::Representability {
333         desc { "checking if `{}` is representable", tcx.def_path_str(key.to_def_id()) }
334         // infinitely sized types will cause a cycle
335         cycle_delay_bug
336         // we don't want recursive representability calls to be forced with
337         // incremental compilation because, if a cycle occurs, we need the
338         // entire cycle to be in memory for diagnostics
339         anon
340     }
341
342     /// An implementation detail for the `representability` query
343     query representability_adt_ty(_: Ty<'tcx>) -> rustc_middle::ty::Representability {
344         desc { "checking if `{}` is representable", key }
345         cycle_delay_bug
346         anon
347     }
348
349     /// Set of param indexes for type params that are in the type's representation
350     query params_in_repr(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32> {
351         desc { "finding type parameters in the representation" }
352         arena_cache
353         no_hash
354         separate_provide_extern
355     }
356
357     /// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
358     query thir_body(key: ty::WithOptConstParam<LocalDefId>)
359         -> Result<(&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId), ErrorGuaranteed>
360     {
361         // Perf tests revealed that hashing THIR is inefficient (see #85729).
362         no_hash
363         desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
364     }
365
366     /// Create a THIR tree for debugging.
367     query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx String {
368         no_hash
369         arena_cache
370         desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
371     }
372
373     /// Create a list-like THIR representation for debugging.
374     query thir_flat(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx String {
375         no_hash
376         arena_cache
377         desc { |tcx| "constructing flat THIR representation for `{}`", tcx.def_path_str(key.did.to_def_id()) }
378     }
379
380     /// Set of all the `DefId`s in this crate that have MIR associated with
381     /// them. This includes all the body owners, but also things like struct
382     /// constructors.
383     query mir_keys(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexSet<LocalDefId> {
384         arena_cache
385         desc { "getting a list of all mir_keys" }
386     }
387
388     /// Maps DefId's that have an associated `mir::Body` to the result
389     /// of the MIR const-checking pass. This is the set of qualifs in
390     /// the final value of a `const`.
391     query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
392         desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
393         cache_on_disk_if { key.is_local() }
394         separate_provide_extern
395     }
396     query mir_const_qualif_const_arg(
397         key: (LocalDefId, DefId)
398     ) -> mir::ConstQualifs {
399         desc {
400             |tcx| "const checking the const argument `{}`",
401             tcx.def_path_str(key.0.to_def_id())
402         }
403     }
404
405     /// Fetch the MIR for a given `DefId` right after it's built - this includes
406     /// unreachable code.
407     query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
408         desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
409     }
410
411     /// Fetch the MIR for a given `DefId` up till the point where it is
412     /// ready for const qualification.
413     ///
414     /// See the README for the `mir` module for details.
415     query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
416         desc {
417             |tcx| "preparing {}`{}` for borrow checking",
418             if key.const_param_did.is_some() { "the const argument " } else { "" },
419             tcx.def_path_str(key.did.to_def_id()),
420         }
421         no_hash
422     }
423
424     /// Try to build an abstract representation of the given constant.
425     query thir_abstract_const(
426         key: DefId
427     ) -> Result<Option<ty::Const<'tcx>>, ErrorGuaranteed> {
428         desc {
429             |tcx| "building an abstract representation for `{}`", tcx.def_path_str(key),
430         }
431         separate_provide_extern
432     }
433     /// Try to build an abstract representation of the given constant.
434     query thir_abstract_const_of_const_arg(
435         key: (LocalDefId, DefId)
436     ) -> Result<Option<ty::Const<'tcx>>, ErrorGuaranteed> {
437         desc {
438             |tcx|
439             "building an abstract representation for the const argument `{}`",
440             tcx.def_path_str(key.0.to_def_id()),
441         }
442     }
443
444     query mir_drops_elaborated_and_const_checked(
445         key: ty::WithOptConstParam<LocalDefId>
446     ) -> &'tcx Steal<mir::Body<'tcx>> {
447         no_hash
448         desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
449     }
450
451     query mir_for_ctfe(
452         key: DefId
453     ) -> &'tcx mir::Body<'tcx> {
454         desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
455         cache_on_disk_if { key.is_local() }
456         separate_provide_extern
457     }
458
459     query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> {
460         desc {
461             |tcx| "caching MIR for CTFE of the const argument `{}`",
462             tcx.def_path_str(key.0.to_def_id())
463         }
464     }
465
466     query mir_promoted(key: ty::WithOptConstParam<LocalDefId>) ->
467         (
468             &'tcx Steal<mir::Body<'tcx>>,
469             &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
470         ) {
471         no_hash
472         desc {
473             |tcx| "processing MIR for {}`{}`",
474             if key.const_param_did.is_some() { "the const argument " } else { "" },
475             tcx.def_path_str(key.did.to_def_id()),
476         }
477     }
478
479     query symbols_for_closure_captures(
480         key: (LocalDefId, LocalDefId)
481     ) -> &'tcx Vec<rustc_span::Symbol> {
482         arena_cache
483         desc {
484             |tcx| "finding symbols for captures of closure `{}` in `{}`",
485             tcx.def_path_str(key.1.to_def_id()),
486             tcx.def_path_str(key.0.to_def_id())
487         }
488     }
489
490     query mir_generator_witnesses(key: DefId) -> &'tcx mir::GeneratorLayout<'tcx> {
491         arena_cache
492         desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) }
493         cache_on_disk_if { key.is_local() }
494         separate_provide_extern
495     }
496
497     query check_generator_obligations(key: LocalDefId) {
498         desc { |tcx| "verify auto trait bounds for generator interior type `{}`", tcx.def_path_str(key.to_def_id()) }
499     }
500
501     /// MIR after our optimization passes have run. This is MIR that is ready
502     /// for codegen. This is also the only query that can fetch non-local MIR, at present.
503     query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
504         desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
505         cache_on_disk_if { key.is_local() }
506         separate_provide_extern
507     }
508
509     /// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
510     /// MIR pass (assuming the -Cinstrument-coverage option is enabled).
511     query coverageinfo(key: ty::InstanceDef<'tcx>) -> &'tcx mir::CoverageInfo {
512         desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
513         arena_cache
514     }
515
516     /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
517     /// function was optimized out before codegen, and before being added to the Coverage Map.
518     query covered_code_regions(key: DefId) -> &'tcx Vec<&'tcx mir::coverage::CodeRegion> {
519         desc {
520             |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
521             tcx.def_path_str(key)
522         }
523         arena_cache
524         cache_on_disk_if { key.is_local() }
525     }
526
527     /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
528     /// `DefId`. This function returns all promoteds in the specified body. The body references
529     /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
530     /// after inlining a body may refer to promoteds from other bodies. In that case you still
531     /// need to use the `DefId` of the original body.
532     query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
533         desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
534         cache_on_disk_if { key.is_local() }
535         separate_provide_extern
536     }
537     query promoted_mir_of_const_arg(
538         key: (LocalDefId, DefId)
539     ) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
540         desc {
541             |tcx| "optimizing promoted MIR for the const argument `{}`",
542             tcx.def_path_str(key.0.to_def_id()),
543         }
544     }
545
546     /// Erases regions from `ty` to yield a new type.
547     /// Normally you would just use `tcx.erase_regions(value)`,
548     /// however, which uses this query as a kind of cache.
549     query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
550         // This query is not expected to have input -- as a result, it
551         // is not a good candidates for "replay" because it is essentially a
552         // pure function of its input (and hence the expectation is that
553         // no caller would be green **apart** from just these
554         // queries). Making it anonymous avoids hashing the result, which
555         // may save a bit of time.
556         anon
557         desc { "erasing regions from `{}`", ty }
558     }
559
560     query wasm_import_module_map(_: CrateNum) -> &'tcx FxHashMap<DefId, String> {
561         arena_cache
562         desc { "getting wasm import module map" }
563     }
564
565     /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
566     /// predicates (where-clauses) directly defined on it. This is
567     /// equal to the `explicit_predicates_of` predicates plus the
568     /// `inferred_outlives_of` predicates.
569     query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> {
570         desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
571     }
572
573     /// Returns everything that looks like a predicate written explicitly
574     /// by the user on a trait item.
575     ///
576     /// Traits are unusual, because predicates on associated types are
577     /// converted into bounds on that type for backwards compatibility:
578     ///
579     /// trait X where Self::U: Copy { type U; }
580     ///
581     /// becomes
582     ///
583     /// trait X { type U: Copy; }
584     ///
585     /// `explicit_predicates_of` and `explicit_item_bounds` will then take
586     /// the appropriate subsets of the predicates here.
587     query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
588         desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) }
589     }
590
591     /// Returns the predicates written explicitly by the user.
592     query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
593         desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
594         cache_on_disk_if { key.is_local() }
595         separate_provide_extern
596     }
597
598     /// Returns the inferred outlives predicates (e.g., for `struct
599     /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
600     query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Clause<'tcx>, Span)] {
601         desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) }
602         cache_on_disk_if { key.is_local() }
603         separate_provide_extern
604     }
605
606     /// Maps from the `DefId` of a trait to the list of
607     /// super-predicates. This is a subset of the full list of
608     /// predicates. We store these in a separate map because we must
609     /// evaluate them even during type conversion, often before the
610     /// full predicates are available (note that supertraits have
611     /// additional acyclicity requirements).
612     query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
613         desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
614         cache_on_disk_if { key.is_local() }
615         separate_provide_extern
616     }
617
618     /// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
619     /// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
620     /// subset of super-predicates that reference traits that define the given associated type.
621     /// This is used to avoid cycles in resolving types like `T::Item`.
622     query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
623         desc { |tcx| "computing the super traits of `{}`{}",
624             tcx.def_path_str(key.0),
625             if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
626         }
627     }
628
629     /// To avoid cycles within the predicates of a single item we compute
630     /// per-type-parameter predicates for resolving `T::AssocTy`.
631     query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
632         desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
633     }
634
635     query trait_def(key: DefId) -> &'tcx ty::TraitDef {
636         desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
637         arena_cache
638         cache_on_disk_if { key.is_local() }
639         separate_provide_extern
640     }
641     query adt_def(key: DefId) -> ty::AdtDef<'tcx> {
642         desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
643         cache_on_disk_if { key.is_local() }
644         separate_provide_extern
645     }
646     query adt_destructor(key: DefId) -> Option<ty::Destructor> {
647         desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
648         cache_on_disk_if { key.is_local() }
649         separate_provide_extern
650     }
651
652     query adt_sized_constraint(key: DefId) -> &'tcx [Ty<'tcx>] {
653         desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
654     }
655
656     query adt_dtorck_constraint(
657         key: DefId
658     ) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution> {
659         desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
660     }
661
662     /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
663     /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
664     /// not have the feature gate active).
665     ///
666     /// **Do not call this function manually.** It is only meant to cache the base data for the
667     /// `is_const_fn` function. Consider using `is_const_fn` or `is_const_fn_raw` instead.
668     query constness(key: DefId) -> hir::Constness {
669         desc { |tcx| "checking if item is const: `{}`", tcx.def_path_str(key) }
670         cache_on_disk_if { key.is_local() }
671         separate_provide_extern
672     }
673
674     query asyncness(key: DefId) -> hir::IsAsync {
675         desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
676         cache_on_disk_if { key.is_local() }
677         separate_provide_extern
678     }
679
680     /// Returns `true` if calls to the function may be promoted.
681     ///
682     /// This is either because the function is e.g., a tuple-struct or tuple-variant
683     /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
684     /// be removed in the future in favour of some form of check which figures out whether the
685     /// function does not inspect the bits of any of its arguments (so is essentially just a
686     /// constructor function).
687     query is_promotable_const_fn(key: DefId) -> bool {
688         desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
689     }
690
691     /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
692     query is_foreign_item(key: DefId) -> bool {
693         desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) }
694         cache_on_disk_if { key.is_local() }
695         separate_provide_extern
696     }
697
698     /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
699     query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
700         desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
701         cache_on_disk_if { def_id.is_local() }
702         separate_provide_extern
703     }
704
705     /// Gets a map with the variance of every item; use `item_variance` instead.
706     query crate_variances(_: ()) -> &'tcx ty::CrateVariancesMap<'tcx> {
707         arena_cache
708         desc { "computing the variances for items in this crate" }
709     }
710
711     /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
712     query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
713         desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
714         cache_on_disk_if { def_id.is_local() }
715         separate_provide_extern
716     }
717
718     /// Maps from thee `DefId` of a type to its (inferred) outlives.
719     query inferred_outlives_crate(_: ()) -> &'tcx ty::CratePredicatesMap<'tcx> {
720         arena_cache
721         desc { "computing the inferred outlives predicates for items in this crate" }
722     }
723
724     /// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
725     query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
726         desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
727         cache_on_disk_if { key.is_local() }
728         separate_provide_extern
729     }
730
731     /// Maps from a trait item to the trait item "descriptor".
732     query associated_item(key: DefId) -> &'tcx ty::AssocItem {
733         desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
734         arena_cache
735         cache_on_disk_if { key.is_local() }
736         separate_provide_extern
737     }
738
739     /// Collects the associated items defined on a trait or impl.
740     query associated_items(key: DefId) -> &'tcx ty::AssocItems<'tcx> {
741         arena_cache
742         desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
743     }
744
745     /// Maps from associated items on a trait to the corresponding associated
746     /// item on the impl specified by `impl_id`.
747     ///
748     /// For example, with the following code
749     ///
750     /// ```
751     /// struct Type {}
752     ///                         // DefId
753     /// trait Trait {           // trait_id
754     ///     fn f();             // trait_f
755     ///     fn g() {}           // trait_g
756     /// }
757     ///
758     /// impl Trait for Type {   // impl_id
759     ///     fn f() {}           // impl_f
760     ///     fn g() {}           // impl_g
761     /// }
762     /// ```
763     ///
764     /// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
765     ///`{ trait_f: impl_f, trait_g: impl_g }`
766     query impl_item_implementor_ids(impl_id: DefId) -> &'tcx FxHashMap<DefId, DefId> {
767         arena_cache
768         desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
769     }
770
771     /// Given an `impl_id`, return the trait it implements.
772     /// Return `None` if this is an inherent impl.
773     query impl_trait_ref(impl_id: DefId) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
774         desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
775         cache_on_disk_if { impl_id.is_local() }
776         separate_provide_extern
777     }
778     query impl_polarity(impl_id: DefId) -> ty::ImplPolarity {
779         desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) }
780         cache_on_disk_if { impl_id.is_local() }
781         separate_provide_extern
782     }
783
784     query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
785         desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
786     }
787
788     /// Maps a `DefId` of a type to a list of its inherent impls.
789     /// Contains implementations of methods that are inherent to a type.
790     /// Methods in these implementations don't need to be exported.
791     query inherent_impls(key: DefId) -> &'tcx [DefId] {
792         desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
793         cache_on_disk_if { key.is_local() }
794         separate_provide_extern
795     }
796
797     query incoherent_impls(key: SimplifiedType) -> &'tcx [DefId] {
798         desc { |tcx| "collecting all inherent impls for `{:?}`", key }
799     }
800
801     /// The result of unsafety-checking this `LocalDefId`.
802     query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
803         desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
804         cache_on_disk_if { true }
805     }
806     query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult {
807         desc {
808             |tcx| "unsafety-checking the const argument `{}`",
809             tcx.def_path_str(key.0.to_def_id())
810         }
811     }
812
813     /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
814     /// used with `-Zthir-unsafeck`.
815     query thir_check_unsafety(key: LocalDefId) {
816         desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
817         cache_on_disk_if { true }
818     }
819     query thir_check_unsafety_for_const_arg(key: (LocalDefId, DefId)) {
820         desc {
821             |tcx| "unsafety-checking the const argument `{}`",
822             tcx.def_path_str(key.0.to_def_id())
823         }
824     }
825
826     /// Returns the types assumed to be well formed while "inside" of the given item.
827     ///
828     /// Note that we've liberated the late bound regions of function signatures, so
829     /// this can not be used to check whether these types are well formed.
830     query assumed_wf_types(key: DefId) -> &'tcx ty::List<Ty<'tcx>> {
831         desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
832     }
833
834     /// Computes the signature of the function.
835     query fn_sig(key: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'tcx>> {
836         desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
837         cache_on_disk_if { key.is_local() }
838         separate_provide_extern
839         cycle_delay_bug
840     }
841
842     /// Performs lint checking for the module.
843     query lint_mod(key: LocalDefId) -> () {
844         desc { |tcx| "linting {}", describe_as_module(key, tcx) }
845     }
846
847     /// Checks the attributes in the module.
848     query check_mod_attrs(key: LocalDefId) -> () {
849         desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
850     }
851
852     /// Checks for uses of unstable APIs in the module.
853     query check_mod_unstable_api_usage(key: LocalDefId) -> () {
854         desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
855     }
856
857     /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
858     query check_mod_const_bodies(key: LocalDefId) -> () {
859         desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
860     }
861
862     /// Checks the loops in the module.
863     query check_mod_loops(key: LocalDefId) -> () {
864         desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
865     }
866
867     query check_mod_naked_functions(key: LocalDefId) -> () {
868         desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
869     }
870
871     query check_mod_item_types(key: LocalDefId) -> () {
872         desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
873     }
874
875     query check_mod_privacy(key: LocalDefId) -> () {
876         desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
877     }
878
879     query check_liveness(key: DefId) {
880         desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key) }
881     }
882
883     /// Return the live symbols in the crate for dead code check.
884     ///
885     /// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and
886     /// their respective impl (i.e., part of the derive macro)
887     query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
888         FxHashSet<LocalDefId>,
889         FxHashMap<LocalDefId, Vec<(DefId, DefId)>>
890     ) {
891         arena_cache
892         desc { "finding live symbols in crate" }
893     }
894
895     query check_mod_deathness(key: LocalDefId) -> () {
896         desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
897     }
898
899     query check_mod_impl_wf(key: LocalDefId) -> () {
900         desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
901     }
902
903     query check_mod_type_wf(key: LocalDefId) -> () {
904         desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
905     }
906
907     query collect_mod_item_types(key: LocalDefId) -> () {
908         desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
909     }
910
911     /// Caches `CoerceUnsized` kinds for impls on custom types.
912     query coerce_unsized_info(key: DefId) -> ty::adjustment::CoerceUnsizedInfo {
913         desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
914         cache_on_disk_if { key.is_local() }
915         separate_provide_extern
916     }
917
918     query typeck_item_bodies(_: ()) -> () {
919         desc { "type-checking all item bodies" }
920     }
921
922     query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
923         desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
924         cache_on_disk_if { true }
925     }
926     query typeck_const_arg(
927         key: (LocalDefId, DefId)
928     ) -> &'tcx ty::TypeckResults<'tcx> {
929         desc {
930             |tcx| "type-checking the const argument `{}`",
931             tcx.def_path_str(key.0.to_def_id()),
932         }
933     }
934     query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
935         desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
936         cache_on_disk_if { true }
937     }
938
939     query used_trait_imports(key: LocalDefId) -> &'tcx UnordSet<LocalDefId> {
940         desc { |tcx| "finding used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) }
941         cache_on_disk_if { true }
942     }
943
944     query has_typeck_results(def_id: DefId) -> bool {
945         desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
946     }
947
948     query coherent_trait(def_id: DefId) -> () {
949         desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
950     }
951
952     /// Borrow-checks the function body. If this is a closure, returns
953     /// additional requirements that the closure's creator must verify.
954     query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
955         desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
956         cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
957     }
958     query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> {
959         desc {
960             |tcx| "borrow-checking the const argument`{}`",
961             tcx.def_path_str(key.0.to_def_id())
962         }
963     }
964
965     /// Gets a complete map from all types to their inherent impls.
966     /// Not meant to be used directly outside of coherence.
967     query crate_inherent_impls(k: ()) -> &'tcx CrateInherentImpls {
968         arena_cache
969         desc { "finding all inherent impls defined in crate" }
970     }
971
972     /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
973     /// Not meant to be used directly outside of coherence.
974     query crate_inherent_impls_overlap_check(_: ()) -> () {
975         desc { "check for overlap between inherent impls defined in this crate" }
976     }
977
978     /// Checks whether all impls in the crate pass the overlap check, returning
979     /// which impls fail it. If all impls are correct, the returned slice is empty.
980     query orphan_check_impl(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
981         desc { |tcx|
982             "checking whether impl `{}` follows the orphan rules",
983             tcx.def_path_str(key.to_def_id()),
984         }
985     }
986
987     /// Check whether the function has any recursion that could cause the inliner to trigger
988     /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
989     /// current function, just all intermediate functions.
990     query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
991         fatal_cycle
992         desc { |tcx|
993             "computing if `{}` (transitively) calls `{}`",
994             key.0,
995             tcx.def_path_str(key.1.to_def_id()),
996         }
997     }
998
999     /// Obtain all the calls into other local functions
1000     query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] {
1001         fatal_cycle
1002         desc { |tcx|
1003             "computing all local function calls in `{}`",
1004             tcx.def_path_str(key.def_id()),
1005         }
1006     }
1007
1008     /// Evaluates a constant and returns the computed allocation.
1009     ///
1010     /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
1011     query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
1012         -> EvalToAllocationRawResult<'tcx> {
1013         desc { |tcx|
1014             "const-evaluating + checking `{}`",
1015             key.value.display(tcx)
1016         }
1017         cache_on_disk_if { true }
1018     }
1019
1020     /// Evaluates const items or anonymous constants
1021     /// (such as enum variant explicit discriminants or array lengths)
1022     /// into a representation suitable for the type system and const generics.
1023     ///
1024     /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
1025     /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
1026     query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
1027         -> EvalToConstValueResult<'tcx> {
1028         desc { |tcx|
1029             "simplifying constant for the type system `{}`",
1030             key.value.display(tcx)
1031         }
1032         cache_on_disk_if { true }
1033     }
1034
1035     /// Evaluate a constant and convert it to a type level constant or
1036     /// return `None` if that is not possible.
1037     query eval_to_valtree(
1038         key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>
1039     ) -> EvalToValTreeResult<'tcx> {
1040         desc { "evaluating type-level constant" }
1041     }
1042
1043     /// Converts a type level constant value into `ConstValue`
1044     query valtree_to_const_val(key: (Ty<'tcx>, ty::ValTree<'tcx>)) -> ConstValue<'tcx> {
1045         desc { "converting type-level constant value to mir constant value"}
1046     }
1047
1048     /// Destructures array, ADT or tuple constants into the constants
1049     /// of their fields.
1050     query destructure_const(key: ty::Const<'tcx>) -> ty::DestructuredConst<'tcx> {
1051         desc { "destructuring type level constant"}
1052     }
1053
1054     /// Tries to destructure an `mir::ConstantKind` ADT or array into its variant index
1055     /// and its field values.
1056     query try_destructure_mir_constant(
1057         key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1058     ) -> Option<mir::DestructuredConstant<'tcx>> {
1059         desc { "destructuring MIR constant"}
1060         remap_env_constness
1061     }
1062
1063     /// Dereference a constant reference or raw pointer and turn the result into a constant
1064     /// again.
1065     query deref_mir_constant(
1066         key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1067     ) -> mir::ConstantKind<'tcx> {
1068         desc { "dereferencing MIR constant" }
1069         remap_env_constness
1070     }
1071
1072     query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
1073         desc { "getting a &core::panic::Location referring to a span" }
1074     }
1075
1076     // FIXME get rid of this with valtrees
1077     query lit_to_const(
1078         key: LitToConstInput<'tcx>
1079     ) -> Result<ty::Const<'tcx>, LitToConstError> {
1080         desc { "converting literal to const" }
1081     }
1082
1083     query lit_to_mir_constant(key: LitToConstInput<'tcx>) -> Result<mir::ConstantKind<'tcx>, LitToConstError> {
1084         desc { "converting literal to mir constant" }
1085     }
1086
1087     query check_match(key: DefId) {
1088         desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
1089         cache_on_disk_if { key.is_local() }
1090     }
1091
1092     /// Performs part of the privacy check and computes effective visibilities.
1093     query effective_visibilities(_: ()) -> &'tcx EffectiveVisibilities {
1094         eval_always
1095         desc { "checking effective visibilities" }
1096     }
1097     query check_private_in_public(_: ()) -> () {
1098         eval_always
1099         desc { "checking for private elements in public interfaces" }
1100     }
1101
1102     query reachable_set(_: ()) -> &'tcx FxHashSet<LocalDefId> {
1103         arena_cache
1104         desc { "reachability" }
1105     }
1106
1107     /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
1108     /// in the case of closures, this will be redirected to the enclosing function.
1109     query region_scope_tree(def_id: DefId) -> &'tcx crate::middle::region::ScopeTree {
1110         desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
1111     }
1112
1113     /// Generates a MIR body for the shim.
1114     query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
1115         arena_cache
1116         desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
1117     }
1118
1119     /// The `symbol_name` query provides the symbol name for calling a
1120     /// given instance from the local crate. In particular, it will also
1121     /// look up the correct symbol name of instances from upstream crates.
1122     query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
1123         desc { "computing the symbol for `{}`", key }
1124         cache_on_disk_if { true }
1125     }
1126
1127     query opt_def_kind(def_id: DefId) -> Option<DefKind> {
1128         desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
1129         cache_on_disk_if { def_id.is_local() }
1130         separate_provide_extern
1131     }
1132
1133     /// Gets the span for the definition.
1134     query def_span(def_id: DefId) -> Span {
1135         desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
1136         cache_on_disk_if { def_id.is_local() }
1137         separate_provide_extern
1138         feedable
1139     }
1140
1141     /// Gets the span for the identifier of the definition.
1142     query def_ident_span(def_id: DefId) -> Option<Span> {
1143         desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
1144         cache_on_disk_if { def_id.is_local() }
1145         separate_provide_extern
1146     }
1147
1148     query lookup_stability(def_id: DefId) -> Option<attr::Stability> {
1149         desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
1150         cache_on_disk_if { def_id.is_local() }
1151         separate_provide_extern
1152     }
1153
1154     query lookup_const_stability(def_id: DefId) -> Option<attr::ConstStability> {
1155         desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
1156         cache_on_disk_if { def_id.is_local() }
1157         separate_provide_extern
1158     }
1159
1160     query lookup_default_body_stability(def_id: DefId) -> Option<attr::DefaultBodyStability> {
1161         desc { |tcx| "looking up default body stability of `{}`", tcx.def_path_str(def_id) }
1162         separate_provide_extern
1163     }
1164
1165     query should_inherit_track_caller(def_id: DefId) -> bool {
1166         desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
1167     }
1168
1169     query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
1170         desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
1171         cache_on_disk_if { def_id.is_local() }
1172         separate_provide_extern
1173     }
1174
1175     /// Determines whether an item is annotated with `doc(hidden)`.
1176     query is_doc_hidden(def_id: DefId) -> bool {
1177         desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) }
1178         separate_provide_extern
1179     }
1180
1181     /// Determines whether an item is annotated with `doc(notable_trait)`.
1182     query is_doc_notable_trait(def_id: DefId) -> bool {
1183         desc { |tcx| "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) }
1184     }
1185
1186     /// Returns the attributes on the item at `def_id`.
1187     ///
1188     /// Do not use this directly, use `tcx.get_attrs` instead.
1189     query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
1190         desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
1191         separate_provide_extern
1192     }
1193
1194     query codegen_fn_attrs(def_id: DefId) -> &'tcx CodegenFnAttrs {
1195         desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
1196         arena_cache
1197         cache_on_disk_if { def_id.is_local() }
1198         separate_provide_extern
1199     }
1200
1201     query asm_target_features(def_id: DefId) -> &'tcx FxHashSet<Symbol> {
1202         desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
1203     }
1204
1205     query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
1206         desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
1207         cache_on_disk_if { def_id.is_local() }
1208         separate_provide_extern
1209     }
1210     /// Gets the rendered value of the specified constant or associated constant.
1211     /// Used by rustdoc.
1212     query rendered_const(def_id: DefId) -> &'tcx String {
1213         arena_cache
1214         desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) }
1215         cache_on_disk_if { def_id.is_local() }
1216         separate_provide_extern
1217     }
1218     query impl_parent(def_id: DefId) -> Option<DefId> {
1219         desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
1220         cache_on_disk_if { def_id.is_local() }
1221         separate_provide_extern
1222     }
1223
1224     query is_ctfe_mir_available(key: DefId) -> bool {
1225         desc { |tcx| "checking if item has CTFE MIR available: `{}`", tcx.def_path_str(key) }
1226         cache_on_disk_if { key.is_local() }
1227         separate_provide_extern
1228     }
1229     query is_mir_available(key: DefId) -> bool {
1230         desc { |tcx| "checking if item has MIR available: `{}`", tcx.def_path_str(key) }
1231         cache_on_disk_if { key.is_local() }
1232         separate_provide_extern
1233     }
1234
1235     query own_existential_vtable_entries(
1236         key: DefId
1237     ) -> &'tcx [DefId] {
1238         desc { |tcx| "finding all existential vtable entries for trait `{}`", tcx.def_path_str(key) }
1239     }
1240
1241     query vtable_entries(key: ty::PolyTraitRef<'tcx>)
1242                         -> &'tcx [ty::VtblEntry<'tcx>] {
1243         desc { |tcx| "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id()) }
1244     }
1245
1246     query vtable_trait_upcasting_coercion_new_vptr_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize> {
1247         desc { |tcx| "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable",
1248             key.1, key.0 }
1249     }
1250
1251     query vtable_allocation(key: (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
1252         desc { |tcx| "vtable const allocation for <{} as {}>",
1253             key.0,
1254             key.1.map(|trait_ref| format!("{}", trait_ref)).unwrap_or("_".to_owned())
1255         }
1256     }
1257
1258     query codegen_select_candidate(
1259         key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
1260     ) -> Result<&'tcx ImplSource<'tcx, ()>, traits::CodegenObligationError> {
1261         cache_on_disk_if { true }
1262         desc { |tcx| "computing candidate for `{}`", key.1 }
1263     }
1264
1265     /// Return all `impl` blocks in the current crate.
1266     query all_local_trait_impls(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexMap<DefId, Vec<LocalDefId>> {
1267         desc { "finding local trait impls" }
1268     }
1269
1270     /// Given a trait `trait_id`, return all known `impl` blocks.
1271     query trait_impls_of(trait_id: DefId) -> &'tcx ty::trait_def::TraitImpls {
1272         arena_cache
1273         desc { |tcx| "finding trait impls of `{}`", tcx.def_path_str(trait_id) }
1274     }
1275
1276     query specialization_graph_of(trait_id: DefId) -> &'tcx specialization_graph::Graph {
1277         arena_cache
1278         desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
1279         cache_on_disk_if { true }
1280     }
1281     query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
1282         desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) }
1283     }
1284     query check_is_object_safe(trait_id: DefId) -> bool {
1285         desc { |tcx| "checking if trait `{}` is object safe", tcx.def_path_str(trait_id) }
1286     }
1287
1288     /// Gets the ParameterEnvironment for a given item; this environment
1289     /// will be in "user-facing" mode, meaning that it is suitable for
1290     /// type-checking etc, and it does not normalize specializable
1291     /// associated types. This is almost always what you want,
1292     /// unless you are doing MIR optimizations, in which case you
1293     /// might want to use `reveal_all()` method to change modes.
1294     query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
1295         desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1296     }
1297
1298     /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
1299     /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
1300     /// as this method is more efficient.
1301     query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
1302         desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
1303     }
1304
1305     /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1306     /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1307     query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1308         desc { "computing whether `{}` is `Copy`", env.value }
1309         remap_env_constness
1310     }
1311     /// Query backing `Ty::is_sized`.
1312     query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1313         desc { "computing whether `{}` is `Sized`", env.value }
1314         remap_env_constness
1315     }
1316     /// Query backing `Ty::is_freeze`.
1317     query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1318         desc { "computing whether `{}` is freeze", env.value }
1319         remap_env_constness
1320     }
1321     /// Query backing `Ty::is_unpin`.
1322     query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1323         desc { "computing whether `{}` is `Unpin`", env.value }
1324         remap_env_constness
1325     }
1326     /// Query backing `Ty::needs_drop`.
1327     query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1328         desc { "computing whether `{}` needs drop", env.value }
1329         remap_env_constness
1330     }
1331     /// Query backing `Ty::has_significant_drop_raw`.
1332     query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1333         desc { "computing whether `{}` has a significant drop", env.value }
1334         remap_env_constness
1335     }
1336
1337     /// Query backing `Ty::is_structural_eq_shallow`.
1338     ///
1339     /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1340     /// correctly.
1341     query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1342         desc {
1343             "computing whether `{}` implements `PartialStructuralEq` and `StructuralEq`",
1344             ty
1345         }
1346     }
1347
1348     /// A list of types where the ADT requires drop if and only if any of
1349     /// those types require drop. If the ADT is known to always need drop
1350     /// then `Err(AlwaysRequiresDrop)` is returned.
1351     query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1352         desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1353         cache_on_disk_if { true }
1354     }
1355
1356     /// A list of types where the ADT requires drop if and only if any of those types
1357     /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1358     /// is considered to not be significant. A drop is significant if it is implemented
1359     /// by the user or does anything that will have any observable behavior (other than
1360     /// freeing up memory). If the ADT is known to have a significant destructor then
1361     /// `Err(AlwaysRequiresDrop)` is returned.
1362     query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1363         desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1364         cache_on_disk_if { false }
1365     }
1366
1367     /// Computes the layout of a type. Note that this implicitly
1368     /// executes in "reveal all" mode, and will normalize the input type.
1369     query layout_of(
1370         key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1371     ) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
1372         depth_limit
1373         desc { "computing layout of `{}`", key.value }
1374         remap_env_constness
1375     }
1376
1377     /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1378     ///
1379     /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1380     /// instead, where the instance is an `InstanceDef::Virtual`.
1381     query fn_abi_of_fn_ptr(
1382         key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1383     ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1384         desc { "computing call ABI of `{}` function pointers", key.value.0 }
1385         remap_env_constness
1386     }
1387
1388     /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1389     /// direct calls to an `fn`.
1390     ///
1391     /// NB: that includes virtual calls, which are represented by "direct calls"
1392     /// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1393     query fn_abi_of_instance(
1394         key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1395     ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1396         desc { "computing call ABI of `{}`", key.value.0 }
1397         remap_env_constness
1398     }
1399
1400     query dylib_dependency_formats(_: CrateNum)
1401                                     -> &'tcx [(CrateNum, LinkagePreference)] {
1402         desc { "getting dylib dependency formats of crate" }
1403         separate_provide_extern
1404     }
1405
1406     query dependency_formats(_: ()) -> &'tcx Lrc<crate::middle::dependency_format::Dependencies> {
1407         arena_cache
1408         desc { "getting the linkage format of all dependencies" }
1409     }
1410
1411     query is_compiler_builtins(_: CrateNum) -> bool {
1412         fatal_cycle
1413         desc { "checking if the crate is_compiler_builtins" }
1414         separate_provide_extern
1415     }
1416     query has_global_allocator(_: CrateNum) -> bool {
1417         // This query depends on untracked global state in CStore
1418         eval_always
1419         fatal_cycle
1420         desc { "checking if the crate has_global_allocator" }
1421         separate_provide_extern
1422     }
1423     query has_alloc_error_handler(_: CrateNum) -> bool {
1424         // This query depends on untracked global state in CStore
1425         eval_always
1426         fatal_cycle
1427         desc { "checking if the crate has_alloc_error_handler" }
1428         separate_provide_extern
1429     }
1430     query has_panic_handler(_: CrateNum) -> bool {
1431         fatal_cycle
1432         desc { "checking if the crate has_panic_handler" }
1433         separate_provide_extern
1434     }
1435     query is_profiler_runtime(_: CrateNum) -> bool {
1436         fatal_cycle
1437         desc { "checking if a crate is `#![profiler_runtime]`" }
1438         separate_provide_extern
1439     }
1440     query has_ffi_unwind_calls(key: LocalDefId) -> bool {
1441         desc { |tcx| "checking if `{}` contains FFI-unwind calls", tcx.def_path_str(key.to_def_id()) }
1442         cache_on_disk_if { true }
1443     }
1444     query required_panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
1445         fatal_cycle
1446         desc { "getting a crate's required panic strategy" }
1447         separate_provide_extern
1448     }
1449     query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1450         fatal_cycle
1451         desc { "getting a crate's configured panic-in-drop strategy" }
1452         separate_provide_extern
1453     }
1454     query is_no_builtins(_: CrateNum) -> bool {
1455         fatal_cycle
1456         desc { "getting whether a crate has `#![no_builtins]`" }
1457         separate_provide_extern
1458     }
1459     query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1460         fatal_cycle
1461         desc { "getting a crate's symbol mangling version" }
1462         separate_provide_extern
1463     }
1464
1465     query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1466         eval_always
1467         desc { "getting crate's ExternCrateData" }
1468         separate_provide_extern
1469     }
1470
1471     query specializes(_: (DefId, DefId)) -> bool {
1472         desc { "computing whether impls specialize one another" }
1473     }
1474     query in_scope_traits_map(_: hir::OwnerId)
1475         -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
1476         desc { "getting traits in scope at a block" }
1477     }
1478
1479     query module_reexports(def_id: LocalDefId) -> Option<&'tcx [ModChild]> {
1480         desc { |tcx| "looking up reexports of module `{}`", tcx.def_path_str(def_id.to_def_id()) }
1481     }
1482
1483     query impl_defaultness(def_id: DefId) -> hir::Defaultness {
1484         desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
1485         cache_on_disk_if { def_id.is_local() }
1486         separate_provide_extern
1487     }
1488
1489     query check_well_formed(key: hir::OwnerId) -> () {
1490         desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1491     }
1492
1493     // The `DefId`s of all non-generic functions and statics in the given crate
1494     // that can be reached from outside the crate.
1495     //
1496     // We expect this items to be available for being linked to.
1497     //
1498     // This query can also be called for `LOCAL_CRATE`. In this case it will
1499     // compute which items will be reachable to other crates, taking into account
1500     // the kind of crate that is currently compiled. Crates with only a
1501     // C interface have fewer reachable things.
1502     //
1503     // Does not include external symbols that don't have a corresponding DefId,
1504     // like the compiler-generated `main` function and so on.
1505     query reachable_non_generics(_: CrateNum)
1506         -> &'tcx DefIdMap<SymbolExportInfo> {
1507         arena_cache
1508         desc { "looking up the exported symbols of a crate" }
1509         separate_provide_extern
1510     }
1511     query is_reachable_non_generic(def_id: DefId) -> bool {
1512         desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1513         cache_on_disk_if { def_id.is_local() }
1514         separate_provide_extern
1515     }
1516     query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1517         desc { |tcx|
1518             "checking whether `{}` is reachable from outside the crate",
1519             tcx.def_path_str(def_id.to_def_id()),
1520         }
1521     }
1522
1523     /// The entire set of monomorphizations the local crate can safely link
1524     /// to because they are exported from upstream crates. Do not depend on
1525     /// this directly, as its value changes anytime a monomorphization gets
1526     /// added or removed in any upstream crate. Instead use the narrower
1527     /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1528     /// better, `Instance::upstream_monomorphization()`.
1529     query upstream_monomorphizations(_: ()) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1530         arena_cache
1531         desc { "collecting available upstream monomorphizations" }
1532     }
1533
1534     /// Returns the set of upstream monomorphizations available for the
1535     /// generic function identified by the given `def_id`. The query makes
1536     /// sure to make a stable selection if the same monomorphization is
1537     /// available in multiple upstream crates.
1538     ///
1539     /// You likely want to call `Instance::upstream_monomorphization()`
1540     /// instead of invoking this query directly.
1541     query upstream_monomorphizations_for(def_id: DefId)
1542         -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
1543     {
1544         desc { |tcx|
1545             "collecting available upstream monomorphizations for `{}`",
1546             tcx.def_path_str(def_id),
1547         }
1548         separate_provide_extern
1549     }
1550
1551     /// Returns the upstream crate that exports drop-glue for the given
1552     /// type (`substs` is expected to be a single-item list containing the
1553     /// type one wants drop-glue for).
1554     ///
1555     /// This is a subset of `upstream_monomorphizations_for` in order to
1556     /// increase dep-tracking granularity. Otherwise adding or removing any
1557     /// type with drop-glue in any upstream crate would invalidate all
1558     /// functions calling drop-glue of an upstream type.
1559     ///
1560     /// You likely want to call `Instance::upstream_monomorphization()`
1561     /// instead of invoking this query directly.
1562     ///
1563     /// NOTE: This query could easily be extended to also support other
1564     ///       common functions that have are large set of monomorphizations
1565     ///       (like `Clone::clone` for example).
1566     query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1567         desc { "available upstream drop-glue for `{:?}`", substs }
1568     }
1569
1570     /// Returns a list of all `extern` blocks of a crate.
1571     query foreign_modules(_: CrateNum) -> &'tcx FxHashMap<DefId, ForeignModule> {
1572         arena_cache
1573         desc { "looking up the foreign modules of a linked crate" }
1574         separate_provide_extern
1575     }
1576
1577     /// Identifies the entry-point (e.g., the `main` function) for a given
1578     /// crate, returning `None` if there is no entry point (such as for library crates).
1579     query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
1580         desc { "looking up the entry function of a crate" }
1581     }
1582
1583     /// Finds the `rustc_proc_macro_decls` item of a crate.
1584     query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1585         desc { "looking up the proc macro declarations for a crate" }
1586     }
1587
1588     // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1589     // Changing the name should cause a compiler error, but in case that changes, be aware.
1590     query crate_hash(_: CrateNum) -> Svh {
1591         eval_always
1592         desc { "looking up the hash a crate" }
1593         separate_provide_extern
1594     }
1595
1596     /// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
1597     query crate_host_hash(_: CrateNum) -> Option<Svh> {
1598         eval_always
1599         desc { "looking up the hash of a host version of a crate" }
1600         separate_provide_extern
1601     }
1602
1603     /// Gets the extra data to put in each output filename for a crate.
1604     /// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
1605     query extra_filename(_: CrateNum) -> &'tcx String {
1606         arena_cache
1607         eval_always
1608         desc { "looking up the extra filename for a crate" }
1609         separate_provide_extern
1610     }
1611
1612     /// Gets the paths where the crate came from in the file system.
1613     query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
1614         arena_cache
1615         eval_always
1616         desc { "looking up the paths for extern crates" }
1617         separate_provide_extern
1618     }
1619
1620     /// Given a crate and a trait, look up all impls of that trait in the crate.
1621     /// Return `(impl_id, self_ty)`.
1622     query implementations_of_trait(_: (CrateNum, DefId)) -> &'tcx [(DefId, Option<SimplifiedType>)] {
1623         desc { "looking up implementations of a trait in a crate" }
1624         separate_provide_extern
1625     }
1626
1627     /// Collects all incoherent impls for the given crate and type.
1628     ///
1629     /// Do not call this directly, but instead use the `incoherent_impls` query.
1630     /// This query is only used to get the data necessary for that query.
1631     query crate_incoherent_impls(key: (CrateNum, SimplifiedType)) -> &'tcx [DefId] {
1632         desc { |tcx| "collecting all impls for a type in a crate" }
1633         separate_provide_extern
1634     }
1635
1636     /// Get the corresponding native library from the `native_libraries` query
1637     query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
1638         desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
1639     }
1640
1641     /// Does lifetime resolution on items. Importantly, we can't resolve
1642     /// lifetimes directly on things like trait methods, because of trait params.
1643     /// See `rustc_resolve::late::lifetimes for details.
1644     query resolve_lifetimes(_: hir::OwnerId) -> &'tcx ResolveLifetimes {
1645         arena_cache
1646         desc { "resolving lifetimes" }
1647     }
1648     query named_region_map(_: hir::OwnerId) ->
1649         Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1650         desc { "looking up a named region" }
1651     }
1652     query is_late_bound_map(_: hir::OwnerId) -> Option<&'tcx FxIndexSet<ItemLocalId>> {
1653         desc { "testing if a region is late bound" }
1654     }
1655     /// For a given item's generic parameter, gets the default lifetimes to be used
1656     /// for each parameter if a trait object were to be passed for that parameter.
1657     /// For example, for `T` in `struct Foo<'a, T>`, this would be `'static`.
1658     /// For `T` in `struct Foo<'a, T: 'a>`, this would instead be `'a`.
1659     /// This query will panic if passed something that is not a type parameter.
1660     query object_lifetime_default(key: DefId) -> ObjectLifetimeDefault {
1661         desc { "looking up lifetime defaults for generic parameter `{}`", tcx.def_path_str(key) }
1662         separate_provide_extern
1663     }
1664     query late_bound_vars_map(_: hir::OwnerId)
1665         -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1666         desc { "looking up late bound vars" }
1667     }
1668
1669     /// Computes the visibility of the provided `def_id`.
1670     ///
1671     /// If the item from the `def_id` doesn't have a visibility, it will panic. For example
1672     /// a generic type parameter will panic if you call this method on it:
1673     ///
1674     /// ```
1675     /// use std::fmt::Debug;
1676     ///
1677     /// pub trait Foo<T: Debug> {}
1678     /// ```
1679     ///
1680     /// In here, if you call `visibility` on `T`, it'll panic.
1681     query visibility(def_id: DefId) -> ty::Visibility<DefId> {
1682         desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
1683         separate_provide_extern
1684     }
1685
1686     query inhabited_predicate_adt(key: DefId) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
1687         desc { "computing the uninhabited predicate of `{:?}`", key }
1688     }
1689
1690     /// Do not call this query directly: invoke `Ty::inhabited_predicate` instead.
1691     query inhabited_predicate_type(key: Ty<'tcx>) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
1692         desc { "computing the uninhabited predicate of `{}`", key }
1693     }
1694
1695     query dep_kind(_: CrateNum) -> CrateDepKind {
1696         eval_always
1697         desc { "fetching what a dependency looks like" }
1698         separate_provide_extern
1699     }
1700
1701     /// Gets the name of the crate.
1702     query crate_name(_: CrateNum) -> Symbol {
1703         feedable
1704         desc { "fetching what a crate is named" }
1705         separate_provide_extern
1706     }
1707     query module_children(def_id: DefId) -> &'tcx [ModChild] {
1708         desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) }
1709         separate_provide_extern
1710     }
1711     query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
1712         desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1713     }
1714
1715     query lib_features(_: ()) -> &'tcx LibFeatures {
1716         arena_cache
1717         desc { "calculating the lib features map" }
1718     }
1719     query defined_lib_features(_: CrateNum) -> &'tcx [(Symbol, Option<Symbol>)] {
1720         desc { "calculating the lib features defined in a crate" }
1721         separate_provide_extern
1722     }
1723     query stability_implications(_: CrateNum) -> &'tcx FxHashMap<Symbol, Symbol> {
1724         arena_cache
1725         desc { "calculating the implications between `#[unstable]` features defined in a crate" }
1726         separate_provide_extern
1727     }
1728     /// Whether the function is an intrinsic
1729     query is_intrinsic(def_id: DefId) -> bool {
1730         desc { |tcx| "checking whether `{}` is an intrinsic", tcx.def_path_str(def_id) }
1731         separate_provide_extern
1732     }
1733     /// Returns the lang items defined in another crate by loading it from metadata.
1734     query get_lang_items(_: ()) -> &'tcx LanguageItems {
1735         arena_cache
1736         eval_always
1737         desc { "calculating the lang items map" }
1738     }
1739
1740     /// Returns all diagnostic items defined in all crates.
1741     query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
1742         arena_cache
1743         eval_always
1744         desc { "calculating the diagnostic items map" }
1745     }
1746
1747     /// Returns the lang items defined in another crate by loading it from metadata.
1748     query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, LangItem)] {
1749         desc { "calculating the lang items defined in a crate" }
1750         separate_provide_extern
1751     }
1752
1753     /// Returns the diagnostic items defined in a crate.
1754     query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
1755         arena_cache
1756         desc { "calculating the diagnostic items map in a crate" }
1757         separate_provide_extern
1758     }
1759
1760     query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1761         desc { "calculating the missing lang items in a crate" }
1762         separate_provide_extern
1763     }
1764     query visible_parent_map(_: ()) -> &'tcx DefIdMap<DefId> {
1765         arena_cache
1766         desc { "calculating the visible parent map" }
1767     }
1768     query trimmed_def_paths(_: ()) -> &'tcx FxHashMap<DefId, Symbol> {
1769         arena_cache
1770         desc { "calculating trimmed def paths" }
1771     }
1772     query missing_extern_crate_item(_: CrateNum) -> bool {
1773         eval_always
1774         desc { "seeing if we're missing an `extern crate` item for this crate" }
1775         separate_provide_extern
1776     }
1777     query used_crate_source(_: CrateNum) -> &'tcx Lrc<CrateSource> {
1778         arena_cache
1779         eval_always
1780         desc { "looking at the source for a crate" }
1781         separate_provide_extern
1782     }
1783     /// Returns the debugger visualizers defined for this crate.
1784     query debugger_visualizers(_: CrateNum) -> &'tcx Vec<rustc_span::DebuggerVisualizerFile> {
1785         arena_cache
1786         desc { "looking up the debugger visualizers for this crate" }
1787         separate_provide_extern
1788     }
1789     query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
1790         eval_always
1791         desc { "generating a postorder list of CrateNums" }
1792     }
1793     /// Returns whether or not the crate with CrateNum 'cnum'
1794     /// is marked as a private dependency
1795     query is_private_dep(c: CrateNum) -> bool {
1796         eval_always
1797         desc { "checking whether crate `{}` is a private dependency", c }
1798         separate_provide_extern
1799     }
1800     query allocator_kind(_: ()) -> Option<AllocatorKind> {
1801         eval_always
1802         desc { "getting the allocator kind for the current crate" }
1803     }
1804     query alloc_error_handler_kind(_: ()) -> Option<AllocatorKind> {
1805         eval_always
1806         desc { "alloc error handler kind for the current crate" }
1807     }
1808
1809     query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1810         desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
1811     }
1812     query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
1813         desc { "fetching potentially unused trait imports" }
1814     }
1815     query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] {
1816         desc { "looking up all possibly unused extern crates" }
1817     }
1818     query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet<Symbol> {
1819         desc { |tcx| "finding names imported by glob use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1820     }
1821
1822     query stability_index(_: ()) -> &'tcx stability::Index {
1823         arena_cache
1824         eval_always
1825         desc { "calculating the stability index for the local crate" }
1826     }
1827     query crates(_: ()) -> &'tcx [CrateNum] {
1828         eval_always
1829         desc { "fetching all foreign CrateNum instances" }
1830     }
1831
1832     /// A list of all traits in a crate, used by rustdoc and error reporting.
1833     /// NOTE: Not named just `traits` due to a naming conflict.
1834     query traits_in_crate(_: CrateNum) -> &'tcx [DefId] {
1835         desc { "fetching all traits in a crate" }
1836         separate_provide_extern
1837     }
1838
1839     /// The list of symbols exported from the given crate.
1840     ///
1841     /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1842     ///   correspond to a publicly visible symbol in `cnum` machine code.
1843     /// - The `exported_symbols` sets of different crates do not intersect.
1844     query exported_symbols(cnum: CrateNum) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
1845         desc { "collecting exported symbols for crate `{}`", cnum}
1846         cache_on_disk_if { *cnum == LOCAL_CRATE }
1847         separate_provide_extern
1848     }
1849
1850     query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1851         eval_always
1852         desc { "collect_and_partition_mono_items" }
1853     }
1854
1855     query is_codegened_item(def_id: DefId) -> bool {
1856         desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
1857     }
1858
1859     /// All items participating in code generation together with items inlined into them.
1860     query codegened_and_inlined_items(_: ()) -> &'tcx DefIdSet {
1861         eval_always
1862         desc { "collecting codegened and inlined items" }
1863     }
1864
1865     query codegen_unit(sym: Symbol) -> &'tcx CodegenUnit<'tcx> {
1866         desc { "getting codegen unit `{sym}`" }
1867     }
1868
1869     query unused_generic_params(key: ty::InstanceDef<'tcx>) -> UnusedGenericParams {
1870         cache_on_disk_if { key.def_id().is_local() }
1871         desc {
1872             |tcx| "determining which generic parameters are unused by `{}`",
1873                 tcx.def_path_str(key.def_id())
1874         }
1875         separate_provide_extern
1876     }
1877
1878     query backend_optimization_level(_: ()) -> OptLevel {
1879         desc { "optimization level used by backend" }
1880     }
1881
1882     /// Return the filenames where output artefacts shall be stored.
1883     ///
1884     /// This query returns an `&Arc` because codegen backends need the value even after the `TyCtxt`
1885     /// has been destroyed.
1886     query output_filenames(_: ()) -> &'tcx Arc<OutputFilenames> {
1887         feedable
1888         desc { "getting output filenames" }
1889         arena_cache
1890     }
1891
1892     /// Do not call this query directly: invoke `normalize` instead.
1893     query normalize_projection_ty(
1894         goal: CanonicalProjectionGoal<'tcx>
1895     ) -> Result<
1896         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1897         NoSolution,
1898     > {
1899         desc { "normalizing `{}`", goal.value.value }
1900         remap_env_constness
1901     }
1902
1903     /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
1904     query try_normalize_generic_arg_after_erasing_regions(
1905         goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1906     ) -> Result<GenericArg<'tcx>, NoSolution> {
1907         desc { "normalizing `{}`", goal.value }
1908         remap_env_constness
1909     }
1910
1911     query implied_outlives_bounds(
1912         goal: CanonicalTyGoal<'tcx>
1913     ) -> Result<
1914         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1915         NoSolution,
1916     > {
1917         desc { "computing implied outlives bounds for `{}`", goal.value.value }
1918         remap_env_constness
1919     }
1920
1921     /// Do not call this query directly:
1922     /// invoke `DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)` instead.
1923     query dropck_outlives(
1924         goal: CanonicalTyGoal<'tcx>
1925     ) -> Result<
1926         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1927         NoSolution,
1928     > {
1929         desc { "computing dropck types for `{}`", goal.value.value }
1930         remap_env_constness
1931     }
1932
1933     /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1934     /// `infcx.predicate_must_hold()` instead.
1935     query evaluate_obligation(
1936         goal: CanonicalPredicateGoal<'tcx>
1937     ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1938         desc { "evaluating trait selection obligation `{}`", goal.value.value }
1939     }
1940
1941     query evaluate_goal(
1942         goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx>
1943     ) -> Result<
1944         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1945         NoSolution
1946     > {
1947         desc { "evaluating trait selection obligation `{}`", goal.value }
1948     }
1949
1950     /// Do not call this query directly: part of the `Eq` type-op
1951     query type_op_ascribe_user_type(
1952         goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1953     ) -> Result<
1954         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1955         NoSolution,
1956     > {
1957         desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value }
1958         remap_env_constness
1959     }
1960
1961     /// Do not call this query directly: part of the `Eq` type-op
1962     query type_op_eq(
1963         goal: CanonicalTypeOpEqGoal<'tcx>
1964     ) -> Result<
1965         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1966         NoSolution,
1967     > {
1968         desc { "evaluating `type_op_eq` `{:?}`", goal.value.value }
1969         remap_env_constness
1970     }
1971
1972     /// Do not call this query directly: part of the `Subtype` type-op
1973     query type_op_subtype(
1974         goal: CanonicalTypeOpSubtypeGoal<'tcx>
1975     ) -> Result<
1976         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1977         NoSolution,
1978     > {
1979         desc { "evaluating `type_op_subtype` `{:?}`", goal.value.value }
1980         remap_env_constness
1981     }
1982
1983     /// Do not call this query directly: part of the `ProvePredicate` type-op
1984     query type_op_prove_predicate(
1985         goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1986     ) -> Result<
1987         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1988         NoSolution,
1989     > {
1990         desc { "evaluating `type_op_prove_predicate` `{:?}`", goal.value.value }
1991     }
1992
1993     /// Do not call this query directly: part of the `Normalize` type-op
1994     query type_op_normalize_ty(
1995         goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1996     ) -> Result<
1997         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1998         NoSolution,
1999     > {
2000         desc { "normalizing `{}`", goal.value.value.value }
2001         remap_env_constness
2002     }
2003
2004     /// Do not call this query directly: part of the `Normalize` type-op
2005     query type_op_normalize_predicate(
2006         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
2007     ) -> Result<
2008         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
2009         NoSolution,
2010     > {
2011         desc { "normalizing `{:?}`", goal.value.value.value }
2012         remap_env_constness
2013     }
2014
2015     /// Do not call this query directly: part of the `Normalize` type-op
2016     query type_op_normalize_poly_fn_sig(
2017         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
2018     ) -> Result<
2019         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
2020         NoSolution,
2021     > {
2022         desc { "normalizing `{:?}`", goal.value.value.value }
2023         remap_env_constness
2024     }
2025
2026     /// Do not call this query directly: part of the `Normalize` type-op
2027     query type_op_normalize_fn_sig(
2028         goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
2029     ) -> Result<
2030         &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
2031         NoSolution,
2032     > {
2033         desc { "normalizing `{:?}`", goal.value.value.value }
2034         remap_env_constness
2035     }
2036
2037     query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
2038         desc { |tcx|
2039             "checking impossible substituted predicates: `{}`",
2040             tcx.def_path_str(key.0)
2041         }
2042     }
2043
2044     query is_impossible_method(key: (DefId, DefId)) -> bool {
2045         desc { |tcx|
2046             "checking if `{}` is impossible to call within `{}`",
2047             tcx.def_path_str(key.1),
2048             tcx.def_path_str(key.0),
2049         }
2050     }
2051
2052     query method_autoderef_steps(
2053         goal: CanonicalTyGoal<'tcx>
2054     ) -> MethodAutoderefStepsResult<'tcx> {
2055         desc { "computing autoderef types for `{}`", goal.value.value }
2056         remap_env_constness
2057     }
2058
2059     query supported_target_features(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
2060         arena_cache
2061         eval_always
2062         desc { "looking up supported target features" }
2063     }
2064
2065     /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
2066     query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
2067         -> usize {
2068         desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
2069     }
2070
2071     query features_query(_: ()) -> &'tcx rustc_feature::Features {
2072         feedable
2073         desc { "looking up enabled feature gates" }
2074     }
2075
2076     /// Attempt to resolve the given `DefId` to an `Instance`, for the
2077     /// given generics args (`SubstsRef`), returning one of:
2078     ///  * `Ok(Some(instance))` on success
2079     ///  * `Ok(None)` when the `SubstsRef` are still too generic,
2080     ///    and therefore don't allow finding the final `Instance`
2081     ///  * `Err(ErrorGuaranteed)` when the `Instance` resolution process
2082     ///    couldn't complete due to errors elsewhere - this is distinct
2083     ///    from `Ok(None)` to avoid misleading diagnostics when an error
2084     ///    has already been/will be emitted, for the original cause
2085     query resolve_instance(
2086         key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
2087     ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
2088         desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
2089         remap_env_constness
2090     }
2091
2092     query resolve_instance_of_const_arg(
2093         key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
2094     ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
2095         desc {
2096             "resolving instance of the const argument `{}`",
2097             ty::Instance::new(key.value.0.to_def_id(), key.value.2),
2098         }
2099         remap_env_constness
2100     }
2101
2102     query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
2103         desc { "revealing opaque types in `{:?}`", key }
2104     }
2105
2106     query limits(key: ()) -> Limits {
2107         desc { "looking up limits" }
2108     }
2109
2110     /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
2111     /// we get an `Unimplemented` error that matches the provided `Predicate`, return
2112     /// the cause of the newly created obligation.
2113     ///
2114     /// This is only used by error-reporting code to get a better cause (in particular, a better
2115     /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
2116     /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
2117     /// because the `ty::Ty`-based wfcheck is always run.
2118     query diagnostic_hir_wf_check(
2119         key: (ty::Predicate<'tcx>, traits::WellFormedLoc)
2120     ) -> &'tcx Option<traits::ObligationCause<'tcx>> {
2121         arena_cache
2122         eval_always
2123         no_hash
2124         desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
2125     }
2126
2127     /// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
2128     /// `--target` and similar).
2129     query global_backend_features(_: ()) -> &'tcx Vec<String> {
2130         arena_cache
2131         eval_always
2132         desc { "computing the backend features for CLI flags" }
2133     }
2134
2135     query generator_diagnostic_data(key: DefId) -> &'tcx Option<GeneratorDiagnosticData<'tcx>> {
2136         arena_cache
2137         desc { |tcx| "looking up generator diagnostic data of `{}`", tcx.def_path_str(key) }
2138         separate_provide_extern
2139     }
2140
2141     query permits_uninit_init(key: ty::ParamEnvAnd<'tcx, TyAndLayout<'tcx>>) -> bool {
2142         desc { "checking to see if `{}` permits being left uninit", key.value.ty }
2143     }
2144
2145     query permits_zero_init(key: ty::ParamEnvAnd<'tcx, TyAndLayout<'tcx>>) -> bool {
2146         desc { "checking to see if `{}` permits being left zeroed", key.value.ty }
2147     }
2148
2149     query compare_impl_const(
2150         key: (LocalDefId, DefId)
2151     ) -> Result<(), ErrorGuaranteed> {
2152         desc { |tcx| "checking assoc const `{}` has the same type as trait item", tcx.def_path_str(key.0.to_def_id()) }
2153     }
2154
2155     query deduced_param_attrs(def_id: DefId) -> &'tcx [ty::DeducedParamAttrs] {
2156         desc { |tcx| "deducing parameter attributes for {}", tcx.def_path_str(def_id) }
2157         separate_provide_extern
2158     }
2159 }