1 use crate::dep_graph::{DepConstructor, DepNode};
2 use crate::errors::DiagnosticBuilder;
3 use crate::hir::def_id::{CrateNum, DefId, DefIndex};
4 use crate::hir::def::{Def, Export};
5 use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
6 use rustc_data_structures::svh::Svh;
7 use crate::infer::canonical::{self, Canonical};
9 use crate::middle::borrowck::BorrowCheckResult;
10 use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
11 use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
12 use crate::middle::privacy::AccessLevels;
13 use crate::middle::reachable::ReachableSet;
14 use crate::middle::region;
15 use crate::middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
16 use crate::middle::stability::{self, DeprecationEntry};
17 use crate::middle::lib_features::LibFeatures;
18 use crate::middle::lang_items::{LanguageItems, LangItem};
19 use crate::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
20 use crate::mir::interpret::{ConstEvalRawResult, ConstEvalResult};
21 use crate::mir::mono::CodegenUnit;
23 use crate::mir::interpret::GlobalId;
24 use crate::session::{CompileResult, CrateDisambiguator};
25 use crate::session::config::{EntryFnType, OutputFilenames, OptLevel};
26 use crate::traits::{self, Vtable};
27 use crate::traits::query::{
28 CanonicalPredicateGoal, CanonicalProjectionGoal,
29 CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
30 CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal,
31 CanonicalTypeOpNormalizeGoal, NoSolution,
33 use crate::traits::query::method_autoderef::MethodAutoderefStepsResult;
34 use crate::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
35 use crate::traits::query::normalize::NormalizationResult;
36 use crate::traits::query::outlives_bounds::OutlivesBound;
37 use crate::traits::specialization_graph;
38 use crate::traits::Clauses;
39 use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
40 use crate::ty::steal::Steal;
41 use crate::ty::subst::Substs;
42 use crate::util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
43 use crate::util::common::{ErrorReported};
44 use crate::util::profiling::ProfileCategory::*;
45 use crate::session::Session;
47 use rustc_data_structures::bit_set::BitSet;
48 use rustc_data_structures::indexed_vec::IndexVec;
49 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
50 use rustc_data_structures::stable_hasher::StableVec;
51 use rustc_data_structures::sync::Lrc;
52 use rustc_target::spec::PanicStrategy;
57 use std::intrinsics::type_name;
58 use syntax_pos::{Span, DUMMY_SP};
59 use syntax_pos::symbol::InternedString;
62 use syntax::feature_gate;
63 use syntax::symbol::Symbol;
67 use self::plumbing::*;
68 pub use self::plumbing::{force_from_dep_node, CycleError};
71 pub use self::job::{QueryJob, QueryInfo};
72 #[cfg(parallel_compiler)]
73 pub use self::job::handle_deadlock;
79 use self::values::Value;
82 pub use self::config::QueryConfig;
83 use self::config::{QueryAccessors, QueryDescription};
86 pub use self::on_disk_cache::OnDiskCache;
88 // Each of these quries corresponds to a function pointer field in the
89 // `Providers` struct for requesting a value of that type, and a method
90 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
91 // which memoizes and does dep-graph tracking, wrapping around the actual
92 // `Providers` that the driver creates (using several `rustc_*` crates).
94 // The result type of each query must implement `Clone`, and additionally
95 // `ty::query::values::Value`, which produces an appropriate placeholder
96 // (error) value if the query resulted in a query cycle.
97 // Queries marked with `fatal_cycle` do not need the latter implementation,
98 // as they will raise an fatal error on query cycles instead.
99 define_queries! { <'tcx>
101 /// Records the type of every item.
102 [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
104 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
105 /// associated generics.
106 [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
108 /// Maps from the def-id of an item (trait/struct/enum/fn) to the
109 /// predicates (where clauses) that must be proven true in order
110 /// to reference it. This is almost always the "predicates query"
113 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
114 /// it is almost always the same as that query, except for the
115 /// case of traits. For traits, `predicates_of` contains
116 /// an additional `Self: Trait<...>` predicate that users don't
117 /// actually write. This reflects the fact that to invoke the
118 /// trait (e.g., via `Default::default`) you must supply types
119 /// that actually implement the trait. (However, this extra
120 /// predicate gets in the way of some checks, which are intended
121 /// to operate over only the actual where-clauses written by the
123 [] fn predicates_of: PredicatesOfItem(DefId) -> Lrc<ty::GenericPredicates<'tcx>>,
125 /// Maps from the def-id of an item (trait/struct/enum/fn) to the
126 /// predicates (where clauses) directly defined on it. This is
127 /// equal to the `explicit_predicates_of` predicates plus the
128 /// `inferred_outlives_of` predicates.
129 [] fn predicates_defined_on: PredicatesDefinedOnItem(DefId)
130 -> Lrc<ty::GenericPredicates<'tcx>>,
132 /// Returns the predicates written explicit by the user.
133 [] fn explicit_predicates_of: ExplicitPredicatesOfItem(DefId)
134 -> Lrc<ty::GenericPredicates<'tcx>>,
136 /// Returns the inferred outlives predicates (e.g., for `struct
137 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
138 [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
140 /// Maps from the def-id of a trait to the list of
141 /// super-predicates. This is a subset of the full list of
142 /// predicates. We store these in a separate map because we must
143 /// evaluate them even during type conversion, often before the
144 /// full predicates are available (note that supertraits have
145 /// additional acyclicity requirements).
146 [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> Lrc<ty::GenericPredicates<'tcx>>,
148 /// To avoid cycles within the predicates of a single item we compute
149 /// per-type-parameter predicates for resolving `T::AssocTy`.
150 [] fn type_param_predicates: type_param_predicates((DefId, DefId))
151 -> Lrc<ty::GenericPredicates<'tcx>>,
153 [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
154 [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
155 [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
156 [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
157 [] fn adt_dtorck_constraint: DtorckConstraint(
159 ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
161 /// True if this is a const fn, use the `is_const_fn` to know whether your crate actually
162 /// sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have
163 /// the feature gate active)
165 /// **Do not call this function manually.** It is only meant to cache the base data for the
166 /// `is_const_fn` function.
167 [] fn is_const_fn_raw: IsConstFn(DefId) -> bool,
170 /// Returns true if calls to the function may be promoted
172 /// This is either because the function is e.g., a tuple-struct or tuple-variant
173 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
174 /// be removed in the future in favour of some form of check which figures out whether the
175 /// function does not inspect the bits of any of its arguments (so is essentially just a
176 /// constructor function).
177 [] fn is_promotable_const_fn: IsPromotableConstFn(DefId) -> bool,
179 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
180 [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
182 /// Get a map with the variance of every item; use `item_variance`
184 [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
186 /// Maps from def-id of a type or region parameter to its
187 /// (inferred) variance.
188 [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
192 /// Maps from def-id of a type to its (inferred) outlives.
193 [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
194 -> Lrc<ty::CratePredicatesMap<'tcx>>,
198 /// Maps from an impl/trait def-id to a list of the def-ids of its items
199 [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
201 /// Maps from a trait item to the trait item "descriptor"
202 [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
204 [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
205 [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
207 [] fn issue33140_self_ty: Issue33140SelfTy(DefId) -> Option<ty::Ty<'tcx>>,
211 /// Maps a DefId of a type to a list of its inherent impls.
212 /// Contains implementations of methods that are inherent to a type.
213 /// Methods in these implementations don't need to be exported.
214 [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
218 /// Set of all the def-ids in this crate that have MIR associated with
219 /// them. This includes all the body owners, but also things like struct
221 [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
223 /// Maps DefId's that have an associated Mir to the result
224 /// of the MIR qualify_consts pass. The actual meaning of
225 /// the value isn't known except to the pass itself.
226 [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<BitSet<mir::Local>>),
228 /// Fetch the MIR for a given def-id right after it's built - this includes
229 /// unreachable code.
230 [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
232 /// Fetch the MIR for a given def-id up till the point where it is
233 /// ready for const evaluation.
235 /// See the README for the `mir` module for details.
236 [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
238 [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
240 /// MIR after our optimization passes have run. This is MIR that is ready
241 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
242 [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
246 /// The result of unsafety-checking this def-id.
247 [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
249 /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
250 [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
252 /// The signature of functions and closures.
253 [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
257 /// Checks the attributes in the module
258 [] fn check_mod_attrs: CheckModAttrs(DefId) -> (),
260 [] fn check_mod_unstable_api_usage: CheckModUnstableApiUsage(DefId) -> (),
262 /// Checks the loops in the module
263 [] fn check_mod_loops: CheckModLoops(DefId) -> (),
265 [] fn check_mod_item_types: CheckModItemTypes(DefId) -> (),
267 [] fn check_mod_privacy: CheckModPrivacy(DefId) -> (),
269 [] fn check_mod_intrinsics: CheckModIntrinsics(DefId) -> (),
271 [] fn check_mod_liveness: CheckModLiveness(DefId) -> (),
273 [] fn check_mod_impl_wf: CheckModImplWf(DefId) -> (),
275 [] fn collect_mod_item_types: CollectModItemTypes(DefId) -> (),
277 /// Caches CoerceUnsized kinds for impls on custom types.
278 [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
279 -> ty::adjustment::CoerceUnsizedInfo,
283 [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
285 [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
289 [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
293 [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
295 [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
299 [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
301 /// Borrow checks the function body. If this is a closure, returns
302 /// additional requirements that the closure's creator must verify.
303 [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
307 /// Gets a complete map from all types to their inherent impls.
308 /// Not meant to be used directly outside of coherence.
309 /// (Defined only for LOCAL_CRATE)
310 [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum)
311 -> Lrc<CrateInherentImpls>,
313 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
314 /// Not meant to be used directly outside of coherence.
315 /// (Defined only for LOCAL_CRATE)
316 [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum)
321 /// Evaluate a constant without running sanity checks
323 /// DO NOT USE THIS outside const eval. Const eval uses this to break query cycles during
324 /// validation. Please add a comment to every use site explaining why using `const_eval`
326 [] fn const_eval_raw: const_eval_raw_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
327 -> ConstEvalRawResult<'tcx>,
329 /// Results of evaluating const items or constants embedded in
330 /// other items (such as enum variant explicit discriminants).
331 [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
332 -> ConstEvalResult<'tcx>,
336 [] fn check_match: CheckMatch(DefId)
337 -> Result<(), ErrorReported>,
339 /// Performs the privacy check and computes "access levels".
340 [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
344 [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
346 /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
347 /// in the case of closures, this will be redirected to the enclosing function.
348 [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
350 [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
352 [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
353 [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
355 [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
356 [] fn def_span: DefSpan(DefId) -> Span,
357 [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
358 [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
359 [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
363 [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
367 [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
368 /// Gets the rendered value of the specified constant or associated constant.
370 [] fn rendered_const: RenderedConst(DefId) -> String,
371 [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
375 [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
376 [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
377 [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
381 [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
385 [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
386 -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
390 [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
391 (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
395 [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
396 [] fn specialization_graph_of: SpecializationGraph(DefId)
397 -> Lrc<specialization_graph::Graph>,
398 [] fn is_object_safe: ObjectSafety(DefId) -> bool,
400 /// Get the ParameterEnvironment for a given item; this environment
401 /// will be in "user-facing" mode, meaning that it is suitabe for
402 /// type-checking etc, and it does not normalize specializable
403 /// associated types. This is almost always what you want,
404 /// unless you are doing MIR optimizations, in which case you
405 /// might want to use `reveal_all()` method to change modes.
406 [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
408 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
409 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
410 [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
411 [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
412 [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
413 [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
414 [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
415 -> Result<&'tcx ty::layout::LayoutDetails,
416 ty::layout::LayoutError<'tcx>>,
420 [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
421 -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
425 [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
426 [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
427 [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
428 [fatal_cycle] fn has_panic_handler: HasPanicHandler(CrateNum) -> bool,
429 [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
430 [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
431 [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
432 [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
434 [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
438 [] fn specializes: specializes_node((DefId, DefId)) -> bool,
439 [] fn in_scope_traits_map: InScopeTraits(DefIndex)
440 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
444 [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
445 [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
449 [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
451 [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
452 [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
453 [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
457 // The DefIds of all non-generic functions and statics in the given crate
458 // that can be reached from outside the crate.
460 // We expect this items to be available for being linked to.
462 // This query can also be called for LOCAL_CRATE. In this case it will
463 // compute which items will be reachable to other crates, taking into account
464 // the kind of crate that is currently compiled. Crates with only a
465 // C interface have fewer reachable things.
467 // Does not include external symbols that don't have a corresponding DefId,
468 // like the compiler-generated `main` function and so on.
469 [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
470 -> Lrc<DefIdMap<SymbolExportLevel>>,
471 [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
472 [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
476 [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
477 -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
478 [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
479 -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
483 [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
485 [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
487 /// Identifies the entry-point (e.g. the `main` function) for a given
488 /// crate, returning `None` if there is no entry point (such as for library crates).
489 [] fn entry_fn: EntryFn(CrateNum) -> Option<(DefId, EntryFnType)>,
490 [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
491 [] fn proc_macro_decls_static: ProcMacroDeclsStatic(CrateNum) -> Option<DefId>,
492 [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
493 [] fn crate_hash: CrateHash(CrateNum) -> Svh,
494 [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
495 [] fn extra_filename: ExtraFileName(CrateNum) -> String,
499 [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
501 [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
506 [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
507 -> Lrc<FxHashSet<DefId>>,
508 [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
509 [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
510 [] fn native_library_kind: NativeLibraryKind(DefId)
511 -> Option<NativeLibraryKind>,
515 [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
519 // Lifetime resolution. See `middle::resolve_lifetimes`.
520 [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
521 [] fn named_region_map: NamedRegion(DefIndex) ->
522 Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
523 [] fn is_late_bound_map: IsLateBound(DefIndex) ->
524 Option<Lrc<FxHashSet<ItemLocalId>>>,
525 [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
526 -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
530 [] fn visibility: Visibility(DefId) -> ty::Visibility,
534 [] fn dep_kind: DepKind(CrateNum) -> DepKind,
535 [] fn crate_name: CrateName(CrateNum) -> Symbol,
536 [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
537 [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
539 [] fn get_lib_features: get_lib_features_node(CrateNum) -> Lrc<LibFeatures>,
540 [] fn defined_lib_features: DefinedLibFeatures(CrateNum)
541 -> Lrc<Vec<(Symbol, Option<Symbol>)>>,
542 [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
543 [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
544 [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
545 [] fn visible_parent_map: visible_parent_map_node(CrateNum)
546 -> Lrc<DefIdMap<DefId>>,
547 [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
548 [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
549 [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
551 [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
552 [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
553 [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
554 -> Lrc<Vec<(DefId, Span)>>,
555 [] fn names_imported_by_glob_use: NamesImportedByGlobUse(DefId)
556 -> Lrc<FxHashSet<ast::Name>>,
558 [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
559 [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
561 /// A vector of every trait accessible in the whole crate
562 /// (i.e., including those from subcrates). This is used only for
564 [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
568 [] fn exported_symbols: ExportedSymbols(CrateNum)
569 -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
573 [] fn collect_and_partition_mono_items:
574 collect_and_partition_mono_items_node(CrateNum)
575 -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
576 [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
577 [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
578 [] fn backend_optimization_level: BackendOptimizationLevel(CrateNum) -> OptLevel,
582 [] fn output_filenames: output_filenames_node(CrateNum)
583 -> Arc<OutputFilenames>,
587 // Erases regions from `ty` to yield a new type.
588 // Normally you would just use `tcx.erase_regions(&value)`,
589 // however, which uses this query as a kind of cache.
590 [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
592 /// Do not call this query directly: invoke `normalize` instead.
593 [] fn normalize_projection_ty: NormalizeProjectionTy(
594 CanonicalProjectionGoal<'tcx>
596 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>>,
600 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
601 [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
602 ParamEnvAnd<'tcx, Ty<'tcx>>
605 [] fn implied_outlives_bounds: ImpliedOutlivesBounds(
606 CanonicalTyGoal<'tcx>
608 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>,
612 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
613 [] fn dropck_outlives: DropckOutlives(
614 CanonicalTyGoal<'tcx>
616 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>,
620 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
621 /// `infcx.predicate_must_hold()` instead.
622 [] fn evaluate_obligation: EvaluateObligation(
623 CanonicalPredicateGoal<'tcx>
624 ) -> Result<traits::EvaluationResult, traits::OverflowError>,
626 [] fn evaluate_goal: EvaluateGoal(
627 traits::ChalkCanonicalGoal<'tcx>
629 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
633 /// Do not call this query directly: part of the `Eq` type-op
634 [] fn type_op_ascribe_user_type: TypeOpAscribeUserType(
635 CanonicalTypeOpAscribeUserTypeGoal<'tcx>
637 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
641 /// Do not call this query directly: part of the `Eq` type-op
642 [] fn type_op_eq: TypeOpEq(
643 CanonicalTypeOpEqGoal<'tcx>
645 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
649 /// Do not call this query directly: part of the `Subtype` type-op
650 [] fn type_op_subtype: TypeOpSubtype(
651 CanonicalTypeOpSubtypeGoal<'tcx>
653 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
657 /// Do not call this query directly: part of the `ProvePredicate` type-op
658 [] fn type_op_prove_predicate: TypeOpProvePredicate(
659 CanonicalTypeOpProvePredicateGoal<'tcx>
661 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
665 /// Do not call this query directly: part of the `Normalize` type-op
666 [] fn type_op_normalize_ty: TypeOpNormalizeTy(
667 CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
669 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>>,
673 /// Do not call this query directly: part of the `Normalize` type-op
674 [] fn type_op_normalize_predicate: TypeOpNormalizePredicate(
675 CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
677 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>>,
681 /// Do not call this query directly: part of the `Normalize` type-op
682 [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig(
683 CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
685 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>>,
689 /// Do not call this query directly: part of the `Normalize` type-op
690 [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig(
691 CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
693 Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>>,
697 [] fn substitute_normalize_and_test_predicates:
698 substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
700 [] fn method_autoderef_steps: MethodAutoderefSteps(
701 CanonicalTyGoal<'tcx>
702 ) -> MethodAutoderefStepsResult<'tcx>,
706 [] fn target_features_whitelist:
707 target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
709 // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
710 [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
713 [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
717 [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>,
719 [] fn program_clauses_for_env: ProgramClausesForEnv(
720 traits::Environment<'tcx>
723 // Get the chalk-style environment of the given item.
724 [] fn environment: Environment(DefId) -> traits::Environment<'tcx>,
728 [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
729 -> Lrc<FxHashMap<DefId, String>>,
733 // `try_get_query` can't be public because it uses the private query
734 // implementation traits, so we provide access to it selectively.
735 impl<'a, 'tcx, 'lcx> TyCtxt<'a, 'tcx, 'lcx> {
736 pub fn try_adt_sized_constraint(
740 ) -> Result<&'tcx [Ty<'tcx>], Box<DiagnosticBuilder<'a>>> {
741 self.try_get_query::<queries::adt_sized_constraint<'_>>(span, key)
743 pub fn try_needs_drop_raw(
746 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
747 ) -> Result<bool, Box<DiagnosticBuilder<'a>>> {
748 self.try_get_query::<queries::needs_drop_raw<'_>>(span, key)
750 pub fn try_optimized_mir(
754 ) -> Result<&'tcx mir::Mir<'tcx>, Box<DiagnosticBuilder<'a>>> {
755 self.try_get_query::<queries::optimized_mir<'_>>(span, key)
759 //////////////////////////////////////////////////////////////////////
760 // These functions are little shims used to find the dep-node for a
761 // given query when there is not a *direct* mapping:
764 fn features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
765 DepConstructor::Features
768 fn codegen_fn_attrs<'tcx>(id: DefId) -> DepConstructor<'tcx> {
769 DepConstructor::CodegenFnAttrs { 0: id }
772 fn erase_regions_ty<'tcx>(ty: Ty<'tcx>) -> DepConstructor<'tcx> {
773 DepConstructor::EraseRegionsTy { ty }
776 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
777 DepConstructor::TypeParamPredicates {
783 fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
784 (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> DepConstructor<'tcx> {
785 DepConstructor::FulfillObligation {
791 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
792 DepConstructor::Coherence
795 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
796 DepConstructor::CoherenceInherentImplOverlapCheck
799 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
800 DepConstructor::Reachability
803 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
804 DepConstructor::MirShim {
809 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
810 DepConstructor::InstanceSymbolName { instance }
813 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
814 DepConstructor::TypeckBodiesKrate
817 fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
818 -> DepConstructor<'tcx> {
819 DepConstructor::ConstEval { param_env }
821 fn const_eval_raw_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
822 -> DepConstructor<'tcx> {
823 DepConstructor::ConstEvalRaw { param_env }
826 fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
827 DepConstructor::MirKeys
830 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
831 DepConstructor::CrateVariances
834 fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
835 DepConstructor::IsCopy { param_env }
838 fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
839 DepConstructor::IsSized { param_env }
842 fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
843 DepConstructor::IsFreeze { param_env }
846 fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
847 DepConstructor::NeedsDrop { param_env }
850 fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
851 DepConstructor::Layout { param_env }
854 fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
855 DepConstructor::LintLevels
858 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
859 DepConstructor::Specializes { impl1: a, impl2: b }
862 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
863 -> DepConstructor<'tcx>
865 DepConstructor::ImplementationsOfTrait { krate, trait_id }
868 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
869 DepConstructor::LinkArgs
872 fn get_lib_features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
873 DepConstructor::GetLibFeatures
876 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
877 DepConstructor::GetLangItems
880 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
881 DepConstructor::VisibleParentMap
884 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
885 DepConstructor::PostorderCnums
888 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
889 DepConstructor::MaybeUnusedExternCrates
892 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
893 DepConstructor::StabilityIndex
896 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
897 DepConstructor::AllCrateNums
900 fn all_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
901 DepConstructor::AllTraits
904 fn collect_and_partition_mono_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
905 DepConstructor::CollectAndPartitionMonoItems
908 fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
909 DepConstructor::OutputFilenames
912 fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> {
913 DepConstructor::VtableMethods{ trait_ref }
916 fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>))
917 -> DepConstructor<'tcx> {
918 DepConstructor::SubstituteNormalizeAndTestPredicates { key }
921 fn target_features_whitelist_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
922 DepConstructor::TargetFeaturesWhitelist
925 fn instance_def_size_estimate_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>)
926 -> DepConstructor<'tcx> {
927 DepConstructor::InstanceDefSizeEstimate {