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