1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig};
12 use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
15 use middle::const_val;
16 use middle::privacy::AccessLevels;
17 use middle::region::RegionMaps;
19 use mir::transform::{MirSuite, MirPassIndex};
20 use session::CompileResult;
21 use ty::{self, CrateInherentImpls, Ty, TyCtxt};
24 use ty::subst::Substs;
25 use util::nodemap::{DefIdSet, NodeSet};
27 use rustc_data_structures::indexed_vec::IndexVec;
28 use std::cell::{RefCell, RefMut};
32 use std::collections::BTreeMap;
35 use syntax_pos::{Span, DUMMY_SP};
36 use syntax::symbol::Symbol;
38 pub trait Key: Clone + Hash + Eq + Debug {
39 fn map_crate(&self) -> CrateNum;
40 fn default_span(&self, tcx: TyCtxt) -> Span;
43 impl<'tcx> Key for ty::InstanceDef<'tcx> {
44 fn map_crate(&self) -> CrateNum {
48 fn default_span(&self, tcx: TyCtxt) -> Span {
49 tcx.def_span(self.def_id())
53 impl<'tcx> Key for ty::Instance<'tcx> {
54 fn map_crate(&self) -> CrateNum {
58 fn default_span(&self, tcx: TyCtxt) -> Span {
59 tcx.def_span(self.def_id())
63 impl Key for CrateNum {
64 fn map_crate(&self) -> CrateNum {
67 fn default_span(&self, _: TyCtxt) -> Span {
73 fn map_crate(&self) -> CrateNum {
76 fn default_span(&self, tcx: TyCtxt) -> Span {
81 impl Key for (DefId, DefId) {
82 fn map_crate(&self) -> CrateNum {
85 fn default_span(&self, tcx: TyCtxt) -> Span {
86 self.1.default_span(tcx)
90 impl Key for (CrateNum, DefId) {
91 fn map_crate(&self) -> CrateNum {
94 fn default_span(&self, tcx: TyCtxt) -> Span {
95 self.1.default_span(tcx)
99 impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
100 fn map_crate(&self) -> CrateNum {
103 fn default_span(&self, tcx: TyCtxt) -> Span {
104 self.0.default_span(tcx)
108 impl Key for (MirSuite, DefId) {
109 fn map_crate(&self) -> CrateNum {
112 fn default_span(&self, tcx: TyCtxt) -> Span {
113 self.1.default_span(tcx)
117 impl Key for (MirSuite, MirPassIndex, DefId) {
118 fn map_crate(&self) -> CrateNum {
121 fn default_span(&self, tcx: TyCtxt) -> Span {
122 self.2.default_span(tcx)
126 trait Value<'tcx>: Sized {
127 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self;
130 impl<'tcx, T> Value<'tcx> for T {
131 default fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> T {
132 tcx.sess.abort_if_errors();
133 bug!("Value::from_cycle_error called without errors");
137 impl<'tcx, T: Default> Value<'tcx> for T {
138 default fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> T {
143 impl<'tcx> Value<'tcx> for Ty<'tcx> {
144 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
149 impl<'tcx> Value<'tcx> for ty::DtorckConstraint<'tcx> {
150 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
155 impl<'tcx> Value<'tcx> for ty::SymbolName {
156 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
157 ty::SymbolName { name: Symbol::intern("<error>").as_str() }
161 pub struct CycleError<'a, 'tcx: 'a> {
163 cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
166 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
167 pub fn report_cycle(self, CycleError { span, cycle }: CycleError) {
168 // Subtle: release the refcell lock before invoking `describe()`
169 // below by dropping `cycle`.
170 let stack = cycle.to_vec();
173 assert!(!stack.is_empty());
175 // Disable naming impls with types in this path, since that
176 // sometimes cycles itself, leading to extra cycle errors.
177 // (And cycle errors around impls tend to occur during the
178 // collect/coherence phases anyhow.)
179 item_path::with_forced_impl_filename_line(|| {
181 struct_span_err!(self.sess, span, E0391,
182 "unsupported cyclic reference between types/traits detected");
183 err.span_label(span, &format!("cyclic reference"));
185 err.span_note(stack[0].0, &format!("the cycle begins when {}...",
186 stack[0].1.describe(self)));
188 for &(span, ref query) in &stack[1..] {
189 err.span_note(span, &format!("...which then requires {}...",
190 query.describe(self)));
193 err.note(&format!("...which then again requires {}, completing the cycle.",
194 stack[0].1.describe(self)));
200 fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
201 -> Result<R, CycleError<'a, 'gcx>>
202 where F: FnOnce() -> R
205 let mut stack = self.maps.query_stack.borrow_mut();
206 if let Some((i, _)) = stack.iter().enumerate().rev()
207 .find(|&(_, &(_, ref q))| *q == query) {
208 return Err(CycleError {
210 cycle: RefMut::map(stack, |stack| &mut stack[i..])
213 stack.push((span, query));
216 let result = compute();
218 self.maps.query_stack.borrow_mut().pop();
224 trait QueryDescription: DepTrackingMapConfig {
225 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
228 impl<M: DepTrackingMapConfig<Key=DefId>> QueryDescription for M {
229 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
230 format!("processing `{}`", tcx.item_path_str(def_id))
234 impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
235 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
236 format!("computing the supertraits of `{}`",
237 tcx.item_path_str(def_id))
241 impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
242 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
243 let id = tcx.hir.as_local_node_id(def_id).unwrap();
244 format!("computing the bounds for type parameter `{}`",
245 tcx.hir.ty_param_name(id))
249 impl<'tcx> QueryDescription for queries::coherent_trait<'tcx> {
250 fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
251 format!("coherence checking all impls of trait `{}`",
252 tcx.item_path_str(def_id))
256 impl<'tcx> QueryDescription for queries::crate_inherent_impls<'tcx> {
257 fn describe(_: TyCtxt, k: CrateNum) -> String {
258 format!("all inherent impls defined in crate `{:?}`", k)
262 impl<'tcx> QueryDescription for queries::crate_inherent_impls_overlap_check<'tcx> {
263 fn describe(_: TyCtxt, _: CrateNum) -> String {
264 format!("check for overlap between inherent impls defined in this crate")
268 impl<'tcx> QueryDescription for queries::mir_shims<'tcx> {
269 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
270 format!("generating MIR shim for `{}`",
271 tcx.item_path_str(def.def_id()))
275 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
276 fn describe(_: TyCtxt, _: CrateNum) -> String {
277 format!("privacy access levels")
281 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
282 fn describe(_: TyCtxt, _: CrateNum) -> String {
283 format!("type-checking all item bodies")
287 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
288 fn describe(_: TyCtxt, _: CrateNum) -> String {
289 format!("reachability")
293 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
294 fn describe(tcx: TyCtxt, (def_id, _): (DefId, &'tcx Substs<'tcx>)) -> String {
295 format!("const-evaluating `{}`", tcx.item_path_str(def_id))
299 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
300 fn describe(_: TyCtxt, _: CrateNum) -> String {
301 format!("getting a list of all mir_keys")
305 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
306 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
307 format!("computing the symbol for `{}`", instance)
311 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
312 fn describe(_: TyCtxt, _: DefId) -> String {
317 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
318 fn describe(_: TyCtxt, _: DefId) -> String {
323 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
324 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
325 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
329 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
330 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
331 format!("const checking if rvalue is promotable to static `{}`",
332 tcx.item_path_str(def_id))
336 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
337 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
338 format!("checking if item is mir available: `{}`",
339 tcx.item_path_str(def_id))
343 macro_rules! define_maps {
346 [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
349 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
352 impl<$tcx> Maps<$tcx> {
353 pub fn new(dep_graph: DepGraph,
354 providers: IndexVec<CrateNum, Providers<$tcx>>)
358 query_stack: RefCell::new(vec![]),
359 $($name: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
365 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
366 pub enum Query<$tcx> {
367 $($(#[$attr])* $name($K)),*
370 impl<$tcx> Query<$tcx> {
371 pub fn describe(&self, tcx: TyCtxt) -> String {
373 $(Query::$name(key) => queries::$name::describe(tcx, key)),*
379 use std::marker::PhantomData;
381 $(#[allow(bad_style)]
382 pub struct $name<$tcx> {
383 data: PhantomData<&$tcx ()>
387 $(impl<$tcx> DepTrackingMapConfig for queries::$name<$tcx> {
392 fn to_dep_node(key: &$K) -> DepNode<DefId> {
393 use dep_graph::DepNode::*;
398 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
399 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
403 -> Result<R, CycleError<'a, $tcx>>
404 where F: FnOnce(&$V) -> R
406 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
411 if let Some(result) = tcx.maps.$name.borrow().get(&key) {
412 return Ok(f(result));
415 // FIXME(eddyb) Get more valid Span's on queries.
416 // def_span guard is necesary to prevent a recursive loop,
417 // default_span calls def_span query internally.
418 if span == DUMMY_SP && stringify!($name) != "def_span" {
419 span = key.default_span(tcx)
422 let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key));
424 let result = tcx.cycle_check(span, Query::$name(key), || {
425 let provider = tcx.maps.providers[key.map_crate()].$name;
426 provider(tcx.global_tcx(), key)
429 Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result)))
432 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
433 -> Result<$V, CycleError<'a, $tcx>> {
434 Self::try_get_with(tcx, span, key, Clone::clone)
437 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
438 // FIXME(eddyb) Move away from using `DepTrackingMap`
439 // so we don't have to explicitly ignore a false edge:
440 // we can't observe a value dependency, only side-effects,
441 // through `force`, and once everything has been updated,
442 // perhaps only diagnostics, if those, will remain.
443 let _ignore = tcx.dep_graph.in_ignore();
444 match Self::try_get_with(tcx, span, key, |_| ()) {
446 Err(e) => tcx.report_cycle(e)
451 #[derive(Copy, Clone)]
452 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
453 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
457 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
458 type Target = TyCtxt<'a, 'gcx, 'tcx>;
459 fn deref(&self) -> &Self::Target {
464 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
465 /// Return a transparent wrapper for `TyCtxt` which uses
466 /// `span` as the location of queries performed through it.
467 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
475 pub fn $name(self, key: $K) -> $V {
476 self.at(DUMMY_SP).$name(key)
480 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
482 pub fn $name(self, key: $K) -> $V {
483 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
484 self.report_cycle(e);
485 Value::from_cycle_error(self.global_tcx())
490 define_provider_struct! {
492 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
496 impl<$tcx> Copy for Providers<$tcx> {}
497 impl<$tcx> Clone for Providers<$tcx> {
498 fn clone(&self) -> Self { *self }
503 macro_rules! define_map_struct {
506 input: $input:tt) => {
517 output: ($($output:tt)*)) => {
518 pub struct Maps<$tcx> {
519 providers: IndexVec<CrateNum, Providers<$tcx>>,
520 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
525 // Field recognized and ready to shift into the output
527 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
529 output: ($($output:tt)*)) => {
534 $(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>,)
538 // Detect things with the `pub` modifier
540 input: (([pub $($other_modifiers:tt)*] $attrs:tt $name:tt) $($input:tt)*),
541 output: $output:tt) => {
544 ready: ([pub] $attrs $name),
550 // No modifiers left? This is a private item.
552 input: (([] $attrs:tt $name:tt) $($input:tt)*),
553 output: $output:tt) => {
556 ready: ([pub] $attrs $name),
562 // Skip other modifiers
564 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
565 output: $output:tt) => {
568 input: (([$($modifiers)*] $($fields)*) $($input)*),
574 macro_rules! define_provider_struct {
576 (tcx: $tcx:tt, input: $input:tt) => {
577 define_provider_struct! {
587 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
588 pub struct Providers<$tcx> {
589 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
592 impl<$tcx> Default for Providers<$tcx> {
593 fn default() -> Self {
594 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
595 bug!("tcx.maps.{}({:?}) unsupported by its crate",
596 stringify!($name), key);
598 Providers { $($name),* }
603 // Something ready to shift:
605 ready: ($name:tt $K:tt $V:tt),
607 output: ($($output:tt)*)) => {
608 define_provider_struct! {
611 output: ($($output)* ($name $K $V))
615 // Regular queries produce a `V` only.
617 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
618 output: $output:tt) => {
619 define_provider_struct! {
621 ready: ($name $K $V),
629 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
630 output: $output:tt) => {
631 define_provider_struct! {
633 input: (([$($modifiers)*] $($fields)*) $($input)*),
639 // Each of these maps also corresponds to a method on a
640 // `Provider` trait for requesting a value of that type,
641 // and a method on `Maps` itself for doing that in a
642 // a way that memoizes and does dep-graph tracking,
643 // wrapping around the actual chain of providers that
644 // the driver creates (using several `rustc_*` crates).
645 define_maps! { <'tcx>
646 /// Records the type of every item.
647 [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
649 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
650 /// associated generics and predicates.
651 [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
652 [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
654 /// Maps from the def-id of a trait to the list of
655 /// super-predicates. This is a subset of the full list of
656 /// predicates. We store these in a separate map because we must
657 /// evaluate them even during type conversion, often before the
658 /// full predicates are available (note that supertraits have
659 /// additional acyclicity requirements).
660 [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
662 /// To avoid cycles within the predicates of a single item we compute
663 /// per-type-parameter predicates for resolving `T::AssocTy`.
664 [] type_param_predicates: TypeParamPredicates((DefId, DefId))
665 -> ty::GenericPredicates<'tcx>,
667 [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
668 [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
669 [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
670 [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
671 [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
673 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
674 [] is_foreign_item: IsForeignItem(DefId) -> bool,
676 /// Maps from def-id of a type or region parameter to its
677 /// (inferred) variance.
678 [pub] variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
680 /// Maps from an impl/trait def-id to a list of the def-ids of its items
681 [] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
683 /// Maps from a trait item to the trait item "descriptor"
684 [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
686 [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
687 [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
689 /// Maps a DefId of a type to a list of its inherent impls.
690 /// Contains implementations of methods that are inherent to a type.
691 /// Methods in these implementations don't need to be exported.
692 [] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
694 /// Set of all the def-ids in this crate that have MIR associated with
695 /// them. This includes all the body owners, but also things like struct
697 [] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
699 /// Maps DefId's that have an associated Mir to the result
700 /// of the MIR qualify_consts pass. The actual meaning of
701 /// the value isn't known except to the pass itself.
702 [] mir_const_qualif: Mir(DefId) -> u8,
704 /// Fetch the MIR for a given def-id up till the point where it is
705 /// ready for const evaluation.
707 /// See the README for the `mir` module for details.
708 [] mir_const: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
710 [] mir_validated: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
712 /// MIR after our optimization passes have run. This is MIR that is ready
713 /// for trans. This is also the only query that can fetch non-local MIR, at present.
714 [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
716 /// Records the type of each closure. The def ID is the ID of the
717 /// expression defining the closure.
718 [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
720 /// Records the type of each closure. The def ID is the ID of the
721 /// expression defining the closure.
722 [] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
724 /// Caches CoerceUnsized kinds for impls on custom types.
725 [] coerce_unsized_info: ItemSignature(DefId)
726 -> ty::adjustment::CoerceUnsizedInfo,
728 [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
730 [] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
732 [] has_typeck_tables: TypeckTables(DefId) -> bool,
734 [] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
736 [] borrowck: BorrowCheck(DefId) -> (),
738 /// Gets a complete map from all types to their inherent impls.
739 /// Not meant to be used directly outside of coherence.
740 /// (Defined only for LOCAL_CRATE)
741 [] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
743 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
744 /// Not meant to be used directly outside of coherence.
745 /// (Defined only for LOCAL_CRATE)
746 [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
748 /// Results of evaluating const items or constants embedded in
749 /// other items (such as enum variant explicit discriminants).
750 [] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
751 -> const_val::EvalResult<'tcx>,
753 /// Performs the privacy check and computes "access levels".
754 [] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
756 [] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
758 /// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
759 /// in the case of closures or "inline" expressions, this will be redirected to the enclosing
761 [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps<'tcx>>,
763 [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
765 [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
766 [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
768 [] describe_def: DescribeDef(DefId) -> Option<Def>,
769 [] def_span: DefSpan(DefId) -> Span,
771 [] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
772 [] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
773 [] is_mir_available: metadata_dep_node(DefId) -> bool,
776 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
777 DepNode::CoherenceCheckTrait(def_id)
780 fn crate_inherent_impls_dep_node(_: CrateNum) -> DepNode<DefId> {
784 fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
785 DepNode::Reachability
788 fn metadata_dep_node(def_id: DefId) -> DepNode<DefId> {
789 DepNode::MetaData(def_id)
792 fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
796 fn symbol_name_dep_node(instance: ty::Instance) -> DepNode<DefId> {
797 // symbol_name uses the substs only to traverse them to find the
798 // hash, and that does not create any new dep-nodes.
799 DepNode::SymbolName(instance.def.def_id())
802 fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
803 DepNode::TypeckBodiesKrate
806 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
807 DepNode::ConstEval(def_id)
810 fn mir_keys(_: CrateNum) -> DepNode<DefId> {