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