]> git.lizzy.rs Git - rust.git/blob - src/librustc/ty/query/mod.rs
rustc(codegen): uncache `def_symbol_name` prefix from `symbol_name`.
[rust.git] / src / librustc / ty / query / mod.rs
1 use crate::dep_graph::{self, DepConstructor, DepNode};
2 use crate::hir::def_id::{CrateNum, DefId, DefIndex};
3 use crate::hir::def::{Def, Export};
4 use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
5 use crate::infer::canonical::{self, Canonical};
6 use crate::lint;
7 use crate::middle::borrowck::BorrowCheckResult;
8 use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
9 use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
10 use crate::middle::privacy::AccessLevels;
11 use crate::middle::reachable::ReachableSet;
12 use crate::middle::region;
13 use crate::middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
14 use crate::middle::stability::{self, DeprecationEntry};
15 use crate::middle::lib_features::LibFeatures;
16 use crate::middle::lang_items::{LanguageItems, LangItem};
17 use crate::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
18 use crate::mir::interpret::{ConstEvalRawResult, ConstEvalResult};
19 use crate::mir::mono::CodegenUnit;
20 use crate::mir;
21 use crate::mir::interpret::GlobalId;
22 use crate::session::CrateDisambiguator;
23 use crate::session::config::{EntryFnType, OutputFilenames, OptLevel};
24 use crate::traits::{self, Vtable};
25 use crate::traits::query::{
26     CanonicalPredicateGoal, CanonicalProjectionGoal,
27     CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
28     CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal,
29     CanonicalTypeOpNormalizeGoal, NoSolution,
30 };
31 use crate::traits::query::method_autoderef::MethodAutoderefStepsResult;
32 use crate::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
33 use crate::traits::query::normalize::NormalizationResult;
34 use crate::traits::query::outlives_bounds::OutlivesBound;
35 use crate::traits::specialization_graph;
36 use crate::traits::Clauses;
37 use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, AdtSizedConstraint};
38 use crate::ty::steal::Steal;
39 use crate::ty::util::NeedsDrop;
40 use crate::ty::subst::SubstsRef;
41 use crate::util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
42 use crate::util::common::{ErrorReported};
43 use crate::util::profiling::ProfileCategory::*;
44 use crate::session::Session;
45
46 use rustc_data_structures::svh::Svh;
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_data_structures::fingerprint::Fingerprint;
53 use rustc_target::spec::PanicStrategy;
54
55 use std::borrow::Cow;
56 use std::ops::Deref;
57 use std::sync::Arc;
58 use std::intrinsics::type_name;
59 use syntax_pos::{Span, DUMMY_SP};
60 use syntax_pos::symbol::InternedString;
61 use syntax::attr;
62 use syntax::ast;
63 use syntax::feature_gate;
64 use syntax::symbol::Symbol;
65
66 #[macro_use]
67 mod plumbing;
68 use self::plumbing::*;
69 pub use self::plumbing::{force_from_dep_node, CycleError};
70
71 mod job;
72 pub use self::job::{QueryJob, QueryInfo};
73 #[cfg(parallel_compiler)]
74 pub use self::job::handle_deadlock;
75
76 mod keys;
77 use self::keys::Key;
78
79 mod values;
80 use self::values::Value;
81
82 mod config;
83 pub(crate) use self::config::QueryDescription;
84 pub use self::config::QueryConfig;
85 use self::config::QueryAccessors;
86
87 mod on_disk_cache;
88 pub use self::on_disk_cache::OnDiskCache;
89
90 // Each of these queries 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).
95 //
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
102 rustc_query_append! { [define_queries!][ <'tcx>
103     Other {
104         /// Run analysis passes on the crate
105         [] fn analysis: Analysis(CrateNum) -> Result<(), ErrorReported>,
106
107         /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
108         /// predicates (where-clauses) directly defined on it. This is
109         /// equal to the `explicit_predicates_of` predicates plus the
110         /// `inferred_outlives_of` predicates.
111         [] fn predicates_defined_on: PredicatesDefinedOnItem(DefId)
112             -> Lrc<ty::GenericPredicates<'tcx>>,
113
114         /// Returns the predicates written explicit by the user.
115         [] fn explicit_predicates_of: ExplicitPredicatesOfItem(DefId)
116             -> Lrc<ty::GenericPredicates<'tcx>>,
117
118         /// Returns the inferred outlives predicates (e.g., for `struct
119         /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
120         [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
121
122         /// Maps from the `DefId` of a trait to the list of
123         /// super-predicates. This is a subset of the full list of
124         /// predicates. We store these in a separate map because we must
125         /// evaluate them even during type conversion, often before the
126         /// full predicates are available (note that supertraits have
127         /// additional acyclicity requirements).
128         [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> Lrc<ty::GenericPredicates<'tcx>>,
129
130         /// To avoid cycles within the predicates of a single item we compute
131         /// per-type-parameter predicates for resolving `T::AssocTy`.
132         [] fn type_param_predicates: type_param_predicates((DefId, DefId))
133             -> Lrc<ty::GenericPredicates<'tcx>>,
134
135         [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
136         [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
137         [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
138
139         // The cycle error here should be reported as an error by `check_representable`.
140         // We consider the type as Sized in the meanwhile to avoid
141         // further errors (done in impl Value for AdtSizedConstraint).
142         // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
143         // in case we accidentally otherwise don't emit an error.
144         [cycle_delay_bug] fn adt_sized_constraint: SizedConstraint(
145             DefId
146         ) -> AdtSizedConstraint<'tcx>,
147
148         [] fn adt_dtorck_constraint: DtorckConstraint(
149             DefId
150         ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
151
152         /// True if this is a const fn, use the `is_const_fn` to know whether your crate actually
153         /// sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have
154         /// the feature gate active)
155         ///
156         /// **Do not call this function manually.** It is only meant to cache the base data for the
157         /// `is_const_fn` function.
158         [] fn is_const_fn_raw: IsConstFn(DefId) -> bool,
159
160
161         /// Returns true if calls to the function may be promoted
162         ///
163         /// This is either because the function is e.g., a tuple-struct or tuple-variant
164         /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
165         /// be removed in the future in favour of some form of check which figures out whether the
166         /// function does not inspect the bits of any of its arguments (so is essentially just a
167         /// constructor function).
168         [] fn is_promotable_const_fn: IsPromotableConstFn(DefId) -> bool,
169
170         /// True if this is a foreign item (i.e., linked via `extern { ... }`).
171         [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
172
173         /// Get a map with the variance of every item; use `item_variance`
174         /// instead.
175         [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
176
177         /// Maps from def-id of a type or region parameter to its
178         /// (inferred) variance.
179         [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
180     },
181
182     TypeChecking {
183         /// Maps from def-id of a type to its (inferred) outlives.
184         [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
185             -> Lrc<ty::CratePredicatesMap<'tcx>>,
186     },
187
188     Other {
189         /// Maps from an impl/trait def-id to a list of the def-ids of its items
190         [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
191
192         /// Maps from a trait item to the trait item "descriptor"
193         [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
194
195         [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
196         [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
197
198         [] fn issue33140_self_ty: Issue33140SelfTy(DefId) -> Option<ty::Ty<'tcx>>,
199     },
200
201     TypeChecking {
202         /// Maps a DefId of a type to a list of its inherent impls.
203         /// Contains implementations of methods that are inherent to a type.
204         /// Methods in these implementations don't need to be exported.
205         [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
206     },
207
208     TypeChecking {
209         /// The result of unsafety-checking this `DefId`.
210         [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
211
212         /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
213         [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
214
215         /// The signature of functions and closures.
216         [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
217     },
218
219     Other {
220         [] fn lint_mod: LintMod(DefId) -> (),
221
222         /// Checks the attributes in the module
223         [] fn check_mod_attrs: CheckModAttrs(DefId) -> (),
224
225         [] fn check_mod_unstable_api_usage: CheckModUnstableApiUsage(DefId) -> (),
226
227         /// Checks the loops in the module
228         [] fn check_mod_loops: CheckModLoops(DefId) -> (),
229
230         [] fn check_mod_item_types: CheckModItemTypes(DefId) -> (),
231
232         [] fn check_mod_privacy: CheckModPrivacy(DefId) -> (),
233
234         [] fn check_mod_intrinsics: CheckModIntrinsics(DefId) -> (),
235
236         [] fn check_mod_liveness: CheckModLiveness(DefId) -> (),
237
238         [] fn check_mod_impl_wf: CheckModImplWf(DefId) -> (),
239
240         [] fn collect_mod_item_types: CollectModItemTypes(DefId) -> (),
241
242         /// Caches CoerceUnsized kinds for impls on custom types.
243         [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
244             -> ty::adjustment::CoerceUnsizedInfo,
245     },
246
247     TypeChecking {
248         [] fn typeck_item_bodies:
249                 typeck_item_bodies_dep_node(CrateNum) -> (),
250
251         [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
252     },
253
254     Other {
255         [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
256     },
257
258     TypeChecking {
259         [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
260
261         [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
262     },
263
264     BorrowChecking {
265         [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
266
267         /// Borrow checks the function body. If this is a closure, returns
268         /// additional requirements that the closure's creator must verify.
269         [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
270     },
271
272     TypeChecking {
273         /// Gets a complete map from all types to their inherent impls.
274         /// Not meant to be used directly outside of coherence.
275         /// (Defined only for `LOCAL_CRATE`.)
276         [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum)
277             -> Lrc<CrateInherentImpls>,
278
279         /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
280         /// Not meant to be used directly outside of coherence.
281         /// (Defined only for `LOCAL_CRATE`.)
282         [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum)
283             -> (),
284     },
285
286     Other {
287         /// Evaluate a constant without running sanity checks
288         ///
289         /// **Do not use this** outside const eval. Const eval uses this to break query cycles
290         /// during validation. Please add a comment to every use site explaining why using
291         /// `const_eval` isn't sufficient
292         [] fn const_eval_raw: const_eval_raw_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
293             -> ConstEvalRawResult<'tcx>,
294
295         /// Results of evaluating const items or constants embedded in
296         /// other items (such as enum variant explicit discriminants).
297         [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
298             -> ConstEvalResult<'tcx>,
299     },
300
301     TypeChecking {
302         [] fn check_match: CheckMatch(DefId) -> (),
303
304         /// Performs part of the privacy check and computes "access levels".
305         [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
306         [] fn check_private_in_public: CheckPrivateInPublic(CrateNum) -> (),
307     },
308
309     Other {
310         [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
311
312         /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
313         /// in the case of closures, this will be redirected to the enclosing function.
314         [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
315
316         [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
317
318         [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
319
320         [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
321         [] fn def_span: DefSpan(DefId) -> Span,
322         [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
323         [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
324         [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
325     },
326
327     Codegen {
328         [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
329     },
330
331     Other {
332         [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
333         /// Gets the rendered value of the specified constant or associated constant.
334         /// Used by rustdoc.
335         [] fn rendered_const: RenderedConst(DefId) -> String,
336         [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
337     },
338
339     TypeChecking {
340         [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
341         [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
342         [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
343     },
344
345     Codegen {
346         [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
347     },
348
349     Other {
350         [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
351                             -> Lrc<Vec<Option<(DefId, SubstsRef<'tcx>)>>>,
352     },
353
354     Codegen {
355         [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
356             (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
357     },
358
359     TypeChecking {
360         [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
361         [] fn specialization_graph_of: SpecializationGraph(DefId)
362             -> Lrc<specialization_graph::Graph>,
363         [] fn is_object_safe: ObjectSafety(DefId) -> bool,
364
365         /// Gets the ParameterEnvironment for a given item; this environment
366         /// will be in "user-facing" mode, meaning that it is suitabe for
367         /// type-checking etc, and it does not normalize specializable
368         /// associated types. This is almost always what you want,
369         /// unless you are doing MIR optimizations, in which case you
370         /// might want to use `reveal_all()` method to change modes.
371         [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
372
373         /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
374         /// `ty.is_copy()`, etc, since that will prune the environment where possible.
375         [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
376         [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
377         [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
378
379         // The cycle error here should be reported as an error by `check_representable`.
380         // We consider the type as not needing drop in the meanwhile to avoid
381         // further errors (done in impl Value for NeedsDrop).
382         // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
383         // in case we accidentally otherwise don't emit an error.
384         [cycle_delay_bug] fn needs_drop_raw: needs_drop_dep_node(
385             ty::ParamEnvAnd<'tcx, Ty<'tcx>>
386         ) -> NeedsDrop,
387
388         [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
389                                     -> Result<&'tcx ty::layout::LayoutDetails,
390                                                 ty::layout::LayoutError<'tcx>>,
391     },
392
393     Other {
394         [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
395                                         -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
396     },
397
398     Codegen {
399         [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
400         [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
401         [fatal_cycle] fn has_panic_handler: HasPanicHandler(CrateNum) -> bool,
402         [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
403         [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
404         [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
405         [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
406
407         [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
408     },
409
410     TypeChecking {
411         [] fn specializes: specializes_node((DefId, DefId)) -> bool,
412         [] fn in_scope_traits_map: InScopeTraits(DefIndex)
413             -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
414     },
415
416     Other {
417         [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
418     },
419
420     TypeChecking {
421         [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
422
423         [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
424         [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
425         [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
426     },
427
428     Linking {
429         // The DefIds of all non-generic functions and statics in the given crate
430         // that can be reached from outside the crate.
431         //
432         // We expect this items to be available for being linked to.
433         //
434         // This query can also be called for LOCAL_CRATE. In this case it will
435         // compute which items will be reachable to other crates, taking into account
436         // the kind of crate that is currently compiled. Crates with only a
437         // C interface have fewer reachable things.
438         //
439         // Does not include external symbols that don't have a corresponding DefId,
440         // like the compiler-generated `main` function and so on.
441         [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
442             -> Lrc<DefIdMap<SymbolExportLevel>>,
443         [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
444         [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
445     },
446
447     Codegen {
448         [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
449             -> Lrc<DefIdMap<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>>,
450         [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
451             -> Option<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>,
452     },
453
454     Other {
455         [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
456
457         /// Identifies the entry-point (e.g., the `main` function) for a given
458         /// crate, returning `None` if there is no entry point (such as for library crates).
459         [] fn entry_fn: EntryFn(CrateNum) -> Option<(DefId, EntryFnType)>,
460         [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
461         [] fn proc_macro_decls_static: ProcMacroDeclsStatic(CrateNum) -> Option<DefId>,
462         [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
463         [] fn crate_hash: CrateHash(CrateNum) -> Svh,
464         [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
465         [] fn extra_filename: ExtraFileName(CrateNum) -> String,
466     },
467
468     TypeChecking {
469         [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
470             -> Lrc<Vec<DefId>>,
471         [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
472             -> Lrc<Vec<DefId>>,
473     },
474
475     Other {
476         [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
477             -> Lrc<FxHashSet<DefId>>,
478         [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
479         [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
480         [] fn native_library_kind: NativeLibraryKind(DefId)
481             -> Option<NativeLibraryKind>,
482     },
483
484     Linking {
485         [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
486     },
487
488     BorrowChecking {
489         // Lifetime resolution. See `middle::resolve_lifetimes`.
490         [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
491         [] fn named_region_map: NamedRegion(DefIndex) ->
492             Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
493         [] fn is_late_bound_map: IsLateBound(DefIndex) ->
494             Option<Lrc<FxHashSet<ItemLocalId>>>,
495         [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
496             -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
497     },
498
499     TypeChecking {
500         [] fn visibility: Visibility(DefId) -> ty::Visibility,
501     },
502
503     Other {
504         [] fn dep_kind: DepKind(CrateNum) -> DepKind,
505         [] fn crate_name: CrateName(CrateNum) -> Symbol,
506         [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
507         [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
508
509         [] fn get_lib_features: get_lib_features_node(CrateNum) -> Lrc<LibFeatures>,
510         [] fn defined_lib_features: DefinedLibFeatures(CrateNum)
511             -> Lrc<Vec<(Symbol, Option<Symbol>)>>,
512         [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
513         [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
514         [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
515         [] fn visible_parent_map: visible_parent_map_node(CrateNum)
516             -> Lrc<DefIdMap<DefId>>,
517         [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
518         [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
519         [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
520
521         [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
522         [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
523         [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
524             -> Lrc<Vec<(DefId, Span)>>,
525         [] fn names_imported_by_glob_use: NamesImportedByGlobUse(DefId)
526             -> Lrc<FxHashSet<ast::Name>>,
527
528         [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
529         [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
530
531         /// A vector of every trait accessible in the whole crate
532         /// (i.e., including those from subcrates). This is used only for
533         /// error reporting.
534         [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
535     },
536
537     Linking {
538         [] fn exported_symbols: ExportedSymbols(CrateNum)
539             -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
540     },
541
542     Codegen {
543         [] fn collect_and_partition_mono_items:
544             collect_and_partition_mono_items_node(CrateNum)
545             -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
546         [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
547         [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
548         [] fn backend_optimization_level: BackendOptimizationLevel(CrateNum) -> OptLevel,
549     },
550
551     Other {
552         [] fn output_filenames: output_filenames_node(CrateNum)
553             -> Arc<OutputFilenames>,
554     },
555
556     TypeChecking {
557         /// Do not call this query directly: invoke `normalize` instead.
558         [] fn normalize_projection_ty: NormalizeProjectionTy(
559             CanonicalProjectionGoal<'tcx>
560         ) -> Result<
561             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>>,
562             NoSolution,
563         >,
564
565         /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
566         [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
567             ParamEnvAnd<'tcx, Ty<'tcx>>
568         ) -> Ty<'tcx>,
569
570         [] fn implied_outlives_bounds: ImpliedOutlivesBounds(
571             CanonicalTyGoal<'tcx>
572         ) -> Result<
573             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>,
574             NoSolution,
575         >,
576
577         /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
578         [] fn dropck_outlives: DropckOutlives(
579             CanonicalTyGoal<'tcx>
580         ) -> Result<
581             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>,
582             NoSolution,
583         >,
584
585         /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
586         /// `infcx.predicate_must_hold()` instead.
587         [] fn evaluate_obligation: EvaluateObligation(
588             CanonicalPredicateGoal<'tcx>
589         ) -> Result<traits::EvaluationResult, traits::OverflowError>,
590
591         [] fn evaluate_goal: EvaluateGoal(
592             traits::ChalkCanonicalGoal<'tcx>
593         ) -> Result<
594             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
595             NoSolution
596         >,
597
598         /// Do not call this query directly: part of the `Eq` type-op
599         [] fn type_op_ascribe_user_type: TypeOpAscribeUserType(
600             CanonicalTypeOpAscribeUserTypeGoal<'tcx>
601         ) -> Result<
602             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
603             NoSolution,
604         >,
605
606         /// Do not call this query directly: part of the `Eq` type-op
607         [] fn type_op_eq: TypeOpEq(
608             CanonicalTypeOpEqGoal<'tcx>
609         ) -> Result<
610             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
611             NoSolution,
612         >,
613
614         /// Do not call this query directly: part of the `Subtype` type-op
615         [] fn type_op_subtype: TypeOpSubtype(
616             CanonicalTypeOpSubtypeGoal<'tcx>
617         ) -> Result<
618             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
619             NoSolution,
620         >,
621
622         /// Do not call this query directly: part of the `ProvePredicate` type-op
623         [] fn type_op_prove_predicate: TypeOpProvePredicate(
624             CanonicalTypeOpProvePredicateGoal<'tcx>
625         ) -> Result<
626             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
627             NoSolution,
628         >,
629
630         /// Do not call this query directly: part of the `Normalize` type-op
631         [] fn type_op_normalize_ty: TypeOpNormalizeTy(
632             CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
633         ) -> Result<
634             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>>,
635             NoSolution,
636         >,
637
638         /// Do not call this query directly: part of the `Normalize` type-op
639         [] fn type_op_normalize_predicate: TypeOpNormalizePredicate(
640             CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
641         ) -> Result<
642             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>>,
643             NoSolution,
644         >,
645
646         /// Do not call this query directly: part of the `Normalize` type-op
647         [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig(
648             CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
649         ) -> Result<
650             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>>,
651             NoSolution,
652         >,
653
654         /// Do not call this query directly: part of the `Normalize` type-op
655         [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig(
656             CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
657         ) -> Result<
658             Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>>,
659             NoSolution,
660         >,
661
662         [] fn substitute_normalize_and_test_predicates:
663             substitute_normalize_and_test_predicates_node((DefId, SubstsRef<'tcx>)) -> bool,
664
665         [] fn method_autoderef_steps: MethodAutoderefSteps(
666             CanonicalTyGoal<'tcx>
667         ) -> MethodAutoderefStepsResult<'tcx>,
668     },
669
670     Other {
671         [] fn target_features_whitelist:
672             target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
673
674         // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
675         [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
676             -> usize,
677
678         [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
679     },
680 ]}
681
682 //////////////////////////////////////////////////////////////////////
683 // These functions are little shims used to find the dep-node for a
684 // given query when there is not a *direct* mapping:
685
686
687 fn features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
688     DepConstructor::Features
689 }
690
691 fn codegen_fn_attrs<'tcx>(id: DefId) -> DepConstructor<'tcx> {
692     DepConstructor::CodegenFnAttrs { 0: id }
693 }
694
695 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
696     DepConstructor::TypeParamPredicates {
697         item_id,
698         param_id
699     }
700 }
701
702 fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
703     (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> DepConstructor<'tcx> {
704     DepConstructor::FulfillObligation {
705         param_env,
706         trait_ref
707     }
708 }
709
710 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
711     DepConstructor::Coherence
712 }
713
714 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
715     DepConstructor::CoherenceInherentImplOverlapCheck
716 }
717
718 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
719     DepConstructor::Reachability
720 }
721
722 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
723     DepConstructor::MirShim {
724         instance_def
725     }
726 }
727
728 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
729     DepConstructor::SymbolName { instance }
730 }
731
732 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
733     DepConstructor::TypeckBodiesKrate
734 }
735
736 fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
737                              -> DepConstructor<'tcx> {
738     DepConstructor::ConstEval { param_env }
739 }
740 fn const_eval_raw_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
741                              -> DepConstructor<'tcx> {
742     DepConstructor::ConstEvalRaw { param_env }
743 }
744
745 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
746     DepConstructor::CrateVariances
747 }
748
749 fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
750     DepConstructor::IsCopy { param_env }
751 }
752
753 fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
754     DepConstructor::IsSized { param_env }
755 }
756
757 fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
758     DepConstructor::IsFreeze { param_env }
759 }
760
761 fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
762     DepConstructor::NeedsDrop { param_env }
763 }
764
765 fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
766     DepConstructor::Layout { param_env }
767 }
768
769 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
770     DepConstructor::Specializes { impl1: a, impl2: b }
771 }
772
773 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
774     -> DepConstructor<'tcx>
775 {
776     DepConstructor::ImplementationsOfTrait { krate, trait_id }
777 }
778
779 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
780     DepConstructor::LinkArgs
781 }
782
783 fn get_lib_features_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
784     DepConstructor::GetLibFeatures
785 }
786
787 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
788     DepConstructor::GetLangItems
789 }
790
791 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
792     DepConstructor::VisibleParentMap
793 }
794
795 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
796     DepConstructor::PostorderCnums
797 }
798
799 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
800     DepConstructor::MaybeUnusedExternCrates
801 }
802
803 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
804     DepConstructor::StabilityIndex
805 }
806
807 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
808     DepConstructor::AllCrateNums
809 }
810
811 fn all_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
812     DepConstructor::AllTraits
813 }
814
815 fn collect_and_partition_mono_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
816     DepConstructor::CollectAndPartitionMonoItems
817 }
818
819 fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
820     DepConstructor::OutputFilenames
821 }
822
823 fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> {
824     DepConstructor::VtableMethods{ trait_ref }
825 }
826
827 fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, SubstsRef<'tcx>))
828                                             -> DepConstructor<'tcx> {
829     DepConstructor::SubstituteNormalizeAndTestPredicates { key }
830 }
831
832 fn target_features_whitelist_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
833     DepConstructor::TargetFeaturesWhitelist
834 }
835
836 fn instance_def_size_estimate_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>)
837                                               -> DepConstructor<'tcx> {
838     DepConstructor::InstanceDefSizeEstimate {
839         instance_def
840     }
841 }