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};
37 use syntax::symbol::Symbol;
39 pub trait Key: Clone + Hash + Eq + Debug {
40 fn map_crate(&self) -> CrateNum;
41 fn default_span(&self, tcx: TyCtxt) -> Span;
44 impl<'tcx> Key for ty::InstanceDef<'tcx> {
45 fn map_crate(&self) -> CrateNum {
49 fn default_span(&self, tcx: TyCtxt) -> Span {
50 tcx.def_span(self.def_id())
54 impl<'tcx> Key for ty::Instance<'tcx> {
55 fn map_crate(&self) -> CrateNum {
59 fn default_span(&self, tcx: TyCtxt) -> Span {
60 tcx.def_span(self.def_id())
64 impl Key for CrateNum {
65 fn map_crate(&self) -> CrateNum {
68 fn default_span(&self, _: TyCtxt) -> Span {
74 fn map_crate(&self) -> CrateNum {
77 fn default_span(&self, tcx: TyCtxt) -> Span {
82 impl Key for (DefId, DefId) {
83 fn map_crate(&self) -> CrateNum {
86 fn default_span(&self, tcx: TyCtxt) -> Span {
87 self.1.default_span(tcx)
91 impl Key for (CrateNum, DefId) {
92 fn map_crate(&self) -> CrateNum {
95 fn default_span(&self, tcx: TyCtxt) -> Span {
96 self.1.default_span(tcx)
100 impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
101 fn map_crate(&self) -> CrateNum {
104 fn default_span(&self, tcx: TyCtxt) -> Span {
105 self.0.default_span(tcx)
109 impl Key for (MirSuite, DefId) {
110 fn map_crate(&self) -> CrateNum {
113 fn default_span(&self, tcx: TyCtxt) -> Span {
114 self.1.default_span(tcx)
118 impl Key for (MirSuite, MirPassIndex, DefId) {
119 fn map_crate(&self) -> CrateNum {
122 fn default_span(&self, tcx: TyCtxt) -> Span {
123 self.2.default_span(tcx)
127 trait Value<'tcx>: Sized {
128 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self;
131 impl<'tcx, T> Value<'tcx> for T {
132 default fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> T {
133 tcx.sess.abort_if_errors();
134 bug!("Value::from_cycle_error called without errors");
138 impl<'tcx, T: Default> Value<'tcx> for T {
139 default fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> T {
144 impl<'tcx> Value<'tcx> for Ty<'tcx> {
145 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
150 impl<'tcx> Value<'tcx> for ty::DtorckConstraint<'tcx> {
151 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
156 impl<'tcx> Value<'tcx> for ty::SymbolName {
157 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
158 ty::SymbolName { name: Symbol::intern("<error>").as_str() }
162 pub struct CycleError<'a, 'tcx: 'a> {
164 cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
167 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
168 pub fn report_cycle(self, CycleError { span, cycle }: CycleError) {
169 // Subtle: release the refcell lock before invoking `describe()`
170 // below by dropping `cycle`.
171 let stack = cycle.to_vec();
174 assert!(!stack.is_empty());
176 // Disable naming impls with types in this path, since that
177 // sometimes cycles itself, leading to extra cycle errors.
178 // (And cycle errors around impls tend to occur during the
179 // collect/coherence phases anyhow.)
180 item_path::with_forced_impl_filename_line(|| {
182 struct_span_err!(self.sess, span, E0391,
183 "unsupported cyclic reference between types/traits detected");
184 err.span_label(span, &format!("cyclic reference"));
186 err.span_note(stack[0].0, &format!("the cycle begins when {}...",
187 stack[0].1.describe(self)));
189 for &(span, ref query) in &stack[1..] {
190 err.span_note(span, &format!("...which then requires {}...",
191 query.describe(self)));
194 err.note(&format!("...which then again requires {}, completing the cycle.",
195 stack[0].1.describe(self)));
201 fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
202 -> Result<R, CycleError<'a, 'gcx>>
203 where F: FnOnce() -> R
206 let mut stack = self.maps.query_stack.borrow_mut();
207 if let Some((i, _)) = stack.iter().enumerate().rev()
208 .find(|&(_, &(_, ref q))| *q == query) {
209 return Err(CycleError {
211 cycle: RefMut::map(stack, |stack| &mut stack[i..])
214 stack.push((span, query));
217 let result = compute();
219 self.maps.query_stack.borrow_mut().pop();
225 trait QueryDescription: DepTrackingMapConfig {
226 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
229 impl<M: DepTrackingMapConfig<Key=DefId>> QueryDescription for M {
230 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
231 format!("processing `{}`", tcx.item_path_str(def_id))
235 impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
236 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
237 format!("computing the supertraits of `{}`",
238 tcx.item_path_str(def_id))
242 impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
243 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
244 let id = tcx.hir.as_local_node_id(def_id).unwrap();
245 format!("computing the bounds for type parameter `{}`",
246 tcx.hir.ty_param_name(id))
250 impl<'tcx> QueryDescription for queries::coherent_trait<'tcx> {
251 fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
252 format!("coherence checking all impls of trait `{}`",
253 tcx.item_path_str(def_id))
257 impl<'tcx> QueryDescription for queries::crate_inherent_impls<'tcx> {
258 fn describe(_: TyCtxt, k: CrateNum) -> String {
259 format!("all inherent impls defined in crate `{:?}`", k)
263 impl<'tcx> QueryDescription for queries::crate_inherent_impls_overlap_check<'tcx> {
264 fn describe(_: TyCtxt, _: CrateNum) -> String {
265 format!("check for overlap between inherent impls defined in this crate")
269 impl<'tcx> QueryDescription for queries::mir_shims<'tcx> {
270 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
271 format!("generating MIR shim for `{}`",
272 tcx.item_path_str(def.def_id()))
276 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
277 fn describe(_: TyCtxt, _: CrateNum) -> String {
278 format!("privacy access levels")
282 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
283 fn describe(_: TyCtxt, _: CrateNum) -> String {
284 format!("type-checking all item bodies")
288 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
289 fn describe(_: TyCtxt, _: CrateNum) -> String {
290 format!("reachability")
294 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
295 fn describe(tcx: TyCtxt, (def_id, _): (DefId, &'tcx Substs<'tcx>)) -> String {
296 format!("const-evaluating `{}`", tcx.item_path_str(def_id))
300 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
301 fn describe(_: TyCtxt, _: CrateNum) -> String {
302 format!("getting a list of all mir_keys")
306 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
307 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
308 format!("computing the symbol for `{}`", instance)
312 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
313 fn describe(_: TyCtxt, _: DefId) -> String {
318 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
319 fn describe(_: TyCtxt, _: DefId) -> String {
325 impl<'tcx> QueryDescription for queries::stability<'tcx> {
326 fn describe(_: TyCtxt, _: DefId) -> String {
331 impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
332 fn describe(_: TyCtxt, _: DefId) -> String {
337 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
338 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
339 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
343 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
344 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
345 format!("const checking if rvalue is promotable to static `{}`",
346 tcx.item_path_str(def_id))
350 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
351 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
352 format!("checking if item is mir available: `{}`",
353 tcx.item_path_str(def_id))
357 macro_rules! define_maps {
360 [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
363 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
366 impl<$tcx> Maps<$tcx> {
367 pub fn new(dep_graph: DepGraph,
368 providers: IndexVec<CrateNum, Providers<$tcx>>)
372 query_stack: RefCell::new(vec![]),
373 $($name: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
379 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
380 pub enum Query<$tcx> {
381 $($(#[$attr])* $name($K)),*
384 impl<$tcx> Query<$tcx> {
385 pub fn describe(&self, tcx: TyCtxt) -> String {
387 $(Query::$name(key) => queries::$name::describe(tcx, key)),*
393 use std::marker::PhantomData;
395 $(#[allow(bad_style)]
396 pub struct $name<$tcx> {
397 data: PhantomData<&$tcx ()>
401 $(impl<$tcx> DepTrackingMapConfig for queries::$name<$tcx> {
406 fn to_dep_node(key: &$K) -> DepNode<DefId> {
407 use dep_graph::DepNode::*;
412 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
413 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
417 -> Result<R, CycleError<'a, $tcx>>
418 where F: FnOnce(&$V) -> R
420 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
425 if let Some(result) = tcx.maps.$name.borrow().get(&key) {
426 return Ok(f(result));
429 // FIXME(eddyb) Get more valid Span's on queries.
430 // def_span guard is necesary to prevent a recursive loop,
431 // default_span calls def_span query internally.
432 if span == DUMMY_SP && stringify!($name) != "def_span" {
433 span = key.default_span(tcx)
436 let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key));
438 let result = tcx.cycle_check(span, Query::$name(key), || {
439 let provider = tcx.maps.providers[key.map_crate()].$name;
440 provider(tcx.global_tcx(), key)
443 Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result)))
446 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
447 -> Result<$V, CycleError<'a, $tcx>> {
448 Self::try_get_with(tcx, span, key, Clone::clone)
451 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
452 // FIXME(eddyb) Move away from using `DepTrackingMap`
453 // so we don't have to explicitly ignore a false edge:
454 // we can't observe a value dependency, only side-effects,
455 // through `force`, and once everything has been updated,
456 // perhaps only diagnostics, if those, will remain.
457 let _ignore = tcx.dep_graph.in_ignore();
458 match Self::try_get_with(tcx, span, key, |_| ()) {
460 Err(e) => tcx.report_cycle(e)
465 #[derive(Copy, Clone)]
466 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
467 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
471 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
472 type Target = TyCtxt<'a, 'gcx, 'tcx>;
473 fn deref(&self) -> &Self::Target {
478 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
479 /// Return a transparent wrapper for `TyCtxt` which uses
480 /// `span` as the location of queries performed through it.
481 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
489 pub fn $name(self, key: $K) -> $V {
490 self.at(DUMMY_SP).$name(key)
494 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
496 pub fn $name(self, key: $K) -> $V {
497 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
498 self.report_cycle(e);
499 Value::from_cycle_error(self.global_tcx())
504 define_provider_struct! {
506 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
510 impl<$tcx> Copy for Providers<$tcx> {}
511 impl<$tcx> Clone for Providers<$tcx> {
512 fn clone(&self) -> Self { *self }
517 macro_rules! define_map_struct {
520 input: $input:tt) => {
531 output: ($($output:tt)*)) => {
532 pub struct Maps<$tcx> {
533 providers: IndexVec<CrateNum, Providers<$tcx>>,
534 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
539 // Field recognized and ready to shift into the output
541 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
543 output: ($($output:tt)*)) => {
548 $(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>,)
552 // Detect things with the `pub` modifier
554 input: (([pub $($other_modifiers:tt)*] $attrs:tt $name:tt) $($input:tt)*),
555 output: $output:tt) => {
558 ready: ([pub] $attrs $name),
564 // No modifiers left? This is a private item.
566 input: (([] $attrs:tt $name:tt) $($input:tt)*),
567 output: $output:tt) => {
570 ready: ([pub] $attrs $name),
576 // Skip other modifiers
578 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
579 output: $output:tt) => {
582 input: (([$($modifiers)*] $($fields)*) $($input)*),
588 macro_rules! define_provider_struct {
590 (tcx: $tcx:tt, input: $input:tt) => {
591 define_provider_struct! {
601 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
602 pub struct Providers<$tcx> {
603 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
606 impl<$tcx> Default for Providers<$tcx> {
607 fn default() -> Self {
608 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
609 bug!("tcx.maps.{}({:?}) unsupported by its crate",
610 stringify!($name), key);
612 Providers { $($name),* }
617 // Something ready to shift:
619 ready: ($name:tt $K:tt $V:tt),
621 output: ($($output:tt)*)) => {
622 define_provider_struct! {
625 output: ($($output)* ($name $K $V))
629 // Regular queries produce a `V` only.
631 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
632 output: $output:tt) => {
633 define_provider_struct! {
635 ready: ($name $K $V),
643 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
644 output: $output:tt) => {
645 define_provider_struct! {
647 input: (([$($modifiers)*] $($fields)*) $($input)*),
653 // Each of these maps also corresponds to a method on a
654 // `Provider` trait for requesting a value of that type,
655 // and a method on `Maps` itself for doing that in a
656 // a way that memoizes and does dep-graph tracking,
657 // wrapping around the actual chain of providers that
658 // the driver creates (using several `rustc_*` crates).
659 define_maps! { <'tcx>
660 /// Records the type of every item.
661 [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
663 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
664 /// associated generics and predicates.
665 [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
666 [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
668 /// Maps from the def-id of a trait to the list of
669 /// super-predicates. This is a subset of the full list of
670 /// predicates. We store these in a separate map because we must
671 /// evaluate them even during type conversion, often before the
672 /// full predicates are available (note that supertraits have
673 /// additional acyclicity requirements).
674 [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
676 /// To avoid cycles within the predicates of a single item we compute
677 /// per-type-parameter predicates for resolving `T::AssocTy`.
678 [] type_param_predicates: TypeParamPredicates((DefId, DefId))
679 -> ty::GenericPredicates<'tcx>,
681 [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
682 [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
683 [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
684 [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
685 [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
687 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
688 [] is_foreign_item: IsForeignItem(DefId) -> bool,
690 /// Maps from def-id of a type or region parameter to its
691 /// (inferred) variance.
692 [pub] variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
694 /// Maps from an impl/trait def-id to a list of the def-ids of its items
695 [] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
697 /// Maps from a trait item to the trait item "descriptor"
698 [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
700 [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
701 [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
703 /// Maps a DefId of a type to a list of its inherent impls.
704 /// Contains implementations of methods that are inherent to a type.
705 /// Methods in these implementations don't need to be exported.
706 [] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
708 /// Set of all the def-ids in this crate that have MIR associated with
709 /// them. This includes all the body owners, but also things like struct
711 [] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
713 /// Maps DefId's that have an associated Mir to the result
714 /// of the MIR qualify_consts pass. The actual meaning of
715 /// the value isn't known except to the pass itself.
716 [] mir_const_qualif: Mir(DefId) -> u8,
718 /// Fetch the MIR for a given def-id up till the point where it is
719 /// ready for const evaluation.
721 /// See the README for the `mir` module for details.
722 [] mir_const: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
724 [] mir_validated: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
726 /// MIR after our optimization passes have run. This is MIR that is ready
727 /// for trans. This is also the only query that can fetch non-local MIR, at present.
728 [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
730 /// Records the type of each closure. The def ID is the ID of the
731 /// expression defining the closure.
732 [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
734 /// Records the type of each closure. The def ID is the ID of the
735 /// expression defining the closure.
736 [] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
738 /// Caches CoerceUnsized kinds for impls on custom types.
739 [] coerce_unsized_info: ItemSignature(DefId)
740 -> ty::adjustment::CoerceUnsizedInfo,
742 [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
744 [] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
746 [] has_typeck_tables: TypeckTables(DefId) -> bool,
748 [] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
750 [] borrowck: BorrowCheck(DefId) -> (),
752 /// Gets a complete map from all types to their inherent impls.
753 /// Not meant to be used directly outside of coherence.
754 /// (Defined only for LOCAL_CRATE)
755 [] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
757 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
758 /// Not meant to be used directly outside of coherence.
759 /// (Defined only for LOCAL_CRATE)
760 [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
762 /// Results of evaluating const items or constants embedded in
763 /// other items (such as enum variant explicit discriminants).
764 [] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
765 -> const_val::EvalResult<'tcx>,
767 /// Performs the privacy check and computes "access levels".
768 [] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
770 [] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
772 /// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
773 /// in the case of closures or "inline" expressions, this will be redirected to the enclosing
775 [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps<'tcx>>,
777 [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
779 [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
780 [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
782 [] describe_def: DescribeDef(DefId) -> Option<Def>,
783 [] def_span: DefSpan(DefId) -> Span,
784 [] stability: Stability(DefId) -> Option<attr::Stability>,
785 [] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
786 [] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
787 [] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
788 [] is_mir_available: metadata_dep_node(DefId) -> bool,
791 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
792 DepNode::CoherenceCheckTrait(def_id)
795 fn crate_inherent_impls_dep_node(_: CrateNum) -> DepNode<DefId> {
799 fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
800 DepNode::Reachability
803 fn metadata_dep_node(def_id: DefId) -> DepNode<DefId> {
804 DepNode::MetaData(def_id)
807 fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
811 fn symbol_name_dep_node(instance: ty::Instance) -> DepNode<DefId> {
812 // symbol_name uses the substs only to traverse them to find the
813 // hash, and that does not create any new dep-nodes.
814 DepNode::SymbolName(instance.def.def_id())
817 fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
818 DepNode::TypeckBodiesKrate
821 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
822 DepNode::ConstEval(def_id)
825 fn mir_keys(_: CrateNum) -> DepNode<DefId> {