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::{DepConstructor, DepNode, DepNodeIndex};
12 use errors::{Diagnostic, DiagnosticBuilder};
13 use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex};
14 use hir::def::{Def, Export};
15 use hir::{self, TraitCandidate, ItemLocalId};
18 use middle::const_val;
19 use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary};
20 use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
21 use middle::privacy::AccessLevels;
23 use middle::resolve_lifetime::{Region, ObjectLifetimeDefault};
24 use middle::stability::{self, DeprecationEntry};
25 use middle::lang_items::{LanguageItems, LangItem};
27 use mir::transform::{MirSuite, MirPassIndex};
28 use session::CompileResult;
29 use traits::specialization_graph;
30 use ty::{self, CrateInherentImpls, Ty, TyCtxt};
31 use ty::layout::{Layout, LayoutError};
34 use ty::subst::Substs;
35 use ty::fast_reject::SimplifiedType;
36 use util::nodemap::{DefIdSet, NodeSet, DefIdMap};
37 use util::common::{profq_msg, ProfileQueriesMsg};
39 use rustc_data_structures::indexed_set::IdxSetBuf;
40 use rustc_back::PanicStrategy;
41 use rustc_data_structures::indexed_vec::IndexVec;
42 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
43 use std::cell::{RefCell, RefMut, Cell};
46 use std::marker::PhantomData;
48 use std::collections::BTreeMap;
51 use syntax_pos::{Span, DUMMY_SP};
54 use syntax::symbol::Symbol;
56 pub trait Key: Clone + Hash + Eq + Debug {
57 fn map_crate(&self) -> CrateNum;
58 fn default_span(&self, tcx: TyCtxt) -> Span;
61 impl<'tcx> Key for ty::InstanceDef<'tcx> {
62 fn map_crate(&self) -> CrateNum {
66 fn default_span(&self, tcx: TyCtxt) -> Span {
67 tcx.def_span(self.def_id())
71 impl<'tcx> Key for ty::Instance<'tcx> {
72 fn map_crate(&self) -> CrateNum {
76 fn default_span(&self, tcx: TyCtxt) -> Span {
77 tcx.def_span(self.def_id())
81 impl Key for CrateNum {
82 fn map_crate(&self) -> CrateNum {
85 fn default_span(&self, _: TyCtxt) -> Span {
90 impl Key for DefIndex {
91 fn map_crate(&self) -> CrateNum {
94 fn default_span(&self, _tcx: TyCtxt) -> Span {
100 fn map_crate(&self) -> CrateNum {
103 fn default_span(&self, tcx: TyCtxt) -> Span {
108 impl Key for (DefId, 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 (CrateNum, DefId) {
118 fn map_crate(&self) -> CrateNum {
121 fn default_span(&self, tcx: TyCtxt) -> Span {
122 self.1.default_span(tcx)
126 impl Key for (DefId, SimplifiedType) {
127 fn map_crate(&self) -> CrateNum {
130 fn default_span(&self, tcx: TyCtxt) -> Span {
131 self.0.default_span(tcx)
135 impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
136 fn map_crate(&self) -> CrateNum {
139 fn default_span(&self, tcx: TyCtxt) -> Span {
140 self.0.default_span(tcx)
144 impl Key for (MirSuite, DefId) {
145 fn map_crate(&self) -> CrateNum {
148 fn default_span(&self, tcx: TyCtxt) -> Span {
149 self.1.default_span(tcx)
153 impl Key for (MirSuite, MirPassIndex, DefId) {
154 fn map_crate(&self) -> CrateNum {
157 fn default_span(&self, tcx: TyCtxt) -> Span {
158 self.2.default_span(tcx)
162 impl<'tcx> Key for Ty<'tcx> {
163 fn map_crate(&self) -> CrateNum {
166 fn default_span(&self, _: TyCtxt) -> Span {
171 impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
172 fn map_crate(&self) -> CrateNum {
173 self.value.map_crate()
175 fn default_span(&self, tcx: TyCtxt) -> Span {
176 self.value.default_span(tcx)
180 trait Value<'tcx>: Sized {
181 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self;
184 impl<'tcx, T> Value<'tcx> for T {
185 default fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> T {
186 tcx.sess.abort_if_errors();
187 bug!("Value::from_cycle_error called without errors");
191 impl<'tcx, T: Default> Value<'tcx> for T {
192 default fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> T {
197 impl<'tcx> Value<'tcx> for Ty<'tcx> {
198 fn from_cycle_error<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
203 impl<'tcx> Value<'tcx> for ty::DtorckConstraint<'tcx> {
204 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
209 impl<'tcx> Value<'tcx> for ty::SymbolName {
210 fn from_cycle_error<'a>(_: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
211 ty::SymbolName { name: Symbol::intern("<error>").as_str() }
215 struct QueryMap<D: QueryDescription> {
216 phantom: PhantomData<D>,
217 map: FxHashMap<D::Key, QueryValue<D::Value>>,
220 struct QueryValue<T> {
223 diagnostics: Option<Box<QueryDiagnostics>>,
226 struct QueryDiagnostics {
227 diagnostics: Vec<Diagnostic>,
228 emitted_diagnostics: Cell<bool>,
231 impl<M: QueryDescription> QueryMap<M> {
232 fn new() -> QueryMap<M> {
234 phantom: PhantomData,
240 struct CycleError<'a, 'tcx: 'a> {
242 cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
245 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
246 fn report_cycle(self, CycleError { span, cycle }: CycleError)
247 -> DiagnosticBuilder<'a>
249 // Subtle: release the refcell lock before invoking `describe()`
250 // below by dropping `cycle`.
251 let stack = cycle.to_vec();
254 assert!(!stack.is_empty());
256 // Disable naming impls with types in this path, since that
257 // sometimes cycles itself, leading to extra cycle errors.
258 // (And cycle errors around impls tend to occur during the
259 // collect/coherence phases anyhow.)
260 item_path::with_forced_impl_filename_line(|| {
262 struct_span_err!(self.sess, span, E0391,
263 "unsupported cyclic reference between types/traits detected");
264 err.span_label(span, "cyclic reference");
266 err.span_note(stack[0].0, &format!("the cycle begins when {}...",
267 stack[0].1.describe(self)));
269 for &(span, ref query) in &stack[1..] {
270 err.span_note(span, &format!("...which then requires {}...",
271 query.describe(self)));
274 err.note(&format!("...which then again requires {}, completing the cycle.",
275 stack[0].1.describe(self)));
281 fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
282 -> Result<R, CycleError<'a, 'gcx>>
283 where F: FnOnce() -> R
286 let mut stack = self.maps.query_stack.borrow_mut();
287 if let Some((i, _)) = stack.iter().enumerate().rev()
288 .find(|&(_, &(_, ref q))| *q == query) {
289 return Err(CycleError {
291 cycle: RefMut::map(stack, |stack| &mut stack[i..])
294 stack.push((span, query));
297 let result = compute();
299 self.maps.query_stack.borrow_mut().pop();
305 pub trait QueryConfig {
306 type Key: Eq + Hash + Clone;
310 trait QueryDescription: QueryConfig {
311 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
314 impl<M: QueryConfig<Key=DefId>> QueryDescription for M {
315 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
316 format!("processing `{}`", tcx.item_path_str(def_id))
320 impl<'tcx> QueryDescription for queries::is_copy_raw<'tcx> {
321 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
322 format!("computing whether `{}` is `Copy`", env.value)
326 impl<'tcx> QueryDescription for queries::is_sized_raw<'tcx> {
327 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
328 format!("computing whether `{}` is `Sized`", env.value)
332 impl<'tcx> QueryDescription for queries::is_freeze_raw<'tcx> {
333 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
334 format!("computing whether `{}` is freeze", env.value)
338 impl<'tcx> QueryDescription for queries::needs_drop_raw<'tcx> {
339 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
340 format!("computing whether `{}` needs drop", env.value)
344 impl<'tcx> QueryDescription for queries::layout_raw<'tcx> {
345 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
346 format!("computing layout of `{}`", env.value)
350 impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
351 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
352 format!("computing the supertraits of `{}`",
353 tcx.item_path_str(def_id))
357 impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
358 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
359 let id = tcx.hir.as_local_node_id(def_id).unwrap();
360 format!("computing the bounds for type parameter `{}`",
361 tcx.hir.ty_param_name(id))
365 impl<'tcx> QueryDescription for queries::coherent_trait<'tcx> {
366 fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
367 format!("coherence checking all impls of trait `{}`",
368 tcx.item_path_str(def_id))
372 impl<'tcx> QueryDescription for queries::crate_inherent_impls<'tcx> {
373 fn describe(_: TyCtxt, k: CrateNum) -> String {
374 format!("all inherent impls defined in crate `{:?}`", k)
378 impl<'tcx> QueryDescription for queries::crate_inherent_impls_overlap_check<'tcx> {
379 fn describe(_: TyCtxt, _: CrateNum) -> String {
380 format!("check for overlap between inherent impls defined in this crate")
384 impl<'tcx> QueryDescription for queries::crate_variances<'tcx> {
385 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
386 format!("computing the variances for items in this crate")
390 impl<'tcx> QueryDescription for queries::mir_shims<'tcx> {
391 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
392 format!("generating MIR shim for `{}`",
393 tcx.item_path_str(def.def_id()))
397 impl<'tcx> QueryDescription for queries::privacy_access_levels<'tcx> {
398 fn describe(_: TyCtxt, _: CrateNum) -> String {
399 format!("privacy access levels")
403 impl<'tcx> QueryDescription for queries::typeck_item_bodies<'tcx> {
404 fn describe(_: TyCtxt, _: CrateNum) -> String {
405 format!("type-checking all item bodies")
409 impl<'tcx> QueryDescription for queries::reachable_set<'tcx> {
410 fn describe(_: TyCtxt, _: CrateNum) -> String {
411 format!("reachability")
415 impl<'tcx> QueryDescription for queries::const_eval<'tcx> {
416 fn describe(tcx: TyCtxt, key: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>) -> String {
417 format!("const-evaluating `{}`", tcx.item_path_str(key.value.0))
421 impl<'tcx> QueryDescription for queries::mir_keys<'tcx> {
422 fn describe(_: TyCtxt, _: CrateNum) -> String {
423 format!("getting a list of all mir_keys")
427 impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
428 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
429 format!("computing the symbol for `{}`", instance)
433 impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
434 fn describe(_: TyCtxt, _: DefId) -> String {
439 impl<'tcx> QueryDescription for queries::def_span<'tcx> {
440 fn describe(_: TyCtxt, _: DefId) -> String {
446 impl<'tcx> QueryDescription for queries::lookup_stability<'tcx> {
447 fn describe(_: TyCtxt, _: DefId) -> String {
452 impl<'tcx> QueryDescription for queries::lookup_deprecation_entry<'tcx> {
453 fn describe(_: TyCtxt, _: DefId) -> String {
458 impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
459 fn describe(_: TyCtxt, _: DefId) -> String {
464 impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
465 fn describe(_: TyCtxt, _: DefId) -> String {
466 bug!("is_exported_symbol")
470 impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
471 fn describe(_: TyCtxt, _: DefId) -> String {
476 impl<'tcx> QueryDescription for queries::impl_parent<'tcx> {
477 fn describe(_: TyCtxt, _: DefId) -> String {
482 impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> {
483 fn describe(_: TyCtxt, _: DefId) -> String {
484 bug!("trait_of_item")
488 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
489 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
490 format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
494 impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
495 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
496 format!("const checking if rvalue is promotable to static `{}`",
497 tcx.item_path_str(def_id))
501 impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
502 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
503 format!("checking if item is mir available: `{}`",
504 tcx.item_path_str(def_id))
508 impl<'tcx> QueryDescription for queries::trait_impls_of<'tcx> {
509 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
510 format!("trait impls of `{}`", tcx.item_path_str(def_id))
514 impl<'tcx> QueryDescription for queries::is_object_safe<'tcx> {
515 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
516 format!("determine object safety of trait `{}`", tcx.item_path_str(def_id))
520 impl<'tcx> QueryDescription for queries::is_const_fn<'tcx> {
521 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
522 format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id))
526 impl<'tcx> QueryDescription for queries::dylib_dependency_formats<'tcx> {
527 fn describe(_: TyCtxt, _: CrateNum) -> String {
528 "dylib dependency formats of crate".to_string()
532 impl<'tcx> QueryDescription for queries::is_panic_runtime<'tcx> {
533 fn describe(_: TyCtxt, _: CrateNum) -> String {
534 "checking if the crate is_panic_runtime".to_string()
538 impl<'tcx> QueryDescription for queries::is_compiler_builtins<'tcx> {
539 fn describe(_: TyCtxt, _: CrateNum) -> String {
540 "checking if the crate is_compiler_builtins".to_string()
544 impl<'tcx> QueryDescription for queries::has_global_allocator<'tcx> {
545 fn describe(_: TyCtxt, _: CrateNum) -> String {
546 "checking if the crate has_global_allocator".to_string()
550 impl<'tcx> QueryDescription for queries::extern_crate<'tcx> {
551 fn describe(_: TyCtxt, _: DefId) -> String {
552 "getting crate's ExternCrateData".to_string()
556 impl<'tcx> QueryDescription for queries::lint_levels<'tcx> {
557 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
558 format!("computing the lint levels for items in this crate")
562 impl<'tcx> QueryDescription for queries::specializes<'tcx> {
563 fn describe(_tcx: TyCtxt, _: (DefId, DefId)) -> String {
564 format!("computing whether impls specialize one another")
568 impl<'tcx> QueryDescription for queries::in_scope_traits_map<'tcx> {
569 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
570 format!("traits in scope at a block")
574 impl<'tcx> QueryDescription for queries::is_no_builtins<'tcx> {
575 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
576 format!("test whether a crate has #![no_builtins]")
580 impl<'tcx> QueryDescription for queries::panic_strategy<'tcx> {
581 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
582 format!("query a crate's configured panic strategy")
586 impl<'tcx> QueryDescription for queries::is_profiler_runtime<'tcx> {
587 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
588 format!("query a crate is #![profiler_runtime]")
592 impl<'tcx> QueryDescription for queries::is_sanitizer_runtime<'tcx> {
593 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
594 format!("query a crate is #![sanitizer_runtime]")
598 impl<'tcx> QueryDescription for queries::exported_symbols<'tcx> {
599 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
600 format!("looking up the exported symbols of a crate")
604 impl<'tcx> QueryDescription for queries::native_libraries<'tcx> {
605 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
606 format!("looking up the native libraries of a linked crate")
610 impl<'tcx> QueryDescription for queries::plugin_registrar_fn<'tcx> {
611 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
612 format!("looking up the plugin registrar for a crate")
616 impl<'tcx> QueryDescription for queries::derive_registrar_fn<'tcx> {
617 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
618 format!("looking up the derive registrar for a crate")
622 impl<'tcx> QueryDescription for queries::crate_disambiguator<'tcx> {
623 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
624 format!("looking up the disambiguator a crate")
628 impl<'tcx> QueryDescription for queries::crate_hash<'tcx> {
629 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
630 format!("looking up the hash a crate")
634 impl<'tcx> QueryDescription for queries::original_crate_name<'tcx> {
635 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
636 format!("looking up the original name a crate")
640 impl<'tcx> QueryDescription for queries::implementations_of_trait<'tcx> {
641 fn describe(_tcx: TyCtxt, _: (CrateNum, DefId)) -> String {
642 format!("looking up implementations of a trait in a crate")
646 impl<'tcx> QueryDescription for queries::all_trait_implementations<'tcx> {
647 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
648 format!("looking up all (?) trait implementations")
652 impl<'tcx> QueryDescription for queries::link_args<'tcx> {
653 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
654 format!("looking up link arguments for a crate")
658 impl<'tcx> QueryDescription for queries::named_region_map<'tcx> {
659 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
660 format!("looking up a named region")
664 impl<'tcx> QueryDescription for queries::is_late_bound_map<'tcx> {
665 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
666 format!("testing if a region is late boudn")
670 impl<'tcx> QueryDescription for queries::object_lifetime_defaults_map<'tcx> {
671 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
672 format!("looking up lifetime defaults for a region")
676 impl<'tcx> QueryDescription for queries::dep_kind<'tcx> {
677 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
678 format!("fetching what a dependency looks like")
682 impl<'tcx> QueryDescription for queries::crate_name<'tcx> {
683 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
684 format!("fetching what a crate is named")
688 impl<'tcx> QueryDescription for queries::get_lang_items<'tcx> {
689 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
690 format!("calculating the lang items map")
694 impl<'tcx> QueryDescription for queries::defined_lang_items<'tcx> {
695 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
696 format!("calculating the lang items defined in a crate")
700 impl<'tcx> QueryDescription for queries::missing_lang_items<'tcx> {
701 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
702 format!("calculating the missing lang items in a crate")
706 impl<'tcx> QueryDescription for queries::visible_parent_map<'tcx> {
707 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
708 format!("calculating the visible parent map")
712 impl<'tcx> QueryDescription for queries::missing_extern_crate_item<'tcx> {
713 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
714 format!("seeing if we're missing an `extern crate` item for this crate")
718 impl<'tcx> QueryDescription for queries::used_crate_source<'tcx> {
719 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
720 format!("looking at the source for a crate")
724 impl<'tcx> QueryDescription for queries::postorder_cnums<'tcx> {
725 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
726 format!("generating a postorder list of CrateNums")
730 impl<'tcx> QueryDescription for queries::maybe_unused_extern_crates<'tcx> {
731 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
732 format!("looking up all possibly unused extern crates")
736 impl<'tcx> QueryDescription for queries::stability_index<'tcx> {
737 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
738 format!("calculating the stability index for the local crate")
742 impl<'tcx> QueryDescription for queries::all_crate_nums<'tcx> {
743 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
744 format!("fetching all foreign CrateNum instances")
748 // If enabled, send a message to the profile-queries thread
749 macro_rules! profq_msg {
750 ($tcx:expr, $msg:expr) => {
751 if cfg!(debug_assertions) {
752 if $tcx.sess.profile_queries() {
759 // If enabled, format a key using its debug string, which can be
760 // expensive to compute (in terms of time).
761 macro_rules! profq_key {
762 ($tcx:expr, $key:expr) => {
763 if cfg!(debug_assertions) {
764 if $tcx.sess.profile_queries_and_keys() {
765 Some(format!("{:?}", $key))
771 macro_rules! define_maps {
774 [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
777 input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
780 impl<$tcx> Maps<$tcx> {
781 pub fn new(providers: IndexVec<CrateNum, Providers<$tcx>>)
785 query_stack: RefCell::new(vec![]),
786 $($name: RefCell::new(QueryMap::new())),*
792 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
793 pub enum Query<$tcx> {
794 $($(#[$attr])* $name($K)),*
798 #[derive(Clone, Debug, PartialEq, Eq)]
800 $($name(Option<String>)),*
803 impl<$tcx> Query<$tcx> {
804 pub fn describe(&self, tcx: TyCtxt) -> String {
805 let (r, name) = match *self {
806 $(Query::$name(key) => {
807 (queries::$name::describe(tcx, key), stringify!($name))
810 if tcx.sess.verbose() {
811 format!("{} [{}]", r, name)
819 use std::marker::PhantomData;
821 $(#[allow(bad_style)]
822 pub struct $name<$tcx> {
823 data: PhantomData<&$tcx ()>
827 $(impl<$tcx> QueryConfig for queries::$name<$tcx> {
832 impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
834 fn to_dep_node(tcx: TyCtxt<'a, $tcx, 'lcx>, key: &$K) -> DepNode {
835 use dep_graph::DepConstructor::*;
837 DepNode::new(tcx, $node(*key))
840 fn try_get_with<F, R>(tcx: TyCtxt<'a, $tcx, 'lcx>,
844 -> Result<R, CycleError<'a, $tcx>>
845 where F: FnOnce(&$V) -> R
847 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
853 ProfileQueriesMsg::QueryBegin(
855 QueryMsg::$name(profq_key!(tcx, key))
859 if let Some(value) = tcx.maps.$name.borrow().map.get(&key) {
860 if let Some(ref d) = value.diagnostics {
861 if !d.emitted_diagnostics.get() {
862 d.emitted_diagnostics.set(true);
863 let handle = tcx.sess.diagnostic();
864 for diagnostic in d.diagnostics.iter() {
865 DiagnosticBuilder::new_diagnostic(handle, diagnostic.clone())
870 profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
871 tcx.dep_graph.read_index(value.index);
872 return Ok(f(&value.value));
874 // else, we are going to run the provider:
875 profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
877 // FIXME(eddyb) Get more valid Span's on queries.
878 // def_span guard is necessary to prevent a recursive loop,
879 // default_span calls def_span query internally.
880 if span == DUMMY_SP && stringify!($name) != "def_span" {
881 span = key.default_span(tcx)
884 let res = tcx.cycle_check(span, Query::$name(key), || {
885 let dep_node = Self::to_dep_node(tcx, &key);
887 tcx.sess.diagnostic().track_diagnostics(|| {
888 if dep_node.kind.is_anon() {
889 tcx.dep_graph.with_anon_task(dep_node.kind, || {
890 let provider = tcx.maps.providers[key.map_crate()].$name;
891 provider(tcx.global_tcx(), key)
894 fn run_provider<'a, 'tcx, 'lcx>(tcx: TyCtxt<'a, 'tcx, 'lcx>,
897 let provider = tcx.maps.providers[key.map_crate()].$name;
898 provider(tcx.global_tcx(), key)
901 tcx.dep_graph.with_task(dep_node, tcx, key, run_provider)
905 profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
906 let ((result, dep_node_index), diagnostics) = res;
908 tcx.dep_graph.read_index(dep_node_index);
910 let value = QueryValue {
912 index: dep_node_index,
913 diagnostics: if diagnostics.len() == 0 {
916 Some(Box::new(QueryDiagnostics {
918 emitted_diagnostics: Cell::new(true),
932 pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
933 -> Result<$V, DiagnosticBuilder<'a>> {
934 match Self::try_get_with(tcx, span, key, Clone::clone) {
936 Err(e) => Err(tcx.report_cycle(e)),
940 pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
941 // Ignore dependencies, since we not reading the computed value
942 let _task = tcx.dep_graph.in_ignore();
944 match Self::try_get_with(tcx, span, key, |_| ()) {
946 Err(e) => tcx.report_cycle(e).emit(),
951 #[derive(Copy, Clone)]
952 pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
953 pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
957 impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
958 type Target = TyCtxt<'a, 'gcx, 'tcx>;
959 fn deref(&self) -> &Self::Target {
964 impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
965 /// Return a transparent wrapper for `TyCtxt` which uses
966 /// `span` as the location of queries performed through it.
967 pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
975 pub fn $name(self, key: $K) -> $V {
976 self.at(DUMMY_SP).$name(key)
980 impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
982 pub fn $name(self, key: $K) -> $V {
983 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|mut e| {
985 Value::from_cycle_error(self.global_tcx())
990 define_provider_struct! {
992 input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
996 impl<$tcx> Copy for Providers<$tcx> {}
997 impl<$tcx> Clone for Providers<$tcx> {
998 fn clone(&self) -> Self { *self }
1003 macro_rules! define_map_struct {
1006 input: $input:tt) => {
1007 define_map_struct! {
1017 output: ($($output:tt)*)) => {
1018 pub struct Maps<$tcx> {
1019 providers: IndexVec<CrateNum, Providers<$tcx>>,
1020 query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
1025 // Field recognized and ready to shift into the output
1027 ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
1029 output: ($($output:tt)*)) => {
1030 define_map_struct! {
1033 output: ($($output)*
1034 $(#[$attr])* $($pub)* $name: RefCell<QueryMap<queries::$name<$tcx>>>,)
1038 // No modifiers left? This is a private item.
1040 input: (([] $attrs:tt $name:tt) $($input:tt)*),
1041 output: $output:tt) => {
1042 define_map_struct! {
1044 ready: ([] $attrs $name),
1045 input: ($($input)*),
1050 // Skip other modifiers
1052 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
1053 output: $output:tt) => {
1054 define_map_struct! {
1056 input: (([$($modifiers)*] $($fields)*) $($input)*),
1062 macro_rules! define_provider_struct {
1064 (tcx: $tcx:tt, input: $input:tt) => {
1065 define_provider_struct! {
1075 output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
1076 pub struct Providers<$tcx> {
1077 $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
1080 impl<$tcx> Default for Providers<$tcx> {
1081 fn default() -> Self {
1082 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
1083 bug!("tcx.maps.{}({:?}) unsupported by its crate",
1084 stringify!($name), key);
1086 Providers { $($name),* }
1091 // Something ready to shift:
1093 ready: ($name:tt $K:tt $V:tt),
1095 output: ($($output:tt)*)) => {
1096 define_provider_struct! {
1099 output: ($($output)* ($name $K $V))
1103 // Regular queries produce a `V` only.
1105 input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
1106 output: $output:tt) => {
1107 define_provider_struct! {
1109 ready: ($name $K $V),
1110 input: ($($input)*),
1117 input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
1118 output: $output:tt) => {
1119 define_provider_struct! {
1121 input: (([$($modifiers)*] $($fields)*) $($input)*),
1127 // Each of these maps also corresponds to a method on a
1128 // `Provider` trait for requesting a value of that type,
1129 // and a method on `Maps` itself for doing that in a
1130 // a way that memoizes and does dep-graph tracking,
1131 // wrapping around the actual chain of providers that
1132 // the driver creates (using several `rustc_*` crates).
1133 define_maps! { <'tcx>
1134 /// Records the type of every item.
1135 [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
1137 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
1138 /// associated generics and predicates.
1139 [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
1140 [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
1142 /// Maps from the def-id of a trait to the list of
1143 /// super-predicates. This is a subset of the full list of
1144 /// predicates. We store these in a separate map because we must
1145 /// evaluate them even during type conversion, often before the
1146 /// full predicates are available (note that supertraits have
1147 /// additional acyclicity requirements).
1148 [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
1150 /// To avoid cycles within the predicates of a single item we compute
1151 /// per-type-parameter predicates for resolving `T::AssocTy`.
1152 [] fn type_param_predicates: type_param_predicates((DefId, DefId))
1153 -> ty::GenericPredicates<'tcx>,
1155 [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
1156 [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
1157 [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
1158 [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
1159 [] fn adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
1161 /// True if this is a const fn
1162 [] fn is_const_fn: IsConstFn(DefId) -> bool,
1164 /// True if this is a foreign item (i.e., linked via `extern { ... }`).
1165 [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
1167 /// True if this is a default impl (aka impl Foo for ..)
1168 [] fn is_default_impl: IsDefaultImpl(DefId) -> bool,
1170 /// Get a map with the variance of every item; use `item_variance`
1172 [] fn crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
1174 /// Maps from def-id of a type or region parameter to its
1175 /// (inferred) variance.
1176 [] fn variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
1178 /// Maps from an impl/trait def-id to a list of the def-ids of its items
1179 [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
1181 /// Maps from a trait item to the trait item "descriptor"
1182 [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
1184 [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
1185 [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
1187 /// Maps a DefId of a type to a list of its inherent impls.
1188 /// Contains implementations of methods that are inherent to a type.
1189 /// Methods in these implementations don't need to be exported.
1190 [] fn inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
1192 /// Set of all the def-ids in this crate that have MIR associated with
1193 /// them. This includes all the body owners, but also things like struct
1195 [] fn mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
1197 /// Maps DefId's that have an associated Mir to the result
1198 /// of the MIR qualify_consts pass. The actual meaning of
1199 /// the value isn't known except to the pass itself.
1200 [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Rc<IdxSetBuf<mir::Local>>),
1202 /// Fetch the MIR for a given def-id up till the point where it is
1203 /// ready for const evaluation.
1205 /// See the README for the `mir` module for details.
1206 [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
1208 [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
1210 /// MIR after our optimization passes have run. This is MIR that is ready
1211 /// for trans. This is also the only query that can fetch non-local MIR, at present.
1212 [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
1214 /// Type of each closure. The def ID is the ID of the
1215 /// expression defining the closure.
1216 [] fn closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
1218 /// The signature of functions and closures.
1219 [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
1221 /// Records the signature of each generator. The def ID is the ID of the
1222 /// expression defining the closure.
1223 [] fn generator_sig: GenSignature(DefId) -> Option<ty::PolyGenSig<'tcx>>,
1225 /// Caches CoerceUnsized kinds for impls on custom types.
1226 [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
1227 -> ty::adjustment::CoerceUnsizedInfo,
1229 [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
1231 [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
1233 [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
1235 [] fn coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
1237 [] fn borrowck: BorrowCheck(DefId) -> (),
1238 // FIXME: shouldn't this return a `Result<(), BorrowckErrors>` instead?
1239 [] fn mir_borrowck: MirBorrowCheck(DefId) -> (),
1241 /// Gets a complete map from all types to their inherent impls.
1242 /// Not meant to be used directly outside of coherence.
1243 /// (Defined only for LOCAL_CRATE)
1244 [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
1246 /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
1247 /// Not meant to be used directly outside of coherence.
1248 /// (Defined only for LOCAL_CRATE)
1249 [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
1251 /// Results of evaluating const items or constants embedded in
1252 /// other items (such as enum variant explicit discriminants).
1253 [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
1254 -> const_val::EvalResult<'tcx>,
1256 /// Performs the privacy check and computes "access levels".
1257 [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
1259 [] fn reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
1261 /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
1262 /// in the case of closures, this will be redirected to the enclosing function.
1263 [] fn region_scope_tree: RegionScopeTree(DefId) -> Rc<region::ScopeTree>,
1265 [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
1267 [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
1268 [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
1270 [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
1271 [] fn def_span: DefSpan(DefId) -> Span,
1272 [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
1273 [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
1274 [] fn item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
1275 [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
1276 [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
1277 [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
1278 [] fn is_exported_symbol: IsExportedSymbol(DefId) -> bool,
1279 [] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId)
1280 -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
1281 [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
1282 [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
1284 [] fn trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
1285 [] fn specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
1286 [] fn is_object_safe: ObjectSafety(DefId) -> bool,
1288 // Get the ParameterEnvironment for a given item; this environment
1289 // will be in "user-facing" mode, meaning that it is suitabe for
1290 // type-checking etc, and it does not normalize specializable
1291 // associated types. This is almost always what you want,
1292 // unless you are doing MIR optimizations, in which case you
1293 // might want to use `reveal_all()` method to change modes.
1294 [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
1296 // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
1297 // `ty.is_copy()`, etc, since that will prune the environment where possible.
1298 [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1299 [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1300 [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1301 [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1302 [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
1303 -> Result<&'tcx Layout, LayoutError<'tcx>>,
1305 [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
1306 -> Rc<Vec<(CrateNum, LinkagePreference)>>,
1308 [] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
1309 [] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
1310 [] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
1311 [] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
1312 [] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
1313 [] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
1314 [] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
1316 [] fn extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
1318 [] fn specializes: specializes_node((DefId, DefId)) -> bool,
1319 [] fn in_scope_traits_map: InScopeTraits(DefIndex)
1320 -> Option<Rc<FxHashMap<ItemLocalId, Rc<Vec<TraitCandidate>>>>>,
1321 [] fn module_exports: ModuleExports(DefId) -> Option<Rc<Vec<Export>>>,
1322 [] fn lint_levels: lint_levels_node(CrateNum) -> Rc<lint::LintLevelMap>,
1324 [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
1325 [] fn exported_symbols: ExportedSymbols(CrateNum) -> Rc<Vec<DefId>>,
1326 [] fn native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
1327 [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
1328 [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
1329 [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol,
1330 [] fn crate_hash: CrateHash(CrateNum) -> Svh,
1331 [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
1333 [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
1335 [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
1338 [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
1339 [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
1340 [] fn native_library_kind: NativeLibraryKind(DefId)
1341 -> Option<NativeLibraryKind>,
1342 [] fn link_args: link_args_node(CrateNum) -> Rc<Vec<String>>,
1344 [] fn named_region_map: NamedRegion(DefIndex) ->
1345 Option<Rc<FxHashMap<ItemLocalId, Region>>>,
1346 [] fn is_late_bound_map: IsLateBound(DefIndex) ->
1347 Option<Rc<FxHashSet<ItemLocalId>>>,
1348 [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
1349 -> Option<Rc<FxHashMap<ItemLocalId, Rc<Vec<ObjectLifetimeDefault>>>>>,
1351 [] fn visibility: Visibility(DefId) -> ty::Visibility,
1352 [] fn dep_kind: DepKind(CrateNum) -> DepKind,
1353 [] fn crate_name: CrateName(CrateNum) -> Symbol,
1354 [] fn item_children: ItemChildren(DefId) -> Rc<Vec<Export>>,
1355 [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
1357 [] fn get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
1358 [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
1359 [] fn missing_lang_items: MissingLangItems(CrateNum) -> Rc<Vec<LangItem>>,
1360 [] fn extern_const_body: ExternConstBody(DefId) -> &'tcx hir::Body,
1361 [] fn visible_parent_map: visible_parent_map_node(CrateNum)
1362 -> Rc<DefIdMap<DefId>>,
1363 [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
1364 [] fn used_crate_source: UsedCrateSource(CrateNum) -> Rc<CrateSource>,
1365 [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Rc<Vec<CrateNum>>,
1367 [] fn freevars: Freevars(DefId) -> Option<Rc<Vec<hir::Freevar>>>,
1368 [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
1369 [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
1370 -> Rc<Vec<(DefId, Span)>>,
1372 [] fn stability_index: stability_index_node(CrateNum) -> Rc<stability::Index<'tcx>>,
1373 [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Rc<Vec<CrateNum>>,
1376 fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
1377 DepConstructor::TypeParamPredicates {
1383 fn coherent_trait_dep_node<'tcx>((_, def_id): (CrateNum, DefId)) -> DepConstructor<'tcx> {
1384 DepConstructor::CoherenceCheckTrait(def_id)
1387 fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1388 DepConstructor::Coherence
1391 fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1392 DepConstructor::CoherenceInherentImplOverlapCheck
1395 fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1396 DepConstructor::Reachability
1399 fn mir_shim_dep_node<'tcx>(instance_def: ty::InstanceDef<'tcx>) -> DepConstructor<'tcx> {
1400 DepConstructor::MirShim {
1405 fn symbol_name_dep_node<'tcx>(instance: ty::Instance<'tcx>) -> DepConstructor<'tcx> {
1406 DepConstructor::InstanceSymbolName { instance }
1409 fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1410 DepConstructor::TypeckBodiesKrate
1413 fn const_eval_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
1414 -> DepConstructor<'tcx> {
1415 DepConstructor::ConstEval
1418 fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1419 DepConstructor::MirKeys
1422 fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1423 DepConstructor::CrateVariances
1426 fn is_copy_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
1427 DepConstructor::IsCopy
1430 fn is_sized_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
1431 DepConstructor::IsSized
1434 fn is_freeze_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
1435 DepConstructor::IsFreeze
1438 fn needs_drop_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
1439 DepConstructor::NeedsDrop
1442 fn layout_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
1443 DepConstructor::Layout
1446 fn lint_levels_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1447 DepConstructor::LintLevels
1450 fn specializes_node<'tcx>((a, b): (DefId, DefId)) -> DepConstructor<'tcx> {
1451 DepConstructor::Specializes { impl1: a, impl2: b }
1454 fn implementations_of_trait_node<'tcx>((krate, trait_id): (CrateNum, DefId))
1455 -> DepConstructor<'tcx>
1457 DepConstructor::ImplementationsOfTrait { krate, trait_id }
1460 fn link_args_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1461 DepConstructor::LinkArgs
1464 fn get_lang_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1465 DepConstructor::GetLangItems
1468 fn visible_parent_map_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1469 DepConstructor::VisibleParentMap
1472 fn postorder_cnums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1473 DepConstructor::PostorderCnums
1476 fn maybe_unused_extern_crates_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1477 DepConstructor::MaybeUnusedExternCrates
1480 fn stability_index_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1481 DepConstructor::StabilityIndex
1484 fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1485 DepConstructor::AllCrateNums