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