1 use crate::ty::query::QueryDescription;
2 use crate::ty::query::queries;
3 use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
4 use crate::ty::subst::SubstsRef;
5 use crate::dep_graph::SerializedDepNodeIndex;
6 use crate::hir::def_id::{CrateNum, DefId, DefIndex};
7 use crate::mir::interpret::GlobalId;
9 use crate::traits::query::{
10 CanonicalPredicateGoal, CanonicalProjectionGoal,
11 CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
12 CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal,
13 CanonicalTypeOpNormalizeGoal,
17 use syntax_pos::symbol::InternedString;
20 // Each of these queries corresponds to a function pointer field in the
21 // `Providers` struct for requesting a value of that type, and a method
22 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
23 // which memoizes and does dep-graph tracking, wrapping around the actual
24 // `Providers` that the driver creates (using several `rustc_*` crates).
26 // The result type of each query must implement `Clone`, and additionally
27 // `ty::query::values::Value`, which produces an appropriate placeholder
28 // (error) value if the query resulted in a query cycle.
29 // Queries marked with `fatal_cycle` do not need the latter implementation,
30 // as they will raise an fatal error on query cycles instead.
33 /// Records the type of every item.
34 query type_of(key: DefId) -> Ty<'tcx> {
35 cache { key.is_local() }
38 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
39 /// associated generics.
40 query generics_of(key: DefId) -> &'tcx ty::Generics {
41 cache { key.is_local() }
42 load_cached(tcx, id) {
43 let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
44 .try_load_query_result(tcx, id);
45 generics.map(|x| tcx.alloc_generics(x))
49 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
50 /// predicates (where-clauses) that must be proven true in order
51 /// to reference it. This is almost always the "predicates query"
54 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
55 /// it is almost always the same as that query, except for the
56 /// case of traits. For traits, `predicates_of` contains
57 /// an additional `Self: Trait<...>` predicate that users don't
58 /// actually write. This reflects the fact that to invoke the
59 /// trait (e.g., via `Default::default`) you must supply types
60 /// that actually implement the trait. (However, this extra
61 /// predicate gets in the way of some checks, which are intended
62 /// to operate over only the actual where-clauses written by the
64 query predicates_of(_: DefId) -> Lrc<ty::GenericPredicates<'tcx>> {}
66 query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLibrary>> {
67 desc { "looking up the native libraries of a linked crate" }
70 query lint_levels(_: CrateNum) -> Lrc<lint::LintLevelMap> {
72 desc { "computing the lint levels for items in this crate" }
77 query is_panic_runtime(_: CrateNum) -> bool {
79 desc { "checking if the crate is_panic_runtime" }
84 /// Set of all the `DefId`s in this crate that have MIR associated with
85 /// them. This includes all the body owners, but also things like struct
87 query mir_keys(_: CrateNum) -> &'tcx DefIdSet {
88 desc { "getting a list of all mir_keys" }
91 /// Maps DefId's that have an associated Mir to the result
92 /// of the MIR qualify_consts pass. The actual meaning of
93 /// the value isn't known except to the pass itself.
94 query mir_const_qualif(key: DefId) -> (u8, Lrc<BitSet<mir::Local>>) {
95 cache { key.is_local() }
98 /// Fetch the MIR for a given `DefId` right after it's built - this includes
100 query mir_built(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {}
102 /// Fetch the MIR for a given `DefId` up till the point where it is
103 /// ready for const evaluation.
105 /// See the README for the `mir` module for details.
106 query mir_const(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {
110 query mir_validated(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {
114 /// MIR after our optimization passes have run. This is MIR that is ready
115 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
116 query optimized_mir(key: DefId) -> &'tcx mir::Mir<'tcx> {
117 cache { key.is_local() }
118 load_cached(tcx, id) {
119 let mir: Option<crate::mir::Mir<'tcx>> = tcx.queries.on_disk_cache
120 .try_load_query_result(tcx, id);
121 mir.map(|x| tcx.alloc_mir(x))
127 // Erases regions from `ty` to yield a new type.
128 // Normally you would just use `tcx.erase_regions(&value)`,
129 // however, which uses this query as a kind of cache.
130 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
131 // This query is not expected to have input -- as a result, it
132 // is not a good candidates for "replay" because it is essentially a
133 // pure function of its input (and hence the expectation is that
134 // no caller would be green **apart** from just these
135 // queries). Making it anonymous avoids hashing the result, which
136 // may save a bit of time.
139 desc { "erasing regions from `{:?}`", ty }
142 query program_clauses_for(_: DefId) -> Clauses<'tcx> {
143 desc { "generating chalk-style clauses" }
146 query program_clauses_for_env(_: traits::Environment<'tcx>) -> Clauses<'tcx> {
148 desc { "generating chalk-style clauses for environment" }
151 // Get the chalk-style environment of the given item.
152 query environment(_: DefId) -> traits::Environment<'tcx> {
153 desc { "return a chalk-style environment" }
158 query wasm_import_module_map(_: CrateNum) -> Lrc<FxHashMap<DefId, String>> {
159 desc { "wasm import module map" }
164 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
165 /// predicates (where-clauses) directly defined on it. This is
166 /// equal to the `explicit_predicates_of` predicates plus the
167 /// `inferred_outlives_of` predicates.
168 query predicates_defined_on(_: DefId)
169 -> Lrc<ty::GenericPredicates<'tcx>> {}
171 /// Returns the predicates written explicit by the user.
172 query explicit_predicates_of(_: DefId)
173 -> Lrc<ty::GenericPredicates<'tcx>> {}
175 /// Returns the inferred outlives predicates (e.g., for `struct
176 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
177 query inferred_outlives_of(_: DefId) -> Lrc<Vec<ty::Predicate<'tcx>>> {}
179 /// Maps from the `DefId` of a trait to the list of
180 /// super-predicates. This is a subset of the full list of
181 /// predicates. We store these in a separate map because we must
182 /// evaluate them even during type conversion, often before the
183 /// full predicates are available (note that supertraits have
184 /// additional acyclicity requirements).
185 query super_predicates_of(key: DefId) -> Lrc<ty::GenericPredicates<'tcx>> {
186 desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
189 /// To avoid cycles within the predicates of a single item we compute
190 /// per-type-parameter predicates for resolving `T::AssocTy`.
191 query type_param_predicates(key: (DefId, DefId))
192 -> Lrc<ty::GenericPredicates<'tcx>> {
194 desc { |tcx| "computing the bounds for type parameter `{}`", {
195 let id = tcx.hir().as_local_hir_id(key.1).unwrap();
196 tcx.hir().ty_param_name(id)
200 query trait_def(_: DefId) -> &'tcx ty::TraitDef {}
201 query adt_def(_: DefId) -> &'tcx ty::AdtDef {}
202 query adt_destructor(_: DefId) -> Option<ty::Destructor> {}
204 // The cycle error here should be reported as an error by `check_representable`.
205 // We consider the type as Sized in the meanwhile to avoid
206 // further errors (done in impl Value for AdtSizedConstraint).
207 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
208 // in case we accidentally otherwise don't emit an error.
209 query adt_sized_constraint(
211 ) -> AdtSizedConstraint<'tcx> {
215 query adt_dtorck_constraint(
217 ) -> Result<DtorckConstraint<'tcx>, NoSolution> {}
219 /// True if this is a const fn, use the `is_const_fn` to know whether your crate actually
220 /// sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have
221 /// the feature gate active)
223 /// **Do not call this function manually.** It is only meant to cache the base data for the
224 /// `is_const_fn` function.
225 query is_const_fn_raw(key: DefId) -> bool {
226 desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
229 /// Returns true if calls to the function may be promoted
231 /// This is either because the function is e.g., a tuple-struct or tuple-variant
232 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
233 /// be removed in the future in favour of some form of check which figures out whether the
234 /// function does not inspect the bits of any of its arguments (so is essentially just a
235 /// constructor function).
236 query is_promotable_const_fn(_: DefId) -> bool {}
238 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
239 query is_foreign_item(_: DefId) -> bool {}
241 /// Get a map with the variance of every item; use `item_variance`
243 query crate_variances(_: CrateNum) -> Lrc<ty::CrateVariancesMap> {
244 desc { "computing the variances for items in this crate" }
247 /// Maps from def-id of a type or region parameter to its
248 /// (inferred) variance.
249 query variances_of(_: DefId) -> Lrc<Vec<ty::Variance>> {}
253 /// Maps from def-id of a type to its (inferred) outlives.
254 query inferred_outlives_crate(_: CrateNum)
255 -> Lrc<ty::CratePredicatesMap<'tcx>> {
256 desc { "computing the inferred outlives predicates for items in this crate" }
261 /// Maps from an impl/trait def-id to a list of the def-ids of its items
262 query associated_item_def_ids(_: DefId) -> Lrc<Vec<DefId>> {}
264 /// Maps from a trait item to the trait item "descriptor"
265 query associated_item(_: DefId) -> ty::AssociatedItem {}
267 query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
268 query impl_polarity(_: DefId) -> hir::ImplPolarity {}
270 query issue33140_self_ty(_: DefId) -> Option<ty::Ty<'tcx>> {}
274 /// Maps a DefId of a type to a list of its inherent impls.
275 /// Contains implementations of methods that are inherent to a type.
276 /// Methods in these implementations don't need to be exported.
277 query inherent_impls(_: DefId) -> Lrc<Vec<DefId>> {
283 /// The result of unsafety-checking this `DefId`.
284 query unsafety_check_result(_: DefId) -> mir::UnsafetyCheckResult {}
286 /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
287 query unsafe_derive_on_repr_packed(_: DefId) -> () {}
289 /// The signature of functions and closures.
290 query fn_sig(_: DefId) -> ty::PolyFnSig<'tcx> {}
294 query lint_mod(key: DefId) -> () {
295 desc { |tcx| "linting {}", key.describe_as_module(tcx) }
298 /// Checks the attributes in the module
299 query check_mod_attrs(key: DefId) -> () {
300 desc { |tcx| "checking attributes in {}", key.describe_as_module(tcx) }
303 query check_mod_unstable_api_usage(key: DefId) -> () {
304 desc { |tcx| "checking for unstable API usage in {}", key.describe_as_module(tcx) }
307 /// Checks the loops in the module
308 query check_mod_loops(key: DefId) -> () {
309 desc { |tcx| "checking loops in {}", key.describe_as_module(tcx) }
312 query check_mod_item_types(key: DefId) -> () {
313 desc { |tcx| "checking item types in {}", key.describe_as_module(tcx) }
316 query check_mod_privacy(key: DefId) -> () {
317 desc { |tcx| "checking privacy in {}", key.describe_as_module(tcx) }
320 query check_mod_intrinsics(key: DefId) -> () {
321 desc { |tcx| "checking intrinsics in {}", key.describe_as_module(tcx) }
324 query check_mod_liveness(key: DefId) -> () {
325 desc { |tcx| "checking liveness of variables in {}", key.describe_as_module(tcx) }
328 query check_mod_impl_wf(key: DefId) -> () {
329 desc { |tcx| "checking that impls are well-formed in {}", key.describe_as_module(tcx) }
332 query collect_mod_item_types(key: DefId) -> () {
333 desc { |tcx| "collecting item types in {}", key.describe_as_module(tcx) }
336 /// Caches CoerceUnsized kinds for impls on custom types.
337 query coerce_unsized_info(_: DefId)
338 -> ty::adjustment::CoerceUnsizedInfo {}
342 query typeck_item_bodies(_: CrateNum) -> () {
343 desc { "type-checking all item bodies" }
346 query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
347 cache { key.is_local() }
348 load_cached(tcx, id) {
349 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
350 .queries.on_disk_cache
351 .try_load_query_result(tcx, id);
353 typeck_tables.map(|tables| tcx.alloc_tables(tables))
359 query used_trait_imports(_: DefId) -> Lrc<DefIdSet> {}
363 query has_typeck_tables(_: DefId) -> bool {}
365 query coherent_trait(def_id: DefId) -> () {
366 desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
371 query borrowck(_: DefId) -> Lrc<BorrowCheckResult> {}
373 /// Borrow checks the function body. If this is a closure, returns
374 /// additional requirements that the closure's creator must verify.
375 query mir_borrowck(_: DefId) -> mir::BorrowCheckResult<'tcx> {}
379 /// Gets a complete map from all types to their inherent impls.
380 /// Not meant to be used directly outside of coherence.
381 /// (Defined only for `LOCAL_CRATE`.)
382 query crate_inherent_impls(k: CrateNum)
383 -> Lrc<CrateInherentImpls> {
385 desc { "all inherent impls defined in crate `{:?}`", k }
388 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
389 /// Not meant to be used directly outside of coherence.
390 /// (Defined only for `LOCAL_CRATE`.)
391 query crate_inherent_impls_overlap_check(_: CrateNum)
394 desc { "check for overlap between inherent impls defined in this crate" }
399 /// Evaluate a constant without running sanity checks
401 /// **Do not use this** outside const eval. Const eval uses this to break query cycles
402 /// during validation. Please add a comment to every use site explaining why using
403 /// `const_eval` isn't sufficient
404 query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
405 -> ConstEvalRawResult<'tcx> {
408 "const-evaluating `{}`",
409 tcx.def_path_str(key.value.instance.def.def_id())
412 load_cached(tcx, id) {
413 tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok)
417 /// Results of evaluating const items or constants embedded in
418 /// other items (such as enum variant explicit discriminants).
419 query const_eval(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
420 -> ConstEvalResult<'tcx> {
423 "const-evaluating + checking `{}`",
424 tcx.def_path_str(key.value.instance.def.def_id())
427 load_cached(tcx, id) {
428 tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok)
434 query check_match(_: DefId) -> () {}
436 /// Performs part of the privacy check and computes "access levels".
437 query privacy_access_levels(_: CrateNum) -> Lrc<AccessLevels> {
439 desc { "privacy access levels" }
441 query check_private_in_public(_: CrateNum) -> () {
443 desc { "checking for private elements in public interfaces" }
448 query reachable_set(_: CrateNum) -> ReachableSet {
449 desc { "reachability" }
452 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
453 /// in the case of closures, this will be redirected to the enclosing function.
454 query region_scope_tree(_: DefId) -> Lrc<region::ScopeTree> {}
456 query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx> {
458 desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
461 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName {
463 desc { "computing the symbol for `{}`", key }
467 query describe_def(_: DefId) -> Option<Def> {}
468 query def_span(_: DefId) -> Span {
469 // FIXME(mw): DefSpans are not really inputs since they are derived from
470 // HIR. But at the moment HIR hashing still contains some hacks that allow
471 // to make type debuginfo to be source location independent. Declaring
472 // DefSpan an input makes sure that changes to these are always detected
473 // regardless of HIR hashing.
476 query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
477 query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
478 query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
482 query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {}
486 query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
487 /// Gets the rendered value of the specified constant or associated constant.
489 query rendered_const(_: DefId) -> String {}
490 query impl_parent(_: DefId) -> Option<DefId> {}
494 query trait_of_item(_: DefId) -> Option<DefId> {}
495 query const_is_rvalue_promotable_to_static(key: DefId) -> bool {
497 "const checking if rvalue is promotable to static `{}`",
498 tcx.def_path_str(key)
502 query rvalue_promotable_map(key: DefId) -> Lrc<ItemLocalSet> {
504 "checking which parts of `{}` are promotable to static",
505 tcx.def_path_str(key)
511 query is_mir_available(key: DefId) -> bool {
512 desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
517 query vtable_methods(key: ty::PolyTraitRef<'tcx>)
518 -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
520 desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) }
525 query codegen_fulfill_obligation(
526 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
527 ) -> Vtable<'tcx, ()> {
531 "checking if `{}` fulfills its obligations",
532 tcx.def_path_str(key.1.def_id())
538 query trait_impls_of(key: DefId) -> Lrc<ty::trait_def::TraitImpls> {
539 desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
541 query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph {}
542 query is_object_safe(key: DefId) -> bool {
543 desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
546 /// Gets the ParameterEnvironment for a given item; this environment
547 /// will be in "user-facing" mode, meaning that it is suitabe for
548 /// type-checking etc, and it does not normalize specializable
549 /// associated types. This is almost always what you want,
550 /// unless you are doing MIR optimizations, in which case you
551 /// might want to use `reveal_all()` method to change modes.
552 query param_env(_: DefId) -> ty::ParamEnv<'tcx> {}
554 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
555 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
556 query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
558 desc { "computing whether `{}` is `Copy`", env.value }
560 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
562 desc { "computing whether `{}` is `Sized`", env.value }
564 query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
566 desc { "computing whether `{}` is freeze", env.value }
569 // The cycle error here should be reported as an error by `check_representable`.
570 // We consider the type as not needing drop in the meanwhile to avoid
571 // further errors (done in impl Value for NeedsDrop).
572 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
573 // in case we accidentally otherwise don't emit an error.
574 query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> NeedsDrop {
577 desc { "computing whether `{}` needs drop", env.value }
581 env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
582 ) -> Result<&'tcx ty::layout::LayoutDetails, ty::layout::LayoutError<'tcx>> {
584 desc { "computing layout of `{}`", env.value }
589 query dylib_dependency_formats(_: CrateNum)
590 -> Lrc<Vec<(CrateNum, LinkagePreference)>> {
591 desc { "dylib dependency formats of crate" }
596 query is_compiler_builtins(_: CrateNum) -> bool {
598 desc { "checking if the crate is_compiler_builtins" }
600 query has_global_allocator(_: CrateNum) -> bool {
602 desc { "checking if the crate has_global_allocator" }
604 query has_panic_handler(_: CrateNum) -> bool {
606 desc { "checking if the crate has_panic_handler" }
608 query is_sanitizer_runtime(_: CrateNum) -> bool {
610 desc { "query a crate is #![sanitizer_runtime]" }
612 query is_profiler_runtime(_: CrateNum) -> bool {
614 desc { "query a crate is #![profiler_runtime]" }
616 query panic_strategy(_: CrateNum) -> PanicStrategy {
618 desc { "query a crate's configured panic strategy" }
620 query is_no_builtins(_: CrateNum) -> bool {
622 desc { "test whether a crate has #![no_builtins]" }
625 query extern_crate(_: DefId) -> Lrc<Option<ExternCrate>> {
627 desc { "getting crate's ExternCrateData" }
632 query specializes(_: (DefId, DefId)) -> bool {
634 desc { "computing whether impls specialize one another" }
636 query in_scope_traits_map(_: DefIndex)
637 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>> {
639 desc { "traits in scope at a block" }
644 query module_exports(_: DefId) -> Option<Lrc<Vec<Export<hir::HirId>>>> {
650 query impl_defaultness(_: DefId) -> hir::Defaultness {}
652 query check_item_well_formed(_: DefId) -> () {}
653 query check_trait_item_well_formed(_: DefId) -> () {}
654 query check_impl_item_well_formed(_: DefId) -> () {}
658 // The DefIds of all non-generic functions and statics in the given crate
659 // that can be reached from outside the crate.
661 // We expect this items to be available for being linked to.
663 // This query can also be called for LOCAL_CRATE. In this case it will
664 // compute which items will be reachable to other crates, taking into account
665 // the kind of crate that is currently compiled. Crates with only a
666 // C interface have fewer reachable things.
668 // Does not include external symbols that don't have a corresponding DefId,
669 // like the compiler-generated `main` function and so on.
670 query reachable_non_generics(_: CrateNum)
671 -> Lrc<DefIdMap<SymbolExportLevel>> {
672 desc { "looking up the exported symbols of a crate" }
674 query is_reachable_non_generic(_: DefId) -> bool {}
675 query is_unreachable_local_definition(_: DefId) -> bool {}
679 query upstream_monomorphizations(
681 ) -> Lrc<DefIdMap<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>> {
682 desc { "collecting available upstream monomorphizations `{:?}`", k }
684 query upstream_monomorphizations_for(_: DefId)
685 -> Option<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>> {}
689 query foreign_modules(_: CrateNum) -> Lrc<Vec<ForeignModule>> {
690 desc { "looking up the foreign modules of a linked crate" }
693 /// Identifies the entry-point (e.g., the `main` function) for a given
694 /// crate, returning `None` if there is no entry point (such as for library crates).
695 query entry_fn(_: CrateNum) -> Option<(DefId, EntryFnType)> {
696 desc { "looking up the entry function of a crate" }
698 query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
699 desc { "looking up the plugin registrar for a crate" }
701 query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
702 desc { "looking up the derive registrar for a crate" }
704 query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
706 desc { "looking up the disambiguator a crate" }
708 query crate_hash(_: CrateNum) -> Svh {
710 desc { "looking up the hash a crate" }
712 query original_crate_name(_: CrateNum) -> Symbol {
714 desc { "looking up the original name a crate" }
716 query extra_filename(_: CrateNum) -> String {
718 desc { "looking up the extra filename for a crate" }
723 query implementations_of_trait(_: (CrateNum, DefId))
726 desc { "looking up implementations of a trait in a crate" }
728 query all_trait_implementations(_: CrateNum)
730 desc { "looking up all (?) trait implementations" }
735 query dllimport_foreign_items(_: CrateNum)
736 -> Lrc<FxHashSet<DefId>> {
737 desc { "dllimport_foreign_items" }
739 query is_dllimport_foreign_item(_: DefId) -> bool {}
740 query is_statically_included_foreign_item(_: DefId) -> bool {}
741 query native_library_kind(_: DefId)
742 -> Option<NativeLibraryKind> {}
746 query link_args(_: CrateNum) -> Lrc<Vec<String>> {
748 desc { "looking up link arguments for a crate" }
753 // Lifetime resolution. See `middle::resolve_lifetimes`.
754 query resolve_lifetimes(_: CrateNum) -> Lrc<ResolveLifetimes> {
755 desc { "resolving lifetimes" }
757 query named_region_map(_: DefIndex) ->
758 Option<Lrc<FxHashMap<ItemLocalId, Region>>> {
759 desc { "looking up a named region" }
761 query is_late_bound_map(_: DefIndex) ->
762 Option<Lrc<FxHashSet<ItemLocalId>>> {
763 desc { "testing if a region is late bound" }
765 query object_lifetime_defaults_map(_: DefIndex)
766 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>> {
767 desc { "looking up lifetime defaults for a region" }
772 query visibility(_: DefId) -> ty::Visibility {}
776 query dep_kind(_: CrateNum) -> DepKind {
778 desc { "fetching what a dependency looks like" }
780 query crate_name(_: CrateNum) -> Symbol {
782 desc { "fetching what a crate is named" }
784 query item_children(_: DefId) -> Lrc<Vec<Export<hir::HirId>>> {}
785 query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
787 query get_lib_features(_: CrateNum) -> Lrc<LibFeatures> {
789 desc { "calculating the lib features map" }
791 query defined_lib_features(_: CrateNum)
792 -> Lrc<Vec<(Symbol, Option<Symbol>)>> {
793 desc { "calculating the lib features defined in a crate" }
795 query get_lang_items(_: CrateNum) -> Lrc<LanguageItems> {
797 desc { "calculating the lang items map" }
799 query defined_lang_items(_: CrateNum) -> Lrc<Vec<(DefId, usize)>> {
800 desc { "calculating the lang items defined in a crate" }
802 query missing_lang_items(_: CrateNum) -> Lrc<Vec<LangItem>> {
803 desc { "calculating the missing lang items in a crate" }
805 query visible_parent_map(_: CrateNum)
806 -> Lrc<DefIdMap<DefId>> {
807 desc { "calculating the visible parent map" }
809 query missing_extern_crate_item(_: CrateNum) -> bool {
811 desc { "seeing if we're missing an `extern crate` item for this crate" }
813 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
815 desc { "looking at the source for a crate" }
817 query postorder_cnums(_: CrateNum) -> Lrc<Vec<CrateNum>> {
819 desc { "generating a postorder list of CrateNums" }
822 query freevars(_: DefId) -> Option<Lrc<Vec<hir::Freevar>>> {
825 query maybe_unused_trait_import(_: DefId) -> bool {
828 query maybe_unused_extern_crates(_: CrateNum)
829 -> Lrc<Vec<(DefId, Span)>> {
831 desc { "looking up all possibly unused extern crates" }
833 query names_imported_by_glob_use(_: DefId)
834 -> Lrc<FxHashSet<ast::Name>> {
838 query stability_index(_: CrateNum) -> Lrc<stability::Index<'tcx>> {
840 desc { "calculating the stability index for the local crate" }
842 query all_crate_nums(_: CrateNum) -> Lrc<Vec<CrateNum>> {
844 desc { "fetching all foreign CrateNum instances" }
847 /// A vector of every trait accessible in the whole crate
848 /// (i.e., including those from subcrates). This is used only for
850 query all_traits(_: CrateNum) -> Lrc<Vec<DefId>> {
851 desc { "fetching all foreign and local traits" }
856 query exported_symbols(_: CrateNum)
857 -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
858 desc { "exported_symbols" }
863 query collect_and_partition_mono_items(_: CrateNum)
864 -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>) {
866 desc { "collect_and_partition_mono_items" }
868 query is_codegened_item(_: DefId) -> bool {}
869 query codegen_unit(_: InternedString) -> Arc<CodegenUnit<'tcx>> {
871 desc { "codegen_unit" }
873 query backend_optimization_level(_: CrateNum) -> OptLevel {
874 desc { "optimization level used by backend" }
879 query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
881 desc { "output_filenames" }
886 /// Do not call this query directly: invoke `normalize` instead.
887 query normalize_projection_ty(
888 goal: CanonicalProjectionGoal<'tcx>
890 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>>,
894 desc { "normalizing `{:?}`", goal }
897 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
898 query normalize_ty_after_erasing_regions(
899 goal: ParamEnvAnd<'tcx, Ty<'tcx>>
902 desc { "normalizing `{:?}`", goal }
905 query implied_outlives_bounds(
906 goal: CanonicalTyGoal<'tcx>
908 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>,
912 desc { "computing implied outlives bounds for `{:?}`", goal }
915 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
916 query dropck_outlives(
917 goal: CanonicalTyGoal<'tcx>
919 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>,
923 desc { "computing dropck types for `{:?}`", goal }
926 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
927 /// `infcx.predicate_must_hold()` instead.
928 query evaluate_obligation(
929 goal: CanonicalPredicateGoal<'tcx>
930 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
932 desc { "evaluating trait selection obligation `{}`", goal.value.value }
936 goal: traits::ChalkCanonicalGoal<'tcx>
938 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
942 desc { "evaluating trait selection obligation `{}`", goal.value.goal }
945 /// Do not call this query directly: part of the `Eq` type-op
946 query type_op_ascribe_user_type(
947 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
949 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
953 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
956 /// Do not call this query directly: part of the `Eq` type-op
958 goal: CanonicalTypeOpEqGoal<'tcx>
960 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
964 desc { "evaluating `type_op_eq` `{:?}`", goal }
967 /// Do not call this query directly: part of the `Subtype` type-op
968 query type_op_subtype(
969 goal: CanonicalTypeOpSubtypeGoal<'tcx>
971 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
975 desc { "evaluating `type_op_subtype` `{:?}`", goal }
978 /// Do not call this query directly: part of the `ProvePredicate` type-op
979 query type_op_prove_predicate(
980 goal: CanonicalTypeOpProvePredicateGoal<'tcx>
982 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
986 desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
989 /// Do not call this query directly: part of the `Normalize` type-op
990 query type_op_normalize_ty(
991 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
993 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>>,
997 desc { "normalizing `{:?}`", goal }
1000 /// Do not call this query directly: part of the `Normalize` type-op
1001 query type_op_normalize_predicate(
1002 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1004 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>>,
1008 desc { "normalizing `{:?}`", goal }
1011 /// Do not call this query directly: part of the `Normalize` type-op
1012 query type_op_normalize_poly_fn_sig(
1013 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1015 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>>,
1019 desc { "normalizing `{:?}`", goal }
1022 /// Do not call this query directly: part of the `Normalize` type-op
1023 query type_op_normalize_fn_sig(
1024 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1026 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>>,
1030 desc { "normalizing `{:?}`", goal }
1033 query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1036 "testing substituted normalized predicates:`{}`",
1037 tcx.def_path_str(key.0)
1041 query method_autoderef_steps(
1042 goal: CanonicalTyGoal<'tcx>
1043 ) -> MethodAutoderefStepsResult<'tcx> {
1045 desc { "computing autoderef types for `{:?}`", goal }
1050 query target_features_whitelist(_: CrateNum) -> Lrc<FxHashMap<String, Option<String>>> {
1052 desc { "looking up the whitelist of target features" }
1055 // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1056 query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1059 desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1062 query features_query(_: CrateNum) -> Lrc<feature_gate::Features> {
1064 desc { "looking up enabled feature gates" }