1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use dep_graph::{DepConstructor, DepNode};
12 use errors::DiagnosticBuilder;
13 use hir::def_id::{CrateNum, DefId, DefIndex};
14 use hir::def::{Def, Export};
15 use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
17 use infer::canonical::{self, Canonical};
19 use middle::borrowck::BorrowCheckResult;
20 use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
21 use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
22 use middle::privacy::AccessLevels;
23 use middle::reachable::ReachableSet;
25 use middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
26 use middle::stability::{self, DeprecationEntry};
27 use middle::lang_items::{LanguageItems, LangItem};
28 use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
29 use mir::interpret::ConstEvalResult;
30 use mir::mono::{CodegenUnit, Stats};
32 use mir::interpret::{GlobalId, Allocation};
33 use session::{CompileResult, CrateDisambiguator};
34 use session::config::OutputFilenames;
35 use traits::{self, Vtable};
36 use traits::query::{CanonicalPredicateGoal, CanonicalProjectionGoal,
37 CanonicalTyGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal,
38 CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, NoSolution};
39 use traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
40 use traits::query::normalize::NormalizationResult;
41 use traits::query::outlives_bounds::OutlivesBound;
42 use traits::specialization_graph;
44 use ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
46 use ty::subst::Substs;
47 use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
48 use util::common::{ErrorReported};
49 use util::profiling::ProfileCategory::*;
51 use rustc_data_structures::indexed_set::IdxSetBuf;
52 use rustc_target::spec::PanicStrategy;
53 use rustc_data_structures::indexed_vec::IndexVec;
54 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
55 use rustc_data_structures::stable_hasher::StableVec;
58 use rustc_data_structures::sync::Lrc;
60 use syntax_pos::{Span, DUMMY_SP};
61 use syntax_pos::symbol::InternedString;
64 use syntax::feature_gate;
65 use syntax::symbol::Symbol;
69 use self::plumbing::*;
70 pub use self::plumbing::{force_from_dep_node, CycleError};
73 pub use self::job::{QueryJob, QueryInfo};
74 #[cfg(parallel_queries)]
75 pub use self::job::handle_deadlock;
81 use self::values::Value;
84 pub use self::config::QueryConfig;
85 use self::config::{QueryAccessors, QueryDescription};
88 pub use self::on_disk_cache::OnDiskCache;
90 // Each of these quries corresponds to a function pointer field in the
91 // `Providers` struct for requesting a value of that type, and a method
92 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
93 // which memoizes and does dep-graph tracking, wrapping around the actual
94 // `Providers` that the driver creates (using several `rustc_*` crates).
96 // The result type of each query must implement `Clone`, and additionally
97 // `ty::query::values::Value`, which produces an appropriate placeholder
98 // (error) value if the query resulted in a query cycle.
99 // Queries marked with `fatal_cycle` do not need the latter implementation,
100 // as they will raise an fatal error on query cycles instead.
101 define_queries! { <'tcx>
103 /// Records the type of every item.
104 [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
106 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
107 /// associated generics.
108 [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
110 /// Maps from the def-id of an item (trait/struct/enum/fn) to the
111 /// predicates (where clauses) that must be proven true in order
112 /// to reference it. This is almost always the "predicates query"
115 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
116 /// it is almost always the same as that query, except for the
117 /// case of traits. For traits, `predicates_of` contains
118 /// an additional `Self: Trait<...>` predicate that users don't
119 /// actually write. This reflects the fact that to invoke the
120 /// trait (e.g., via `Default::default`) you must supply types
121 /// that actually implement the trait. (However, this extra
122 /// predicate gets in the way of some checks, which are intended
123 /// to operate over only the actual where-clauses written by the
125 [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
127 /// Maps from the def-id of an item (trait/struct/enum/fn) to the
128 /// predicates (where clauses) directly defined on it. This is
129 /// equal to the `explicit_predicates_of` predicates plus the
130 /// `inferred_outlives_of` predicates.
131 [] fn predicates_defined_on: PredicatesDefinedOnItem(DefId) -> ty::GenericPredicates<'tcx>,
133 /// Returns the predicates written explicit by the user.
134 [] fn explicit_predicates_of: ExplicitPredicatesOfItem(DefId)
135 -> ty::GenericPredicates<'tcx>,
137 /// Returns the inferred outlives predicates (e.g., for `struct
138 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
139 [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
141 /// Maps from the def-id of a trait to the list of
142 /// super-predicates. This is a subset of the full list of
143 /// predicates. We store these in a separate map because we must
144 /// evaluate them even during type conversion, often before the
145 /// full predicates are available (note that supertraits have
146 /// additional acyclicity requirements).
147 [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
149 /// To avoid cycles within the predicates of a single item we compute
150 /// per-type-parameter predicates for resolving `T::AssocTy`.
151 [] fn type_param_predicates: type_param_predicates((DefId, DefId))
152 -> ty::GenericPredicates<'tcx>,
154 [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
155 [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
156 [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
157 [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
158 [] fn adt_dtorck_constraint: DtorckConstraint(
160 ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
162 /// True if this is a const fn
163 [] fn is_const_fn: IsConstFn(DefId) -> bool,
165 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
166 [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
168 /// Get a map with the variance of every item; use `item_variance`
170 [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
172 /// Maps from def-id of a type or region parameter to its
173 /// (inferred) variance.
174 [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
178 /// Maps from def-id of a type to its (inferred) outlives.
179 [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
180 -> Lrc<ty::CratePredicatesMap<'tcx>>,
184 /// Maps from an impl/trait def-id to a list of the def-ids of its items
185 [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
187 /// Maps from a trait item to the trait item "descriptor"
188 [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
190 [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
191 [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
195 /// Maps a DefId of a type to a list of its inherent impls.
196 /// Contains implementations of methods that are inherent to a type.
197 /// Methods in these implementations don't need to be exported.
198 [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
202 /// Set of all the def-ids in this crate that have MIR associated with
203 /// them. This includes all the body owners, but also things like struct
205 [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
207 /// Maps DefId's that have an associated Mir to the result
208 /// of the MIR qualify_consts pass. The actual meaning of
209 /// the value isn't known except to the pass itself.
210 [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<IdxSetBuf<mir::Local>>),
212 /// Fetch the MIR for a given def-id right after it's built - this includes
213 /// unreachable code.
214 [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
216 /// Fetch the MIR for a given def-id up till the point where it is
217 /// ready for const evaluation.
219 /// See the README for the `mir` module for details.
220 [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
222 [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
224 /// MIR after our optimization passes have run. This is MIR that is ready
225 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
226 [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
230 /// The result of unsafety-checking this def-id.
231 [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
233 /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
234 [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
236 /// The signature of functions and closures.
237 [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
241 /// Caches CoerceUnsized kinds for impls on custom types.
242 [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
243 -> ty::adjustment::CoerceUnsizedInfo,
247 [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
249 [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
253 [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
257 [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
259 [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
263 [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
265 /// Borrow checks the function body. If this is a closure, returns
266 /// additional requirements that the closure's creator must verify.
267 [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
271 /// Gets a complete map from all types to their inherent impls.
272 /// Not meant to be used directly outside of coherence.
273 /// (Defined only for LOCAL_CRATE)
274 [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
276 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
277 /// Not meant to be used directly outside of coherence.
278 /// (Defined only for LOCAL_CRATE)
279 [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum)
284 /// Results of evaluating const items or constants embedded in
285 /// other items (such as enum variant explicit discriminants).
286 [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
287 -> ConstEvalResult<'tcx>,
289 /// Converts a constant value to an constant allocation
290 [] fn const_value_to_allocation: const_value_to_allocation(
291 &'tcx ty::Const<'tcx>
292 ) -> &'tcx Allocation,
296 [] fn check_match: CheckMatch(DefId)
297 -> Result<(), ErrorReported>,
299 /// Performs the privacy check and computes "access levels".
300 [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
304 [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
306 /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
307 /// in the case of closures, this will be redirected to the enclosing function.
308 [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
310 [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
312 [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
313 [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
315 [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
316 [] fn def_span: DefSpan(DefId) -> Span,
317 [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
318 [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
319 [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
323 [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
327 [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
328 /// Gets the rendered value of the specified constant or associated constant.
330 [] fn rendered_const: RenderedConst(DefId) -> String,
331 [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
335 [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
336 [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
337 [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
341 [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
345 [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
346 -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
350 [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
351 (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
355 [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
356 [] fn specialization_graph_of: SpecializationGraph(DefId)
357 -> Lrc<specialization_graph::Graph>,
358 [] fn is_object_safe: ObjectSafety(DefId) -> bool,
360 // Get the ParameterEnvironment for a given item; this environment
361 // will be in "user-facing" mode, meaning that it is suitabe for
362 // type-checking etc, and it does not normalize specializable
363 // associated types. This is almost always what you want,
364 // unless you are doing MIR optimizations, in which case you
365 // might want to use `reveal_all()` method to change modes.
366 [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
368 // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
369 // `ty.is_copy()`, etc, since that will prune the environment where possible.
370 [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
371 [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
372 [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
373 [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
374 [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
375 -> Result<&'tcx ty::layout::LayoutDetails,
376 ty::layout::LayoutError<'tcx>>,
380 [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
381 -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
385 [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
386 [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
387 [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
388 [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
389 [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
390 [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
391 [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
393 [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
397 [] fn specializes: specializes_node((DefId, DefId)) -> bool,
398 [] fn in_scope_traits_map: InScopeTraits(DefIndex)
399 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
403 [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
404 [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
408 [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
410 [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
411 [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
412 [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
416 // The DefIds of all non-generic functions and statics in the given crate
417 // that can be reached from outside the crate.
419 // We expect this items to be available for being linked to.
421 // This query can also be called for LOCAL_CRATE. In this case it will
422 // compute which items will be reachable to other crates, taking into account
423 // the kind of crate that is currently compiled. Crates with only a
424 // C interface have fewer reachable things.
426 // Does not include external symbols that don't have a corresponding DefId,
427 // like the compiler-generated `main` function and so on.
428 [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
429 -> Lrc<DefIdMap<SymbolExportLevel>>,
430 [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
431 [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
435 [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
436 -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
437 [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
438 -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
442 [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
444 [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
446 [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
447 [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
448 [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
449 [] fn crate_hash: CrateHash(CrateNum) -> Svh,
450 [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
451 [] fn extra_filename: ExtraFileName(CrateNum) -> String,
455 [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
457 [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
462 [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
463 -> Lrc<FxHashSet<DefId>>,
464 [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
465 [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
466 [] fn native_library_kind: NativeLibraryKind(DefId)
467 -> Option<NativeLibraryKind>,
471 [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
475 // Lifetime resolution. See `middle::resolve_lifetimes`.
476 [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
477 [] fn named_region_map: NamedRegion(DefIndex) ->
478 Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
479 [] fn is_late_bound_map: IsLateBound(DefIndex) ->
480 Option<Lrc<FxHashSet<ItemLocalId>>>,
481 [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
482 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
486 [] fn visibility: Visibility(DefId) -> ty::Visibility,
490 [] fn dep_kind: DepKind(CrateNum) -> DepKind,
491 [] fn crate_name: CrateName(CrateNum) -> Symbol,
492 [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
493 [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
495 [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
496 [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
497 [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
498 [] fn visible_parent_map: visible_parent_map_node(CrateNum)
499 -> Lrc<DefIdMap<DefId>>,
500 [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
501 [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
502 [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
504 [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
505 [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
506 [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
507 -> Lrc<Vec<(DefId, Span)>>,
509 [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
510 [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
512 /// A vector of every trait accessible in the whole crate
513 /// (i.e. including those from subcrates). This is used only for
515 [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
519 [] fn exported_symbols: ExportedSymbols(CrateNum)
520 -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
524 [] fn collect_and_partition_mono_items:
525 collect_and_partition_mono_items_node(CrateNum)
526 -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
527 [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
528 [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
529 [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
533 [] fn output_filenames: output_filenames_node(CrateNum)
534 -> Arc<OutputFilenames>,
538 // Erases regions from `ty` to yield a new type.
539 // Normally you would just use `tcx.erase_regions(&value)`,
540 // however, which uses this query as a kind of cache.
541 [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
543 /// Do not call this query directly: invoke `normalize` instead.
544 [] fn normalize_projection_ty: NormalizeProjectionTy(
545 CanonicalProjectionGoal<'tcx>
547 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, NormalizationResult<'tcx>>>>,
551 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
552 [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
553 ParamEnvAnd<'tcx, Ty<'tcx>>
556 [] fn implied_outlives_bounds: ImpliedOutlivesBounds(
557 CanonicalTyGoal<'tcx>
559 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, Vec<OutlivesBound<'tcx>>>>>,
563 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
564 [] fn dropck_outlives: DropckOutlives(
565 CanonicalTyGoal<'tcx>
567 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>,
571 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
572 /// `infcx.predicate_must_hold()` instead.
573 [] fn evaluate_obligation: EvaluateObligation(
574 CanonicalPredicateGoal<'tcx>
575 ) -> Result<traits::EvaluationResult, traits::OverflowError>,
577 /// Do not call this query directly: part of the `Eq` type-op
578 [] fn type_op_eq: TypeOpEq(
579 CanonicalTypeOpEqGoal<'tcx>
581 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
585 /// Do not call this query directly: part of the `Subtype` type-op
586 [] fn type_op_subtype: TypeOpSubtype(
587 CanonicalTypeOpSubtypeGoal<'tcx>
589 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
593 /// Do not call this query directly: part of the `ProvePredicate` type-op
594 [] fn type_op_prove_predicate: TypeOpProvePredicate(
595 CanonicalTypeOpProvePredicateGoal<'tcx>
597 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
601 /// Do not call this query directly: part of the `Normalize` type-op
602 [] fn type_op_normalize_ty: TypeOpNormalizeTy(
603 CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
605 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, Ty<'tcx>>>>,
609 /// Do not call this query directly: part of the `Normalize` type-op
610 [] fn type_op_normalize_predicate: TypeOpNormalizePredicate(
611 CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
613 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::Predicate<'tcx>>>>,
617 /// Do not call this query directly: part of the `Normalize` type-op
618 [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig(
619 CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
621 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::PolyFnSig<'tcx>>>>,
625 /// Do not call this query directly: part of the `Normalize` type-op
626 [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig(
627 CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
629 Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::FnSig<'tcx>>>>,
633 [] fn substitute_normalize_and_test_predicates:
634 substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
638 [] fn target_features_whitelist:
639 target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
641 // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
642 [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
645 [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
649 [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>,
651 [] fn program_clauses_for_env: ProgramClausesForEnv(
657 [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
658 -> Lrc<FxHashMap<DefId, String>>,
662 // `try_get_query` can't be public because it uses the private query
663 // implementation traits, so we provide access to it selectively.
664 impl<'a, 'tcx, 'lcx> TyCtxt<'a, 'tcx, 'lcx> {
665 pub fn try_adt_sized_constraint(
669 ) -> Result<&'tcx [Ty<'tcx>], DiagnosticBuilder<'a>> {
670 self.try_get_query::<queries::adt_sized_constraint>(span, key)
672 pub fn try_needs_drop_raw(
675 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
676 ) -> Result<bool, DiagnosticBuilder<'a>> {
677 self.try_get_query::<queries::needs_drop_raw>(span, key)
679 pub fn try_optimized_mir(
683 ) -> Result<&'tcx mir::Mir<'tcx>, DiagnosticBuilder<'a>> {
684 self.try_get_query::<queries::optimized_mir>(span, key)
688 //////////////////////////////////////////////////////////////////////
689 // These functions are little shims used to find the dep-node for a
690 // given query when there is not a *direct* mapping:
693 fn features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
694 DepConstructor::Features
697 fn codegen_fn_attrs<'tcx>(id: DefId) -> DepConstructor<'tcx> {
698 DepConstructor::CodegenFnAttrs { 0: id }
701 fn erase_regions_ty<'tcx>(ty: Ty<'tcx>) -> DepConstructor<'tcx> {
702 DepConstructor::EraseRegionsTy { ty }
705 fn const_value_to_allocation<'tcx>(
706 val: &'tcx ty::Const<'tcx>,
707 ) -> DepConstructor<'tcx> {
708 DepConstructor::ConstValueToAllocation { val }
711 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
712 DepConstructor::TypeParamPredicates {
718 fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
719 (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> DepConstructor<'tcx> {
720 DepConstructor::FulfillObligation {
726 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
727 DepConstructor::Coherence
730 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
731 DepConstructor::CoherenceInherentImplOverlapCheck
734 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
735 DepConstructor::Reachability
738 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
739 DepConstructor::MirShim {
744 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
745 DepConstructor::InstanceSymbolName { instance }
748 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
749 DepConstructor::TypeckBodiesKrate
752 fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
753 -> DepConstructor<'tcx> {
754 DepConstructor::ConstEval { param_env }
757 fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
758 DepConstructor::MirKeys
761 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
762 DepConstructor::CrateVariances
765 fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
766 DepConstructor::IsCopy { param_env }
769 fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
770 DepConstructor::IsSized { param_env }
773 fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
774 DepConstructor::IsFreeze { param_env }
777 fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
778 DepConstructor::NeedsDrop { param_env }
781 fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
782 DepConstructor::Layout { param_env }
785 fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
786 DepConstructor::LintLevels
789 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
790 DepConstructor::Specializes { impl1: a, impl2: b }
793 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
794 -> DepConstructor<'tcx>
796 DepConstructor::ImplementationsOfTrait { krate, trait_id }
799 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
800 DepConstructor::LinkArgs
803 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
804 DepConstructor::GetLangItems
807 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
808 DepConstructor::VisibleParentMap
811 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
812 DepConstructor::PostorderCnums
815 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
816 DepConstructor::MaybeUnusedExternCrates
819 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
820 DepConstructor::StabilityIndex
823 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
824 DepConstructor::AllCrateNums
827 fn all_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
828 DepConstructor::AllTraits
831 fn collect_and_partition_mono_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
832 DepConstructor::CollectAndPartitionMonoItems
835 fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
836 DepConstructor::OutputFilenames
839 fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> {
840 DepConstructor::VtableMethods{ trait_ref }
843 fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>))
844 -> DepConstructor<'tcx> {
845 DepConstructor::SubstituteNormalizeAndTestPredicates { key }
848 fn target_features_whitelist_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
849 DepConstructor::TargetFeaturesWhitelist
852 fn instance_def_size_estimate_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>)
853 -> DepConstructor<'tcx> {
854 DepConstructor::InstanceDefSizeEstimate {