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::{RecoverKey,DepKind, DepNode, SerializedDepNodeIndex};
6 use crate::hir::def_id::{CrateNum, DefId, DefIndex};
8 use crate::mir::interpret::GlobalId;
10 use crate::traits::query::{
11 CanonicalPredicateGoal, CanonicalProjectionGoal,
12 CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
13 CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal,
14 CanonicalTypeOpNormalizeGoal,
18 use syntax_pos::symbol::InternedString;
21 // Each of these queries corresponds to a function pointer field in the
22 // `Providers` struct for requesting a value of that type, and a method
23 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
24 // which memoizes and does dep-graph tracking, wrapping around the actual
25 // `Providers` that the driver creates (using several `rustc_*` crates).
27 // The result type of each query must implement `Clone`, and additionally
28 // `ty::query::values::Value`, which produces an appropriate placeholder
29 // (error) value if the query resulted in a query cycle.
30 // Queries marked with `fatal_cycle` do not need the latter implementation,
31 // as they will raise an fatal error on query cycles instead.
34 /// Records the type of every item.
35 query type_of(key: DefId) -> Ty<'tcx> {
36 cache_on_disk_if { key.is_local() }
39 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
40 /// associated generics.
41 query generics_of(key: DefId) -> &'tcx ty::Generics {
42 cache_on_disk_if { key.is_local() }
43 load_cached(tcx, id) {
44 let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
45 .try_load_query_result(tcx, id);
46 generics.map(|x| &*tcx.arena.alloc(x))
50 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
51 /// predicates (where-clauses) that must be proven true in order
52 /// to reference it. This is almost always the "predicates query"
55 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
56 /// it is almost always the same as that query, except for the
57 /// case of traits. For traits, `predicates_of` contains
58 /// an additional `Self: Trait<...>` predicate that users don't
59 /// actually write. This reflects the fact that to invoke the
60 /// trait (e.g., via `Default::default`) you must supply types
61 /// that actually implement the trait. (However, this extra
62 /// predicate gets in the way of some checks, which are intended
63 /// to operate over only the actual where-clauses written by the
65 query predicates_of(key: DefId) -> &'tcx ty::GenericPredicates<'tcx> {
66 cache_on_disk_if { key.is_local() }
69 query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLibrary>> {
70 desc { "looking up the native libraries of a linked crate" }
73 query lint_levels(_: CrateNum) -> &'tcx lint::LintLevelMap {
75 desc { "computing the lint levels for items in this crate" }
80 query is_panic_runtime(_: CrateNum) -> bool {
82 desc { "checking if the crate is_panic_runtime" }
87 /// Set of all the `DefId`s in this crate that have MIR associated with
88 /// them. This includes all the body owners, but also things like struct
90 query mir_keys(_: CrateNum) -> &'tcx DefIdSet {
91 desc { "getting a list of all mir_keys" }
94 /// Maps DefId's that have an associated `mir::Body` to the result
95 /// of the MIR qualify_consts pass. The actual meaning of
96 /// the value isn't known except to the pass itself.
97 query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet<mir::Local>) {
98 cache_on_disk_if { key.is_local() }
101 /// Fetch the MIR for a given `DefId` right after it's built - this includes
102 /// unreachable code.
103 query mir_built(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {}
105 /// Fetch the MIR for a given `DefId` up till the point where it is
106 /// ready for const evaluation.
108 /// See the README for the `mir` module for details.
109 query mir_const(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
113 query mir_validated(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
117 /// MIR after our optimization passes have run. This is MIR that is ready
118 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
119 query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
120 cache_on_disk_if { key.is_local() }
121 load_cached(tcx, id) {
122 let mir: Option<crate::mir::Body<'tcx>> = tcx.queries.on_disk_cache
123 .try_load_query_result(tcx, id);
124 mir.map(|x| &*tcx.arena.alloc(x))
128 query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> { }
132 // Erases regions from `ty` to yield a new type.
133 // Normally you would just use `tcx.erase_regions(&value)`,
134 // however, which uses this query as a kind of cache.
135 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
136 // This query is not expected to have input -- as a result, it
137 // is not a good candidates for "replay" because it is essentially a
138 // pure function of its input (and hence the expectation is that
139 // no caller would be green **apart** from just these
140 // queries). Making it anonymous avoids hashing the result, which
141 // may save a bit of time.
144 desc { "erasing regions from `{:?}`", ty }
147 query program_clauses_for(_: DefId) -> Clauses<'tcx> {
148 desc { "generating chalk-style clauses" }
151 query program_clauses_for_env(_: traits::Environment<'tcx>) -> Clauses<'tcx> {
153 desc { "generating chalk-style clauses for environment" }
156 // Get the chalk-style environment of the given item.
157 query environment(_: DefId) -> traits::Environment<'tcx> {
158 desc { "return a chalk-style environment" }
163 query wasm_import_module_map(_: CrateNum) -> &'tcx FxHashMap<DefId, String> {
164 desc { "wasm import module map" }
169 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
170 /// predicates (where-clauses) directly defined on it. This is
171 /// equal to the `explicit_predicates_of` predicates plus the
172 /// `inferred_outlives_of` predicates.
173 query predicates_defined_on(_: DefId)
174 -> &'tcx ty::GenericPredicates<'tcx> {}
176 /// Returns the predicates written explicitly by the user.
177 query explicit_predicates_of(_: DefId)
178 -> &'tcx ty::GenericPredicates<'tcx> {}
180 /// Returns the inferred outlives predicates (e.g., for `struct
181 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
182 query inferred_outlives_of(_: DefId) -> &'tcx [ty::Predicate<'tcx>] {}
184 /// Maps from the `DefId` of a trait to the list of
185 /// super-predicates. This is a subset of the full list of
186 /// predicates. We store these in a separate map because we must
187 /// evaluate them even during type conversion, often before the
188 /// full predicates are available (note that supertraits have
189 /// additional acyclicity requirements).
190 query super_predicates_of(key: DefId) -> &'tcx ty::GenericPredicates<'tcx> {
191 desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
194 /// To avoid cycles within the predicates of a single item we compute
195 /// per-type-parameter predicates for resolving `T::AssocTy`.
196 query type_param_predicates(key: (DefId, DefId))
197 -> &'tcx ty::GenericPredicates<'tcx> {
199 desc { |tcx| "computing the bounds for type parameter `{}`", {
200 let id = tcx.hir().as_local_hir_id(key.1).unwrap();
201 tcx.hir().ty_param_name(id)
205 query trait_def(_: DefId) -> &'tcx ty::TraitDef {}
206 query adt_def(_: DefId) -> &'tcx ty::AdtDef {}
207 query adt_destructor(_: DefId) -> Option<ty::Destructor> {}
209 // The cycle error here should be reported as an error by `check_representable`.
210 // We consider the type as Sized in the meanwhile to avoid
211 // further errors (done in impl Value for AdtSizedConstraint).
212 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
213 // in case we accidentally otherwise don't emit an error.
214 query adt_sized_constraint(
216 ) -> AdtSizedConstraint<'tcx> {
220 query adt_dtorck_constraint(
222 ) -> Result<DtorckConstraint<'tcx>, NoSolution> {}
224 /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
225 /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
226 /// not have the feature gate active).
228 /// **Do not call this function manually.** It is only meant to cache the base data for the
229 /// `is_const_fn` function.
230 query is_const_fn_raw(key: DefId) -> bool {
231 desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
234 /// Returns `true` if calls to the function may be promoted.
236 /// This is either because the function is e.g., a tuple-struct or tuple-variant
237 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
238 /// be removed in the future in favour of some form of check which figures out whether the
239 /// function does not inspect the bits of any of its arguments (so is essentially just a
240 /// constructor function).
241 query is_promotable_const_fn(_: DefId) -> bool {}
243 query const_fn_is_allowed_fn_ptr(_: DefId) -> bool {}
245 /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
246 query is_foreign_item(_: DefId) -> bool {}
248 /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
249 query static_mutability(_: DefId) -> Option<hir::Mutability> {}
251 /// Gets a map with the variance of every item; use `item_variance` instead.
252 query crate_variances(_: CrateNum) -> &'tcx ty::CrateVariancesMap<'tcx> {
253 desc { "computing the variances for items in this crate" }
256 /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
257 query variances_of(_: DefId) -> &'tcx [ty::Variance] {}
261 /// Maps from thee `DefId` of a type to its (inferred) outlives.
262 query inferred_outlives_crate(_: CrateNum)
263 -> &'tcx ty::CratePredicatesMap<'tcx> {
264 desc { "computing the inferred outlives predicates for items in this crate" }
269 /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
270 query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}
272 /// Maps from a trait item to the trait item "descriptor".
273 query associated_item(_: DefId) -> ty::AssocItem {}
275 query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
276 query impl_polarity(_: DefId) -> hir::ImplPolarity {}
278 query issue33140_self_ty(_: DefId) -> Option<ty::Ty<'tcx>> {}
282 /// Maps a `DefId` of a type to a list of its inherent impls.
283 /// Contains implementations of methods that are inherent to a type.
284 /// Methods in these implementations don't need to be exported.
285 query inherent_impls(_: DefId) -> &'tcx [DefId] {
291 /// The result of unsafety-checking this `DefId`.
292 query unsafety_check_result(key: DefId) -> mir::UnsafetyCheckResult {
293 cache_on_disk_if { key.is_local() }
296 /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
297 query unsafe_derive_on_repr_packed(_: DefId) -> () {}
299 /// The signature of functions and closures.
300 query fn_sig(_: DefId) -> ty::PolyFnSig<'tcx> {}
304 query lint_mod(key: DefId) -> () {
305 desc { |tcx| "linting {}", key.describe_as_module(tcx) }
308 /// Checks the attributes in the module.
309 query check_mod_attrs(key: DefId) -> () {
310 desc { |tcx| "checking attributes in {}", key.describe_as_module(tcx) }
313 query check_mod_unstable_api_usage(key: DefId) -> () {
314 desc { |tcx| "checking for unstable API usage in {}", key.describe_as_module(tcx) }
317 /// Checks the loops in the module.
318 query check_mod_loops(key: DefId) -> () {
319 desc { |tcx| "checking loops in {}", key.describe_as_module(tcx) }
322 query check_mod_item_types(key: DefId) -> () {
323 desc { |tcx| "checking item types in {}", key.describe_as_module(tcx) }
326 query check_mod_privacy(key: DefId) -> () {
327 desc { |tcx| "checking privacy in {}", key.describe_as_module(tcx) }
330 query check_mod_intrinsics(key: DefId) -> () {
331 desc { |tcx| "checking intrinsics in {}", key.describe_as_module(tcx) }
334 query check_mod_liveness(key: DefId) -> () {
335 desc { |tcx| "checking liveness of variables in {}", key.describe_as_module(tcx) }
338 query check_mod_impl_wf(key: DefId) -> () {
339 desc { |tcx| "checking that impls are well-formed in {}", key.describe_as_module(tcx) }
342 query collect_mod_item_types(key: DefId) -> () {
343 desc { |tcx| "collecting item types in {}", key.describe_as_module(tcx) }
346 /// Caches `CoerceUnsized` kinds for impls on custom types.
347 query coerce_unsized_info(_: DefId)
348 -> ty::adjustment::CoerceUnsizedInfo {}
352 query typeck_item_bodies(_: CrateNum) -> () {
353 desc { "type-checking all item bodies" }
356 query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
357 cache_on_disk_if { key.is_local() }
358 load_cached(tcx, id) {
359 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
360 .queries.on_disk_cache
361 .try_load_query_result(tcx, id);
363 typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
369 query used_trait_imports(key: DefId) -> &'tcx DefIdSet {
370 cache_on_disk_if { key.is_local() }
375 query has_typeck_tables(_: DefId) -> bool {}
377 query coherent_trait(def_id: DefId) -> () {
378 desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
383 query borrowck(key: DefId) -> &'tcx BorrowCheckResult {
384 cache_on_disk_if { key.is_local() }
387 /// Borrow-checks the function body. If this is a closure, returns
388 /// additional requirements that the closure's creator must verify.
389 query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
390 cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) }
395 /// Gets a complete map from all types to their inherent impls.
396 /// Not meant to be used directly outside of coherence.
397 /// (Defined only for `LOCAL_CRATE`.)
398 query crate_inherent_impls(k: CrateNum)
399 -> &'tcx CrateInherentImpls {
401 desc { "all inherent impls defined in crate `{:?}`", k }
404 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
405 /// Not meant to be used directly outside of coherence.
406 /// (Defined only for `LOCAL_CRATE`.)
407 query crate_inherent_impls_overlap_check(_: CrateNum)
410 desc { "check for overlap between inherent impls defined in this crate" }
415 /// Evaluates a constant without running sanity checks.
417 /// **Do not use this** outside const eval. Const eval uses this to break query cycles
418 /// during validation. Please add a comment to every use site explaining why using
419 /// `const_eval` isn't sufficient.
420 query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
421 -> ConstEvalRawResult<'tcx> {
424 "const-evaluating `{}`",
425 tcx.def_path_str(key.value.instance.def.def_id())
427 cache_on_disk_if(_, opt_result) {
428 // Only store results without errors
429 // FIXME: We never store these
430 opt_result.map_or(true, |r| r.is_ok())
434 /// Results of evaluating const items or constants embedded in
435 /// other items (such as enum variant explicit discriminants).
436 query const_eval(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
437 -> ConstEvalResult<'tcx> {
440 "const-evaluating + checking `{}`",
441 tcx.def_path_str(key.value.instance.def.def_id())
443 cache_on_disk_if(_, opt_result) {
444 // Only store results without errors
445 opt_result.map_or(true, |r| r.is_ok())
449 /// Extracts a field of a (variant of a) const.
451 key: ty::ParamEnvAnd<'tcx, (&'tcx ty::Const<'tcx>, mir::Field)>
452 ) -> &'tcx ty::Const<'tcx> {
455 desc { "extract field of const" }
458 /// Produces an absolute path representation of the given type. See also the documentation
459 /// on `std::any::type_name`.
460 query type_name(key: Ty<'tcx>) -> &'tcx ty::Const<'tcx> {
463 desc { "get absolute path of type" }
469 query check_match(key: DefId) -> () {
470 cache_on_disk_if { key.is_local() }
473 /// Performs part of the privacy check and computes "access levels".
474 query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
476 desc { "privacy access levels" }
478 query check_private_in_public(_: CrateNum) -> () {
480 desc { "checking for private elements in public interfaces" }
485 query reachable_set(_: CrateNum) -> ReachableSet {
486 desc { "reachability" }
489 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
490 /// in the case of closures, this will be redirected to the enclosing function.
491 query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
493 query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
495 desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
498 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName {
500 desc { "computing the symbol for `{}`", key }
501 cache_on_disk_if { true }
504 query def_kind(_: DefId) -> Option<DefKind> {}
505 query def_span(_: DefId) -> Span {
506 // FIXME(mw): DefSpans are not really inputs since they are derived from
507 // HIR. But at the moment HIR hashing still contains some hacks that allow
508 // to make type debuginfo to be source location independent. Declaring
509 // DefSpan an input makes sure that changes to these are always detected
510 // regardless of HIR hashing.
513 query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
514 query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
515 query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
519 query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {
520 cache_on_disk_if { true }
525 query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
526 /// Gets the rendered value of the specified constant or associated constant.
528 query rendered_const(_: DefId) -> String {}
529 query impl_parent(_: DefId) -> Option<DefId> {}
533 query trait_of_item(_: DefId) -> Option<DefId> {}
534 query const_is_rvalue_promotable_to_static(key: DefId) -> bool {
536 "const checking if rvalue is promotable to static `{}`",
537 tcx.def_path_str(key)
539 cache_on_disk_if { true }
541 query rvalue_promotable_map(key: DefId) -> &'tcx ItemLocalSet {
543 "checking which parts of `{}` are promotable to static",
544 tcx.def_path_str(key)
550 query is_mir_available(key: DefId) -> bool {
551 desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
556 query vtable_methods(key: ty::PolyTraitRef<'tcx>)
557 -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
559 desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) }
564 query codegen_fulfill_obligation(
565 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
566 ) -> Vtable<'tcx, ()> {
568 cache_on_disk_if { true }
570 "checking if `{}` fulfills its obligations",
571 tcx.def_path_str(key.1.def_id())
577 query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls {
578 desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
580 query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph {
581 cache_on_disk_if { true }
583 query is_object_safe(key: DefId) -> bool {
584 desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
587 /// Gets the ParameterEnvironment for a given item; this environment
588 /// will be in "user-facing" mode, meaning that it is suitabe for
589 /// type-checking etc, and it does not normalize specializable
590 /// associated types. This is almost always what you want,
591 /// unless you are doing MIR optimizations, in which case you
592 /// might want to use `reveal_all()` method to change modes.
593 query param_env(_: DefId) -> ty::ParamEnv<'tcx> {}
595 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
596 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
597 query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
599 desc { "computing whether `{}` is `Copy`", env.value }
601 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
603 desc { "computing whether `{}` is `Sized`", env.value }
605 query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
607 desc { "computing whether `{}` is freeze", env.value }
610 // The cycle error here should be reported as an error by `check_representable`.
611 // We consider the type as not needing drop in the meanwhile to avoid
612 // further errors (done in impl Value for NeedsDrop).
613 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
614 // in case we accidentally otherwise don't emit an error.
615 query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> NeedsDrop {
618 desc { "computing whether `{}` needs drop", env.value }
622 env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
623 ) -> Result<&'tcx ty::layout::LayoutDetails, ty::layout::LayoutError<'tcx>> {
625 desc { "computing layout of `{}`", env.value }
630 query dylib_dependency_formats(_: CrateNum)
631 -> &'tcx [(CrateNum, LinkagePreference)] {
632 desc { "dylib dependency formats of crate" }
637 query is_compiler_builtins(_: CrateNum) -> bool {
639 desc { "checking if the crate is_compiler_builtins" }
641 query has_global_allocator(_: CrateNum) -> bool {
643 desc { "checking if the crate has_global_allocator" }
645 query has_panic_handler(_: CrateNum) -> bool {
647 desc { "checking if the crate has_panic_handler" }
649 query is_sanitizer_runtime(_: CrateNum) -> bool {
651 desc { "query a crate is #![sanitizer_runtime]" }
653 query is_profiler_runtime(_: CrateNum) -> bool {
655 desc { "query a crate is #![profiler_runtime]" }
657 query panic_strategy(_: CrateNum) -> PanicStrategy {
659 desc { "query a crate's configured panic strategy" }
661 query is_no_builtins(_: CrateNum) -> bool {
663 desc { "test whether a crate has #![no_builtins]" }
665 query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
667 desc { "query a crate's symbol mangling version" }
670 query extern_crate(_: DefId) -> Option<&'tcx ExternCrate> {
672 desc { "getting crate's ExternCrateData" }
677 query specializes(_: (DefId, DefId)) -> bool {
679 desc { "computing whether impls specialize one another" }
681 query in_scope_traits_map(_: DefIndex)
682 -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
684 desc { "traits in scope at a block" }
689 query module_exports(_: DefId) -> Option<&'tcx [Export<hir::HirId>]> {
695 query impl_defaultness(_: DefId) -> hir::Defaultness {}
697 query check_item_well_formed(_: DefId) -> () {}
698 query check_trait_item_well_formed(_: DefId) -> () {}
699 query check_impl_item_well_formed(_: DefId) -> () {}
703 // The `DefId`s of all non-generic functions and statics in the given crate
704 // that can be reached from outside the crate.
706 // We expect this items to be available for being linked to.
708 // This query can also be called for `LOCAL_CRATE`. In this case it will
709 // compute which items will be reachable to other crates, taking into account
710 // the kind of crate that is currently compiled. Crates with only a
711 // C interface have fewer reachable things.
713 // Does not include external symbols that don't have a corresponding DefId,
714 // like the compiler-generated `main` function and so on.
715 query reachable_non_generics(_: CrateNum)
716 -> &'tcx DefIdMap<SymbolExportLevel> {
717 desc { "looking up the exported symbols of a crate" }
719 query is_reachable_non_generic(_: DefId) -> bool {}
720 query is_unreachable_local_definition(_: DefId) -> bool {}
724 query upstream_monomorphizations(
726 ) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
727 desc { "collecting available upstream monomorphizations `{:?}`", k }
729 query upstream_monomorphizations_for(_: DefId)
730 -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {}
734 query foreign_modules(_: CrateNum) -> &'tcx [ForeignModule] {
735 desc { "looking up the foreign modules of a linked crate" }
738 /// Identifies the entry-point (e.g., the `main` function) for a given
739 /// crate, returning `None` if there is no entry point (such as for library crates).
740 query entry_fn(_: CrateNum) -> Option<(DefId, EntryFnType)> {
741 desc { "looking up the entry function of a crate" }
743 query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
744 desc { "looking up the plugin registrar for a crate" }
746 query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
747 desc { "looking up the derive registrar for a crate" }
749 query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
751 desc { "looking up the disambiguator a crate" }
753 query crate_hash(_: CrateNum) -> Svh {
755 desc { "looking up the hash a crate" }
757 query original_crate_name(_: CrateNum) -> Symbol {
759 desc { "looking up the original name a crate" }
761 query extra_filename(_: CrateNum) -> String {
763 desc { "looking up the extra filename for a crate" }
768 query implementations_of_trait(_: (CrateNum, DefId))
771 desc { "looking up implementations of a trait in a crate" }
773 query all_trait_implementations(_: CrateNum)
775 desc { "looking up all (?) trait implementations" }
780 query dllimport_foreign_items(_: CrateNum)
781 -> &'tcx FxHashSet<DefId> {
782 desc { "dllimport_foreign_items" }
784 query is_dllimport_foreign_item(_: DefId) -> bool {}
785 query is_statically_included_foreign_item(_: DefId) -> bool {}
786 query native_library_kind(_: DefId)
787 -> Option<NativeLibraryKind> {}
791 query link_args(_: CrateNum) -> Lrc<Vec<String>> {
793 desc { "looking up link arguments for a crate" }
798 // Lifetime resolution. See `middle::resolve_lifetimes`.
799 query resolve_lifetimes(_: CrateNum) -> &'tcx ResolveLifetimes {
800 desc { "resolving lifetimes" }
802 query named_region_map(_: DefIndex) ->
803 Option<&'tcx FxHashMap<ItemLocalId, Region>> {
804 desc { "looking up a named region" }
806 query is_late_bound_map(_: DefIndex) ->
807 Option<&'tcx FxHashSet<ItemLocalId>> {
808 desc { "testing if a region is late bound" }
810 query object_lifetime_defaults_map(_: DefIndex)
811 -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>> {
812 desc { "looking up lifetime defaults for a region" }
817 query visibility(_: DefId) -> ty::Visibility {}
821 query dep_kind(_: CrateNum) -> DepKind {
823 desc { "fetching what a dependency looks like" }
825 query crate_name(_: CrateNum) -> Symbol {
827 desc { "fetching what a crate is named" }
829 query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
830 query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
832 query get_lib_features(_: CrateNum) -> &'tcx LibFeatures {
834 desc { "calculating the lib features map" }
836 query defined_lib_features(_: CrateNum)
837 -> &'tcx [(Symbol, Option<Symbol>)] {
838 desc { "calculating the lib features defined in a crate" }
840 query get_lang_items(_: CrateNum) -> &'tcx LanguageItems {
842 desc { "calculating the lang items map" }
844 query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
845 desc { "calculating the lang items defined in a crate" }
847 query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
848 desc { "calculating the missing lang items in a crate" }
850 query visible_parent_map(_: CrateNum)
851 -> &'tcx DefIdMap<DefId> {
852 desc { "calculating the visible parent map" }
854 query missing_extern_crate_item(_: CrateNum) -> bool {
856 desc { "seeing if we're missing an `extern crate` item for this crate" }
858 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
860 desc { "looking at the source for a crate" }
862 query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] {
864 desc { "generating a postorder list of CrateNums" }
867 query upvars(_: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
870 query maybe_unused_trait_import(_: DefId) -> bool {
873 query maybe_unused_extern_crates(_: CrateNum)
874 -> &'tcx [(DefId, Span)] {
876 desc { "looking up all possibly unused extern crates" }
878 query names_imported_by_glob_use(_: DefId)
879 -> Lrc<FxHashSet<ast::Name>> {
883 query stability_index(_: CrateNum) -> &'tcx stability::Index<'tcx> {
885 desc { "calculating the stability index for the local crate" }
887 query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
889 desc { "fetching all foreign CrateNum instances" }
892 /// A vector of every trait accessible in the whole crate
893 /// (i.e., including those from subcrates). This is used only for
895 query all_traits(_: CrateNum) -> &'tcx [DefId] {
896 desc { "fetching all foreign and local traits" }
901 query exported_symbols(_: CrateNum)
902 -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
903 desc { "exported_symbols" }
908 query collect_and_partition_mono_items(_: CrateNum)
909 -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>) {
911 desc { "collect_and_partition_mono_items" }
913 query is_codegened_item(_: DefId) -> bool {}
914 query codegen_unit(_: InternedString) -> Arc<CodegenUnit<'tcx>> {
916 desc { "codegen_unit" }
918 query backend_optimization_level(_: CrateNum) -> OptLevel {
919 desc { "optimization level used by backend" }
924 query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
926 desc { "output_filenames" }
931 /// Do not call this query directly: invoke `normalize` instead.
932 query normalize_projection_ty(
933 goal: CanonicalProjectionGoal<'tcx>
935 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
939 desc { "normalizing `{:?}`", goal }
942 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
943 query normalize_ty_after_erasing_regions(
944 goal: ParamEnvAnd<'tcx, Ty<'tcx>>
947 desc { "normalizing `{:?}`", goal }
950 query implied_outlives_bounds(
951 goal: CanonicalTyGoal<'tcx>
953 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
957 desc { "computing implied outlives bounds for `{:?}`", goal }
960 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
961 query dropck_outlives(
962 goal: CanonicalTyGoal<'tcx>
964 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
968 desc { "computing dropck types for `{:?}`", goal }
971 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
972 /// `infcx.predicate_must_hold()` instead.
973 query evaluate_obligation(
974 goal: CanonicalPredicateGoal<'tcx>
975 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
977 desc { "evaluating trait selection obligation `{}`", goal.value.value }
981 goal: traits::ChalkCanonicalGoal<'tcx>
983 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
987 desc { "evaluating trait selection obligation `{}`", goal.value.goal }
990 /// Do not call this query directly: part of the `Eq` type-op
991 query type_op_ascribe_user_type(
992 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
994 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
998 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1001 /// Do not call this query directly: part of the `Eq` type-op
1003 goal: CanonicalTypeOpEqGoal<'tcx>
1005 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1009 desc { "evaluating `type_op_eq` `{:?}`", goal }
1012 /// Do not call this query directly: part of the `Subtype` type-op
1013 query type_op_subtype(
1014 goal: CanonicalTypeOpSubtypeGoal<'tcx>
1016 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1020 desc { "evaluating `type_op_subtype` `{:?}`", goal }
1023 /// Do not call this query directly: part of the `ProvePredicate` type-op
1024 query type_op_prove_predicate(
1025 goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1027 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1031 desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1034 /// Do not call this query directly: part of the `Normalize` type-op
1035 query type_op_normalize_ty(
1036 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1038 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1042 desc { "normalizing `{:?}`", goal }
1045 /// Do not call this query directly: part of the `Normalize` type-op
1046 query type_op_normalize_predicate(
1047 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1049 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1053 desc { "normalizing `{:?}`", goal }
1056 /// Do not call this query directly: part of the `Normalize` type-op
1057 query type_op_normalize_poly_fn_sig(
1058 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1060 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1064 desc { "normalizing `{:?}`", goal }
1067 /// Do not call this query directly: part of the `Normalize` type-op
1068 query type_op_normalize_fn_sig(
1069 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1071 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1075 desc { "normalizing `{:?}`", goal }
1078 query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1081 "testing substituted normalized predicates:`{}`",
1082 tcx.def_path_str(key.0)
1086 query method_autoderef_steps(
1087 goal: CanonicalTyGoal<'tcx>
1088 ) -> MethodAutoderefStepsResult<'tcx> {
1090 desc { "computing autoderef types for `{:?}`", goal }
1095 query target_features_whitelist(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
1097 desc { "looking up the whitelist of target features" }
1100 // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1101 query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1104 desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1107 query features_query(_: CrateNum) -> &'tcx feature_gate::Features {
1109 desc { "looking up enabled feature gates" }