]> git.lizzy.rs Git - rust.git/blob - src/librustc/ty/maps/mod.rs
Replace Rc with Lrc for shared data
[rust.git] / src / librustc / ty / maps / mod.rs
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.
4 //
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.
10
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};
16 use hir::svh::Svh;
17 use lint;
18 use middle::borrowck::BorrowCheckResult;
19 use middle::const_val;
20 use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary,
21                      ExternBodyNestedBodies};
22 use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody};
23 use middle::privacy::AccessLevels;
24 use middle::reachable::ReachableSet;
25 use middle::region;
26 use middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
27 use middle::stability::{self, DeprecationEntry};
28 use middle::lang_items::{LanguageItems, LangItem};
29 use middle::exported_symbols::SymbolExportLevel;
30 use mir::mono::{CodegenUnit, Stats};
31 use mir;
32 use session::{CompileResult, CrateDisambiguator};
33 use session::config::OutputFilenames;
34 use traits::Vtable;
35 use traits::specialization_graph;
36 use ty::{self, CrateInherentImpls, Ty, TyCtxt};
37 use ty::steal::Steal;
38 use ty::subst::Substs;
39 use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
40 use util::common::{profq_msg, ErrorReported, ProfileQueriesMsg};
41
42 use rustc_data_structures::indexed_set::IdxSetBuf;
43 use rustc_back::PanicStrategy;
44 use rustc_data_structures::indexed_vec::IndexVec;
45 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
46 use rustc_data_structures::stable_hasher::StableVec;
47
48 use std::ops::Deref;
49 use rustc_data_structures::sync::Lrc;
50 use std::sync::Arc;
51 use syntax_pos::{Span, DUMMY_SP};
52 use syntax_pos::symbol::InternedString;
53 use syntax::attr;
54 use syntax::ast;
55 use syntax::symbol::Symbol;
56
57 #[macro_use]
58 mod plumbing;
59 use self::plumbing::*;
60 pub use self::plumbing::force_from_dep_node;
61
62 mod keys;
63 pub use self::keys::Key;
64
65 mod values;
66 use self::values::Value;
67
68 mod config;
69 pub use self::config::QueryConfig;
70 use self::config::QueryDescription;
71
72 mod on_disk_cache;
73 pub use self::on_disk_cache::OnDiskCache;
74
75 // Each of these maps also corresponds to a method on a
76 // `Provider` trait for requesting a value of that type,
77 // and a method on `Maps` itself for doing that in a
78 // a way that memoizes and does dep-graph tracking,
79 // wrapping around the actual chain of providers that
80 // the driver creates (using several `rustc_*` crates).
81 //
82 // The result of query must implement Clone. They must also implement ty::maps::values::Value
83 // which produces an appropiate error value if the query resulted in a query cycle.
84 // Queries marked with `fatal_cycle` do not need that implementation
85 // as they will raise an fatal error on query cycles instead.
86 define_maps! { <'tcx>
87     /// Records the type of every item.
88     [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
89
90     /// Maps from the def-id of an item (trait/struct/enum/fn) to its
91     /// associated generics and predicates.
92     [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
93     [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
94
95     /// Maps from the def-id of a trait to the list of
96     /// super-predicates. This is a subset of the full list of
97     /// predicates. We store these in a separate map because we must
98     /// evaluate them even during type conversion, often before the
99     /// full predicates are available (note that supertraits have
100     /// additional acyclicity requirements).
101     [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
102
103     /// To avoid cycles within the predicates of a single item we compute
104     /// per-type-parameter predicates for resolving `T::AssocTy`.
105     [] fn type_param_predicates: type_param_predicates((DefId, DefId))
106         -> ty::GenericPredicates<'tcx>,
107
108     [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
109     [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
110     [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
111     [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
112     [] fn adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
113
114     /// True if this is a const fn
115     [] fn is_const_fn: IsConstFn(DefId) -> bool,
116
117     /// True if this is a foreign item (i.e., linked via `extern { ... }`).
118     [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
119
120     /// Get a map with the variance of every item; use `item_variance`
121     /// instead.
122     [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
123
124     /// Maps from def-id of a type or region parameter to its
125     /// (inferred) variance.
126     [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
127
128     /// Maps from def-id of a type to its (inferred) outlives.
129     [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Vec<ty::Predicate<'tcx>>,
130
131     /// Maps from an impl/trait def-id to a list of the def-ids of its items
132     [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
133
134     /// Maps from a trait item to the trait item "descriptor"
135     [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
136
137     [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
138     [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
139
140     /// Maps a DefId of a type to a list of its inherent impls.
141     /// Contains implementations of methods that are inherent to a type.
142     /// Methods in these implementations don't need to be exported.
143     [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
144
145     /// Set of all the def-ids in this crate that have MIR associated with
146     /// them. This includes all the body owners, but also things like struct
147     /// constructors.
148     [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
149
150     /// Maps DefId's that have an associated Mir to the result
151     /// of the MIR qualify_consts pass. The actual meaning of
152     /// the value isn't known except to the pass itself.
153     [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<IdxSetBuf<mir::Local>>),
154
155     /// Fetch the MIR for a given def-id right after it's built - this includes
156     /// unreachable code.
157     [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
158
159     /// Fetch the MIR for a given def-id up till the point where it is
160     /// ready for const evaluation.
161     ///
162     /// See the README for the `mir` module for details.
163     [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
164
165     [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
166
167     /// MIR after our optimization passes have run. This is MIR that is ready
168     /// for trans. This is also the only query that can fetch non-local MIR, at present.
169     [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
170
171     /// The result of unsafety-checking this def-id.
172     [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
173
174     /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
175     [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
176
177     /// The signature of functions and closures.
178     [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
179
180     /// Caches CoerceUnsized kinds for impls on custom types.
181     [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
182         -> ty::adjustment::CoerceUnsizedInfo,
183
184     [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
185
186     [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
187
188     [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
189
190     [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
191
192     [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
193
194     [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
195
196     /// Borrow checks the function body. If this is a closure, returns
197     /// additional requirements that the closure's creator must verify.
198     [] fn mir_borrowck: MirBorrowCheck(DefId) -> Option<mir::ClosureRegionRequirements<'tcx>>,
199
200     /// Gets a complete map from all types to their inherent impls.
201     /// Not meant to be used directly outside of coherence.
202     /// (Defined only for LOCAL_CRATE)
203     [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
204
205     /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
206     /// Not meant to be used directly outside of coherence.
207     /// (Defined only for LOCAL_CRATE)
208     [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
209
210     /// Results of evaluating const items or constants embedded in
211     /// other items (such as enum variant explicit discriminants).
212     [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
213         -> const_val::EvalResult<'tcx>,
214
215     [] fn check_match: CheckMatch(DefId)
216         -> Result<(), ErrorReported>,
217
218     /// Performs the privacy check and computes "access levels".
219     [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
220
221     [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
222
223     /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
224     /// in the case of closures, this will be redirected to the enclosing function.
225     [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
226
227     [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
228
229     [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
230     [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
231
232     [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
233     [] fn def_span: DefSpan(DefId) -> Span,
234     [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
235     [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
236     [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
237     [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
238     [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
239     [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
240     [] fn is_exported_symbol: IsExportedSymbol(DefId) -> bool,
241     [] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> ExternBodyNestedBodies,
242     [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
243     [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
244     [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
245     [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
246                           -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
247
248     [] fn trans_fulfill_obligation: fulfill_obligation_dep_node(
249         (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
250     [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
251     [] fn specialization_graph_of: SpecializationGraph(DefId) -> Lrc<specialization_graph::Graph>,
252     [] fn is_object_safe: ObjectSafety(DefId) -> bool,
253
254     // Get the ParameterEnvironment for a given item; this environment
255     // will be in "user-facing" mode, meaning that it is suitabe for
256     // type-checking etc, and it does not normalize specializable
257     // associated types. This is almost always what you want,
258     // unless you are doing MIR optimizations, in which case you
259     // might want to use `reveal_all()` method to change modes.
260     [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
261
262     // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
263     // `ty.is_copy()`, etc, since that will prune the environment where possible.
264     [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
265     [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
266     [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
267     [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
268     [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
269                                   -> Result<&'tcx ty::layout::LayoutDetails,
270                                             ty::layout::LayoutError<'tcx>>,
271
272     [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
273                                     -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
274
275     [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
276     [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
277     [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
278     [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
279     [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
280     [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
281     [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
282
283     [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
284
285     [] fn specializes: specializes_node((DefId, DefId)) -> bool,
286     [] fn in_scope_traits_map: InScopeTraits(DefIndex)
287         -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
288     [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
289     [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
290
291     [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
292     [] fn exported_symbol_ids: ExportedSymbolIds(CrateNum) -> Lrc<DefIdSet>,
293     [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
294     [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
295     [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
296     [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
297     [] fn crate_hash: CrateHash(CrateNum) -> Svh,
298     [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
299
300     [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
301         -> Lrc<Vec<DefId>>,
302     [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
303         -> Lrc<Vec<DefId>>,
304
305     [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
306     [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
307     [] fn native_library_kind: NativeLibraryKind(DefId)
308         -> Option<NativeLibraryKind>,
309     [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
310
311     // Lifetime resolution. See `middle::resolve_lifetimes`.
312     [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
313     [] fn named_region_map: NamedRegion(DefIndex) ->
314         Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
315     [] fn is_late_bound_map: IsLateBound(DefIndex) ->
316         Option<Lrc<FxHashSet<ItemLocalId>>>,
317     [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
318         -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
319
320     [] fn visibility: Visibility(DefId) -> ty::Visibility,
321     [] fn dep_kind: DepKind(CrateNum) -> DepKind,
322     [] fn crate_name: CrateName(CrateNum) -> Symbol,
323     [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
324     [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
325
326     [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
327     [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
328     [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
329     [] fn extern_const_body: ExternConstBody(DefId) -> ExternConstBody<'tcx>,
330     [] fn visible_parent_map: visible_parent_map_node(CrateNum)
331         -> Lrc<DefIdMap<DefId>>,
332     [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
333     [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
334     [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
335
336     [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
337     [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
338     [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
339         -> Lrc<Vec<(DefId, Span)>>,
340
341     [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
342     [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
343
344     [] fn exported_symbols: ExportedSymbols(CrateNum)
345         -> Arc<Vec<(String, Option<DefId>, SymbolExportLevel)>>,
346     [] fn collect_and_partition_translation_items:
347         collect_and_partition_translation_items_node(CrateNum)
348         -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
349     [] fn export_name: ExportName(DefId) -> Option<Symbol>,
350     [] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
351     [] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
352     [] fn is_translated_item: IsTranslatedItem(DefId) -> bool,
353     [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
354     [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
355     [] fn output_filenames: output_filenames_node(CrateNum)
356         -> Arc<OutputFilenames>,
357
358     [] fn has_copy_closures: HasCopyClosures(CrateNum) -> bool,
359     [] fn has_clone_closures: HasCloneClosures(CrateNum) -> bool,
360
361     // Erases regions from `ty` to yield a new type.
362     // Normally you would just use `tcx.erase_regions(&value)`,
363     // however, which uses this query as a kind of cache.
364     [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
365     [] fn fully_normalize_monormophic_ty: normalize_ty_node(Ty<'tcx>) -> Ty<'tcx>,
366
367     [] fn substitute_normalize_and_test_predicates:
368         substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
369
370     [] fn target_features_whitelist:
371         target_features_whitelist_node(CrateNum) -> Lrc<FxHashSet<String>>,
372     [] fn target_features_enabled: TargetFeaturesEnabled(DefId) -> Lrc<Vec<String>>,
373
374     // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
375     [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
376         -> usize,
377 }
378
379 //////////////////////////////////////////////////////////////////////
380 // These functions are little shims used to find the dep-node for a
381 // given query when there is not a *direct* mapping:
382
383 fn erase_regions_ty<'tcx>(ty: Ty<'tcx>) -> DepConstructor<'tcx> {
384     DepConstructor::EraseRegionsTy { ty }
385 }
386
387 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
388     DepConstructor::TypeParamPredicates {
389         item_id,
390         param_id
391     }
392 }
393
394 fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
395     (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> DepConstructor<'tcx> {
396     DepConstructor::FulfillObligation {
397         param_env,
398         trait_ref
399     }
400 }
401
402 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
403     DepConstructor::Coherence
404 }
405
406 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
407     DepConstructor::CoherenceInherentImplOverlapCheck
408 }
409
410 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
411     DepConstructor::Reachability
412 }
413
414 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
415     DepConstructor::MirShim {
416         instance_def
417     }
418 }
419
420 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
421     DepConstructor::InstanceSymbolName { instance }
422 }
423
424 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
425     DepConstructor::TypeckBodiesKrate
426 }
427
428 fn const_eval_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
429                              -> DepConstructor<'tcx> {
430     DepConstructor::ConstEval { param_env }
431 }
432
433 fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
434     DepConstructor::MirKeys
435 }
436
437 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
438     DepConstructor::CrateVariances
439 }
440
441 fn is_copy_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
442     DepConstructor::IsCopy { param_env }
443 }
444
445 fn is_sized_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
446     DepConstructor::IsSized { param_env }
447 }
448
449 fn is_freeze_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
450     DepConstructor::IsFreeze { param_env }
451 }
452
453 fn needs_drop_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
454     DepConstructor::NeedsDrop { param_env }
455 }
456
457 fn layout_dep_node<'tcx>(param_env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
458     DepConstructor::Layout { param_env }
459 }
460
461 fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
462     DepConstructor::LintLevels
463 }
464
465 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
466     DepConstructor::Specializes { impl1: a, impl2: b }
467 }
468
469 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
470     -> DepConstructor<'tcx>
471 {
472     DepConstructor::ImplementationsOfTrait { krate, trait_id }
473 }
474
475 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
476     DepConstructor::LinkArgs
477 }
478
479 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
480     DepConstructor::GetLangItems
481 }
482
483 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
484     DepConstructor::VisibleParentMap
485 }
486
487 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
488     DepConstructor::PostorderCnums
489 }
490
491 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
492     DepConstructor::MaybeUnusedExternCrates
493 }
494
495 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
496     DepConstructor::StabilityIndex
497 }
498
499 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
500     DepConstructor::AllCrateNums
501 }
502
503 fn collect_and_partition_translation_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
504     DepConstructor::CollectAndPartitionTranslationItems
505 }
506
507 fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
508     DepConstructor::OutputFilenames
509 }
510
511 fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> {
512     DepConstructor::VtableMethods{ trait_ref }
513 }
514 fn normalize_ty_node<'tcx>(_: Ty<'tcx>) -> DepConstructor<'tcx> {
515     DepConstructor::NormalizeTy
516 }
517
518 fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>))
519                                             -> DepConstructor<'tcx> {
520     DepConstructor::SubstituteNormalizeAndTestPredicates { key }
521 }
522
523 fn target_features_whitelist_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
524     DepConstructor::TargetFeaturesWhitelist
525 }
526
527 fn instance_def_size_estimate_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>)
528                                               -> DepConstructor<'tcx> {
529     DepConstructor::InstanceDefSizeEstimate {
530         instance_def
531     }
532 }