]> git.lizzy.rs Git - rust.git/blob - src/librustc/ty/query/mod.rs
a1eb1c43335b1caac4c3f31a4bde61f0ed77147d
[rust.git] / src / librustc / ty / query / mod.rs
1 use crate::dep_graph::{self, DepNode};
2 use crate::hir::def_id::{CrateNum, DefId, DefIndex};
3 use crate::hir::def::{DefKind, Export};
4 use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
5 use crate::infer::canonical::{self, Canonical};
6 use crate::lint;
7 use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
8 use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
9 use crate::middle::privacy::AccessLevels;
10 use crate::middle::reachable::ReachableSet;
11 use crate::middle::region;
12 use crate::middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
13 use crate::middle::stability::{self, DeprecationEntry};
14 use crate::middle::lib_features::LibFeatures;
15 use crate::middle::lang_items::{LanguageItems, LangItem};
16 use crate::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
17 use crate::mir::interpret::{ConstEvalRawResult, ConstEvalResult};
18 use crate::mir::mono::CodegenUnit;
19 use crate::mir;
20 use crate::mir::interpret::GlobalId;
21 use crate::session::CrateDisambiguator;
22 use crate::session::config::{EntryFnType, OutputFilenames, OptLevel, SymbolManglingVersion};
23 use crate::traits::{self, Vtable};
24 use crate::traits::query::{
25     CanonicalPredicateGoal, CanonicalProjectionGoal,
26     CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
27     CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal,
28     CanonicalTypeOpNormalizeGoal, NoSolution,
29 };
30 use crate::traits::query::method_autoderef::MethodAutoderefStepsResult;
31 use crate::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
32 use crate::traits::query::normalize::NormalizationResult;
33 use crate::traits::query::outlives_bounds::OutlivesBound;
34 use crate::traits::specialization_graph;
35 use crate::traits::Clauses;
36 use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, AdtSizedConstraint};
37 use crate::ty::steal::Steal;
38 use crate::ty::util::NeedsDrop;
39 use crate::ty::subst::SubstsRef;
40 use crate::util::nodemap::{DefIdSet, DefIdMap};
41 use crate::util::common::ErrorReported;
42 use rustc_data_structures::profiling::ProfileCategory::*;
43
44 use rustc_data_structures::svh::Svh;
45 use rustc_index::vec::IndexVec;
46 use rustc_data_structures::fx::{FxIndexMap, FxHashMap, FxHashSet};
47 use rustc_data_structures::stable_hasher::StableVec;
48 use rustc_data_structures::sync::Lrc;
49 use rustc_data_structures::fingerprint::Fingerprint;
50 use rustc_target::spec::PanicStrategy;
51
52 use std::borrow::Cow;
53 use std::ops::Deref;
54 use std::sync::Arc;
55 use std::any::type_name;
56 use syntax_pos::{Span, DUMMY_SP};
57 use syntax::attr;
58 use syntax::ast;
59 use syntax::feature_gate;
60 use syntax::symbol::Symbol;
61
62 #[macro_use]
63 mod plumbing;
64 use self::plumbing::*;
65 pub use self::plumbing::{force_from_dep_node, CycleError};
66
67 mod job;
68 pub use self::job::{QueryJob, QueryInfo};
69 #[cfg(parallel_compiler)]
70 pub use self::job::handle_deadlock;
71
72 mod keys;
73 use self::keys::Key;
74
75 mod values;
76 use self::values::Value;
77
78 mod config;
79 pub(crate) use self::config::QueryDescription;
80 pub use self::config::QueryConfig;
81 use self::config::QueryAccessors;
82
83 mod on_disk_cache;
84 pub use self::on_disk_cache::OnDiskCache;
85
86 // Each of these queries corresponds to a function pointer field in the
87 // `Providers` struct for requesting a value of that type, and a method
88 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
89 // which memoizes and does dep-graph tracking, wrapping around the actual
90 // `Providers` that the driver creates (using several `rustc_*` crates).
91 //
92 // The result type of each query must implement `Clone`, and additionally
93 // `ty::query::values::Value`, which produces an appropriate placeholder
94 // (error) value if the query resulted in a query cycle.
95 // Queries marked with `fatal_cycle` do not need the latter implementation,
96 // as they will raise an fatal error on query cycles instead.
97
98 rustc_query_append! { [define_queries!][ <'tcx>
99     Other {
100         /// Runs analysis passes on the crate.
101         [eval_always] fn analysis: Analysis(CrateNum) -> Result<(), ErrorReported>,
102     },
103 ]}