rustc_middle/query/
mod.rs

1//!
2//! # The rustc Query System: Query Definitions and Modifiers
3//!
4//! The core processes in rustc are shipped as queries. Each query is a demand-driven function from some key to a value.
5//! The execution result of the function is cached and directly read during the next request, thereby improving compilation efficiency.
6//! Some results are saved locally and directly read during the next compilation, which are core of incremental compilation.
7//!
8//! ## How to Read This Module
9//!
10//! Each `query` block in this file defines a single query, specifying its key and value types, along with various modifiers.
11//! These query definitions are processed by the [`rustc_macros`], which expands them into the necessary boilerplate code
12//! for the query system—including the [`Providers`] struct (a function table for all query implementations, where each field is
13//! a function pointer to the actual provider), caching, and dependency graph integration.
14//! **Note:** The `Providers` struct is not a Rust trait, but a struct generated by the `rustc_macros` to hold all provider functions.
15//! The `rustc_macros` also supports a set of **query modifiers** (see below) that control the behavior of each query.
16//!
17//! The actual provider functions are implemented in various modules and registered into the `Providers` struct
18//! during compiler initialization (see [`rustc_interface::passes::DEFAULT_QUERY_PROVIDERS`]).
19//!
20//! [`rustc_macros`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/index.html
21//! [`rustc_interface::passes::DEFAULT_QUERY_PROVIDERS`]: ../../rustc_interface/passes/static.DEFAULT_QUERY_PROVIDERS.html
22//!
23//! ## Query Modifiers
24//!
25//! Query modifiers are special flags that alter the behavior of a query. They are parsed and processed by the `rustc_macros`
26//! The main modifiers are:
27//!
28//! - `desc { ... }`: Sets the human-readable description for diagnostics and profiling. Required for every query.
29//! - `arena_cache`: Use an arena for in-memory caching of the query result.
30//! - `cache_on_disk_if { ... }`: Cache the query result to disk if the provided block evaluates to true.
31//! - `fatal_cycle`: If a dependency cycle is detected, abort compilation with a fatal error.
32//! - `cycle_delay_bug`: If a dependency cycle is detected, emit a delayed bug instead of aborting immediately.
33//! - `cycle_stash`: If a dependency cycle is detected, stash the error for later handling.
34//! - `no_hash`: Do not hash the query result for incremental compilation; just mark as dirty if recomputed.
35//! - `anon`: Make the query anonymous in the dependency graph (no dep node is created).
36//! - `eval_always`: Always evaluate the query, ignoring its dependencies and cached results.
37//! - `depth_limit`: Impose a recursion depth limit on the query to prevent stack overflows.
38//! - `separate_provide_extern`: Use separate provider functions for local and external crates.
39//! - `feedable`: Allow the query result to be set from another query ("fed" externally).
40//! - `return_result_from_ensure_ok`: When called via `tcx.ensure_ok()`, return `Result<(), ErrorGuaranteed>` instead of `()`.
41//!   If the query needs to be executed and returns an error, the error is returned to the caller.
42//!   Only valid for queries returning `Result<_, ErrorGuaranteed>`.
43//!
44//! For the up-to-date list, see the `QueryModifiers` struct in
45//! [`rustc_macros/src/query.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_macros/src/query.rs)
46//! and for more details in incremental compilation, see the
47//! [Query modifiers in incremental compilation](https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation-in-detail.html#query-modifiers) section of the rustc-dev-guide.
48//!
49//! ## Query Expansion and Code Generation
50//!
51//! The [`rustc_macros::rustc_queries`] macro expands each query definition into:
52//! - A method on [`TyCtxt`] (and [`TyCtxtAt`]) for invoking the query.
53//! - Provider traits and structs for supplying the query's value.
54//! - Caching and dependency graph integration.
55//! - Support for incremental compilation, disk caching, and arena allocation as controlled by the modifiers.
56//!
57//! [`rustc_macros::rustc_queries`]: ../../rustc_macros/macro.rustc_queries.html
58//!
59//! The macro-based approach allows the query system to be highly flexible and maintainable, while minimizing boilerplate.
60//!
61//! For more details, see the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/query.html).
62
63#![allow(unused_parens)]
64
65use std::ffi::OsStr;
66use std::mem;
67use std::path::PathBuf;
68use std::sync::Arc;
69
70use rustc_abi::Align;
71use rustc_arena::TypedArena;
72use rustc_ast::expand::StrippedCfgItem;
73use rustc_ast::expand::allocator::AllocatorKind;
74use rustc_data_structures::fingerprint::Fingerprint;
75use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
76use rustc_data_structures::sorted_map::SortedMap;
77use rustc_data_structures::steal::Steal;
78use rustc_data_structures::svh::Svh;
79use rustc_data_structures::unord::{UnordMap, UnordSet};
80use rustc_errors::ErrorGuaranteed;
81use rustc_hir::def::{DefKind, DocLinkResMap};
82use rustc_hir::def_id::{
83    CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
84};
85use rustc_hir::lang_items::{LangItem, LanguageItems};
86use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, PreciseCapturingArgKind, TraitCandidate};
87use rustc_index::IndexVec;
88use rustc_lint_defs::LintId;
89use rustc_macros::rustc_queries;
90use rustc_query_system::ich::StableHashingContext;
91use rustc_query_system::query::{
92    QueryCache, QueryMode, QueryStackDeferred, QueryState, try_get_cached,
93};
94use rustc_session::Limits;
95use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
96use rustc_session::cstore::{
97    CrateDepKind, CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
98};
99use rustc_session::lint::LintExpectationId;
100use rustc_span::def_id::LOCAL_CRATE;
101use rustc_span::source_map::Spanned;
102use rustc_span::{DUMMY_SP, Span, Symbol};
103use rustc_target::spec::PanicStrategy;
104use {rustc_abi as abi, rustc_ast as ast, rustc_attr_data_structures as attr, rustc_hir as hir};
105
106use crate::infer::canonical::{self, Canonical};
107use crate::lint::LintExpectation;
108use crate::metadata::ModChild;
109use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
110use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
111use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
112use crate::middle::lib_features::LibFeatures;
113use crate::middle::privacy::EffectiveVisibilities;
114use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg};
115use crate::middle::stability::{self, DeprecationEntry};
116use crate::mir::interpret::{
117    EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult,
118    EvalToValTreeResult, GlobalId, LitToConstInput,
119};
120use crate::mir::mono::{CodegenUnit, CollectionMode, MonoItem, MonoItemPartitions};
121use crate::query::erase::{Erase, erase, restore};
122use crate::query::plumbing::{
123    CyclePlaceholder, DynamicQuery, query_ensure, query_ensure_error_guaranteed, query_get_at,
124};
125use crate::traits::query::{
126    CanonicalAliasGoal, CanonicalDropckOutlivesGoal, CanonicalImpliedOutlivesBoundsGoal,
127    CanonicalPredicateGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
128    CanonicalTypeOpNormalizeGoal, CanonicalTypeOpProvePredicateGoal, DropckConstraint,
129    DropckOutlivesResult, MethodAutoderefStepsResult, NoSolution, NormalizationResult,
130    OutlivesBound,
131};
132use crate::traits::{
133    CodegenObligationError, DynCompatibilityViolation, EvaluationResult, ImplSource,
134    ObligationCause, OverflowError, WellFormedLoc, specialization_graph,
135};
136use crate::ty::fast_reject::SimplifiedType;
137use crate::ty::layout::ValidityRequirement;
138use crate::ty::print::{PrintTraitRefExt, describe_as_module};
139use crate::ty::util::AlwaysRequiresDrop;
140use crate::ty::{
141    self, CrateInherentImpls, GenericArg, GenericArgsRef, PseudoCanonicalInput, SizedTraitKind, Ty,
142    TyCtxt, TyCtxtFeed,
143};
144use crate::{dep_graph, mir, thir};
145
146mod arena_cached;
147pub mod erase;
148mod keys;
149pub use keys::{AsLocalKey, Key, LocalCrate};
150pub mod on_disk_cache;
151#[macro_use]
152pub mod plumbing;
153pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk};
154
155// Each of these queries corresponds to a function pointer field in the
156// `Providers` struct for requesting a value of that type, and a method
157// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
158// which memoizes and does dep-graph tracking, wrapping around the actual
159// `Providers` that the driver creates (using several `rustc_*` crates).
160//
161// The result type of each query must implement `Clone`, and additionally
162// `ty::query::values::Value`, which produces an appropriate placeholder
163// (error) value if the query resulted in a query cycle.
164// Queries marked with `fatal_cycle` do not need the latter implementation,
165// as they will raise an fatal error on query cycles instead.
166rustc_queries! {
167    /// This exists purely for testing the interactions between delayed bugs and incremental.
168    query trigger_delayed_bug(key: DefId) {
169        desc { "triggering a delayed bug for testing incremental" }
170    }
171
172    /// Collects the list of all tools registered using `#![register_tool]`.
173    query registered_tools(_: ()) -> &'tcx ty::RegisteredTools {
174        arena_cache
175        desc { "compute registered tools for crate" }
176    }
177
178    query early_lint_checks(_: ()) {
179        desc { "perform lints prior to AST lowering" }
180    }
181
182    /// Tracked access to environment variables.
183    ///
184    /// Useful for the implementation of `std::env!`, `proc-macro`s change
185    /// detection and other changes in the compiler's behaviour that is easier
186    /// to control with an environment variable than a flag.
187    ///
188    /// NOTE: This currently does not work with dependency info in the
189    /// analysis, codegen and linking passes, place extra code at the top of
190    /// `rustc_interface::passes::write_dep_info` to make that work.
191    query env_var_os(key: &'tcx OsStr) -> Option<&'tcx OsStr> {
192        // Environment variables are global state
193        eval_always
194        desc { "get the value of an environment variable" }
195    }
196
197    query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
198        desc { "getting the resolver outputs" }
199    }
200
201    query resolver_for_lowering_raw(_: ()) -> (&'tcx Steal<(ty::ResolverAstLowering, Arc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
202        eval_always
203        no_hash
204        desc { "getting the resolver for lowering" }
205    }
206
207    /// Return the span for a definition.
208    ///
209    /// Contrary to `def_span` below, this query returns the full absolute span of the definition.
210    /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
211    /// of rustc_middle::hir::source_map.
212    query source_span(key: LocalDefId) -> Span {
213        // Accesses untracked data
214        eval_always
215        desc { "getting the source span" }
216    }
217
218    /// Represents crate as a whole (as distinct from the top-level crate module).
219    ///
220    /// If you call `tcx.hir_crate(())` we will have to assume that any change
221    /// means that you need to be recompiled. This is because the `hir_crate`
222    /// query gives you access to all other items. To avoid this fate, do not
223    /// call `tcx.hir_crate(())`; instead, prefer wrappers like
224    /// [`TyCtxt::hir_visit_all_item_likes_in_crate`].
225    query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
226        arena_cache
227        eval_always
228        desc { "getting the crate HIR" }
229    }
230
231    /// All items in the crate.
232    query hir_crate_items(_: ()) -> &'tcx rustc_middle::hir::ModuleItems {
233        arena_cache
234        eval_always
235        desc { "getting HIR crate items" }
236    }
237
238    /// The items in a module.
239    ///
240    /// This can be conveniently accessed by `tcx.hir_visit_item_likes_in_module`.
241    /// Avoid calling this query directly.
242    query hir_module_items(key: LocalModDefId) -> &'tcx rustc_middle::hir::ModuleItems {
243        arena_cache
244        desc { |tcx| "getting HIR module items in `{}`", tcx.def_path_str(key) }
245        cache_on_disk_if { true }
246    }
247
248    /// Returns HIR ID for the given `LocalDefId`.
249    query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
250        desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key) }
251        feedable
252    }
253
254    /// Gives access to the HIR node's parent for the HIR owner `key`.
255    ///
256    /// This can be conveniently accessed by `tcx.hir_*` methods.
257    /// Avoid calling this query directly.
258    query hir_owner_parent(key: hir::OwnerId) -> hir::HirId {
259        desc { |tcx| "getting HIR parent of `{}`", tcx.def_path_str(key) }
260    }
261
262    /// Gives access to the HIR nodes and bodies inside `key` if it's a HIR owner.
263    ///
264    /// This can be conveniently accessed by `tcx.hir_*` methods.
265    /// Avoid calling this query directly.
266    query opt_hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> {
267        desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key) }
268        feedable
269    }
270
271    /// Gives access to the HIR attributes inside the HIR owner `key`.
272    ///
273    /// This can be conveniently accessed by `tcx.hir_*` methods.
274    /// Avoid calling this query directly.
275    query hir_attr_map(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
276        desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) }
277        feedable
278    }
279
280    /// Gives access to lints emitted during ast lowering.
281    ///
282    /// This can be conveniently accessed by `tcx.hir_*` methods.
283    /// Avoid calling this query directly.
284    query opt_ast_lowering_delayed_lints(key: hir::OwnerId) -> Option<&'tcx hir::lints::DelayedLints> {
285        desc { |tcx| "getting AST lowering delayed lints in `{}`", tcx.def_path_str(key) }
286    }
287
288    /// Returns the *default* of the const pararameter given by `DefId`.
289    ///
290    /// E.g., given `struct Ty<const N: usize = 3>;` this returns `3` for `N`.
291    query const_param_default(param: DefId) -> ty::EarlyBinder<'tcx, ty::Const<'tcx>> {
292        desc { |tcx| "computing the default for const parameter `{}`", tcx.def_path_str(param)  }
293        cache_on_disk_if { param.is_local() }
294        separate_provide_extern
295    }
296
297    /// Returns the *type* of the definition given by `DefId`.
298    ///
299    /// For type aliases (whether eager or lazy) and associated types, this returns
300    /// the underlying aliased type (not the corresponding [alias type]).
301    ///
302    /// For opaque types, this returns and thus reveals the hidden type! If you
303    /// want to detect cycle errors use `type_of_opaque` instead.
304    ///
305    /// To clarify, for type definitions, this does *not* return the "type of a type"
306    /// (aka *kind* or *sort*) in the type-theoretical sense! It merely returns
307    /// the type primarily *associated with* it.
308    ///
309    /// # Panics
310    ///
311    /// This query will panic if the given definition doesn't (and can't
312    /// conceptually) have an (underlying) type.
313    ///
314    /// [alias type]: rustc_middle::ty::AliasTy
315    query type_of(key: DefId) -> ty::EarlyBinder<'tcx, Ty<'tcx>> {
316        desc { |tcx|
317            "{action} `{path}`",
318            action = match tcx.def_kind(key) {
319                DefKind::TyAlias => "expanding type alias",
320                DefKind::TraitAlias => "expanding trait alias",
321                _ => "computing type of",
322            },
323            path = tcx.def_path_str(key),
324        }
325        cache_on_disk_if { key.is_local() }
326        separate_provide_extern
327        feedable
328    }
329
330    /// Returns the *hidden type* of the opaque type given by `DefId` unless a cycle occurred.
331    ///
332    /// This is a specialized instance of [`Self::type_of`] that detects query cycles.
333    /// Unless `CyclePlaceholder` needs to be handled separately, call [`Self::type_of`] instead.
334    /// This is used to improve the error message in cases where revealing the hidden type
335    /// for auto-trait leakage cycles.
336    ///
337    /// # Panics
338    ///
339    /// This query will panic if the given definition is not an opaque type.
340    query type_of_opaque(key: DefId) -> Result<ty::EarlyBinder<'tcx, Ty<'tcx>>, CyclePlaceholder> {
341        desc { |tcx|
342            "computing type of opaque `{path}`",
343            path = tcx.def_path_str(key),
344        }
345        cycle_stash
346    }
347    query type_of_opaque_hir_typeck(key: LocalDefId) -> ty::EarlyBinder<'tcx, Ty<'tcx>> {
348        desc { |tcx|
349            "computing type of opaque `{path}` via HIR typeck",
350            path = tcx.def_path_str(key),
351        }
352    }
353
354    /// Returns whether the type alias given by `DefId` is lazy.
355    ///
356    /// I.e., if the type alias expands / ought to expand to a [free] [alias type]
357    /// instead of the underlying aliased type.
358    ///
359    /// Relevant for features `lazy_type_alias` and `type_alias_impl_trait`.
360    ///
361    /// # Panics
362    ///
363    /// This query *may* panic if the given definition is not a type alias.
364    ///
365    /// [free]: rustc_middle::ty::Free
366    /// [alias type]: rustc_middle::ty::AliasTy
367    query type_alias_is_lazy(key: DefId) -> bool {
368        desc { |tcx|
369            "computing whether the type alias `{path}` is lazy",
370            path = tcx.def_path_str(key),
371        }
372        separate_provide_extern
373    }
374
375    query collect_return_position_impl_trait_in_trait_tys(key: DefId)
376        -> Result<&'tcx DefIdMap<ty::EarlyBinder<'tcx, Ty<'tcx>>>, ErrorGuaranteed>
377    {
378        desc { "comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process" }
379        cache_on_disk_if { key.is_local() }
380        separate_provide_extern
381    }
382
383    query opaque_ty_origin(key: DefId) -> hir::OpaqueTyOrigin<DefId>
384    {
385        desc { "determine where the opaque originates from" }
386        separate_provide_extern
387    }
388
389    query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::DenseBitSet<u32>
390    {
391        arena_cache
392        desc { |tcx|
393            "determining what parameters of `{}` can participate in unsizing",
394            tcx.def_path_str(key),
395        }
396    }
397
398    /// The root query triggering all analysis passes like typeck or borrowck.
399    query analysis(key: ()) {
400        eval_always
401        desc { "running analysis passes on this crate" }
402    }
403
404    /// This query checks the fulfillment of collected lint expectations.
405    /// All lint emitting queries have to be done before this is executed
406    /// to ensure that all expectations can be fulfilled.
407    ///
408    /// This is an extra query to enable other drivers (like rustdoc) to
409    /// only execute a small subset of the `analysis` query, while allowing
410    /// lints to be expected. In rustc, this query will be executed as part of
411    /// the `analysis` query and doesn't have to be called a second time.
412    ///
413    /// Tools can additionally pass in a tool filter. That will restrict the
414    /// expectations to only trigger for lints starting with the listed tool
415    /// name. This is useful for cases were not all linting code from rustc
416    /// was called. With the default `None` all registered lints will also
417    /// be checked for expectation fulfillment.
418    query check_expectations(key: Option<Symbol>) {
419        eval_always
420        desc { "checking lint expectations (RFC 2383)" }
421    }
422
423    /// Returns the *generics* of the definition given by `DefId`.
424    query generics_of(key: DefId) -> &'tcx ty::Generics {
425        desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
426        arena_cache
427        cache_on_disk_if { key.is_local() }
428        separate_provide_extern
429        feedable
430    }
431
432    /// Returns the (elaborated) *predicates* of the definition given by `DefId`
433    /// that must be proven true at usage sites (and which can be assumed at definition site).
434    ///
435    /// This is almost always *the* "predicates query" that you want.
436    ///
437    /// **Tip**: You can use `#[rustc_dump_predicates]` on an item to basically print
438    /// the result of this query for use in UI tests or for debugging purposes.
439    query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
440        desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
441        cache_on_disk_if { key.is_local() }
442    }
443
444    query opaque_types_defined_by(
445        key: LocalDefId
446    ) -> &'tcx ty::List<LocalDefId> {
447        desc {
448            |tcx| "computing the opaque types defined by `{}`",
449            tcx.def_path_str(key.to_def_id())
450        }
451    }
452
453    query nested_bodies_within(
454        key: LocalDefId
455    ) -> &'tcx ty::List<LocalDefId> {
456        desc {
457            |tcx| "computing the coroutines defined within `{}`",
458            tcx.def_path_str(key.to_def_id())
459        }
460    }
461
462    /// Returns the explicitly user-written *bounds* on the associated or opaque type given by `DefId`
463    /// that must be proven true at definition site (and which can be assumed at usage sites).
464    ///
465    /// For associated types, these must be satisfied for an implementation
466    /// to be well-formed, and for opaque types, these are required to be
467    /// satisfied by the hidden type of the opaque.
468    ///
469    /// Bounds from the parent (e.g. with nested `impl Trait`) are not included.
470    ///
471    /// Syntactially, these are the bounds written on associated types in trait
472    /// definitions, or those after the `impl` keyword for an opaque:
473    ///
474    /// ```ignore (illustrative)
475    /// trait Trait { type X: Bound + 'lt; }
476    /// //                    ^^^^^^^^^^^
477    /// fn function() -> impl Debug + Display { /*...*/ }
478    /// //                    ^^^^^^^^^^^^^^^
479    /// ```
480    query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
481        desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
482        cache_on_disk_if { key.is_local() }
483        separate_provide_extern
484        feedable
485    }
486
487    /// Returns the explicitly user-written *bounds* that share the `Self` type of the item.
488    ///
489    /// These are a subset of the [explicit item bounds] that may explicitly be used for things
490    /// like closure signature deduction.
491    ///
492    /// [explicit item bounds]: Self::explicit_item_bounds
493    query explicit_item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
494        desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
495        cache_on_disk_if { key.is_local() }
496        separate_provide_extern
497        feedable
498    }
499
500    /// Returns the (elaborated) *bounds* on the associated or opaque type given by `DefId`
501    /// that must be proven true at definition site (and which can be assumed at usage sites).
502    ///
503    /// Bounds from the parent (e.g. with nested `impl Trait`) are not included.
504    ///
505    /// **Tip**: You can use `#[rustc_dump_item_bounds]` on an item to basically print
506    /// the result of this query for use in UI tests or for debugging purposes.
507    ///
508    /// # Examples
509    ///
510    /// ```
511    /// trait Trait { type Assoc: Eq + ?Sized; }
512    /// ```
513    ///
514    /// While [`Self::explicit_item_bounds`] returns `[<Self as Trait>::Assoc: Eq]`
515    /// here, `item_bounds` returns:
516    ///
517    /// ```text
518    /// [
519    ///     <Self as Trait>::Assoc: Eq,
520    ///     <Self as Trait>::Assoc: PartialEq<<Self as Trait>::Assoc>
521    /// ]
522    /// ```
523    query item_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
524        desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
525    }
526
527    query item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
528        desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
529    }
530
531    query item_non_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
532        desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
533    }
534
535    query impl_super_outlives(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
536        desc { |tcx| "elaborating supertrait outlives for trait of `{}`", tcx.def_path_str(key) }
537    }
538
539    /// Look up all native libraries this crate depends on.
540    /// These are assembled from the following places:
541    /// - `extern` blocks (depending on their `link` attributes)
542    /// - the `libs` (`-l`) option
543    query native_libraries(_: CrateNum) -> &'tcx Vec<NativeLib> {
544        arena_cache
545        desc { "looking up the native libraries of a linked crate" }
546        separate_provide_extern
547    }
548
549    query shallow_lint_levels_on(key: hir::OwnerId) -> &'tcx rustc_middle::lint::ShallowLintLevelMap {
550        arena_cache
551        desc { |tcx| "looking up lint levels for `{}`", tcx.def_path_str(key) }
552    }
553
554    query lint_expectations(_: ()) -> &'tcx Vec<(LintExpectationId, LintExpectation)> {
555        arena_cache
556        desc { "computing `#[expect]`ed lints in this crate" }
557    }
558
559    query lints_that_dont_need_to_run(_: ()) -> &'tcx UnordSet<LintId> {
560        arena_cache
561        desc { "Computing all lints that are explicitly enabled or with a default level greater than Allow" }
562    }
563
564    query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
565        desc { |tcx| "getting the expansion that defined `{}`", tcx.def_path_str(key) }
566        separate_provide_extern
567    }
568
569    query is_panic_runtime(_: CrateNum) -> bool {
570        fatal_cycle
571        desc { "checking if the crate is_panic_runtime" }
572        separate_provide_extern
573    }
574
575    /// Checks whether a type is representable or infinitely sized
576    query representability(_: LocalDefId) -> rustc_middle::ty::Representability {
577        desc { "checking if `{}` is representable", tcx.def_path_str(key) }
578        // infinitely sized types will cause a cycle
579        cycle_delay_bug
580        // we don't want recursive representability calls to be forced with
581        // incremental compilation because, if a cycle occurs, we need the
582        // entire cycle to be in memory for diagnostics
583        anon
584    }
585
586    /// An implementation detail for the `representability` query
587    query representability_adt_ty(_: Ty<'tcx>) -> rustc_middle::ty::Representability {
588        desc { "checking if `{}` is representable", key }
589        cycle_delay_bug
590        anon
591    }
592
593    /// Set of param indexes for type params that are in the type's representation
594    query params_in_repr(key: DefId) -> &'tcx rustc_index::bit_set::DenseBitSet<u32> {
595        desc { "finding type parameters in the representation" }
596        arena_cache
597        no_hash
598        separate_provide_extern
599    }
600
601    /// Fetch the THIR for a given body. The THIR body gets stolen by unsafety checking unless
602    /// `-Zno-steal-thir` is on.
603    query thir_body(key: LocalDefId) -> Result<(&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId), ErrorGuaranteed> {
604        // Perf tests revealed that hashing THIR is inefficient (see #85729).
605        no_hash
606        desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) }
607    }
608
609    /// Set of all the `DefId`s in this crate that have MIR associated with
610    /// them. This includes all the body owners, but also things like struct
611    /// constructors.
612    query mir_keys(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexSet<LocalDefId> {
613        arena_cache
614        desc { "getting a list of all mir_keys" }
615    }
616
617    /// Maps DefId's that have an associated `mir::Body` to the result
618    /// of the MIR const-checking pass. This is the set of qualifs in
619    /// the final value of a `const`.
620    query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
621        desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
622        cache_on_disk_if { key.is_local() }
623        separate_provide_extern
624    }
625
626    /// Build the MIR for a given `DefId` and prepare it for const qualification.
627    ///
628    /// See the [rustc dev guide] for more info.
629    ///
630    /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/construction.html
631    query mir_built(key: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
632        desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key) }
633        feedable
634    }
635
636    /// Try to build an abstract representation of the given constant.
637    query thir_abstract_const(
638        key: DefId
639    ) -> Result<Option<ty::EarlyBinder<'tcx, ty::Const<'tcx>>>, ErrorGuaranteed> {
640        desc {
641            |tcx| "building an abstract representation for `{}`", tcx.def_path_str(key),
642        }
643        separate_provide_extern
644    }
645
646    query mir_drops_elaborated_and_const_checked(key: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
647        no_hash
648        desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key) }
649    }
650
651    query mir_for_ctfe(
652        key: DefId
653    ) -> &'tcx mir::Body<'tcx> {
654        desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
655        cache_on_disk_if { key.is_local() }
656        separate_provide_extern
657    }
658
659    query mir_promoted(key: LocalDefId) -> (
660        &'tcx Steal<mir::Body<'tcx>>,
661        &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
662    ) {
663        no_hash
664        desc { |tcx| "promoting constants in MIR for `{}`", tcx.def_path_str(key) }
665    }
666
667    query closure_typeinfo(key: LocalDefId) -> ty::ClosureTypeInfo<'tcx> {
668        desc {
669            |tcx| "finding symbols for captures of closure `{}`",
670            tcx.def_path_str(key)
671        }
672    }
673
674    /// Returns names of captured upvars for closures and coroutines.
675    ///
676    /// Here are some examples:
677    ///  - `name__field1__field2` when the upvar is captured by value.
678    ///  - `_ref__name__field` when the upvar is captured by reference.
679    ///
680    /// For coroutines this only contains upvars that are shared by all states.
681    query closure_saved_names_of_captured_variables(def_id: DefId) -> &'tcx IndexVec<abi::FieldIdx, Symbol> {
682        arena_cache
683        desc { |tcx| "computing debuginfo for closure `{}`", tcx.def_path_str(def_id) }
684        separate_provide_extern
685    }
686
687    query mir_coroutine_witnesses(key: DefId) -> Option<&'tcx mir::CoroutineLayout<'tcx>> {
688        arena_cache
689        desc { |tcx| "coroutine witness types for `{}`", tcx.def_path_str(key) }
690        cache_on_disk_if { key.is_local() }
691        separate_provide_extern
692    }
693
694    query check_coroutine_obligations(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
695        desc { |tcx| "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) }
696        return_result_from_ensure_ok
697    }
698
699    /// MIR after our optimization passes have run. This is MIR that is ready
700    /// for codegen. This is also the only query that can fetch non-local MIR, at present.
701    query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
702        desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
703        cache_on_disk_if { key.is_local() }
704        separate_provide_extern
705    }
706
707    /// Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on
708    /// this def and any enclosing defs, up to the crate root.
709    ///
710    /// Returns `false` if `#[coverage(off)]` was found, or `true` if
711    /// either `#[coverage(on)]` or no coverage attribute was found.
712    query coverage_attr_on(key: LocalDefId) -> bool {
713        desc { |tcx| "checking for `#[coverage(..)]` on `{}`", tcx.def_path_str(key) }
714        feedable
715    }
716
717    /// Scans through a function's MIR after MIR optimizations, to prepare the
718    /// information needed by codegen when `-Cinstrument-coverage` is active.
719    ///
720    /// This includes the details of where to insert `llvm.instrprof.increment`
721    /// intrinsics, and the expression tables to be embedded in the function's
722    /// coverage metadata.
723    ///
724    /// FIXME(Zalathar): This query's purpose has drifted a bit and should
725    /// probably be renamed, but that can wait until after the potential
726    /// follow-ups to #136053 have settled down.
727    ///
728    /// Returns `None` for functions that were not instrumented.
729    query coverage_ids_info(key: ty::InstanceKind<'tcx>) -> Option<&'tcx mir::coverage::CoverageIdsInfo> {
730        desc { |tcx| "retrieving coverage IDs info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
731        arena_cache
732    }
733
734    /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
735    /// `DefId`. This function returns all promoteds in the specified body. The body references
736    /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
737    /// after inlining a body may refer to promoteds from other bodies. In that case you still
738    /// need to use the `DefId` of the original body.
739    query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
740        desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
741        cache_on_disk_if { key.is_local() }
742        separate_provide_extern
743    }
744
745    /// Erases regions from `ty` to yield a new type.
746    /// Normally you would just use `tcx.erase_regions(value)`,
747    /// however, which uses this query as a kind of cache.
748    query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
749        // This query is not expected to have input -- as a result, it
750        // is not a good candidates for "replay" because it is essentially a
751        // pure function of its input (and hence the expectation is that
752        // no caller would be green **apart** from just these
753        // queries). Making it anonymous avoids hashing the result, which
754        // may save a bit of time.
755        anon
756        desc { "erasing regions from `{}`", ty }
757    }
758
759    query wasm_import_module_map(_: CrateNum) -> &'tcx DefIdMap<String> {
760        arena_cache
761        desc { "getting wasm import module map" }
762    }
763
764    /// Returns the explicitly user-written *predicates and bounds* of the trait given by `DefId`.
765    ///
766    /// Traits are unusual, because predicates on associated types are
767    /// converted into bounds on that type for backwards compatibility:
768    ///
769    /// ```
770    /// trait X where Self::U: Copy { type U; }
771    /// ```
772    ///
773    /// becomes
774    ///
775    /// ```
776    /// trait X { type U: Copy; }
777    /// ```
778    ///
779    /// [`Self::explicit_predicates_of`] and [`Self::explicit_item_bounds`] will
780    /// then take the appropriate subsets of the predicates here.
781    ///
782    /// # Panics
783    ///
784    /// This query will panic if the given definition is not a trait.
785    query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
786        desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key) }
787    }
788
789    /// Returns the explicitly user-written *predicates* of the definition given by `DefId`
790    /// that must be proven true at usage sites (and which can be assumed at definition site).
791    ///
792    /// You should probably use [`Self::predicates_of`] unless you're looking for
793    /// predicates with explicit spans for diagnostics purposes.
794    query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
795        desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
796        cache_on_disk_if { key.is_local() }
797        separate_provide_extern
798        feedable
799    }
800
801    /// Returns the *inferred outlives-predicates* of the item given by `DefId`.
802    ///
803    /// E.g., for `struct Foo<'a, T> { x: &'a T }`, this would return `[T: 'a]`.
804    ///
805    /// **Tip**: You can use `#[rustc_outlives]` on an item to basically print the
806    /// result of this query for use in UI tests or for debugging purposes.
807    query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Clause<'tcx>, Span)] {
808        desc { |tcx| "computing inferred outlives-predicates of `{}`", tcx.def_path_str(key) }
809        cache_on_disk_if { key.is_local() }
810        separate_provide_extern
811        feedable
812    }
813
814    /// Returns the explicitly user-written *super-predicates* of the trait given by `DefId`.
815    ///
816    /// These predicates are unelaborated and consequently don't contain transitive super-predicates.
817    ///
818    /// This is a subset of the full list of predicates. We store these in a separate map
819    /// because we must evaluate them even during type conversion, often before the full
820    /// predicates are available (note that super-predicates must not be cyclic).
821    query explicit_super_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
822        desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
823        cache_on_disk_if { key.is_local() }
824        separate_provide_extern
825    }
826
827    /// The predicates of the trait that are implied during elaboration.
828    ///
829    /// This is a superset of the super-predicates of the trait, but a subset of the predicates
830    /// of the trait. For regular traits, this includes all super-predicates and their
831    /// associated type bounds. For trait aliases, currently, this includes all of the
832    /// predicates of the trait alias.
833    query explicit_implied_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
834        desc { |tcx| "computing the implied predicates of `{}`", tcx.def_path_str(key) }
835        cache_on_disk_if { key.is_local() }
836        separate_provide_extern
837    }
838
839    /// The Ident is the name of an associated type.The query returns only the subset
840    /// of supertraits that define the given associated type. This is used to avoid
841    /// cycles in resolving type-dependent associated item paths like `T::Item`.
842    query explicit_supertraits_containing_assoc_item(
843        key: (DefId, rustc_span::Ident)
844    ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
845        desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
846            tcx.def_path_str(key.0),
847            key.1
848        }
849    }
850
851    /// Compute the conditions that need to hold for a conditionally-const item to be const.
852    /// That is, compute the set of `[const]` where clauses for a given item.
853    ///
854    /// This can be thought of as the `[const]` equivalent of `predicates_of`. These are the
855    /// predicates that need to be proven at usage sites, and can be assumed at definition.
856    ///
857    /// This query also computes the `[const]` where clauses for associated types, which are
858    /// not "const", but which have item bounds which may be `[const]`. These must hold for
859    /// the `[const]` item bound to hold.
860    query const_conditions(
861        key: DefId
862    ) -> ty::ConstConditions<'tcx> {
863        desc { |tcx| "computing the conditions for `{}` to be considered const",
864            tcx.def_path_str(key)
865        }
866        separate_provide_extern
867    }
868
869    /// Compute the const bounds that are implied for a conditionally-const item.
870    ///
871    /// This can be though of as the `[const]` equivalent of `explicit_item_bounds`. These
872    /// are the predicates that need to proven at definition sites, and can be assumed at
873    /// usage sites.
874    query explicit_implied_const_bounds(
875        key: DefId
876    ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {
877        desc { |tcx| "computing the implied `[const]` bounds for `{}`",
878            tcx.def_path_str(key)
879        }
880        separate_provide_extern
881    }
882
883    /// To avoid cycles within the predicates of a single item we compute
884    /// per-type-parameter predicates for resolving `T::AssocTy`.
885    query type_param_predicates(
886        key: (LocalDefId, LocalDefId, rustc_span::Ident)
887    ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
888        desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir_ty_param_name(key.1) }
889    }
890
891    query trait_def(key: DefId) -> &'tcx ty::TraitDef {
892        desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
893        arena_cache
894        cache_on_disk_if { key.is_local() }
895        separate_provide_extern
896    }
897    query adt_def(key: DefId) -> ty::AdtDef<'tcx> {
898        desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
899        cache_on_disk_if { key.is_local() }
900        separate_provide_extern
901    }
902    query adt_destructor(key: DefId) -> Option<ty::Destructor> {
903        desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
904        cache_on_disk_if { key.is_local() }
905        separate_provide_extern
906    }
907    query adt_async_destructor(key: DefId) -> Option<ty::AsyncDestructor> {
908        desc { |tcx| "computing `AsyncDrop` impl for `{}`", tcx.def_path_str(key) }
909        cache_on_disk_if { key.is_local() }
910        separate_provide_extern
911    }
912    query adt_sizedness_constraint(
913        key: (DefId, SizedTraitKind)
914    ) -> Option<ty::EarlyBinder<'tcx, Ty<'tcx>>> {
915        desc { |tcx| "computing the sizedness constraint for `{}`", tcx.def_path_str(key.0) }
916    }
917
918    query adt_dtorck_constraint(
919        key: DefId
920    ) -> &'tcx DropckConstraint<'tcx> {
921        desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
922    }
923
924    /// Returns the constness of the function-like[^1] definition given by `DefId`.
925    ///
926    /// Tuple struct/variant constructors are *always* const, foreign functions are
927    /// *never* const. The rest is const iff marked with keyword `const` (or rather
928    /// its parent in the case of associated functions).
929    ///
930    /// <div class="warning">
931    ///
932    /// **Do not call this query** directly. It is only meant to cache the base data for the
933    /// higher-level functions. Consider using `is_const_fn` or `is_const_trait_impl` instead.
934    ///
935    /// Also note that neither of them takes into account feature gates, stability and
936    /// const predicates/conditions!
937    ///
938    /// </div>
939    ///
940    /// # Panics
941    ///
942    /// This query will panic if the given definition is not function-like[^1].
943    ///
944    /// [^1]: Tuple struct/variant constructors, closures and free, associated and foreign functions.
945    query constness(key: DefId) -> hir::Constness {
946        desc { |tcx| "checking if item is const: `{}`", tcx.def_path_str(key) }
947        separate_provide_extern
948        feedable
949    }
950
951    query asyncness(key: DefId) -> ty::Asyncness {
952        desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
953        separate_provide_extern
954    }
955
956    /// Returns `true` if calls to the function may be promoted.
957    ///
958    /// This is either because the function is e.g., a tuple-struct or tuple-variant
959    /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
960    /// be removed in the future in favour of some form of check which figures out whether the
961    /// function does not inspect the bits of any of its arguments (so is essentially just a
962    /// constructor function).
963    query is_promotable_const_fn(key: DefId) -> bool {
964        desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
965    }
966
967    /// The body of the coroutine, modified to take its upvars by move rather than by ref.
968    ///
969    /// This is used by coroutine-closures, which must return a different flavor of coroutine
970    /// when called using `AsyncFnOnce::call_once`. It is produced by the `ByMoveBody` pass which
971    /// is run right after building the initial MIR, and will only be populated for coroutines
972    /// which come out of the async closure desugaring.
973    query coroutine_by_move_body_def_id(def_id: DefId) -> DefId {
974        desc { |tcx| "looking up the coroutine by-move body for `{}`", tcx.def_path_str(def_id) }
975        separate_provide_extern
976    }
977
978    /// Returns `Some(coroutine_kind)` if the node pointed to by `def_id` is a coroutine.
979    query coroutine_kind(def_id: DefId) -> Option<hir::CoroutineKind> {
980        desc { |tcx| "looking up coroutine kind of `{}`", tcx.def_path_str(def_id) }
981        separate_provide_extern
982        feedable
983    }
984
985    query coroutine_for_closure(def_id: DefId) -> DefId {
986        desc { |_tcx| "Given a coroutine-closure def id, return the def id of the coroutine returned by it" }
987        separate_provide_extern
988    }
989
990    query coroutine_hidden_types(
991        def_id: DefId
992    ) -> ty::EarlyBinder<'tcx, ty::Binder<'tcx, ty::CoroutineWitnessTypes<TyCtxt<'tcx>>>> {
993        desc { "looking up the hidden types stored across await points in a coroutine" }
994    }
995
996    /// Gets a map with the variances of every item in the local crate.
997    ///
998    /// <div class="warning">
999    ///
1000    /// **Do not call this query** directly, use [`Self::variances_of`] instead.
1001    ///
1002    /// </div>
1003    query crate_variances(_: ()) -> &'tcx ty::CrateVariancesMap<'tcx> {
1004        arena_cache
1005        desc { "computing the variances for items in this crate" }
1006    }
1007
1008    /// Returns the (inferred) variances of the item given by `DefId`.
1009    ///
1010    /// The list of variances corresponds to the list of (early-bound) generic
1011    /// parameters of the item (including its parents).
1012    ///
1013    /// **Tip**: You can use `#[rustc_variance]` on an item to basically print the
1014    /// result of this query for use in UI tests or for debugging purposes.
1015    query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
1016        desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
1017        cache_on_disk_if { def_id.is_local() }
1018        separate_provide_extern
1019        cycle_delay_bug
1020    }
1021
1022    /// Gets a map with the inferred outlives-predicates of every item in the local crate.
1023    ///
1024    /// <div class="warning">
1025    ///
1026    /// **Do not call this query** directly, use [`Self::inferred_outlives_of`] instead.
1027    ///
1028    /// </div>
1029    query inferred_outlives_crate(_: ()) -> &'tcx ty::CratePredicatesMap<'tcx> {
1030        arena_cache
1031        desc { "computing the inferred outlives-predicates for items in this crate" }
1032    }
1033
1034    /// Maps from an impl/trait or struct/variant `DefId`
1035    /// to a list of the `DefId`s of its associated items or fields.
1036    query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
1037        desc { |tcx| "collecting associated items or fields of `{}`", tcx.def_path_str(key) }
1038        cache_on_disk_if { key.is_local() }
1039        separate_provide_extern
1040    }
1041
1042    /// Maps from a trait/impl item to the trait/impl item "descriptor".
1043    query associated_item(key: DefId) -> ty::AssocItem {
1044        desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
1045        cache_on_disk_if { key.is_local() }
1046        separate_provide_extern
1047        feedable
1048    }
1049
1050    /// Collects the associated items defined on a trait or impl.
1051    query associated_items(key: DefId) -> &'tcx ty::AssocItems {
1052        arena_cache
1053        desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
1054    }
1055
1056    /// Maps from associated items on a trait to the corresponding associated
1057    /// item on the impl specified by `impl_id`.
1058    ///
1059    /// For example, with the following code
1060    ///
1061    /// ```
1062    /// struct Type {}
1063    ///                         // DefId
1064    /// trait Trait {           // trait_id
1065    ///     fn f();             // trait_f
1066    ///     fn g() {}           // trait_g
1067    /// }
1068    ///
1069    /// impl Trait for Type {   // impl_id
1070    ///     fn f() {}           // impl_f
1071    ///     fn g() {}           // impl_g
1072    /// }
1073    /// ```
1074    ///
1075    /// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
1076    ///`{ trait_f: impl_f, trait_g: impl_g }`
1077    query impl_item_implementor_ids(impl_id: DefId) -> &'tcx DefIdMap<DefId> {
1078        arena_cache
1079        desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
1080    }
1081
1082    /// Given `fn_def_id` of a trait or of an impl that implements a given trait:
1083    /// if `fn_def_id` is the def id of a function defined inside a trait, then it creates and returns
1084    /// the associated items that correspond to each impl trait in return position for that trait.
1085    /// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
1086    /// creates and returns the associated items that correspond to each impl trait in return position
1087    /// of the implemented trait.
1088    query associated_types_for_impl_traits_in_associated_fn(fn_def_id: DefId) -> &'tcx [DefId] {
1089        desc { |tcx| "creating associated items for opaque types returned by `{}`", tcx.def_path_str(fn_def_id) }
1090        cache_on_disk_if { fn_def_id.is_local() }
1091        separate_provide_extern
1092    }
1093
1094    /// Given an `impl_id`, return the trait it implements along with some header information.
1095    /// Return `None` if this is an inherent impl.
1096    query impl_trait_header(impl_id: DefId) -> Option<ty::ImplTraitHeader<'tcx>> {
1097        desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
1098        cache_on_disk_if { impl_id.is_local() }
1099        separate_provide_extern
1100    }
1101
1102    /// Given an `impl_def_id`, return true if the self type is guaranteed to be unsized due
1103    /// to either being one of the built-in unsized types (str/slice/dyn) or to be a struct
1104    /// whose tail is one of those types.
1105    query impl_self_is_guaranteed_unsized(impl_def_id: DefId) -> bool {
1106        desc { |tcx| "computing whether `{}` has a guaranteed unsized self type", tcx.def_path_str(impl_def_id) }
1107    }
1108
1109    /// Maps a `DefId` of a type to a list of its inherent impls.
1110    /// Contains implementations of methods that are inherent to a type.
1111    /// Methods in these implementations don't need to be exported.
1112    query inherent_impls(key: DefId) -> &'tcx [DefId] {
1113        desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
1114        cache_on_disk_if { key.is_local() }
1115        separate_provide_extern
1116    }
1117
1118    query incoherent_impls(key: SimplifiedType) -> &'tcx [DefId] {
1119        desc { |tcx| "collecting all inherent impls for `{:?}`", key }
1120    }
1121
1122    /// Unsafety-check this `LocalDefId`.
1123    query check_unsafety(key: LocalDefId) {
1124        desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
1125    }
1126
1127    /// Checks well-formedness of tail calls (`become f()`).
1128    query check_tail_calls(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
1129        desc { |tcx| "tail-call-checking `{}`", tcx.def_path_str(key) }
1130        return_result_from_ensure_ok
1131    }
1132
1133    /// Returns the types assumed to be well formed while "inside" of the given item.
1134    ///
1135    /// Note that we've liberated the late bound regions of function signatures, so
1136    /// this can not be used to check whether these types are well formed.
1137    query assumed_wf_types(key: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] {
1138        desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
1139    }
1140
1141    /// We need to store the assumed_wf_types for an RPITIT so that impls of foreign
1142    /// traits with return-position impl trait in traits can inherit the right wf types.
1143    query assumed_wf_types_for_rpitit(key: DefId) -> &'tcx [(Ty<'tcx>, Span)] {
1144        desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
1145        separate_provide_extern
1146    }
1147
1148    /// Computes the signature of the function.
1149    query fn_sig(key: DefId) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> {
1150        desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
1151        cache_on_disk_if { key.is_local() }
1152        separate_provide_extern
1153        cycle_delay_bug
1154    }
1155
1156    /// Performs lint checking for the module.
1157    query lint_mod(key: LocalModDefId) {
1158        desc { |tcx| "linting {}", describe_as_module(key, tcx) }
1159    }
1160
1161    query check_unused_traits(_: ()) {
1162        desc { "checking unused trait imports in crate" }
1163    }
1164
1165    /// Checks the attributes in the module.
1166    query check_mod_attrs(key: LocalModDefId) {
1167        desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
1168    }
1169
1170    /// Checks for uses of unstable APIs in the module.
1171    query check_mod_unstable_api_usage(key: LocalModDefId) {
1172        desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
1173    }
1174
1175    query check_mod_privacy(key: LocalModDefId) {
1176        desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
1177    }
1178
1179    query check_liveness(key: LocalDefId) {
1180        desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key) }
1181    }
1182
1183    /// Return the live symbols in the crate for dead code check.
1184    ///
1185    /// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and
1186    /// their respective impl (i.e., part of the derive macro)
1187    query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
1188        LocalDefIdSet,
1189        LocalDefIdMap<FxIndexSet<(DefId, DefId)>>
1190    ) {
1191        arena_cache
1192        desc { "finding live symbols in crate" }
1193    }
1194
1195    query check_mod_deathness(key: LocalModDefId) {
1196        desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
1197    }
1198
1199    query check_type_wf(key: ()) -> Result<(), ErrorGuaranteed> {
1200        desc { "checking that types are well-formed" }
1201        return_result_from_ensure_ok
1202    }
1203
1204    /// Caches `CoerceUnsized` kinds for impls on custom types.
1205    query coerce_unsized_info(key: DefId) -> Result<ty::adjustment::CoerceUnsizedInfo, ErrorGuaranteed> {
1206        desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
1207        cache_on_disk_if { key.is_local() }
1208        separate_provide_extern
1209        return_result_from_ensure_ok
1210    }
1211
1212    query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
1213        desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
1214        cache_on_disk_if(tcx) { !tcx.is_typeck_child(key.to_def_id()) }
1215    }
1216
1217    query used_trait_imports(key: LocalDefId) -> &'tcx UnordSet<LocalDefId> {
1218        desc { |tcx| "finding used_trait_imports `{}`", tcx.def_path_str(key) }
1219        cache_on_disk_if { true }
1220    }
1221
1222    query coherent_trait(def_id: DefId) -> Result<(), ErrorGuaranteed> {
1223        desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
1224        return_result_from_ensure_ok
1225    }
1226
1227    /// Borrow-checks the given typeck root, e.g. functions, const/static items,
1228    /// and its children, e.g. closures, inline consts.
1229    query mir_borrowck(key: LocalDefId) -> Result<&'tcx mir::ConcreteOpaqueTypes<'tcx>, ErrorGuaranteed> {
1230        desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
1231    }
1232
1233    /// Gets a complete map from all types to their inherent impls.
1234    ///
1235    /// <div class="warning">
1236    ///
1237    /// **Not meant to be used** directly outside of coherence.
1238    ///
1239    /// </div>
1240    query crate_inherent_impls(k: ()) -> (&'tcx CrateInherentImpls, Result<(), ErrorGuaranteed>) {
1241        desc { "finding all inherent impls defined in crate" }
1242    }
1243
1244    /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
1245    ///
1246    /// <div class="warning">
1247    ///
1248    /// **Not meant to be used** directly outside of coherence.
1249    ///
1250    /// </div>
1251    query crate_inherent_impls_validity_check(_: ()) -> Result<(), ErrorGuaranteed> {
1252        desc { "check for inherent impls that should not be defined in crate" }
1253        return_result_from_ensure_ok
1254    }
1255
1256    /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
1257    ///
1258    /// <div class="warning">
1259    ///
1260    /// **Not meant to be used** directly outside of coherence.
1261    ///
1262    /// </div>
1263    query crate_inherent_impls_overlap_check(_: ()) -> Result<(), ErrorGuaranteed> {
1264        desc { "check for overlap between inherent impls defined in this crate" }
1265        return_result_from_ensure_ok
1266    }
1267
1268    /// Checks whether all impls in the crate pass the overlap check, returning
1269    /// which impls fail it. If all impls are correct, the returned slice is empty.
1270    query orphan_check_impl(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
1271        desc { |tcx|
1272            "checking whether impl `{}` follows the orphan rules",
1273            tcx.def_path_str(key),
1274        }
1275        return_result_from_ensure_ok
1276    }
1277
1278    /// Return the set of (transitive) callees that may result in a recursive call to `key`.
1279    query mir_callgraph_cyclic(key: LocalDefId) -> &'tcx UnordSet<LocalDefId> {
1280        fatal_cycle
1281        arena_cache
1282        desc { |tcx|
1283            "computing (transitive) callees of `{}` that may recurse",
1284            tcx.def_path_str(key),
1285        }
1286        cache_on_disk_if { true }
1287    }
1288
1289    /// Obtain all the calls into other local functions
1290    query mir_inliner_callees(key: ty::InstanceKind<'tcx>) -> &'tcx [(DefId, GenericArgsRef<'tcx>)] {
1291        fatal_cycle
1292        desc { |tcx|
1293            "computing all local function calls in `{}`",
1294            tcx.def_path_str(key.def_id()),
1295        }
1296    }
1297
1298    /// Computes the tag (if any) for a given type and variant.
1299    ///
1300    /// `None` means that the variant doesn't need a tag (because it is niched).
1301    ///
1302    /// # Panics
1303    ///
1304    /// This query will panic for uninhabited variants and if the passed type is not an enum.
1305    query tag_for_variant(
1306        key: PseudoCanonicalInput<'tcx, (Ty<'tcx>, abi::VariantIdx)>,
1307    ) -> Option<ty::ScalarInt> {
1308        desc { "computing variant tag for enum" }
1309    }
1310
1311    /// Evaluates a constant and returns the computed allocation.
1312    ///
1313    /// <div class="warning">
1314    ///
1315    /// **Do not call this query** directly, use [`Self::eval_to_const_value_raw`] or
1316    /// [`Self::eval_to_valtree`] instead.
1317    ///
1318    /// </div>
1319    query eval_to_allocation_raw(key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>)
1320        -> EvalToAllocationRawResult<'tcx> {
1321        desc { |tcx|
1322            "const-evaluating + checking `{}`",
1323            key.value.display(tcx)
1324        }
1325        cache_on_disk_if { true }
1326    }
1327
1328    /// Evaluate a static's initializer, returning the allocation of the initializer's memory.
1329    query eval_static_initializer(key: DefId) -> EvalStaticInitializerRawResult<'tcx> {
1330        desc { |tcx|
1331            "evaluating initializer of static `{}`",
1332            tcx.def_path_str(key)
1333        }
1334        cache_on_disk_if { key.is_local() }
1335        separate_provide_extern
1336        feedable
1337    }
1338
1339    /// Evaluates const items or anonymous constants[^1] into a representation
1340    /// suitable for the type system and const generics.
1341    ///
1342    /// <div class="warning">
1343    ///
1344    /// **Do not call this** directly, use one of the following wrappers:
1345    /// [`TyCtxt::const_eval_poly`], [`TyCtxt::const_eval_resolve`],
1346    /// [`TyCtxt::const_eval_instance`], or [`TyCtxt::const_eval_global_id`].
1347    ///
1348    /// </div>
1349    ///
1350    /// [^1]: Such as enum variant explicit discriminants or array lengths.
1351    query eval_to_const_value_raw(key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>)
1352        -> EvalToConstValueResult<'tcx> {
1353        desc { |tcx|
1354            "simplifying constant for the type system `{}`",
1355            key.value.display(tcx)
1356        }
1357        depth_limit
1358        cache_on_disk_if { true }
1359    }
1360
1361    /// Evaluate a constant and convert it to a type level constant or
1362    /// return `None` if that is not possible.
1363    query eval_to_valtree(
1364        key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>
1365    ) -> EvalToValTreeResult<'tcx> {
1366        desc { "evaluating type-level constant" }
1367    }
1368
1369    /// Converts a type-level constant value into a MIR constant value.
1370    query valtree_to_const_val(key: ty::Value<'tcx>) -> mir::ConstValue<'tcx> {
1371        desc { "converting type-level constant value to MIR constant value"}
1372    }
1373
1374    /// Destructures array, ADT or tuple constants into the constants
1375    /// of their fields.
1376    query destructure_const(key: ty::Const<'tcx>) -> ty::DestructuredConst<'tcx> {
1377        desc { "destructuring type level constant"}
1378    }
1379
1380    // FIXME get rid of this with valtrees
1381    query lit_to_const(
1382        key: LitToConstInput<'tcx>
1383    ) -> ty::Const<'tcx> {
1384        desc { "converting literal to const" }
1385    }
1386
1387    query check_match(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
1388        desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
1389        return_result_from_ensure_ok
1390    }
1391
1392    /// Performs part of the privacy check and computes effective visibilities.
1393    query effective_visibilities(_: ()) -> &'tcx EffectiveVisibilities {
1394        eval_always
1395        desc { "checking effective visibilities" }
1396    }
1397    query check_private_in_public(_: ()) {
1398        eval_always
1399        desc { "checking for private elements in public interfaces" }
1400    }
1401
1402    query reachable_set(_: ()) -> &'tcx LocalDefIdSet {
1403        arena_cache
1404        desc { "reachability" }
1405        cache_on_disk_if { true }
1406    }
1407
1408    /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
1409    /// in the case of closures, this will be redirected to the enclosing function.
1410    query region_scope_tree(def_id: DefId) -> &'tcx crate::middle::region::ScopeTree {
1411        desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
1412    }
1413
1414    /// Generates a MIR body for the shim.
1415    query mir_shims(key: ty::InstanceKind<'tcx>) -> &'tcx mir::Body<'tcx> {
1416        arena_cache
1417        desc {
1418            |tcx| "generating MIR shim for `{}`, instance={:?}",
1419            tcx.def_path_str(key.def_id()),
1420            key
1421        }
1422    }
1423
1424    /// The `symbol_name` query provides the symbol name for calling a
1425    /// given instance from the local crate. In particular, it will also
1426    /// look up the correct symbol name of instances from upstream crates.
1427    query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
1428        desc { "computing the symbol for `{}`", key }
1429        cache_on_disk_if { true }
1430    }
1431
1432    query def_kind(def_id: DefId) -> DefKind {
1433        desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
1434        cache_on_disk_if { def_id.is_local() }
1435        separate_provide_extern
1436        feedable
1437    }
1438
1439    /// Gets the span for the definition.
1440    query def_span(def_id: DefId) -> Span {
1441        desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
1442        cache_on_disk_if { def_id.is_local() }
1443        separate_provide_extern
1444        feedable
1445    }
1446
1447    /// Gets the span for the identifier of the definition.
1448    query def_ident_span(def_id: DefId) -> Option<Span> {
1449        desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
1450        cache_on_disk_if { def_id.is_local() }
1451        separate_provide_extern
1452        feedable
1453    }
1454
1455    query lookup_stability(def_id: DefId) -> Option<attr::Stability> {
1456        desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
1457        cache_on_disk_if { def_id.is_local() }
1458        separate_provide_extern
1459    }
1460
1461    query lookup_const_stability(def_id: DefId) -> Option<attr::ConstStability> {
1462        desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
1463        cache_on_disk_if { def_id.is_local() }
1464        separate_provide_extern
1465    }
1466
1467    query lookup_default_body_stability(def_id: DefId) -> Option<attr::DefaultBodyStability> {
1468        desc { |tcx| "looking up default body stability of `{}`", tcx.def_path_str(def_id) }
1469        separate_provide_extern
1470    }
1471
1472    query should_inherit_track_caller(def_id: DefId) -> bool {
1473        desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
1474    }
1475
1476    query inherited_align(def_id: DefId) -> Option<Align> {
1477        desc { |tcx| "computing inherited_align of `{}`", tcx.def_path_str(def_id) }
1478    }
1479
1480    query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
1481        desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
1482        cache_on_disk_if { def_id.is_local() }
1483        separate_provide_extern
1484    }
1485
1486    /// Determines whether an item is annotated with `#[doc(hidden)]`.
1487    query is_doc_hidden(def_id: DefId) -> bool {
1488        desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) }
1489        separate_provide_extern
1490    }
1491
1492    /// Determines whether an item is annotated with `#[doc(notable_trait)]`.
1493    query is_doc_notable_trait(def_id: DefId) -> bool {
1494        desc { |tcx| "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) }
1495    }
1496
1497    /// Returns the attributes on the item at `def_id`.
1498    ///
1499    /// Do not use this directly, use `tcx.get_attrs` instead.
1500    query attrs_for_def(def_id: DefId) -> &'tcx [hir::Attribute] {
1501        desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
1502        separate_provide_extern
1503    }
1504
1505    query codegen_fn_attrs(def_id: DefId) -> &'tcx CodegenFnAttrs {
1506        desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
1507        arena_cache
1508        cache_on_disk_if { def_id.is_local() }
1509        separate_provide_extern
1510        feedable
1511    }
1512
1513    query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet<Symbol> {
1514        desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
1515    }
1516
1517    query fn_arg_idents(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] {
1518        desc { |tcx| "looking up function parameter identifiers for `{}`", tcx.def_path_str(def_id) }
1519        separate_provide_extern
1520    }
1521
1522    /// Gets the rendered value of the specified constant or associated constant.
1523    /// Used by rustdoc.
1524    query rendered_const(def_id: DefId) -> &'tcx String {
1525        arena_cache
1526        desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) }
1527        separate_provide_extern
1528    }
1529
1530    /// Gets the rendered precise capturing args for an opaque for use in rustdoc.
1531    query rendered_precise_capturing_args(def_id: DefId) -> Option<&'tcx [PreciseCapturingArgKind<Symbol, Symbol>]> {
1532        desc { |tcx| "rendering precise capturing args for `{}`", tcx.def_path_str(def_id) }
1533        separate_provide_extern
1534    }
1535
1536    query impl_parent(def_id: DefId) -> Option<DefId> {
1537        desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
1538        separate_provide_extern
1539    }
1540
1541    query is_ctfe_mir_available(key: DefId) -> bool {
1542        desc { |tcx| "checking if item has CTFE MIR available: `{}`", tcx.def_path_str(key) }
1543        cache_on_disk_if { key.is_local() }
1544        separate_provide_extern
1545    }
1546    query is_mir_available(key: DefId) -> bool {
1547        desc { |tcx| "checking if item has MIR available: `{}`", tcx.def_path_str(key) }
1548        cache_on_disk_if { key.is_local() }
1549        separate_provide_extern
1550    }
1551
1552    query own_existential_vtable_entries(
1553        key: DefId
1554    ) -> &'tcx [DefId] {
1555        desc { |tcx| "finding all existential vtable entries for trait `{}`", tcx.def_path_str(key) }
1556    }
1557
1558    query vtable_entries(key: ty::TraitRef<'tcx>)
1559                        -> &'tcx [ty::VtblEntry<'tcx>] {
1560        desc { |tcx| "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id) }
1561    }
1562
1563    query first_method_vtable_slot(key: ty::TraitRef<'tcx>) -> usize {
1564        desc { |tcx| "finding the slot within the vtable of `{}` for the implementation of `{}`", key.self_ty(), key.print_only_trait_name() }
1565    }
1566
1567    query supertrait_vtable_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize> {
1568        desc { |tcx| "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable",
1569            key.1, key.0 }
1570    }
1571
1572    query vtable_allocation(key: (Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
1573        desc { |tcx| "vtable const allocation for <{} as {}>",
1574            key.0,
1575            key.1.map(|trait_ref| format!("{trait_ref}")).unwrap_or_else(|| "_".to_owned())
1576        }
1577    }
1578
1579    query codegen_select_candidate(
1580        key: PseudoCanonicalInput<'tcx, ty::TraitRef<'tcx>>
1581    ) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
1582        cache_on_disk_if { true }
1583        desc { |tcx| "computing candidate for `{}`", key.value }
1584    }
1585
1586    /// Return all `impl` blocks in the current crate.
1587    query all_local_trait_impls(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexMap<DefId, Vec<LocalDefId>> {
1588        desc { "finding local trait impls" }
1589    }
1590
1591    /// Return all `impl` blocks of the given trait in the current crate.
1592    query local_trait_impls(trait_id: DefId) -> &'tcx [LocalDefId] {
1593        desc { "finding local trait impls of `{}`", tcx.def_path_str(trait_id) }
1594    }
1595
1596    /// Given a trait `trait_id`, return all known `impl` blocks.
1597    query trait_impls_of(trait_id: DefId) -> &'tcx ty::trait_def::TraitImpls {
1598        arena_cache
1599        desc { |tcx| "finding trait impls of `{}`", tcx.def_path_str(trait_id) }
1600    }
1601
1602    query specialization_graph_of(trait_id: DefId) -> Result<&'tcx specialization_graph::Graph, ErrorGuaranteed> {
1603        desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
1604        cache_on_disk_if { true }
1605        return_result_from_ensure_ok
1606    }
1607    query dyn_compatibility_violations(trait_id: DefId) -> &'tcx [DynCompatibilityViolation] {
1608        desc { |tcx| "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) }
1609    }
1610    query is_dyn_compatible(trait_id: DefId) -> bool {
1611        desc { |tcx| "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) }
1612    }
1613
1614    /// Gets the ParameterEnvironment for a given item; this environment
1615    /// will be in "user-facing" mode, meaning that it is suitable for
1616    /// type-checking etc, and it does not normalize specializable
1617    /// associated types.
1618    ///
1619    /// You should almost certainly not use this. If you already have an InferCtxt, then
1620    /// you should also probably have a `ParamEnv` from when it was built. If you don't,
1621    /// then you should take a `TypingEnv` to ensure that you handle opaque types correctly.
1622    query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
1623        desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1624        feedable
1625    }
1626
1627    /// Like `param_env`, but returns the `ParamEnv` after all opaque types have been
1628    /// replaced with their hidden type. This is used in the old trait solver
1629    /// when in `PostAnalysis` mode and should not be called directly.
1630    query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> {
1631        desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
1632    }
1633
1634    /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1635    /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1636    query is_copy_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1637        desc { "computing whether `{}` is `Copy`", env.value }
1638    }
1639    /// Trait selection queries. These are best used by invoking `ty.is_use_cloned_modulo_regions()`,
1640    /// `ty.is_use_cloned()`, etc, since that will prune the environment where possible.
1641    query is_use_cloned_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1642        desc { "computing whether `{}` is `UseCloned`", env.value }
1643    }
1644    /// Query backing `Ty::is_sized`.
1645    query is_sized_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1646        desc { "computing whether `{}` is `Sized`", env.value }
1647    }
1648    /// Query backing `Ty::is_freeze`.
1649    query is_freeze_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1650        desc { "computing whether `{}` is freeze", env.value }
1651    }
1652    /// Query backing `Ty::is_unpin`.
1653    query is_unpin_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1654        desc { "computing whether `{}` is `Unpin`", env.value }
1655    }
1656    /// Query backing `Ty::is_async_drop`.
1657    query is_async_drop_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1658        desc { "computing whether `{}` is `AsyncDrop`", env.value }
1659    }
1660    /// Query backing `Ty::needs_drop`.
1661    query needs_drop_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1662        desc { "computing whether `{}` needs drop", env.value }
1663    }
1664    /// Query backing `Ty::needs_async_drop`.
1665    query needs_async_drop_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1666        desc { "computing whether `{}` needs async drop", env.value }
1667    }
1668    /// Query backing `Ty::has_significant_drop_raw`.
1669    query has_significant_drop_raw(env: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
1670        desc { "computing whether `{}` has a significant drop", env.value }
1671    }
1672
1673    /// Query backing `Ty::is_structural_eq_shallow`.
1674    ///
1675    /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1676    /// correctly.
1677    query has_structural_eq_impl(ty: Ty<'tcx>) -> bool {
1678        desc {
1679            "computing whether `{}` implements `StructuralPartialEq`",
1680            ty
1681        }
1682    }
1683
1684    /// A list of types where the ADT requires drop if and only if any of
1685    /// those types require drop. If the ADT is known to always need drop
1686    /// then `Err(AlwaysRequiresDrop)` is returned.
1687    query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1688        desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1689        cache_on_disk_if { true }
1690    }
1691
1692    /// A list of types where the ADT requires async drop if and only if any of
1693    /// those types require async drop. If the ADT is known to always need async drop
1694    /// then `Err(AlwaysRequiresDrop)` is returned.
1695    query adt_async_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1696        desc { |tcx| "computing when `{}` needs async drop", tcx.def_path_str(def_id) }
1697        cache_on_disk_if { true }
1698    }
1699
1700    /// A list of types where the ADT requires drop if and only if any of those types
1701    /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1702    /// is considered to not be significant. A drop is significant if it is implemented
1703    /// by the user or does anything that will have any observable behavior (other than
1704    /// freeing up memory). If the ADT is known to have a significant destructor then
1705    /// `Err(AlwaysRequiresDrop)` is returned.
1706    query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1707        desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1708    }
1709
1710    /// Returns a list of types which (a) have a potentially significant destructor
1711    /// and (b) may be dropped as a result of dropping a value of some type `ty`
1712    /// (in the given environment).
1713    ///
1714    /// The idea of "significant" drop is somewhat informal and is used only for
1715    /// diagnostics and edition migrations. The idea is that a significant drop may have
1716    /// some visible side-effect on execution; freeing memory is NOT considered a side-effect.
1717    /// The rules are as follows:
1718    /// * Type with no explicit drop impl do not have significant drop.
1719    /// * Types with a drop impl are assumed to have significant drop unless they have a `#[rustc_insignificant_dtor]` annotation.
1720    ///
1721    /// Note that insignificant drop is a "shallow" property. A type like `Vec<LockGuard>` does not
1722    /// have significant drop but the type `LockGuard` does, and so if `ty  = Vec<LockGuard>`
1723    /// then the return value would be `&[LockGuard]`.
1724    /// *IMPORTANT*: *DO NOT* run this query before promoted MIR body is constructed,
1725    /// because this query partially depends on that query.
1726    /// Otherwise, there is a risk of query cycles.
1727    query list_significant_drop_tys(ty: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
1728        desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
1729    }
1730
1731    /// Computes the layout of a type. Note that this implicitly
1732    /// executes in `TypingMode::PostAnalysis`, and will normalize the input type.
1733    query layout_of(
1734        key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>
1735    ) -> Result<ty::layout::TyAndLayout<'tcx>, &'tcx ty::layout::LayoutError<'tcx>> {
1736        depth_limit
1737        desc { "computing layout of `{}`", key.value }
1738        // we emit our own error during query cycle handling
1739        cycle_delay_bug
1740    }
1741
1742    /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1743    ///
1744    /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1745    /// instead, where the instance is an `InstanceKind::Virtual`.
1746    query fn_abi_of_fn_ptr(
1747        key: ty::PseudoCanonicalInput<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1748    ) -> Result<&'tcx rustc_target::callconv::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
1749        desc { "computing call ABI of `{}` function pointers", key.value.0 }
1750    }
1751
1752    /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1753    /// direct calls to an `fn`.
1754    ///
1755    /// NB: that includes virtual calls, which are represented by "direct calls"
1756    /// to an `InstanceKind::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1757    query fn_abi_of_instance(
1758        key: ty::PseudoCanonicalInput<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1759    ) -> Result<&'tcx rustc_target::callconv::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
1760        desc { "computing call ABI of `{}`", key.value.0 }
1761    }
1762
1763    query dylib_dependency_formats(_: CrateNum)
1764                                    -> &'tcx [(CrateNum, LinkagePreference)] {
1765        desc { "getting dylib dependency formats of crate" }
1766        separate_provide_extern
1767    }
1768
1769    query dependency_formats(_: ()) -> &'tcx Arc<crate::middle::dependency_format::Dependencies> {
1770        arena_cache
1771        desc { "getting the linkage format of all dependencies" }
1772    }
1773
1774    query is_compiler_builtins(_: CrateNum) -> bool {
1775        fatal_cycle
1776        desc { "checking if the crate is_compiler_builtins" }
1777        separate_provide_extern
1778    }
1779    query has_global_allocator(_: CrateNum) -> bool {
1780        // This query depends on untracked global state in CStore
1781        eval_always
1782        fatal_cycle
1783        desc { "checking if the crate has_global_allocator" }
1784        separate_provide_extern
1785    }
1786    query has_alloc_error_handler(_: CrateNum) -> bool {
1787        // This query depends on untracked global state in CStore
1788        eval_always
1789        fatal_cycle
1790        desc { "checking if the crate has_alloc_error_handler" }
1791        separate_provide_extern
1792    }
1793    query has_panic_handler(_: CrateNum) -> bool {
1794        fatal_cycle
1795        desc { "checking if the crate has_panic_handler" }
1796        separate_provide_extern
1797    }
1798    query is_profiler_runtime(_: CrateNum) -> bool {
1799        fatal_cycle
1800        desc { "checking if a crate is `#![profiler_runtime]`" }
1801        separate_provide_extern
1802    }
1803    query has_ffi_unwind_calls(key: LocalDefId) -> bool {
1804        desc { |tcx| "checking if `{}` contains FFI-unwind calls", tcx.def_path_str(key) }
1805        cache_on_disk_if { true }
1806    }
1807    query required_panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
1808        fatal_cycle
1809        desc { "getting a crate's required panic strategy" }
1810        separate_provide_extern
1811    }
1812    query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1813        fatal_cycle
1814        desc { "getting a crate's configured panic-in-drop strategy" }
1815        separate_provide_extern
1816    }
1817    query is_no_builtins(_: CrateNum) -> bool {
1818        fatal_cycle
1819        desc { "getting whether a crate has `#![no_builtins]`" }
1820        separate_provide_extern
1821    }
1822    query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1823        fatal_cycle
1824        desc { "getting a crate's symbol mangling version" }
1825        separate_provide_extern
1826    }
1827
1828    query extern_crate(def_id: CrateNum) -> Option<&'tcx ExternCrate> {
1829        eval_always
1830        desc { "getting crate's ExternCrateData" }
1831        separate_provide_extern
1832    }
1833
1834    query specialization_enabled_in(cnum: CrateNum) -> bool {
1835        desc { "checking whether the crate enabled `specialization`/`min_specialization`" }
1836        separate_provide_extern
1837    }
1838
1839    query specializes(_: (DefId, DefId)) -> bool {
1840        desc { "computing whether impls specialize one another" }
1841    }
1842    query in_scope_traits_map(_: hir::OwnerId)
1843        -> Option<&'tcx ItemLocalMap<Box<[TraitCandidate]>>> {
1844        desc { "getting traits in scope at a block" }
1845    }
1846
1847    /// Returns whether the impl or associated function has the `default` keyword.
1848    query defaultness(def_id: DefId) -> hir::Defaultness {
1849        desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
1850        separate_provide_extern
1851        feedable
1852    }
1853
1854    query check_well_formed(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
1855        desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) }
1856        return_result_from_ensure_ok
1857    }
1858
1859    query enforce_impl_non_lifetime_params_are_constrained(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
1860        desc { |tcx| "checking that `{}`'s generics are constrained by the impl header", tcx.def_path_str(key) }
1861        return_result_from_ensure_ok
1862    }
1863
1864    // The `DefId`s of all non-generic functions and statics in the given crate
1865    // that can be reached from outside the crate.
1866    //
1867    // We expect this items to be available for being linked to.
1868    //
1869    // This query can also be called for `LOCAL_CRATE`. In this case it will
1870    // compute which items will be reachable to other crates, taking into account
1871    // the kind of crate that is currently compiled. Crates with only a
1872    // C interface have fewer reachable things.
1873    //
1874    // Does not include external symbols that don't have a corresponding DefId,
1875    // like the compiler-generated `main` function and so on.
1876    query reachable_non_generics(_: CrateNum)
1877        -> &'tcx DefIdMap<SymbolExportInfo> {
1878        arena_cache
1879        desc { "looking up the exported symbols of a crate" }
1880        separate_provide_extern
1881    }
1882    query is_reachable_non_generic(def_id: DefId) -> bool {
1883        desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1884        cache_on_disk_if { def_id.is_local() }
1885        separate_provide_extern
1886    }
1887    query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1888        desc { |tcx|
1889            "checking whether `{}` is reachable from outside the crate",
1890            tcx.def_path_str(def_id),
1891        }
1892    }
1893
1894    /// The entire set of monomorphizations the local crate can safely
1895    /// link to because they are exported from upstream crates. Do
1896    /// not depend on this directly, as its value changes anytime
1897    /// a monomorphization gets added or removed in any upstream
1898    /// crate. Instead use the narrower `upstream_monomorphizations_for`,
1899    /// `upstream_drop_glue_for`, `upstream_async_drop_glue_for`, or,
1900    /// even better, `Instance::upstream_monomorphization()`.
1901    query upstream_monomorphizations(_: ()) -> &'tcx DefIdMap<UnordMap<GenericArgsRef<'tcx>, CrateNum>> {
1902        arena_cache
1903        desc { "collecting available upstream monomorphizations" }
1904    }
1905
1906    /// Returns the set of upstream monomorphizations available for the
1907    /// generic function identified by the given `def_id`. The query makes
1908    /// sure to make a stable selection if the same monomorphization is
1909    /// available in multiple upstream crates.
1910    ///
1911    /// You likely want to call `Instance::upstream_monomorphization()`
1912    /// instead of invoking this query directly.
1913    query upstream_monomorphizations_for(def_id: DefId)
1914        -> Option<&'tcx UnordMap<GenericArgsRef<'tcx>, CrateNum>>
1915    {
1916        desc { |tcx|
1917            "collecting available upstream monomorphizations for `{}`",
1918            tcx.def_path_str(def_id),
1919        }
1920        separate_provide_extern
1921    }
1922
1923    /// Returns the upstream crate that exports drop-glue for the given
1924    /// type (`args` is expected to be a single-item list containing the
1925    /// type one wants drop-glue for).
1926    ///
1927    /// This is a subset of `upstream_monomorphizations_for` in order to
1928    /// increase dep-tracking granularity. Otherwise adding or removing any
1929    /// type with drop-glue in any upstream crate would invalidate all
1930    /// functions calling drop-glue of an upstream type.
1931    ///
1932    /// You likely want to call `Instance::upstream_monomorphization()`
1933    /// instead of invoking this query directly.
1934    ///
1935    /// NOTE: This query could easily be extended to also support other
1936    ///       common functions that have are large set of monomorphizations
1937    ///       (like `Clone::clone` for example).
1938    query upstream_drop_glue_for(args: GenericArgsRef<'tcx>) -> Option<CrateNum> {
1939        desc { "available upstream drop-glue for `{:?}`", args }
1940    }
1941
1942    /// Returns the upstream crate that exports async-drop-glue for
1943    /// the given type (`args` is expected to be a single-item list
1944    /// containing the type one wants async-drop-glue for).
1945    ///
1946    /// This is a subset of `upstream_monomorphizations_for` in order
1947    /// to increase dep-tracking granularity. Otherwise adding or
1948    /// removing any type with async-drop-glue in any upstream crate
1949    /// would invalidate all functions calling async-drop-glue of an
1950    /// upstream type.
1951    ///
1952    /// You likely want to call `Instance::upstream_monomorphization()`
1953    /// instead of invoking this query directly.
1954    ///
1955    /// NOTE: This query could easily be extended to also support other
1956    ///       common functions that have are large set of monomorphizations
1957    ///       (like `Clone::clone` for example).
1958    query upstream_async_drop_glue_for(args: GenericArgsRef<'tcx>) -> Option<CrateNum> {
1959        desc { "available upstream async-drop-glue for `{:?}`", args }
1960    }
1961
1962    /// Returns a list of all `extern` blocks of a crate.
1963    query foreign_modules(_: CrateNum) -> &'tcx FxIndexMap<DefId, ForeignModule> {
1964        arena_cache
1965        desc { "looking up the foreign modules of a linked crate" }
1966        separate_provide_extern
1967    }
1968
1969    /// Lint against `extern fn` declarations having incompatible types.
1970    query clashing_extern_declarations(_: ()) {
1971        desc { "checking `extern fn` declarations are compatible" }
1972    }
1973
1974    /// Identifies the entry-point (e.g., the `main` function) for a given
1975    /// crate, returning `None` if there is no entry point (such as for library crates).
1976    query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
1977        desc { "looking up the entry function of a crate" }
1978    }
1979
1980    /// Finds the `rustc_proc_macro_decls` item of a crate.
1981    query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1982        desc { "looking up the proc macro declarations for a crate" }
1983    }
1984
1985    // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1986    // Changing the name should cause a compiler error, but in case that changes, be aware.
1987    //
1988    // The hash should not be calculated before the `analysis` pass is complete, specifically
1989    // until `tcx.untracked().definitions.freeze()` has been called, otherwise if incremental
1990    // compilation is enabled calculating this hash can freeze this structure too early in
1991    // compilation and cause subsequent crashes when attempting to write to `definitions`
1992    query crate_hash(_: CrateNum) -> Svh {
1993        eval_always
1994        desc { "looking up the hash a crate" }
1995        separate_provide_extern
1996    }
1997
1998    /// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
1999    query crate_host_hash(_: CrateNum) -> Option<Svh> {
2000        eval_always
2001        desc { "looking up the hash of a host version of a crate" }
2002        separate_provide_extern
2003    }
2004
2005    /// Gets the extra data to put in each output filename for a crate.
2006    /// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
2007    query extra_filename(_: CrateNum) -> &'tcx String {
2008        arena_cache
2009        eval_always
2010        desc { "looking up the extra filename for a crate" }
2011        separate_provide_extern
2012    }
2013
2014    /// Gets the paths where the crate came from in the file system.
2015    query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
2016        arena_cache
2017        eval_always
2018        desc { "looking up the paths for extern crates" }
2019        separate_provide_extern
2020    }
2021
2022    /// Given a crate and a trait, look up all impls of that trait in the crate.
2023    /// Return `(impl_id, self_ty)`.
2024    query implementations_of_trait(_: (CrateNum, DefId)) -> &'tcx [(DefId, Option<SimplifiedType>)] {
2025        desc { "looking up implementations of a trait in a crate" }
2026        separate_provide_extern
2027    }
2028
2029    /// Collects all incoherent impls for the given crate and type.
2030    ///
2031    /// Do not call this directly, but instead use the `incoherent_impls` query.
2032    /// This query is only used to get the data necessary for that query.
2033    query crate_incoherent_impls(key: (CrateNum, SimplifiedType)) -> &'tcx [DefId] {
2034        desc { |tcx| "collecting all impls for a type in a crate" }
2035        separate_provide_extern
2036    }
2037
2038    /// Get the corresponding native library from the `native_libraries` query
2039    query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
2040        desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
2041    }
2042
2043    query inherit_sig_for_delegation_item(def_id: LocalDefId) -> &'tcx [Ty<'tcx>] {
2044        desc { "inheriting delegation signature" }
2045    }
2046
2047    /// Does lifetime resolution on items. Importantly, we can't resolve
2048    /// lifetimes directly on things like trait methods, because of trait params.
2049    /// See `rustc_resolve::late::lifetimes` for details.
2050    query resolve_bound_vars(owner_id: hir::OwnerId) -> &'tcx ResolveBoundVars {
2051        arena_cache
2052        desc { |tcx| "resolving lifetimes for `{}`", tcx.def_path_str(owner_id) }
2053    }
2054    query named_variable_map(owner_id: hir::OwnerId) -> &'tcx SortedMap<ItemLocalId, ResolvedArg> {
2055        desc { |tcx| "looking up a named region inside `{}`", tcx.def_path_str(owner_id) }
2056    }
2057    query is_late_bound_map(owner_id: hir::OwnerId) -> Option<&'tcx FxIndexSet<ItemLocalId>> {
2058        desc { |tcx| "testing if a region is late bound inside `{}`", tcx.def_path_str(owner_id) }
2059    }
2060    /// Returns the *default lifetime* to be used if a trait object type were to be passed for
2061    /// the type parameter given by `DefId`.
2062    ///
2063    /// **Tip**: You can use `#[rustc_object_lifetime_default]` on an item to basically
2064    /// print the result of this query for use in UI tests or for debugging purposes.
2065    ///
2066    /// # Examples
2067    ///
2068    /// - For `T` in `struct Foo<'a, T: 'a>(&'a T);`, this would be `Param('a)`
2069    /// - For `T` in `struct Bar<'a, T>(&'a T);`, this would be `Empty`
2070    ///
2071    /// # Panics
2072    ///
2073    /// This query will panic if the given definition is not a type parameter.
2074    query object_lifetime_default(def_id: DefId) -> ObjectLifetimeDefault {
2075        desc { "looking up lifetime defaults for type parameter `{}`", tcx.def_path_str(def_id) }
2076        separate_provide_extern
2077    }
2078    query late_bound_vars_map(owner_id: hir::OwnerId)
2079        -> &'tcx SortedMap<ItemLocalId, Vec<ty::BoundVariableKind>> {
2080        desc { |tcx| "looking up late bound vars inside `{}`", tcx.def_path_str(owner_id) }
2081    }
2082    /// For an opaque type, return the list of (captured lifetime, inner generic param).
2083    /// ```ignore (illustrative)
2084    /// fn foo<'a: 'a, 'b, T>(&'b u8) -> impl Into<Self> + 'b { ... }
2085    /// ```
2086    ///
2087    /// We would return `[('a, '_a), ('b, '_b)]`, with `'a` early-bound and `'b` late-bound.
2088    ///
2089    /// After hir_ty_lowering, we get:
2090    /// ```ignore (pseudo-code)
2091    /// opaque foo::<'a>::opaque<'_a, '_b>: Into<Foo<'_a>> + '_b;
2092    ///                          ^^^^^^^^ inner generic params
2093    /// fn foo<'a>: for<'b> fn(&'b u8) -> foo::<'a>::opaque::<'a, 'b>
2094    ///                                                       ^^^^^^ captured lifetimes
2095    /// ```
2096    query opaque_captured_lifetimes(def_id: LocalDefId) -> &'tcx [(ResolvedArg, LocalDefId)] {
2097        desc { |tcx| "listing captured lifetimes for opaque `{}`", tcx.def_path_str(def_id) }
2098    }
2099
2100    /// Computes the visibility of the provided `def_id`.
2101    ///
2102    /// If the item from the `def_id` doesn't have a visibility, it will panic. For example
2103    /// a generic type parameter will panic if you call this method on it:
2104    ///
2105    /// ```
2106    /// use std::fmt::Debug;
2107    ///
2108    /// pub trait Foo<T: Debug> {}
2109    /// ```
2110    ///
2111    /// In here, if you call `visibility` on `T`, it'll panic.
2112    query visibility(def_id: DefId) -> ty::Visibility<DefId> {
2113        desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
2114        separate_provide_extern
2115        feedable
2116    }
2117
2118    query inhabited_predicate_adt(key: DefId) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
2119        desc { "computing the uninhabited predicate of `{:?}`", key }
2120    }
2121
2122    /// Do not call this query directly: invoke `Ty::inhabited_predicate` instead.
2123    query inhabited_predicate_type(key: Ty<'tcx>) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
2124        desc { "computing the uninhabited predicate of `{}`", key }
2125    }
2126
2127    query dep_kind(_: CrateNum) -> CrateDepKind {
2128        eval_always
2129        desc { "fetching what a dependency looks like" }
2130        separate_provide_extern
2131    }
2132
2133    /// Gets the name of the crate.
2134    query crate_name(_: CrateNum) -> Symbol {
2135        feedable
2136        desc { "fetching what a crate is named" }
2137        separate_provide_extern
2138    }
2139    query module_children(def_id: DefId) -> &'tcx [ModChild] {
2140        desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) }
2141        separate_provide_extern
2142    }
2143    query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
2144        desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id) }
2145    }
2146
2147    /// Gets the number of definitions in a foreign crate.
2148    ///
2149    /// This allows external tools to iterate over all definitions in a foreign crate.
2150    ///
2151    /// This should never be used for the local crate, instead use `iter_local_def_id`.
2152    query num_extern_def_ids(_: CrateNum) -> usize {
2153        desc { "fetching the number of definitions in a crate" }
2154        separate_provide_extern
2155    }
2156
2157    query lib_features(_: CrateNum) -> &'tcx LibFeatures {
2158        desc { "calculating the lib features defined in a crate" }
2159        separate_provide_extern
2160        arena_cache
2161    }
2162    query stability_implications(_: CrateNum) -> &'tcx UnordMap<Symbol, Symbol> {
2163        arena_cache
2164        desc { "calculating the implications between `#[unstable]` features defined in a crate" }
2165        separate_provide_extern
2166    }
2167    /// Whether the function is an intrinsic
2168    query intrinsic_raw(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
2169        desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) }
2170        separate_provide_extern
2171    }
2172    /// Returns the lang items defined in another crate by loading it from metadata.
2173    query get_lang_items(_: ()) -> &'tcx LanguageItems {
2174        arena_cache
2175        eval_always
2176        desc { "calculating the lang items map" }
2177    }
2178
2179    /// Returns all diagnostic items defined in all crates.
2180    query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
2181        arena_cache
2182        eval_always
2183        desc { "calculating the diagnostic items map" }
2184    }
2185
2186    /// Returns the lang items defined in another crate by loading it from metadata.
2187    query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, LangItem)] {
2188        desc { "calculating the lang items defined in a crate" }
2189        separate_provide_extern
2190    }
2191
2192    /// Returns the diagnostic items defined in a crate.
2193    query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
2194        arena_cache
2195        desc { "calculating the diagnostic items map in a crate" }
2196        separate_provide_extern
2197    }
2198
2199    query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
2200        desc { "calculating the missing lang items in a crate" }
2201        separate_provide_extern
2202    }
2203
2204    /// The visible parent map is a map from every item to a visible parent.
2205    /// It prefers the shortest visible path to an item.
2206    /// Used for diagnostics, for example path trimming.
2207    /// The parents are modules, enums or traits.
2208    query visible_parent_map(_: ()) -> &'tcx DefIdMap<DefId> {
2209        arena_cache
2210        desc { "calculating the visible parent map" }
2211    }
2212    /// Collects the "trimmed", shortest accessible paths to all items for diagnostics.
2213    /// See the [provider docs](`rustc_middle::ty::print::trimmed_def_paths`) for more info.
2214    query trimmed_def_paths(_: ()) -> &'tcx DefIdMap<Symbol> {
2215        arena_cache
2216        desc { "calculating trimmed def paths" }
2217    }
2218    query missing_extern_crate_item(_: CrateNum) -> bool {
2219        eval_always
2220        desc { "seeing if we're missing an `extern crate` item for this crate" }
2221        separate_provide_extern
2222    }
2223    query used_crate_source(_: CrateNum) -> &'tcx Arc<CrateSource> {
2224        arena_cache
2225        eval_always
2226        desc { "looking at the source for a crate" }
2227        separate_provide_extern
2228    }
2229
2230    /// Returns the debugger visualizers defined for this crate.
2231    /// NOTE: This query has to be marked `eval_always` because it reads data
2232    ///       directly from disk that is not tracked anywhere else. I.e. it
2233    ///       represents a genuine input to the query system.
2234    query debugger_visualizers(_: CrateNum) -> &'tcx Vec<DebuggerVisualizerFile> {
2235        arena_cache
2236        desc { "looking up the debugger visualizers for this crate" }
2237        separate_provide_extern
2238        eval_always
2239    }
2240
2241    query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
2242        eval_always
2243        desc { "generating a postorder list of CrateNums" }
2244    }
2245    /// Returns whether or not the crate with CrateNum 'cnum'
2246    /// is marked as a private dependency
2247    query is_private_dep(c: CrateNum) -> bool {
2248        eval_always
2249        desc { "checking whether crate `{}` is a private dependency", c }
2250        separate_provide_extern
2251    }
2252    query allocator_kind(_: ()) -> Option<AllocatorKind> {
2253        eval_always
2254        desc { "getting the allocator kind for the current crate" }
2255    }
2256    query alloc_error_handler_kind(_: ()) -> Option<AllocatorKind> {
2257        eval_always
2258        desc { "alloc error handler kind for the current crate" }
2259    }
2260
2261    query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
2262        desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
2263    }
2264    query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
2265        desc { "fetching potentially unused trait imports" }
2266    }
2267
2268    query stability_index(_: ()) -> &'tcx stability::Index {
2269        arena_cache
2270        eval_always
2271        desc { "calculating the stability index for the local crate" }
2272    }
2273    /// All available crates in the graph, including those that should not be user-facing
2274    /// (such as private crates).
2275    query crates(_: ()) -> &'tcx [CrateNum] {
2276        eval_always
2277        desc { "fetching all foreign CrateNum instances" }
2278    }
2279    // Crates that are loaded non-speculatively (not for diagnostics or doc links).
2280    // FIXME: This is currently only used for collecting lang items, but should be used instead of
2281    // `crates` in most other cases too.
2282    query used_crates(_: ()) -> &'tcx [CrateNum] {
2283        eval_always
2284        desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
2285    }
2286
2287    /// A list of all traits in a crate, used by rustdoc and error reporting.
2288    query traits(_: CrateNum) -> &'tcx [DefId] {
2289        desc { "fetching all traits in a crate" }
2290        separate_provide_extern
2291    }
2292
2293    query trait_impls_in_crate(_: CrateNum) -> &'tcx [DefId] {
2294        desc { "fetching all trait impls in a crate" }
2295        separate_provide_extern
2296    }
2297
2298    query stable_order_of_exportable_impls(_: CrateNum) -> &'tcx FxIndexMap<DefId, usize> {
2299        desc { "fetching the stable impl's order" }
2300        separate_provide_extern
2301    }
2302
2303    query exportable_items(_: CrateNum) -> &'tcx [DefId] {
2304        desc { "fetching all exportable items in a crate" }
2305        separate_provide_extern
2306    }
2307
2308    /// The list of non-generic symbols exported from the given crate.
2309    ///
2310    /// This is separate from exported_generic_symbols to avoid having
2311    /// to deserialize all non-generic symbols too for upstream crates
2312    /// in the upstream_monomorphizations query.
2313    ///
2314    /// - All names contained in `exported_non_generic_symbols(cnum)` are
2315    ///   guaranteed to correspond to a publicly visible symbol in `cnum`
2316    ///   machine code.
2317    /// - The `exported_non_generic_symbols` and `exported_generic_symbols`
2318    ///   sets of different crates do not intersect.
2319    query exported_non_generic_symbols(cnum: CrateNum) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
2320        desc { "collecting exported non-generic symbols for crate `{}`", cnum}
2321        cache_on_disk_if { *cnum == LOCAL_CRATE }
2322        separate_provide_extern
2323    }
2324
2325    /// The list of generic symbols exported from the given crate.
2326    ///
2327    /// - All names contained in `exported_generic_symbols(cnum)` are
2328    ///   guaranteed to correspond to a publicly visible symbol in `cnum`
2329    ///   machine code.
2330    /// - The `exported_non_generic_symbols` and `exported_generic_symbols`
2331    ///   sets of different crates do not intersect.
2332    query exported_generic_symbols(cnum: CrateNum) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
2333        desc { "collecting exported generic symbols for crate `{}`", cnum}
2334        cache_on_disk_if { *cnum == LOCAL_CRATE }
2335        separate_provide_extern
2336    }
2337
2338    query collect_and_partition_mono_items(_: ()) -> MonoItemPartitions<'tcx> {
2339        eval_always
2340        desc { "collect_and_partition_mono_items" }
2341    }
2342
2343    query is_codegened_item(def_id: DefId) -> bool {
2344        desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
2345    }
2346
2347    query codegen_unit(sym: Symbol) -> &'tcx CodegenUnit<'tcx> {
2348        desc { "getting codegen unit `{sym}`" }
2349    }
2350
2351    query backend_optimization_level(_: ()) -> OptLevel {
2352        desc { "optimization level used by backend" }
2353    }
2354
2355    /// Return the filenames where output artefacts shall be stored.
2356    ///
2357    /// This query returns an `&Arc` because codegen backends need the value even after the `TyCtxt`
2358    /// has been destroyed.
2359    query output_filenames(_: ()) -> &'tcx Arc<OutputFilenames> {
2360        feedable
2361        desc { "getting output filenames" }
2362        arena_cache
2363    }
2364
2365    /// <div class="warning">
2366    ///
2367    /// Do not call this query directly: Invoke `normalize` instead.
2368    ///
2369    /// </div>
2370    query normalize_canonicalized_projection_ty(
2371        goal: CanonicalAliasGoal<'tcx>
2372    ) -> Result<
2373        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
2374        NoSolution,
2375    > {
2376        desc { "normalizing `{}`", goal.canonical.value.value }
2377    }
2378
2379    /// <div class="warning">
2380    ///
2381    /// Do not call this query directly: Invoke `normalize` instead.
2382    ///
2383    /// </div>
2384    query normalize_canonicalized_free_alias(
2385        goal: CanonicalAliasGoal<'tcx>
2386    ) -> Result<
2387        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
2388        NoSolution,
2389    > {
2390        desc { "normalizing `{}`", goal.canonical.value.value }
2391    }
2392
2393    /// <div class="warning">
2394    ///
2395    /// Do not call this query directly: Invoke `normalize` instead.
2396    ///
2397    /// </div>
2398    query normalize_canonicalized_inherent_projection_ty(
2399        goal: CanonicalAliasGoal<'tcx>
2400    ) -> Result<
2401        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
2402        NoSolution,
2403    > {
2404        desc { "normalizing `{}`", goal.canonical.value.value }
2405    }
2406
2407    /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
2408    query try_normalize_generic_arg_after_erasing_regions(
2409        goal: PseudoCanonicalInput<'tcx, GenericArg<'tcx>>
2410    ) -> Result<GenericArg<'tcx>, NoSolution> {
2411        desc { "normalizing `{}`", goal.value }
2412    }
2413
2414    query implied_outlives_bounds(
2415        key: (CanonicalImpliedOutlivesBoundsGoal<'tcx>, bool)
2416    ) -> Result<
2417        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
2418        NoSolution,
2419    > {
2420        desc { "computing implied outlives bounds for `{}` (hack disabled = {:?})", key.0.canonical.value.value.ty, key.1 }
2421    }
2422
2423    /// Do not call this query directly:
2424    /// invoke `DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)` instead.
2425    query dropck_outlives(
2426        goal: CanonicalDropckOutlivesGoal<'tcx>
2427    ) -> Result<
2428        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
2429        NoSolution,
2430    > {
2431        desc { "computing dropck types for `{}`", goal.canonical.value.value.dropped_ty }
2432    }
2433
2434    /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
2435    /// `infcx.predicate_must_hold()` instead.
2436    query evaluate_obligation(
2437        goal: CanonicalPredicateGoal<'tcx>
2438    ) -> Result<EvaluationResult, OverflowError> {
2439        desc { "evaluating trait selection obligation `{}`", goal.canonical.value.value }
2440    }
2441
2442    /// Do not call this query directly: part of the `Eq` type-op
2443    query type_op_ascribe_user_type(
2444        goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
2445    ) -> Result<
2446        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
2447        NoSolution,
2448    > {
2449        desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.canonical.value.value }
2450    }
2451
2452    /// Do not call this query directly: part of the `ProvePredicate` type-op
2453    query type_op_prove_predicate(
2454        goal: CanonicalTypeOpProvePredicateGoal<'tcx>
2455    ) -> Result<
2456        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
2457        NoSolution,
2458    > {
2459        desc { "evaluating `type_op_prove_predicate` `{:?}`", goal.canonical.value.value }
2460    }
2461
2462    /// Do not call this query directly: part of the `Normalize` type-op
2463    query type_op_normalize_ty(
2464        goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
2465    ) -> Result<
2466        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
2467        NoSolution,
2468    > {
2469        desc { "normalizing `{}`", goal.canonical.value.value.value }
2470    }
2471
2472    /// Do not call this query directly: part of the `Normalize` type-op
2473    query type_op_normalize_clause(
2474        goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Clause<'tcx>>
2475    ) -> Result<
2476        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Clause<'tcx>>>,
2477        NoSolution,
2478    > {
2479        desc { "normalizing `{:?}`", goal.canonical.value.value.value }
2480    }
2481
2482    /// Do not call this query directly: part of the `Normalize` type-op
2483    query type_op_normalize_poly_fn_sig(
2484        goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
2485    ) -> Result<
2486        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
2487        NoSolution,
2488    > {
2489        desc { "normalizing `{:?}`", goal.canonical.value.value.value }
2490    }
2491
2492    /// Do not call this query directly: part of the `Normalize` type-op
2493    query type_op_normalize_fn_sig(
2494        goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
2495    ) -> Result<
2496        &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
2497        NoSolution,
2498    > {
2499        desc { "normalizing `{:?}`", goal.canonical.value.value.value }
2500    }
2501
2502    query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool {
2503        desc { |tcx|
2504            "checking impossible instantiated predicates: `{}`",
2505            tcx.def_path_str(key.0)
2506        }
2507    }
2508
2509    query is_impossible_associated_item(key: (DefId, DefId)) -> bool {
2510        desc { |tcx|
2511            "checking if `{}` is impossible to reference within `{}`",
2512            tcx.def_path_str(key.1),
2513            tcx.def_path_str(key.0),
2514        }
2515    }
2516
2517    query method_autoderef_steps(
2518        goal: CanonicalTyGoal<'tcx>
2519    ) -> MethodAutoderefStepsResult<'tcx> {
2520        desc { "computing autoderef types for `{}`", goal.canonical.value.value }
2521    }
2522
2523    /// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
2524    query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
2525        arena_cache
2526        eval_always
2527        desc { "looking up Rust target features" }
2528    }
2529
2530    query implied_target_features(feature: Symbol) -> &'tcx Vec<Symbol> {
2531        arena_cache
2532        eval_always
2533        desc { "looking up implied target features" }
2534    }
2535
2536    query features_query(_: ()) -> &'tcx rustc_feature::Features {
2537        feedable
2538        desc { "looking up enabled feature gates" }
2539    }
2540
2541    query crate_for_resolver((): ()) -> &'tcx Steal<(rustc_ast::Crate, rustc_ast::AttrVec)> {
2542        feedable
2543        no_hash
2544        desc { "the ast before macro expansion and name resolution" }
2545    }
2546
2547    /// Attempt to resolve the given `DefId` to an `Instance`, for the
2548    /// given generics args (`GenericArgsRef`), returning one of:
2549    ///  * `Ok(Some(instance))` on success
2550    ///  * `Ok(None)` when the `GenericArgsRef` are still too generic,
2551    ///    and therefore don't allow finding the final `Instance`
2552    ///  * `Err(ErrorGuaranteed)` when the `Instance` resolution process
2553    ///    couldn't complete due to errors elsewhere - this is distinct
2554    ///    from `Ok(None)` to avoid misleading diagnostics when an error
2555    ///    has already been/will be emitted, for the original cause.
2556    query resolve_instance_raw(
2557        key: ty::PseudoCanonicalInput<'tcx, (DefId, GenericArgsRef<'tcx>)>
2558    ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
2559        desc { "resolving instance `{}`", ty::Instance::new_raw(key.value.0, key.value.1) }
2560    }
2561
2562    query reveal_opaque_types_in_bounds(key: ty::Clauses<'tcx>) -> ty::Clauses<'tcx> {
2563        desc { "revealing opaque types in `{:?}`", key }
2564    }
2565
2566    query limits(key: ()) -> Limits {
2567        desc { "looking up limits" }
2568    }
2569
2570    /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
2571    /// we get an `Unimplemented` error that matches the provided `Predicate`, return
2572    /// the cause of the newly created obligation.
2573    ///
2574    /// This is only used by error-reporting code to get a better cause (in particular, a better
2575    /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
2576    /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
2577    /// because the `ty::Ty`-based wfcheck is always run.
2578    query diagnostic_hir_wf_check(
2579        key: (ty::Predicate<'tcx>, WellFormedLoc)
2580    ) -> Option<&'tcx ObligationCause<'tcx>> {
2581        arena_cache
2582        eval_always
2583        no_hash
2584        desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
2585    }
2586
2587    /// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
2588    /// `--target` and similar).
2589    query global_backend_features(_: ()) -> &'tcx Vec<String> {
2590        arena_cache
2591        eval_always
2592        desc { "computing the backend features for CLI flags" }
2593    }
2594
2595    query check_validity_requirement(key: (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>)) -> Result<bool, &'tcx ty::layout::LayoutError<'tcx>> {
2596        desc { "checking validity requirement for `{}`: {}", key.1.value, key.0 }
2597    }
2598
2599    /// This takes the def-id of an associated item from a impl of a trait,
2600    /// and checks its validity against the trait item it corresponds to.
2601    ///
2602    /// Any other def id will ICE.
2603    query compare_impl_item(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
2604        desc { |tcx| "checking assoc item `{}` is compatible with trait definition", tcx.def_path_str(key) }
2605        return_result_from_ensure_ok
2606    }
2607
2608    query deduced_param_attrs(def_id: DefId) -> &'tcx [ty::DeducedParamAttrs] {
2609        desc { |tcx| "deducing parameter attributes for {}", tcx.def_path_str(def_id) }
2610        separate_provide_extern
2611    }
2612
2613    query doc_link_resolutions(def_id: DefId) -> &'tcx DocLinkResMap {
2614        eval_always
2615        desc { "resolutions for documentation links for a module" }
2616        separate_provide_extern
2617    }
2618
2619    query doc_link_traits_in_scope(def_id: DefId) -> &'tcx [DefId] {
2620        eval_always
2621        desc { "traits in scope for documentation links for a module" }
2622        separate_provide_extern
2623    }
2624
2625    /// Get all item paths that were stripped by a `#[cfg]` in a particular crate.
2626    /// Should not be called for the local crate before the resolver outputs are created, as it
2627    /// is only fed there.
2628    query stripped_cfg_items(cnum: CrateNum) -> &'tcx [StrippedCfgItem] {
2629        desc { "getting cfg-ed out item names" }
2630        separate_provide_extern
2631    }
2632
2633    query generics_require_sized_self(def_id: DefId) -> bool {
2634        desc { "check whether the item has a `where Self: Sized` bound" }
2635    }
2636
2637    query cross_crate_inlinable(def_id: DefId) -> bool {
2638        desc { "whether the item should be made inlinable across crates" }
2639        separate_provide_extern
2640    }
2641
2642    /// Perform monomorphization-time checking on this item.
2643    /// This is used for lints/errors that can only be checked once the instance is fully
2644    /// monomorphized.
2645    query check_mono_item(key: ty::Instance<'tcx>) {
2646        desc { "monomorphization-time checking" }
2647    }
2648
2649    /// Builds the set of functions that should be skipped for the move-size check.
2650    query skip_move_check_fns(_: ()) -> &'tcx FxIndexSet<DefId> {
2651        arena_cache
2652        desc { "functions to skip for move-size check" }
2653    }
2654
2655    query items_of_instance(key: (ty::Instance<'tcx>, CollectionMode)) -> (&'tcx [Spanned<MonoItem<'tcx>>], &'tcx [Spanned<MonoItem<'tcx>>]) {
2656        desc { "collecting items used by `{}`", key.0 }
2657        cache_on_disk_if { true }
2658    }
2659
2660    query size_estimate(key: ty::Instance<'tcx>) -> usize {
2661        desc { "estimating codegen size of `{}`", key }
2662        cache_on_disk_if { true }
2663    }
2664
2665    query anon_const_kind(def_id: DefId) -> ty::AnonConstKind {
2666        desc { |tcx| "looking up anon const kind of `{}`", tcx.def_path_str(def_id) }
2667        separate_provide_extern
2668    }
2669}
2670
2671rustc_with_all_queries! { define_callbacks! }
2672rustc_feedable_queries! { define_feedable! }