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 traits::specialization_graph;
22 use ty::{self, CrateInherentImpls, Ty, TyCtxt};
25 use ty::subst::Substs;
26 use ty::fast_reject::SimplifiedType;
27 use util::nodemap::{DefIdSet, NodeSet};
29 use rustc_data_structures::indexed_vec::IndexVec;
30 use std::cell::{RefCell, RefMut};
34 use std::collections::BTreeMap;
37 use syntax_pos::{Span, DUMMY_SP};
40 use syntax::symbol::Symbol;
42 pub trait Key: Clone + Hash + Eq + Debug {
43 fn map_crate(&self) -> CrateNum;
44 fn default_span(&self, tcx: TyCtxt) -> Span;
47 impl<'tcx> Key for ty::InstanceDef<'tcx> {
48 fn map_crate(&self) -> CrateNum {
52 fn default_span(&self, tcx: TyCtxt) -> Span {
53 tcx.def_span(self.def_id())
57 impl<'tcx> Key for ty::Instance<'tcx> {
58 fn map_crate(&self) -> CrateNum {
62 fn default_span(&self, tcx: TyCtxt) -> Span {
63 tcx.def_span(self.def_id())
67 impl Key for CrateNum {
68 fn map_crate(&self) -> CrateNum {
71 fn default_span(&self, _: TyCtxt) -> Span {
77 fn map_crate(&self) -> CrateNum {
80 fn default_span(&self, tcx: TyCtxt) -> Span {
85 impl Key for (DefId, DefId) {
86 fn map_crate(&self) -> CrateNum {
89 fn default_span(&self, tcx: TyCtxt) -> Span {
90 self.1.default_span(tcx)
94 impl Key for (CrateNum, DefId) {
95 fn map_crate(&self) -> CrateNum {
98 fn default_span(&self, tcx: TyCtxt) -> Span {
99 self.1.default_span(tcx)
103 impl Key for (DefId, SimplifiedType) {
104 fn map_crate(&self) -> CrateNum {
107 fn default_span(&self, tcx: TyCtxt) -> Span {
108 self.0.default_span(tcx)
112 impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
113 fn map_crate(&self) -> CrateNum {
116 fn default_span(&self, tcx: TyCtxt) -> Span {
117 self.0.default_span(tcx)
121 impl Key for (MirSuite, DefId) {
122 fn map_crate(&self) -> CrateNum {
125 fn default_span(&self, tcx: TyCtxt) -> Span {
126 self.1.default_span(tcx)
130 impl Key for (MirSuite, MirPassIndex, DefId) {
131 fn map_crate(&self) -> CrateNum {
134 fn default_span(&self, tcx: TyCtxt) -> Span {
135 self.2.default_span(tcx)
139 trait Value<'tcx>: Sized {
140 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self;
143 impl<'tcx, T> Value<'tcx> for T {
144 default fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> T {
145 tcx.sess.abort_if_errors();
146 bug!("Value::from_cycle_error called without errors");
150 impl<'tcx, T: Default> Value<'tcx> for T {
151 default fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> T {
156 impl<'tcx> Value<'tcx> for Ty<'tcx> {
157 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
162 impl<'tcx> Value<'tcx> for ty::DtorckConstraint<'tcx> {
163 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
168 impl<'tcx> Value<'tcx> for ty::SymbolName {
169 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
170 ty::SymbolName { name: Symbol::intern("<error>").as_str() }
174 pub struct CycleError<'a, 'tcx: 'a> {
176 cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
179 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
180 pub fn report_cycle(self, CycleError { span, cycle }: CycleError) {
181 // Subtle: release the refcell lock before invoking `describe()`
182 // below by dropping `cycle`.
183 let stack = cycle.to_vec();
186 assert!(!stack.is_empty());
188 // Disable naming impls with types in this path, since that
189 // sometimes cycles itself, leading to extra cycle errors.
190 // (And cycle errors around impls tend to occur during the
191 // collect/coherence phases anyhow.)
192 item_path::with_forced_impl_filename_line(|| {
194 struct_span_err!(self.sess, span, E0391,
195 "unsupported cyclic reference between types/traits detected");
196 err.span_label(span, "cyclic reference");
198 err.span_note(stack[0].0, &format!("the cycle begins when {}...",
199 stack[0].1.describe(self)));
201 for &(span, ref query) in &stack[1..] {
202 err.span_note(span, &format!("...which then requires {}...",
203 query.describe(self)));
206 err.note(&format!("...which then again requires {}, completing the cycle.",
207 stack[0].1.describe(self)));
213 fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
214 -> Result<R, CycleError<'a, 'gcx>>
215 where F: FnOnce() -> R
218 let mut stack = self.maps.query_stack.borrow_mut();
219 if let Some((i, _)) = stack.iter().enumerate().rev()
220 .find(|&(_, &(_, ref q))| *q == query) {
221 return Err(CycleError {
223 cycle: RefMut::map(stack, |stack| &mut stack[i..])
226 stack.push((span, query));
229 let result = compute();
231 self.maps.query_stack.borrow_mut().pop();
237 trait QueryDescription: DepTrackingMapConfig {
238 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
241 impl<M: DepTrackingMapConfig<Key=DefId>> QueryDescription for M {
242 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
243 format!("processing `{}`", tcx.item_path_str(def_id))
247 impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
248 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
249 format!("computing the supertraits of `{}`",
250 tcx.item_path_str(def_id))
254 impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
255 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
256 let id = tcx.hir.as_local_node_id(def_id).unwrap();
257 format!("computing the bounds for type parameter `{}`",
258 tcx.hir.ty_param_name(id))
262 impl<'tcx> QueryDescription for queries::coherent_trait<'tcx> {
263 fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
264 format!("coherence checking all impls of trait `{}`",
265 tcx.item_path_str(def_id))
269 impl<'tcx> QueryDescription for queries::crate_inherent_impls<'tcx> {
270 fn describe(_: TyCtxt, k: CrateNum) -> String {
271 format!("all inherent impls defined in crate `{:?}`", k)
275 impl<'tcx> QueryDescription for queries::crate_inherent_impls_overlap_check<'tcx> {
276 fn describe(_: TyCtxt, _: CrateNum) -> String {
277 format!("check for overlap between inherent impls defined in this crate")
281 impl<'tcx> QueryDescription for queries::crate_variances<'tcx> {
282 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
283 format!("computing the variances for items in this crate")
287 impl<'tcx> QueryDescription for queries::mir_shims<'tcx> {
288 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
289 format!("generating MIR shim for `{}`",
290 tcx.item_path_str(def.def_id()))
294 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
295 fn describe(_: TyCtxt, _: CrateNum) -> String {
296 format!("privacy access levels")
300 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
301 fn describe(_: TyCtxt, _: CrateNum) -> String {
302 format!("type-checking all item bodies")
306 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
307 fn describe(_: TyCtxt, _: CrateNum) -> String {
308 format!("reachability")
312 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
313 fn describe(tcx: TyCtxt, (def_id, _): (DefId, &'tcx Substs<'tcx>)) -> String {
314 format!("const-evaluating `{}`", tcx.item_path_str(def_id))
318 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
319 fn describe(_: TyCtxt, _: CrateNum) -> String {
320 format!("getting a list of all mir_keys")
324 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
325 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
326 format!("computing the symbol for `{}`", instance)
330 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
331 fn describe(_: TyCtxt, _: DefId) -> String {
336 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
337 fn describe(_: TyCtxt, _: DefId) -> String {
343 impl<'tcx> QueryDescription for queries::stability<'tcx> {
344 fn describe(_: TyCtxt, _: DefId) -> String {
349 impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
350 fn describe(_: TyCtxt, _: DefId) -> String {
355 impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
356 fn describe(_: TyCtxt, _: DefId) -> String {
361 impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
362 fn describe(_: TyCtxt, _: DefId) -> String {
363 bug!("is_exported_symbol")
367 impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
368 fn describe(_: TyCtxt, _: DefId) -> String {
373 impl<'tcx> QueryDescription for queries::impl_parent<'tcx> {
374 fn describe(_: TyCtxt, _: DefId) -> String {
379 impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> {
380 fn describe(_: TyCtxt, _: DefId) -> String {
381 bug!("trait_of_item")
385 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
386 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
387 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
391 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
392 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
393 format!("const checking if rvalue is promotable to static `{}`",
394 tcx.item_path_str(def_id))
398 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
399 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
400 format!("checking if item is mir available: `{}`",
401 tcx.item_path_str(def_id))
405 impl<'tcx> QueryDescription for queries::trait_impls_of<'tcx> {
406 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
407 format!("trait impls of `{}`", tcx.item_path_str(def_id))
411 impl<'tcx> QueryDescription for queries::relevant_trait_impls_for<'tcx> {
412 fn describe(tcx: TyCtxt, (def_id, ty): (DefId, SimplifiedType)) -> String {
413 format!("relevant impls for: `({}, {:?})`", tcx.item_path_str(def_id), ty)
417 impl<'tcx> QueryDescription for queries::is_object_safe<'tcx> {
418 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
419 format!("determine object safety of trait `{}`", tcx.item_path_str(def_id))
423 macro_rules! define_maps {
426 [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
429 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
432 impl<$tcx> Maps<$tcx> {
433 pub fn new(dep_graph: DepGraph,
434 providers: IndexVec<CrateNum, Providers<$tcx>>)
438 query_stack: RefCell::new(vec![]),
439 $($name: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
445 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
446 pub enum Query<$tcx> {
447 $($(#[$attr])* $name($K)),*
450 impl<$tcx> Query<$tcx> {
451 pub fn describe(&self, tcx: TyCtxt) -> String {
453 $(Query::$name(key) => queries::$name::describe(tcx, key)),*
459 use std::marker::PhantomData;
461 $(#[allow(bad_style)]
462 pub struct $name<$tcx> {
463 data: PhantomData<&$tcx ()>
467 $(impl<$tcx> DepTrackingMapConfig for queries::$name<$tcx> {
472 fn to_dep_node(key: &$K) -> DepNode<DefId> {
473 use dep_graph::DepNode::*;
478 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
479 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
483 -> Result<R, CycleError<'a, $tcx>>
484 where F: FnOnce(&$V) -> R
486 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
491 if let Some(result) = tcx.maps.$name.borrow().get(&key) {
492 return Ok(f(result));
495 // FIXME(eddyb) Get more valid Span's on queries.
496 // def_span guard is necesary to prevent a recursive loop,
497 // default_span calls def_span query internally.
498 if span == DUMMY_SP && stringify!($name) != "def_span" {
499 span = key.default_span(tcx)
502 let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key));
504 let result = tcx.cycle_check(span, Query::$name(key), || {
505 let provider = tcx.maps.providers[key.map_crate()].$name;
506 provider(tcx.global_tcx(), key)
509 Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result)))
512 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
513 -> Result<$V, CycleError<'a, $tcx>> {
514 Self::try_get_with(tcx, span, key, Clone::clone)
517 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
518 // FIXME(eddyb) Move away from using `DepTrackingMap`
519 // so we don't have to explicitly ignore a false edge:
520 // we can't observe a value dependency, only side-effects,
521 // through `force`, and once everything has been updated,
522 // perhaps only diagnostics, if those, will remain.
523 let _ignore = tcx.dep_graph.in_ignore();
524 match Self::try_get_with(tcx, span, key, |_| ()) {
526 Err(e) => tcx.report_cycle(e)
531 #[derive(Copy, Clone)]
532 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
533 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
537 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
538 type Target = TyCtxt<'a, 'gcx, 'tcx>;
539 fn deref(&self) -> &Self::Target {
544 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
545 /// Return a transparent wrapper for `TyCtxt` which uses
546 /// `span` as the location of queries performed through it.
547 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
555 pub fn $name(self, key: $K) -> $V {
556 self.at(DUMMY_SP).$name(key)
560 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
562 pub fn $name(self, key: $K) -> $V {
563 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
564 self.report_cycle(e);
565 Value::from_cycle_error(self.global_tcx())
570 define_provider_struct! {
572 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
576 impl<$tcx> Copy for Providers<$tcx> {}
577 impl<$tcx> Clone for Providers<$tcx> {
578 fn clone(&self) -> Self { *self }
583 macro_rules! define_map_struct {
586 input: $input:tt) => {
597 output: ($($output:tt)*)) => {
598 pub struct Maps<$tcx> {
599 providers: IndexVec<CrateNum, Providers<$tcx>>,
600 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
605 // Field recognized and ready to shift into the output
607 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
609 output: ($($output:tt)*)) => {
614 $(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>,)
618 // No modifiers left? This is a private item.
620 input: (([] $attrs:tt $name:tt) $($input:tt)*),
621 output: $output:tt) => {
624 ready: ([] $attrs $name),
630 // Skip other modifiers
632 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
633 output: $output:tt) => {
636 input: (([$($modifiers)*] $($fields)*) $($input)*),
642 macro_rules! define_provider_struct {
644 (tcx: $tcx:tt, input: $input:tt) => {
645 define_provider_struct! {
655 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
656 pub struct Providers<$tcx> {
657 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
660 impl<$tcx> Default for Providers<$tcx> {
661 fn default() -> Self {
662 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
663 bug!("tcx.maps.{}({:?}) unsupported by its crate",
664 stringify!($name), key);
666 Providers { $($name),* }
671 // Something ready to shift:
673 ready: ($name:tt $K:tt $V:tt),
675 output: ($($output:tt)*)) => {
676 define_provider_struct! {
679 output: ($($output)* ($name $K $V))
683 // Regular queries produce a `V` only.
685 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
686 output: $output:tt) => {
687 define_provider_struct! {
689 ready: ($name $K $V),
697 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
698 output: $output:tt) => {
699 define_provider_struct! {
701 input: (([$($modifiers)*] $($fields)*) $($input)*),
707 // Each of these maps also corresponds to a method on a
708 // `Provider` trait for requesting a value of that type,
709 // and a method on `Maps` itself for doing that in a
710 // a way that memoizes and does dep-graph tracking,
711 // wrapping around the actual chain of providers that
712 // the driver creates (using several `rustc_*` crates).
713 define_maps! { <'tcx>
714 /// Records the type of every item.
715 [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
717 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
718 /// associated generics and predicates.
719 [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
720 [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
722 /// Maps from the def-id of a trait to the list of
723 /// super-predicates. This is a subset of the full list of
724 /// predicates. We store these in a separate map because we must
725 /// evaluate them even during type conversion, often before the
726 /// full predicates are available (note that supertraits have
727 /// additional acyclicity requirements).
728 [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
730 /// To avoid cycles within the predicates of a single item we compute
731 /// per-type-parameter predicates for resolving `T::AssocTy`.
732 [] type_param_predicates: TypeParamPredicates((DefId, DefId))
733 -> ty::GenericPredicates<'tcx>,
735 [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
736 [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
737 [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
738 [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
739 [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
741 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
742 [] is_foreign_item: IsForeignItem(DefId) -> bool,
744 /// Get a map with the variance of every item; use `item_variance`
746 [] crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
748 /// Maps from def-id of a type or region parameter to its
749 /// (inferred) variance.
750 [] variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
752 /// Maps from an impl/trait def-id to a list of the def-ids of its items
753 [] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
755 /// Maps from a trait item to the trait item "descriptor"
756 [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
758 [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
759 [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
761 /// Maps a DefId of a type to a list of its inherent impls.
762 /// Contains implementations of methods that are inherent to a type.
763 /// Methods in these implementations don't need to be exported.
764 [] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
766 /// Set of all the def-ids in this crate that have MIR associated with
767 /// them. This includes all the body owners, but also things like struct
769 [] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
771 /// Maps DefId's that have an associated Mir to the result
772 /// of the MIR qualify_consts pass. The actual meaning of
773 /// the value isn't known except to the pass itself.
774 [] mir_const_qualif: Mir(DefId) -> u8,
776 /// Fetch the MIR for a given def-id up till the point where it is
777 /// ready for const evaluation.
779 /// See the README for the `mir` module for details.
780 [] mir_const: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
782 [] mir_validated: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
784 /// MIR after our optimization passes have run. This is MIR that is ready
785 /// for trans. This is also the only query that can fetch non-local MIR, at present.
786 [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
788 /// Records the type of each closure. The def ID is the ID of the
789 /// expression defining the closure.
790 [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
792 /// Records the type of each closure. The def ID is the ID of the
793 /// expression defining the closure.
794 [] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
796 /// Caches CoerceUnsized kinds for impls on custom types.
797 [] coerce_unsized_info: ItemSignature(DefId)
798 -> ty::adjustment::CoerceUnsizedInfo,
800 [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
802 [] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
804 [] has_typeck_tables: TypeckTables(DefId) -> bool,
806 [] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
808 [] borrowck: BorrowCheck(DefId) -> (),
810 /// Gets a complete map from all types to their inherent impls.
811 /// Not meant to be used directly outside of coherence.
812 /// (Defined only for LOCAL_CRATE)
813 [] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
815 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
816 /// Not meant to be used directly outside of coherence.
817 /// (Defined only for LOCAL_CRATE)
818 [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
820 /// Results of evaluating const items or constants embedded in
821 /// other items (such as enum variant explicit discriminants).
822 [] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
823 -> const_val::EvalResult<'tcx>,
825 /// Performs the privacy check and computes "access levels".
826 [] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
828 [] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
830 /// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
831 /// in the case of closures or "inline" expressions, this will be redirected to the enclosing
833 [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
835 [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
837 [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
838 [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
840 [] describe_def: DescribeDef(DefId) -> Option<Def>,
841 [] def_span: DefSpan(DefId) -> Span,
842 [] stability: Stability(DefId) -> Option<attr::Stability>,
843 [] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
844 [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
845 [] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
846 [] impl_parent: ImplParent(DefId) -> Option<DefId>,
847 [] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
848 [] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
849 [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
850 [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
851 [] is_mir_available: IsMirAvailable(DefId) -> bool,
853 [] trait_impls_of: TraitImpls(DefId) -> ty::trait_def::TraitImpls,
854 // Note that TraitDef::for_each_relevant_impl() will do type simplication for you.
855 [] relevant_trait_impls_for: relevant_trait_impls_for((DefId, SimplifiedType))
856 -> ty::trait_def::TraitImpls,
857 [] specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
858 [] is_object_safe: ObjectSafety(DefId) -> bool,
861 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
862 DepNode::CoherenceCheckTrait(def_id)
865 fn crate_inherent_impls_dep_node(_: CrateNum) -> DepNode<DefId> {
869 fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
870 DepNode::Reachability
873 fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
877 fn symbol_name_dep_node(instance: ty::Instance) -> DepNode<DefId> {
878 // symbol_name uses the substs only to traverse them to find the
879 // hash, and that does not create any new dep-nodes.
880 DepNode::SymbolName(instance.def.def_id())
883 fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
884 DepNode::TypeckBodiesKrate
887 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
888 DepNode::ConstEval(def_id)
891 fn mir_keys(_: CrateNum) -> DepNode<DefId> {
895 fn crate_variances(_: CrateNum) -> DepNode<DefId> {
896 DepNode::CrateVariances
899 fn relevant_trait_impls_for((def_id, _): (DefId, SimplifiedType)) -> DepNode<DefId> {
900 DepNode::TraitImpls(def_id)