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};
38 use syntax::symbol::Symbol;
40 pub trait Key: Clone + Hash + Eq + Debug {
41 fn map_crate(&self) -> CrateNum;
42 fn default_span(&self, tcx: TyCtxt) -> Span;
45 impl<'tcx> Key for ty::InstanceDef<'tcx> {
46 fn map_crate(&self) -> CrateNum {
50 fn default_span(&self, tcx: TyCtxt) -> Span {
51 tcx.def_span(self.def_id())
55 impl<'tcx> Key for ty::Instance<'tcx> {
56 fn map_crate(&self) -> CrateNum {
60 fn default_span(&self, tcx: TyCtxt) -> Span {
61 tcx.def_span(self.def_id())
65 impl Key for CrateNum {
66 fn map_crate(&self) -> CrateNum {
69 fn default_span(&self, _: TyCtxt) -> Span {
75 fn map_crate(&self) -> CrateNum {
78 fn default_span(&self, tcx: TyCtxt) -> Span {
83 impl Key for (DefId, DefId) {
84 fn map_crate(&self) -> CrateNum {
87 fn default_span(&self, tcx: TyCtxt) -> Span {
88 self.1.default_span(tcx)
92 impl Key for (CrateNum, DefId) {
93 fn map_crate(&self) -> CrateNum {
96 fn default_span(&self, tcx: TyCtxt) -> Span {
97 self.1.default_span(tcx)
101 impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
102 fn map_crate(&self) -> CrateNum {
105 fn default_span(&self, tcx: TyCtxt) -> Span {
106 self.0.default_span(tcx)
110 impl Key for (MirSuite, DefId) {
111 fn map_crate(&self) -> CrateNum {
114 fn default_span(&self, tcx: TyCtxt) -> Span {
115 self.1.default_span(tcx)
119 impl Key for (MirSuite, MirPassIndex, DefId) {
120 fn map_crate(&self) -> CrateNum {
123 fn default_span(&self, tcx: TyCtxt) -> Span {
124 self.2.default_span(tcx)
128 trait Value<'tcx>: Sized {
129 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self;
132 impl<'tcx, T> Value<'tcx> for T {
133 default fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> T {
134 tcx.sess.abort_if_errors();
135 bug!("Value::from_cycle_error called without errors");
139 impl<'tcx, T: Default> Value<'tcx> for T {
140 default fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> T {
145 impl<'tcx> Value<'tcx> for Ty<'tcx> {
146 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
151 impl<'tcx> Value<'tcx> for ty::DtorckConstraint<'tcx> {
152 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
157 impl<'tcx> Value<'tcx> for ty::SymbolName {
158 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
159 ty::SymbolName { name: Symbol::intern("<error>").as_str() }
163 pub struct CycleError<'a, 'tcx: 'a> {
165 cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
168 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
169 pub fn report_cycle(self, CycleError { span, cycle }: CycleError) {
170 // Subtle: release the refcell lock before invoking `describe()`
171 // below by dropping `cycle`.
172 let stack = cycle.to_vec();
175 assert!(!stack.is_empty());
177 // Disable naming impls with types in this path, since that
178 // sometimes cycles itself, leading to extra cycle errors.
179 // (And cycle errors around impls tend to occur during the
180 // collect/coherence phases anyhow.)
181 item_path::with_forced_impl_filename_line(|| {
183 struct_span_err!(self.sess, span, E0391,
184 "unsupported cyclic reference between types/traits detected");
185 err.span_label(span, "cyclic reference");
187 err.span_note(stack[0].0, &format!("the cycle begins when {}...",
188 stack[0].1.describe(self)));
190 for &(span, ref query) in &stack[1..] {
191 err.span_note(span, &format!("...which then requires {}...",
192 query.describe(self)));
195 err.note(&format!("...which then again requires {}, completing the cycle.",
196 stack[0].1.describe(self)));
202 fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
203 -> Result<R, CycleError<'a, 'gcx>>
204 where F: FnOnce() -> R
207 let mut stack = self.maps.query_stack.borrow_mut();
208 if let Some((i, _)) = stack.iter().enumerate().rev()
209 .find(|&(_, &(_, ref q))| *q == query) {
210 return Err(CycleError {
212 cycle: RefMut::map(stack, |stack| &mut stack[i..])
215 stack.push((span, query));
218 let result = compute();
220 self.maps.query_stack.borrow_mut().pop();
226 trait QueryDescription: DepTrackingMapConfig {
227 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
230 impl<M: DepTrackingMapConfig<Key=DefId>> QueryDescription for M {
231 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
232 format!("processing `{}`", tcx.item_path_str(def_id))
236 impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
237 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
238 format!("computing the supertraits of `{}`",
239 tcx.item_path_str(def_id))
243 impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
244 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
245 let id = tcx.hir.as_local_node_id(def_id).unwrap();
246 format!("computing the bounds for type parameter `{}`",
247 tcx.hir.ty_param_name(id))
251 impl<'tcx> QueryDescription for queries::coherent_trait<'tcx> {
252 fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
253 format!("coherence checking all impls of trait `{}`",
254 tcx.item_path_str(def_id))
258 impl<'tcx> QueryDescription for queries::crate_inherent_impls<'tcx> {
259 fn describe(_: TyCtxt, k: CrateNum) -> String {
260 format!("all inherent impls defined in crate `{:?}`", k)
264 impl<'tcx> QueryDescription for queries::crate_inherent_impls_overlap_check<'tcx> {
265 fn describe(_: TyCtxt, _: CrateNum) -> String {
266 format!("check for overlap between inherent impls defined in this crate")
270 impl<'tcx> QueryDescription for queries::crate_variances<'tcx> {
271 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
272 format!("computing the variances for items in this crate")
276 impl<'tcx> QueryDescription for queries::mir_shims<'tcx> {
277 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
278 format!("generating MIR shim for `{}`",
279 tcx.item_path_str(def.def_id()))
283 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
284 fn describe(_: TyCtxt, _: CrateNum) -> String {
285 format!("privacy access levels")
289 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
290 fn describe(_: TyCtxt, _: CrateNum) -> String {
291 format!("type-checking all item bodies")
295 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
296 fn describe(_: TyCtxt, _: CrateNum) -> String {
297 format!("reachability")
301 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
302 fn describe(tcx: TyCtxt, (def_id, _): (DefId, &'tcx Substs<'tcx>)) -> String {
303 format!("const-evaluating `{}`", tcx.item_path_str(def_id))
307 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
308 fn describe(_: TyCtxt, _: CrateNum) -> String {
309 format!("getting a list of all mir_keys")
313 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
314 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
315 format!("computing the symbol for `{}`", instance)
319 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
320 fn describe(_: TyCtxt, _: DefId) -> String {
325 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
326 fn describe(_: TyCtxt, _: DefId) -> String {
332 impl<'tcx> QueryDescription for queries::stability<'tcx> {
333 fn describe(_: TyCtxt, _: DefId) -> String {
338 impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
339 fn describe(_: TyCtxt, _: DefId) -> String {
344 impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
345 fn describe(_: TyCtxt, _: DefId) -> String {
350 impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
351 fn describe(_: TyCtxt, _: DefId) -> String {
352 bug!("is_exported_symbol")
356 impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
357 fn describe(_: TyCtxt, _: DefId) -> String {
362 impl<'tcx> QueryDescription for queries::impl_parent<'tcx> {
363 fn describe(_: TyCtxt, _: DefId) -> String {
368 impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> {
369 fn describe(_: TyCtxt, _: DefId) -> String {
370 bug!("trait_of_item")
374 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
375 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
376 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
380 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
381 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
382 format!("const checking if rvalue is promotable to static `{}`",
383 tcx.item_path_str(def_id))
387 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
388 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
389 format!("checking if item is mir available: `{}`",
390 tcx.item_path_str(def_id))
394 macro_rules! define_maps {
397 [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
400 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
403 impl<$tcx> Maps<$tcx> {
404 pub fn new(dep_graph: DepGraph,
405 providers: IndexVec<CrateNum, Providers<$tcx>>)
409 query_stack: RefCell::new(vec![]),
410 $($name: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
416 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
417 pub enum Query<$tcx> {
418 $($(#[$attr])* $name($K)),*
421 impl<$tcx> Query<$tcx> {
422 pub fn describe(&self, tcx: TyCtxt) -> String {
424 $(Query::$name(key) => queries::$name::describe(tcx, key)),*
430 use std::marker::PhantomData;
432 $(#[allow(bad_style)]
433 pub struct $name<$tcx> {
434 data: PhantomData<&$tcx ()>
438 $(impl<$tcx> DepTrackingMapConfig for queries::$name<$tcx> {
443 fn to_dep_node(key: &$K) -> DepNode<DefId> {
444 use dep_graph::DepNode::*;
449 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
450 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
454 -> Result<R, CycleError<'a, $tcx>>
455 where F: FnOnce(&$V) -> R
457 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
462 if let Some(result) = tcx.maps.$name.borrow().get(&key) {
463 return Ok(f(result));
466 // FIXME(eddyb) Get more valid Span's on queries.
467 // def_span guard is necesary to prevent a recursive loop,
468 // default_span calls def_span query internally.
469 if span == DUMMY_SP && stringify!($name) != "def_span" {
470 span = key.default_span(tcx)
473 let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key));
475 let result = tcx.cycle_check(span, Query::$name(key), || {
476 let provider = tcx.maps.providers[key.map_crate()].$name;
477 provider(tcx.global_tcx(), key)
480 Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result)))
483 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
484 -> Result<$V, CycleError<'a, $tcx>> {
485 Self::try_get_with(tcx, span, key, Clone::clone)
488 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
489 // FIXME(eddyb) Move away from using `DepTrackingMap`
490 // so we don't have to explicitly ignore a false edge:
491 // we can't observe a value dependency, only side-effects,
492 // through `force`, and once everything has been updated,
493 // perhaps only diagnostics, if those, will remain.
494 let _ignore = tcx.dep_graph.in_ignore();
495 match Self::try_get_with(tcx, span, key, |_| ()) {
497 Err(e) => tcx.report_cycle(e)
502 #[derive(Copy, Clone)]
503 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
504 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
508 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
509 type Target = TyCtxt<'a, 'gcx, 'tcx>;
510 fn deref(&self) -> &Self::Target {
515 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
516 /// Return a transparent wrapper for `TyCtxt` which uses
517 /// `span` as the location of queries performed through it.
518 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
526 pub fn $name(self, key: $K) -> $V {
527 self.at(DUMMY_SP).$name(key)
531 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
533 pub fn $name(self, key: $K) -> $V {
534 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
535 self.report_cycle(e);
536 Value::from_cycle_error(self.global_tcx())
541 define_provider_struct! {
543 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
547 impl<$tcx> Copy for Providers<$tcx> {}
548 impl<$tcx> Clone for Providers<$tcx> {
549 fn clone(&self) -> Self { *self }
554 macro_rules! define_map_struct {
557 input: $input:tt) => {
568 output: ($($output:tt)*)) => {
569 pub struct Maps<$tcx> {
570 providers: IndexVec<CrateNum, Providers<$tcx>>,
571 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
576 // Field recognized and ready to shift into the output
578 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
580 output: ($($output:tt)*)) => {
585 $(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>,)
589 // No modifiers left? This is a private item.
591 input: (([] $attrs:tt $name:tt) $($input:tt)*),
592 output: $output:tt) => {
595 ready: ([pub] $attrs $name),
601 // Skip other modifiers
603 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
604 output: $output:tt) => {
607 input: (([$($modifiers)*] $($fields)*) $($input)*),
613 macro_rules! define_provider_struct {
615 (tcx: $tcx:tt, input: $input:tt) => {
616 define_provider_struct! {
626 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
627 pub struct Providers<$tcx> {
628 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
631 impl<$tcx> Default for Providers<$tcx> {
632 fn default() -> Self {
633 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
634 bug!("tcx.maps.{}({:?}) unsupported by its crate",
635 stringify!($name), key);
637 Providers { $($name),* }
642 // Something ready to shift:
644 ready: ($name:tt $K:tt $V:tt),
646 output: ($($output:tt)*)) => {
647 define_provider_struct! {
650 output: ($($output)* ($name $K $V))
654 // Regular queries produce a `V` only.
656 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
657 output: $output:tt) => {
658 define_provider_struct! {
660 ready: ($name $K $V),
668 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
669 output: $output:tt) => {
670 define_provider_struct! {
672 input: (([$($modifiers)*] $($fields)*) $($input)*),
678 // Each of these maps also corresponds to a method on a
679 // `Provider` trait for requesting a value of that type,
680 // and a method on `Maps` itself for doing that in a
681 // a way that memoizes and does dep-graph tracking,
682 // wrapping around the actual chain of providers that
683 // the driver creates (using several `rustc_*` crates).
684 define_maps! { <'tcx>
685 /// Records the type of every item.
686 [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
688 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
689 /// associated generics and predicates.
690 [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
691 [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
693 /// Maps from the def-id of a trait to the list of
694 /// super-predicates. This is a subset of the full list of
695 /// predicates. We store these in a separate map because we must
696 /// evaluate them even during type conversion, often before the
697 /// full predicates are available (note that supertraits have
698 /// additional acyclicity requirements).
699 [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
701 /// To avoid cycles within the predicates of a single item we compute
702 /// per-type-parameter predicates for resolving `T::AssocTy`.
703 [] type_param_predicates: TypeParamPredicates((DefId, DefId))
704 -> ty::GenericPredicates<'tcx>,
706 [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
707 [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
708 [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
709 [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
710 [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
712 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
713 [] is_foreign_item: IsForeignItem(DefId) -> bool,
715 /// Get a map with the variance of every item; use `item_variance`
717 [] crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
719 /// Maps from def-id of a type or region parameter to its
720 /// (inferred) variance.
721 [] variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
723 /// Maps from an impl/trait def-id to a list of the def-ids of its items
724 [] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
726 /// Maps from a trait item to the trait item "descriptor"
727 [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
729 [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
730 [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
732 /// Maps a DefId of a type to a list of its inherent impls.
733 /// Contains implementations of methods that are inherent to a type.
734 /// Methods in these implementations don't need to be exported.
735 [] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
737 /// Set of all the def-ids in this crate that have MIR associated with
738 /// them. This includes all the body owners, but also things like struct
740 [] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
742 /// Maps DefId's that have an associated Mir to the result
743 /// of the MIR qualify_consts pass. The actual meaning of
744 /// the value isn't known except to the pass itself.
745 [] mir_const_qualif: Mir(DefId) -> u8,
747 /// Fetch the MIR for a given def-id up till the point where it is
748 /// ready for const evaluation.
750 /// See the README for the `mir` module for details.
751 [] mir_const: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
753 [] mir_validated: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
755 /// MIR after our optimization passes have run. This is MIR that is ready
756 /// for trans. This is also the only query that can fetch non-local MIR, at present.
757 [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
759 /// Records the type of each closure. The def ID is the ID of the
760 /// expression defining the closure.
761 [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
763 /// Records the type of each closure. The def ID is the ID of the
764 /// expression defining the closure.
765 [] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
767 /// Caches CoerceUnsized kinds for impls on custom types.
768 [] coerce_unsized_info: ItemSignature(DefId)
769 -> ty::adjustment::CoerceUnsizedInfo,
771 [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
773 [] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
775 [] has_typeck_tables: TypeckTables(DefId) -> bool,
777 [] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
779 [] borrowck: BorrowCheck(DefId) -> (),
781 /// Gets a complete map from all types to their inherent impls.
782 /// Not meant to be used directly outside of coherence.
783 /// (Defined only for LOCAL_CRATE)
784 [] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
786 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
787 /// Not meant to be used directly outside of coherence.
788 /// (Defined only for LOCAL_CRATE)
789 [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
791 /// Results of evaluating const items or constants embedded in
792 /// other items (such as enum variant explicit discriminants).
793 [] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
794 -> const_val::EvalResult<'tcx>,
796 /// Performs the privacy check and computes "access levels".
797 [] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
799 [] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
801 /// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
802 /// in the case of closures or "inline" expressions, this will be redirected to the enclosing
804 [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
806 [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
808 [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
809 [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
811 [] describe_def: DescribeDef(DefId) -> Option<Def>,
812 [] def_span: DefSpan(DefId) -> Span,
813 [] stability: Stability(DefId) -> Option<attr::Stability>,
814 [] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
815 [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
816 [] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
817 [] impl_parent: ImplParent(DefId) -> Option<DefId>,
818 [] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
819 [] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
820 [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
821 [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
822 [] is_mir_available: IsMirAvailable(DefId) -> bool,
825 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
826 DepNode::CoherenceCheckTrait(def_id)
829 fn crate_inherent_impls_dep_node(_: CrateNum) -> DepNode<DefId> {
833 fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
834 DepNode::Reachability
837 fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
841 fn symbol_name_dep_node(instance: ty::Instance) -> DepNode<DefId> {
842 // symbol_name uses the substs only to traverse them to find the
843 // hash, and that does not create any new dep-nodes.
844 DepNode::SymbolName(instance.def.def_id())
847 fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
848 DepNode::TypeckBodiesKrate
851 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
852 DepNode::ConstEval(def_id)
855 fn mir_keys(_: CrateNum) -> DepNode<DefId> {
859 fn crate_variances(_: CrateNum) -> DepNode<DefId> {
860 DepNode::CrateVariances