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, &format!("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::mir_shims<'tcx> {
271 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
272 format!("generating MIR shim for `{}`",
273 tcx.item_path_str(def.def_id()))
277 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
278 fn describe(_: TyCtxt, _: CrateNum) -> String {
279 format!("privacy access levels")
283 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
284 fn describe(_: TyCtxt, _: CrateNum) -> String {
285 format!("type-checking all item bodies")
289 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
290 fn describe(_: TyCtxt, _: CrateNum) -> String {
291 format!("reachability")
295 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
296 fn describe(tcx: TyCtxt, (def_id, _): (DefId, &'tcx Substs<'tcx>)) -> String {
297 format!("const-evaluating `{}`", tcx.item_path_str(def_id))
301 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
302 fn describe(_: TyCtxt, _: CrateNum) -> String {
303 format!("getting a list of all mir_keys")
307 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
308 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
309 format!("computing the symbol for `{}`", instance)
313 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
314 fn describe(_: TyCtxt, _: DefId) -> String {
319 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
320 fn describe(_: TyCtxt, _: DefId) -> String {
326 impl<'tcx> QueryDescription for queries::stability<'tcx> {
327 fn describe(_: TyCtxt, _: DefId) -> String {
332 impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
333 fn describe(_: TyCtxt, _: DefId) -> String {
338 impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
339 fn describe(_: TyCtxt, _: DefId) -> String {
344 impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
345 fn describe(_: TyCtxt, _: DefId) -> String {
350 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
351 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
352 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
356 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
357 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
358 format!("const checking if rvalue is promotable to static `{}`",
359 tcx.item_path_str(def_id))
363 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
364 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
365 format!("checking if item is mir available: `{}`",
366 tcx.item_path_str(def_id))
370 macro_rules! define_maps {
373 [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
376 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
379 impl<$tcx> Maps<$tcx> {
380 pub fn new(dep_graph: DepGraph,
381 providers: IndexVec<CrateNum, Providers<$tcx>>)
385 query_stack: RefCell::new(vec![]),
386 $($name: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
392 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
393 pub enum Query<$tcx> {
394 $($(#[$attr])* $name($K)),*
397 impl<$tcx> Query<$tcx> {
398 pub fn describe(&self, tcx: TyCtxt) -> String {
400 $(Query::$name(key) => queries::$name::describe(tcx, key)),*
406 use std::marker::PhantomData;
408 $(#[allow(bad_style)]
409 pub struct $name<$tcx> {
410 data: PhantomData<&$tcx ()>
414 $(impl<$tcx> DepTrackingMapConfig for queries::$name<$tcx> {
419 fn to_dep_node(key: &$K) -> DepNode<DefId> {
420 use dep_graph::DepNode::*;
425 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
426 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
430 -> Result<R, CycleError<'a, $tcx>>
431 where F: FnOnce(&$V) -> R
433 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
438 if let Some(result) = tcx.maps.$name.borrow().get(&key) {
439 return Ok(f(result));
442 // FIXME(eddyb) Get more valid Span's on queries.
443 // def_span guard is necesary to prevent a recursive loop,
444 // default_span calls def_span query internally.
445 if span == DUMMY_SP && stringify!($name) != "def_span" {
446 span = key.default_span(tcx)
449 let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key));
451 let result = tcx.cycle_check(span, Query::$name(key), || {
452 let provider = tcx.maps.providers[key.map_crate()].$name;
453 provider(tcx.global_tcx(), key)
456 Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result)))
459 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
460 -> Result<$V, CycleError<'a, $tcx>> {
461 Self::try_get_with(tcx, span, key, Clone::clone)
464 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
465 // FIXME(eddyb) Move away from using `DepTrackingMap`
466 // so we don't have to explicitly ignore a false edge:
467 // we can't observe a value dependency, only side-effects,
468 // through `force`, and once everything has been updated,
469 // perhaps only diagnostics, if those, will remain.
470 let _ignore = tcx.dep_graph.in_ignore();
471 match Self::try_get_with(tcx, span, key, |_| ()) {
473 Err(e) => tcx.report_cycle(e)
478 #[derive(Copy, Clone)]
479 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
480 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
484 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
485 type Target = TyCtxt<'a, 'gcx, 'tcx>;
486 fn deref(&self) -> &Self::Target {
491 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
492 /// Return a transparent wrapper for `TyCtxt` which uses
493 /// `span` as the location of queries performed through it.
494 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
502 pub fn $name(self, key: $K) -> $V {
503 self.at(DUMMY_SP).$name(key)
507 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
509 pub fn $name(self, key: $K) -> $V {
510 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
511 self.report_cycle(e);
512 Value::from_cycle_error(self.global_tcx())
517 define_provider_struct! {
519 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
523 impl<$tcx> Copy for Providers<$tcx> {}
524 impl<$tcx> Clone for Providers<$tcx> {
525 fn clone(&self) -> Self { *self }
530 macro_rules! define_map_struct {
533 input: $input:tt) => {
544 output: ($($output:tt)*)) => {
545 pub struct Maps<$tcx> {
546 providers: IndexVec<CrateNum, Providers<$tcx>>,
547 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
552 // Field recognized and ready to shift into the output
554 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
556 output: ($($output:tt)*)) => {
561 $(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>,)
565 // Detect things with the `pub` modifier
567 input: (([pub $($other_modifiers:tt)*] $attrs:tt $name:tt) $($input:tt)*),
568 output: $output:tt) => {
571 ready: ([pub] $attrs $name),
577 // No modifiers left? This is a private item.
579 input: (([] $attrs:tt $name:tt) $($input:tt)*),
580 output: $output:tt) => {
583 ready: ([pub] $attrs $name),
589 // Skip other modifiers
591 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
592 output: $output:tt) => {
595 input: (([$($modifiers)*] $($fields)*) $($input)*),
601 macro_rules! define_provider_struct {
603 (tcx: $tcx:tt, input: $input:tt) => {
604 define_provider_struct! {
614 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
615 pub struct Providers<$tcx> {
616 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
619 impl<$tcx> Default for Providers<$tcx> {
620 fn default() -> Self {
621 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
622 bug!("tcx.maps.{}({:?}) unsupported by its crate",
623 stringify!($name), key);
625 Providers { $($name),* }
630 // Something ready to shift:
632 ready: ($name:tt $K:tt $V:tt),
634 output: ($($output:tt)*)) => {
635 define_provider_struct! {
638 output: ($($output)* ($name $K $V))
642 // Regular queries produce a `V` only.
644 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
645 output: $output:tt) => {
646 define_provider_struct! {
648 ready: ($name $K $V),
656 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
657 output: $output:tt) => {
658 define_provider_struct! {
660 input: (([$($modifiers)*] $($fields)*) $($input)*),
666 // Each of these maps also corresponds to a method on a
667 // `Provider` trait for requesting a value of that type,
668 // and a method on `Maps` itself for doing that in a
669 // a way that memoizes and does dep-graph tracking,
670 // wrapping around the actual chain of providers that
671 // the driver creates (using several `rustc_*` crates).
672 define_maps! { <'tcx>
673 /// Records the type of every item.
674 [] type_of: ItemSignature(DefId) -> Ty<'tcx>,
676 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
677 /// associated generics and predicates.
678 [] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
679 [] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
681 /// Maps from the def-id of a trait to the list of
682 /// super-predicates. This is a subset of the full list of
683 /// predicates. We store these in a separate map because we must
684 /// evaluate them even during type conversion, often before the
685 /// full predicates are available (note that supertraits have
686 /// additional acyclicity requirements).
687 [] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
689 /// To avoid cycles within the predicates of a single item we compute
690 /// per-type-parameter predicates for resolving `T::AssocTy`.
691 [] type_param_predicates: TypeParamPredicates((DefId, DefId))
692 -> ty::GenericPredicates<'tcx>,
694 [] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
695 [] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
696 [] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
697 [] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
698 [] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
700 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
701 [] is_foreign_item: IsForeignItem(DefId) -> bool,
703 /// Maps from def-id of a type or region parameter to its
704 /// (inferred) variance.
705 [pub] variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
707 /// Maps from an impl/trait def-id to a list of the def-ids of its items
708 [] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
710 /// Maps from a trait item to the trait item "descriptor"
711 [] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
713 [] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
714 [] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
716 /// Maps a DefId of a type to a list of its inherent impls.
717 /// Contains implementations of methods that are inherent to a type.
718 /// Methods in these implementations don't need to be exported.
719 [] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
721 /// Set of all the def-ids in this crate that have MIR associated with
722 /// them. This includes all the body owners, but also things like struct
724 [] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
726 /// Maps DefId's that have an associated Mir to the result
727 /// of the MIR qualify_consts pass. The actual meaning of
728 /// the value isn't known except to the pass itself.
729 [] mir_const_qualif: Mir(DefId) -> u8,
731 /// Fetch the MIR for a given def-id up till the point where it is
732 /// ready for const evaluation.
734 /// See the README for the `mir` module for details.
735 [] mir_const: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
737 [] mir_validated: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
739 /// MIR after our optimization passes have run. This is MIR that is ready
740 /// for trans. This is also the only query that can fetch non-local MIR, at present.
741 [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
743 /// Records the type of each closure. The def ID is the ID of the
744 /// expression defining the closure.
745 [] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
747 /// Records the type of each closure. The def ID is the ID of the
748 /// expression defining the closure.
749 [] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
751 /// Caches CoerceUnsized kinds for impls on custom types.
752 [] coerce_unsized_info: ItemSignature(DefId)
753 -> ty::adjustment::CoerceUnsizedInfo,
755 [] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
757 [] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
759 [] has_typeck_tables: TypeckTables(DefId) -> bool,
761 [] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
763 [] borrowck: BorrowCheck(DefId) -> (),
765 /// Gets a complete map from all types to their inherent impls.
766 /// Not meant to be used directly outside of coherence.
767 /// (Defined only for LOCAL_CRATE)
768 [] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
770 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
771 /// Not meant to be used directly outside of coherence.
772 /// (Defined only for LOCAL_CRATE)
773 [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
775 /// Results of evaluating const items or constants embedded in
776 /// other items (such as enum variant explicit discriminants).
777 [] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
778 -> const_val::EvalResult<'tcx>,
780 /// Performs the privacy check and computes "access levels".
781 [] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
783 [] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
785 /// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
786 /// in the case of closures or "inline" expressions, this will be redirected to the enclosing
788 [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps<'tcx>>,
790 [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
792 [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
793 [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
795 [] describe_def: DescribeDef(DefId) -> Option<Def>,
796 [] def_span: DefSpan(DefId) -> Span,
797 [] stability: Stability(DefId) -> Option<attr::Stability>,
798 [] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
799 [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
800 [] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
801 [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
802 [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
803 [] is_mir_available: IsMirAvailable(DefId) -> bool,
806 fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
807 DepNode::CoherenceCheckTrait(def_id)
810 fn crate_inherent_impls_dep_node(_: CrateNum) -> DepNode<DefId> {
814 fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
815 DepNode::Reachability
818 fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
822 fn symbol_name_dep_node(instance: ty::Instance) -> DepNode<DefId> {
823 // symbol_name uses the substs only to traverse them to find the
824 // hash, and that does not create any new dep-nodes.
825 DepNode::SymbolName(instance.def.def_id())
828 fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
829 DepNode::TypeckBodiesKrate
832 fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
833 DepNode::ConstEval(def_id)
836 fn mir_keys(_: CrateNum) -> DepNode<DefId> {