Auto merge of #51550 - eddyb:queries-not-maps, r=nikomatsakis

rustc: rename ty::maps to ty::query.

Should've never been `maps` but "query system/engine" didn't fully settle from the start.

r? @michaelwoerister or @nikomatsakis
This commit is contained in:
bors 2018-06-16 08:48:46 +00:00
commit a385095f9a
57 changed files with 247 additions and 209 deletions

View File

@ -6,7 +6,7 @@ This directory contains the source code of the rust project, including:
For more information on how various parts of the compiler work, see the [rustc guide].
Their is also useful content in the following READMEs, which are gradually being moved over to the guide:
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/maps
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query
- https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
- https://github.com/rust-lang/rust/blob/master/src/librustc/infer/region_constraints
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked

View File

@ -656,7 +656,7 @@ impl DepGraph {
// We failed to mark it green, so we try to force the query.
debug!("try_mark_green({:?}) --- trying to force \
dependency {:?}", dep_node, dep_dep_node);
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
if ::ty::query::force_from_dep_node(tcx, dep_dep_node) {
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node_index);
match dep_dep_node_color {
@ -742,14 +742,14 @@ impl DepGraph {
// and emit other diagnostics before these diagnostics are emitted.
// Such diagnostics should be emitted after these.
// See https://github.com/rust-lang/rust/issues/48685
let diagnostics = tcx.on_disk_query_result_cache
let diagnostics = tcx.queries.on_disk_cache
.load_diagnostics(tcx, prev_dep_node_index);
if diagnostics.len() > 0 {
let handle = tcx.sess.diagnostic();
// Promote the previous diagnostics to the current session.
tcx.on_disk_query_result_cache
tcx.queries.on_disk_cache
.store_diagnostics(dep_node_index, diagnostics.clone());
for diagnostic in diagnostics {

View File

@ -45,7 +45,7 @@ use syntax::tokenstream::TokenStream;
use syntax::util::ThinVec;
use syntax::util::parser::ExprPrecedence;
use ty::AdtKind;
use ty::maps::Providers;
use ty::query::Providers;
use rustc_data_structures::indexed_vec;
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};

View File

@ -47,7 +47,7 @@ use syntax::symbol::Symbol;
use syntax::visit as ast_visit;
use syntax_pos::Span;
use ty::TyCtxt;
use ty::maps::Providers;
use ty::query::Providers;
use util::nodemap::NodeMap;
pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore,

View File

@ -11,7 +11,7 @@
use hir::def_id::DefId;
use ty;
use ty::subst::Substs;
use ty::maps::TyCtxtAt;
use ty::query::TyCtxtAt;
use mir::interpret::ConstValue;
use errors::DiagnosticBuilder;

View File

@ -21,7 +21,7 @@ use hir::def::Def;
use hir::def_id::{DefId, CrateNum};
use rustc_data_structures::sync::Lrc;
use ty::{self, TyCtxt};
use ty::maps::Providers;
use ty::query::Providers;
use middle::privacy;
use session::config;
use util::nodemap::{NodeSet, FxHashSet};

View File

@ -27,7 +27,7 @@ use syntax::codemap;
use syntax::ast;
use syntax_pos::{Span, DUMMY_SP};
use ty::TyCtxt;
use ty::maps::Providers;
use ty::query::Providers;
use hir;
use hir::def_id::DefId;

View File

@ -349,8 +349,8 @@ type ScopeRef<'a> = &'a Scope<'a>;
const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
resolve_lifetimes,
named_region_map: |tcx, id| {

View File

@ -991,8 +991,8 @@ impl<'tcx> TraitObligation<'tcx> {
}
}
pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
is_object_safe: object_safety::is_object_safe_provider,
specialization_graph_of: specialize::specialization_graph_provider,
specializes: specialize::specializes,

View File

@ -46,7 +46,7 @@ use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
use ty::TypeVariants::*;
use ty::GenericParamDefKind;
use ty::layout::{LayoutDetails, TargetDataLayout};
use ty::maps;
use ty::query;
use ty::steal::Steal;
use ty::BindingMode;
use ty::CanonicalTy;
@ -863,11 +863,6 @@ pub struct GlobalCtxt<'tcx> {
pub dep_graph: DepGraph,
/// This provides access to the incr. comp. on-disk cache for query results.
/// Do not access this directly. It is only meant to be used by
/// `DepGraph::try_mark_green()` and the query infrastructure in `ty::maps`.
pub(crate) on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
/// Common types, pre-interned for your convenience.
pub types: CommonTypes<'tcx>,
@ -886,7 +881,7 @@ pub struct GlobalCtxt<'tcx> {
/// as well as all upstream crates. Only populated in incremental mode.
pub def_path_hash_to_def_id: Option<FxHashMap<DefPathHash, DefId>>,
pub maps: maps::Maps<'tcx>,
pub(crate) queries: query::Queries<'tcx>,
// Records the free variables refrenced by every closure
// expression. Do not track deps for this, just recompute it from
@ -1074,12 +1069,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// reference to the context, to allow formatting values that need it.
pub fn create_and_enter<F, R>(s: &'tcx Session,
cstore: &'tcx CrateStoreDyn,
local_providers: ty::maps::Providers<'tcx>,
extern_providers: ty::maps::Providers<'tcx>,
local_providers: ty::query::Providers<'tcx>,
extern_providers: ty::query::Providers<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
resolutions: ty::Resolutions,
hir: hir_map::Map<'tcx>,
on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
crate_name: &str,
tx: mpsc::Sender<Box<dyn Any + Send>>,
output_filenames: &OutputFilenames,
@ -1144,7 +1139,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
global_arenas: &arenas.global,
global_interners: interners,
dep_graph: dep_graph.clone(),
on_disk_query_result_cache,
types: common_types,
trait_map,
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
@ -1165,7 +1159,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
.collect(),
hir,
def_path_hash_to_def_id,
maps: maps::Maps::new(providers),
queries: query::Queries::new(providers, on_disk_query_result_cache),
rcache: Lock::new(FxHashMap()),
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
@ -1343,7 +1337,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-> Result<(), E::Error>
where E: ty::codec::TyEncoder
{
self.on_disk_query_result_cache.serialize(self.global_tcx(), encoder)
self.queries.on_disk_cache.serialize(self.global_tcx(), encoder)
}
/// If true, we should use a naive AST walk to determine if match
@ -1702,7 +1696,7 @@ pub mod tls {
use std::fmt;
use std::mem;
use syntax_pos;
use ty::maps;
use ty::query;
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
use rustc_data_structures::OnDrop;
use rustc_data_structures::sync::{self, Lrc, Lock};
@ -1726,8 +1720,8 @@ pub mod tls {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
/// The current query job, if any. This is updated by start_job in
/// ty::maps::plumbing when executing a query
pub query: Option<Lrc<maps::QueryJob<'gcx>>>,
/// ty::query::plumbing when executing a query
pub query: Option<Lrc<query::QueryJob<'gcx>>>,
/// Used to prevent layout from recursing too deeply.
pub layout_depth: usize,
@ -2792,7 +2786,7 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
}
}
pub fn provide(providers: &mut ty::maps::Providers) {
pub fn provide(providers: &mut ty::query::Providers) {
// FIXME(#44234) - almost all of these queries have no sub-queries and
// therefore no actual inputs, they're just reading tables calculated in
// resolve! Does this work? Unsure! That's what the issue is about

View File

@ -11,8 +11,8 @@
use ty::{self, Ty, TyCtxt};
use ty::fold::{TypeFolder, TypeFoldable};
pub(super) fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
pub(super) fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
erase_regions_ty,
..*providers
};

View File

@ -194,8 +194,8 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
})
}
pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
layout_raw,
..*providers
};
@ -1481,7 +1481,7 @@ impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}
}
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'a, 'tcx, 'tcx>> {
type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
@ -1527,7 +1527,7 @@ impl TyCtxt<'a, 'tcx, '_> {
}
}
impl ty::maps::TyCtxtAt<'a, 'tcx, '_> {
impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
/// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode.
#[inline]

View File

@ -85,7 +85,7 @@ pub use self::instance::{Instance, InstanceDef};
pub use self::trait_def::TraitDef;
pub use self::maps::queries;
pub use self::query::queries;
pub mod adjustment;
pub mod binding;
@ -100,8 +100,8 @@ pub mod inhabitedness;
pub mod item_path;
pub mod layout;
pub mod _match;
pub mod maps;
pub mod outlives;
pub mod query;
pub mod relate;
pub mod steal;
pub mod subst;
@ -2175,7 +2175,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
/// Due to normalization being eager, this applies even if
/// the associated type is behind a pointer, e.g. issue #31299.
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] {
match tcx.try_get_query::<queries::adt_sized_constraint>(DUMMY_SP, self.did) {
match tcx.try_adt_sized_constraint(DUMMY_SP, self.did) {
Ok(tys) => tys,
Err(mut bug) => {
debug!("adt_sized_constraint: {:?} is recursive", self);
@ -2917,12 +2917,12 @@ fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
pub fn provide(providers: &mut ty::maps::Providers) {
pub fn provide(providers: &mut ty::query::Providers) {
context::provide(providers);
erase_regions::provide(providers);
layout::provide(providers);
util::provide(providers);
*providers = ty::maps::Providers {
*providers = ty::query::Providers {
associated_item,
associated_item_def_ids,
adt_sized_constraint,

View File

@ -55,7 +55,7 @@ get to use the nice method-call-style syntax. Instead, you invoke
using the `try_get` method, which looks roughly like this:
```rust
use ty::maps::queries;
use ty::query::queries;
...
match queries::type_of::try_get(tcx, DUMMY_SP, self.did) {
Ok(result) => {
@ -207,7 +207,7 @@ by the time you read this README, but at present it looks something
like:
```
define_maps! { <'tcx>
define_queries! { <'tcx>
/// Records the type of every item.
[] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
@ -235,7 +235,7 @@ Let's go over them one by one:
processed.
- **Name of query:** the name of the query method
(`tcx.type_of(..)`). Also used as the name of a struct
(`ty::maps::queries::type_of`) that will be generated to represent
(`ty::query::queries::type_of`) that will be generated to represent
this query.
- **Dep-node constructor:** indicates the constructor function that
connects this query to incremental compilation. Typically, this is a
@ -247,7 +247,7 @@ Let's go over them one by one:
bottom of the file. This is typically used when the query key is
not a def-id, or just not the type that the dep-node expects.
- **Query key type:** the type of the argument to this query.
This type must implement the `ty::maps::keys::Key` trait, which
This type must implement the `ty::query::keys::Key` trait, which
defines (for example) how to map it to a crate, and so forth.
- **Result type of query:** the type produced by this query. This type
should (a) not use `RefCell` or other interior mutability and (b) be
@ -260,14 +260,14 @@ Let's go over them one by one:
So, to add a query:
- Add an entry to `define_maps!` using the format above.
- Add an entry to `define_queries!` using the format above.
- Possibly add a corresponding entry to the dep-node macro.
- Link the provider by modifying the appropriate `provide` method;
or add a new one if needed and ensure that `rustc_driver` is invoking it.
#### Query structs and descriptions
For each kind, the `define_maps` macro will generate a "query struct"
For each kind, the `define_queries` macro will generate a "query struct"
named after the query. This struct is a kind of a place-holder
describing the query. Each such struct implements the
`self::config::QueryConfig` trait, which has associated types for the

View File

@ -15,9 +15,9 @@ use mir::interpret::{GlobalId, ConstValue};
use traits::query::{CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal};
use ty::{self, ParamEnvAnd, Ty, TyCtxt};
use ty::subst::Substs;
use ty::maps::queries;
use ty::maps::Query;
use ty::maps::QueryMap;
use ty::query::queries;
use ty::query::Query;
use ty::query::QueryCache;
use std::hash::Hash;
use std::fmt::Debug;
@ -26,18 +26,20 @@ use rustc_data_structures::sync::Lock;
use rustc_data_structures::stable_hasher::HashStable;
use ich::StableHashingContext;
/// Query configuration and description traits.
// Query configuration and description traits.
pub trait QueryConfig<'tcx> {
const NAME: &'static str;
type Key: Eq + Hash + Clone + Debug;
type Value: Clone + for<'a> HashStable<StableHashingContext<'a>>;
}
pub(super) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
fn query(key: Self::Key) -> Query<'tcx>;
// Don't use this method to access query results, instead use the methods on TyCtxt
fn query_map<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryMap<'tcx, Self>>;
fn query_cache<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryCache<'tcx, Self>>;
fn to_dep_node(tcx: TyCtxt<'_, 'tcx, '_>, key: &Self::Key) -> DepNode;
@ -47,7 +49,7 @@ pub trait QueryConfig<'tcx> {
fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value;
}
pub trait QueryDescription<'tcx>: QueryConfig<'tcx> {
pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
fn describe(tcx: TyCtxt, key: Self::Key) -> String;
#[inline]
@ -62,7 +64,7 @@ pub trait QueryDescription<'tcx>: QueryConfig<'tcx> {
}
}
impl<'tcx, M: QueryConfig<'tcx, Key=DefId>> QueryDescription<'tcx> for M {
impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M {
default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
if !tcx.sess.verbose() {
format!("processing `{}`", tcx.item_path_str(def_id))
@ -233,7 +235,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> {
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id).map(Ok)
tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok)
}
}
@ -257,7 +259,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> {
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
tcx.queries.on_disk_cache.try_load_query_result(tcx, id)
}
}
@ -331,7 +333,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_sta
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
tcx.queries.on_disk_cache.try_load_query_result(tcx, id)
}
}
@ -363,7 +365,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::codegen_fulfill_obligation<'tcx>
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
tcx.queries.on_disk_cache.try_load_query_result(tcx, id)
}
}
@ -683,7 +685,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::typeck_tables_of<'tcx> {
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
.on_disk_query_result_cache
.queries.on_disk_cache
.try_load_query_result(tcx, id);
typeck_tables.map(|tables| tcx.alloc_tables(tables))
@ -699,7 +701,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> {
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
let mir: Option<::mir::Mir<'tcx>> = tcx.on_disk_query_result_cache
let mir: Option<::mir::Mir<'tcx>> = tcx.queries.on_disk_cache
.try_load_query_result(tcx, id);
mir.map(|x| tcx.alloc_mir(x))
}
@ -738,7 +740,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> {
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
let generics: Option<ty::Generics> = tcx.on_disk_query_result_cache
let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
.try_load_query_result(tcx, id);
generics.map(|x| tcx.alloc_generics(x))
}
@ -780,7 +782,7 @@ macro_rules! impl_disk_cacheable_query(
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
tcx.queries.on_disk_cache.try_load_query_result(tcx, id)
}
}
}

View File

@ -15,8 +15,8 @@ use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak};
use rustc_data_structures::OnDrop;
use syntax_pos::Span;
use ty::tls;
use ty::maps::Query;
use ty::maps::plumbing::CycleError;
use ty::query::Query;
use ty::query::plumbing::CycleError;
use ty::context::TyCtxt;
use errors::Diagnostic;
use std::process;
@ -497,7 +497,7 @@ fn deadlock(tcx: TyCtxt<'_, '_, '_>, registry: &rayon_core::Registry) {
});
let mut wakelist = Vec::new();
let mut jobs: Vec<_> = tcx.maps.collect_active_jobs();
let mut jobs: Vec<_> = tcx.queries.collect_active_jobs();
let mut found_cycle = false;

View File

@ -24,10 +24,10 @@ use syntax_pos::symbol::InternedString;
/// The `Key` trait controls what types can legally be used as the key
/// for a query.
pub trait Key: Clone + Hash + Eq + Debug {
pub(super) trait Key: Clone + Hash + Eq + Debug {
/// Given an instance of this key, what crate is it referring to?
/// This is used to find the provider.
fn map_crate(&self) -> CrateNum;
fn query_crate(&self) -> CrateNum;
/// In the event that a cycle occurs, if no explicit span has been
/// given for a query with key `self`, what span should we use?
@ -35,7 +35,7 @@ pub trait Key: Clone + Hash + Eq + Debug {
}
impl<'tcx> Key for ty::InstanceDef<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
@ -45,7 +45,7 @@ impl<'tcx> Key for ty::InstanceDef<'tcx> {
}
impl<'tcx> Key for ty::Instance<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
@ -55,8 +55,8 @@ impl<'tcx> Key for ty::Instance<'tcx> {
}
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
fn map_crate(&self) -> CrateNum {
self.instance.map_crate()
fn query_crate(&self) -> CrateNum {
self.instance.query_crate()
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -65,7 +65,7 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
}
impl Key for CrateNum {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
*self
}
fn default_span(&self, _: TyCtxt) -> Span {
@ -74,7 +74,7 @@ impl Key for CrateNum {
}
impl Key for DefIndex {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
fn default_span(&self, _tcx: TyCtxt) -> Span {
@ -83,7 +83,7 @@ impl Key for DefIndex {
}
impl Key for DefId {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -92,7 +92,7 @@ impl Key for DefId {
}
impl Key for (DefId, DefId) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.0.krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -101,7 +101,7 @@ impl Key for (DefId, DefId) {
}
impl Key for (CrateNum, DefId) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.0
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -110,7 +110,7 @@ impl Key for (CrateNum, DefId) {
}
impl Key for (DefId, SimplifiedType) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.0.krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -119,7 +119,7 @@ impl Key for (DefId, SimplifiedType) {
}
impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.0.krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -128,7 +128,7 @@ impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
}
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.1.def_id().krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -137,7 +137,7 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
}
impl<'tcx> Key for ty::PolyTraitRef<'tcx>{
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
self.def_id().krate
}
fn default_span(&self, tcx: TyCtxt) -> Span {
@ -146,7 +146,7 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx>{
}
impl<'tcx> Key for (mir::interpret::ConstValue<'tcx>, Ty<'tcx>) {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
fn default_span(&self, _: TyCtxt) -> Span {
@ -155,7 +155,7 @@ impl<'tcx> Key for (mir::interpret::ConstValue<'tcx>, Ty<'tcx>) {
}
impl<'tcx> Key for Ty<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
fn default_span(&self, _: TyCtxt) -> Span {
@ -164,7 +164,7 @@ impl<'tcx> Key for Ty<'tcx> {
}
impl<'tcx> Key for ty::ParamEnv<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
fn default_span(&self, _: TyCtxt) -> Span {
@ -173,8 +173,8 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
}
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
fn map_crate(&self) -> CrateNum {
self.value.map_crate()
fn query_crate(&self) -> CrateNum {
self.value.query_crate()
}
fn default_span(&self, tcx: TyCtxt) -> Span {
self.value.default_span(tcx)
@ -182,7 +182,7 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
}
impl Key for InternedString {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
fn default_span(&self, _tcx: TyCtxt) -> Span {
@ -191,7 +191,7 @@ impl Key for InternedString {
}
impl<'tcx> Key for CanonicalProjectionGoal<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
@ -201,7 +201,7 @@ impl<'tcx> Key for CanonicalProjectionGoal<'tcx> {
}
impl<'tcx> Key for CanonicalTyGoal<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}
@ -211,7 +211,7 @@ impl<'tcx> Key for CanonicalTyGoal<'tcx> {
}
impl<'tcx> Key for CanonicalPredicateGoal<'tcx> {
fn map_crate(&self) -> CrateNum {
fn query_crate(&self) -> CrateNum {
LOCAL_CRATE
}

View File

@ -9,6 +9,7 @@
// except according to those terms.
use dep_graph::{DepConstructor, DepNode};
use errors::DiagnosticBuilder;
use hir::def_id::{CrateNum, DefId, DefIndex};
use hir::def::{Def, Export};
use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
@ -71,30 +72,30 @@ pub use self::job::{QueryJob, QueryInfo};
pub use self::job::handle_deadlock;
mod keys;
pub use self::keys::Key;
use self::keys::Key;
mod values;
use self::values::Value;
mod config;
pub use self::config::QueryConfig;
use self::config::QueryDescription;
use self::config::{QueryAccessors, QueryDescription};
mod on_disk_cache;
pub use self::on_disk_cache::OnDiskCache;
// Each of these maps also corresponds to a method on a
// `Provider` trait for requesting a value of that type,
// and a method on `Maps` itself for doing that in a
// a way that memoizes and does dep-graph tracking,
// wrapping around the actual chain of providers that
// the driver creates (using several `rustc_*` crates).
// Each of these quries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result of query must implement Clone. They must also implement ty::maps::values::Value
// which produces an appropriate error value if the query resulted in a query cycle.
// Queries marked with `fatal_cycle` do not need that implementation
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `fatal_cycle` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
define_maps! { <'tcx>
define_queries! { <'tcx>
/// Records the type of every item.
[] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
@ -468,6 +469,32 @@ define_maps! { <'tcx>
-> Lrc<FxHashMap<DefId, String>>,
}
// `try_get_query` can't be public because it uses the private query
// implementation traits, so we provide access to it selectively.
impl<'a, 'tcx, 'lcx> TyCtxt<'a, 'tcx, 'lcx> {
pub fn try_adt_sized_constraint(
self,
span: Span,
key: DefId,
) -> Result<&'tcx [Ty<'tcx>], DiagnosticBuilder<'a>> {
self.try_get_query::<queries::adt_sized_constraint>(span, key)
}
pub fn try_needs_drop_raw(
self,
span: Span,
key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Result<bool, DiagnosticBuilder<'a>> {
self.try_get_query::<queries::needs_drop_raw>(span, key)
}
pub fn try_optimized_mir(
self,
span: Span,
key: DefId,
) -> Result<&'tcx mir::Mir<'tcx>, DiagnosticBuilder<'a>> {
self.try_get_query::<queries::optimized_mir>(span, key)
}
}
//////////////////////////////////////////////////////////////////////
// These functions are little shims used to find the dep-node for a
// given query when there is not a *direct* mapping:

View File

@ -209,7 +209,7 @@ impl<'sess> OnDiskCache<'sess> {
let mut query_result_index = EncodedQueryResultIndex::new();
time(tcx.sess, "encode query results", || {
use ty::maps::queries::*;
use ty::query::queries::*;
let enc = &mut encoder;
let qri = &mut query_result_index;
@ -232,11 +232,11 @@ impl<'sess> OnDiskCache<'sess> {
encode_query_results::<specialization_graph_of, _>(tcx, enc, qri)?;
// const eval is special, it only encodes successfully evaluated constants
use ty::maps::QueryConfig;
let map = const_eval::query_map(tcx).borrow();
assert!(map.active.is_empty());
for (key, entry) in map.results.iter() {
use ty::maps::config::QueryDescription;
use ty::query::QueryAccessors;
let cache = const_eval::query_cache(tcx).borrow();
assert!(cache.active.is_empty());
for (key, entry) in cache.results.iter() {
use ty::query::config::QueryDescription;
if const_eval::cache_on_disk(key.clone()) {
if let Ok(ref value) = entry.value {
let dep_node = SerializedDepNodeIndex::new(entry.index.index());
@ -1099,7 +1099,7 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
time(tcx.sess, desc, || {
let map = Q::query_map(tcx).borrow();
let map = Q::query_cache(tcx).borrow();
assert!(map.active.is_empty());
for (key, entry) in map.results.iter() {
if Q::cache_on_disk(key.clone()) {

View File

@ -19,10 +19,9 @@ use errors::Diagnostic;
use errors::FatalError;
use ty::tls;
use ty::{TyCtxt};
use ty::maps::Query;
use ty::maps::config::QueryConfig;
use ty::maps::config::QueryDescription;
use ty::maps::job::{QueryJob, QueryResult, QueryInfo};
use ty::query::Query;
use ty::query::config::{QueryConfig, QueryDescription};
use ty::query::job::{QueryJob, QueryResult, QueryInfo};
use ty::item_path;
use util::common::{profq_msg, ProfileQueriesMsg, QueryMsg};
@ -35,7 +34,7 @@ use std::collections::hash_map::Entry;
use syntax_pos::Span;
use syntax::codemap::DUMMY_SP;
pub struct QueryMap<'tcx, D: QueryConfig<'tcx> + ?Sized> {
pub struct QueryCache<'tcx, D: QueryConfig<'tcx> + ?Sized> {
pub(super) results: FxHashMap<D::Key, QueryValue<D::Value>>,
pub(super) active: FxHashMap<D::Key, QueryResult<'tcx>>,
}
@ -56,9 +55,9 @@ impl<T> QueryValue<T> {
}
}
impl<'tcx, M: QueryConfig<'tcx>> QueryMap<'tcx, M> {
pub(super) fn new() -> QueryMap<'tcx, M> {
QueryMap {
impl<'tcx, M: QueryConfig<'tcx>> QueryCache<'tcx, M> {
pub(super) fn new() -> QueryCache<'tcx, M> {
QueryCache {
results: FxHashMap(),
active: FxHashMap(),
}
@ -95,7 +94,7 @@ macro_rules! profq_query_msg {
/// A type representing the responsibility to execute the job in the `job` field.
/// This will poison the relevant query if dropped.
pub(super) struct JobOwner<'a, 'tcx: 'a, Q: QueryDescription<'tcx> + 'a> {
map: &'a Lock<QueryMap<'tcx, Q>>,
cache: &'a Lock<QueryCache<'tcx, Q>>,
key: Q::Key,
job: Lrc<QueryJob<'tcx>>,
}
@ -114,9 +113,9 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
span: Span,
key: &Q::Key,
) -> TryGetJob<'a, 'tcx, Q> {
let map = Q::query_map(tcx);
let cache = Q::query_cache(tcx);
loop {
let mut lock = map.borrow_mut();
let mut lock = cache.borrow_mut();
if let Some(value) = lock.results.get(key) {
profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
let result = Ok((value.value.clone(), value.index));
@ -138,7 +137,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
};
let job = Lrc::new(QueryJob::new(info, icx.query.clone()));
let owner = JobOwner {
map,
cache,
job: job.clone(),
key: (*key).clone(),
};
@ -155,20 +154,20 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
}
}
/// Completes the query by updating the query map with the `result`,
/// Completes the query by updating the query cache with the `result`,
/// signals the waiter and forgets the JobOwner, so it won't poison the query
pub(super) fn complete(self, result: &Q::Value, dep_node_index: DepNodeIndex) {
// We can move out of `self` here because we `mem::forget` it below
let key = unsafe { ptr::read(&self.key) };
let job = unsafe { ptr::read(&self.job) };
let map = self.map;
let cache = self.cache;
// Forget ourself so our destructor won't poison the query
mem::forget(self);
let value = QueryValue::new(result.clone(), dep_node_index);
{
let mut lock = map.borrow_mut();
let mut lock = cache.borrow_mut();
lock.active.remove(&key);
lock.results.insert(key, value);
}
@ -215,7 +214,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
impl<'a, 'tcx, Q: QueryDescription<'tcx>> Drop for JobOwner<'a, 'tcx, Q> {
fn drop(&mut self) {
// Poison the query so jobs waiting on it panic
self.map.borrow_mut().active.insert(self.key.clone(), QueryResult::Poisoned);
self.cache.borrow_mut().active.insert(self.key.clone(), QueryResult::Poisoned);
// Also signal the completion of the job, so waiters
// will continue execution
self.job.signal_complete();
@ -231,7 +230,7 @@ pub struct CycleError<'tcx> {
/// The result of `try_get_lock`
pub(super) enum TryGetJob<'a, 'tcx: 'a, D: QueryDescription<'tcx> + 'a> {
/// The query is not yet started. Contains a guard to the map eventually used to start it.
/// The query is not yet started. Contains a guard to the cache eventually used to start it.
NotYetStarted(JobOwner<'a, 'tcx, D>),
/// The query was already completed.
@ -392,7 +391,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.dep_graph.read_index(dep_node_index);
self.on_disk_query_result_cache
self.queries.on_disk_cache
.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
job.complete(&result, dep_node_index);
@ -546,7 +545,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
if dep_node.kind != ::dep_graph::DepKind::Null {
self.on_disk_query_result_cache
self.queries.on_disk_cache
.store_diagnostics(dep_node_index, diagnostics);
}
@ -562,7 +561,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// side-effects -- e.g., in order to report errors for erroneous programs.
///
/// Note: The optimization is only available during incr. comp.
pub fn ensure_query<Q: QueryDescription<'gcx>>(self, key: Q::Key) -> () {
pub(super) fn ensure_query<Q: QueryDescription<'gcx>>(self, key: Q::Key) -> () {
let dep_node = Q::to_dep_node(self, &key);
// Ensuring an "input" or anonymous query makes no sense
@ -595,10 +594,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.force_query_with_job::<Q>(key, job, dep_node)
}
pub fn try_get_query<Q: QueryDescription<'gcx>>(
pub(super) fn try_get_query<Q: QueryDescription<'gcx>>(
self,
span: Span,
key: Q::Key
key: Q::Key,
) -> Result<Q::Value, DiagnosticBuilder<'a>> {
match self.try_get_with::<Q>(span, key) {
Ok(e) => Ok(e),
@ -606,7 +605,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
pub fn get_query<Q: QueryDescription<'gcx>>(self, span: Span, key: Q::Key) -> Q::Value {
pub(super) fn get_query<Q: QueryDescription<'gcx>>(
self,
span: Span,
key: Q::Key,
) -> Q::Value {
self.try_get_query::<Q>(span, key).unwrap_or_else(|mut e| {
e.emit();
Q::handle_cycle_error(self)
@ -627,13 +630,14 @@ macro_rules! handle_cycle_error {
};
}
macro_rules! define_maps {
macro_rules! define_queries {
(<$tcx:tt>
$($(#[$attr:meta])*
[$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
use std::mem;
use ty::maps::job::QueryResult;
#[cfg(parallel_queries)]
use ty::query::job::QueryResult;
use rustc_data_structures::sync::Lock;
use {
rustc_data_structures::stable_hasher::HashStable,
@ -642,20 +646,24 @@ macro_rules! define_maps {
ich::StableHashingContext
};
define_map_struct! {
define_queries_struct! {
tcx: $tcx,
input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
}
impl<$tcx> Maps<$tcx> {
pub fn new(providers: IndexVec<CrateNum, Providers<$tcx>>)
-> Self {
Maps {
impl<$tcx> Queries<$tcx> {
pub fn new(
providers: IndexVec<CrateNum, Providers<$tcx>>,
on_disk_cache: OnDiskCache<'tcx>,
) -> Self {
Queries {
providers,
$($name: Lock::new(QueryMap::new())),*
on_disk_cache,
$($name: Lock::new(QueryCache::new())),*
}
}
#[cfg(parallel_queries)]
pub fn collect_active_jobs(&self) -> Vec<Lrc<QueryJob<$tcx>>> {
let mut jobs = Vec::new();
@ -750,13 +758,15 @@ macro_rules! define_maps {
type Value = $V;
const NAME: &'static str = stringify!($name);
}
impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
fn query(key: Self::Key) -> Query<'tcx> {
Query::$name(key)
}
fn query_map<'a>(tcx: TyCtxt<'a, $tcx, '_>) -> &'a Lock<QueryMap<$tcx, Self>> {
&tcx.maps.$name
fn query_cache<'a>(tcx: TyCtxt<'a, $tcx, '_>) -> &'a Lock<QueryCache<$tcx, Self>> {
&tcx.queries.$name
}
#[allow(unused)]
@ -769,7 +779,7 @@ macro_rules! define_maps {
#[inline]
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value {
__query_compute::$name(move || {
let provider = tcx.maps.providers[key.map_crate()].$name;
let provider = tcx.queries.providers[key.query_crate()].$name;
provider(tcx.global_tcx(), key)
})
}
@ -840,12 +850,18 @@ macro_rules! define_maps {
}
}
macro_rules! define_map_struct {
macro_rules! define_queries_struct {
(tcx: $tcx:tt,
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
pub struct Maps<$tcx> {
pub(crate) struct Queries<$tcx> {
/// This provides access to the incr. comp. on-disk cache for query results.
/// Do not access this directly. It is only meant to be used by
/// `DepGraph::try_mark_green()` and the query infrastructure.
pub(crate) on_disk_cache: OnDiskCache<'tcx>,
providers: IndexVec<CrateNum, Providers<$tcx>>,
$($(#[$attr])* $name: Lock<QueryMap<$tcx, queries::$name<$tcx>>>,)*
$($(#[$attr])* $name: Lock<QueryCache<$tcx, queries::$name<$tcx>>>,)*
}
};
}
@ -860,7 +876,7 @@ macro_rules! define_provider_struct {
impl<$tcx> Default for Providers<$tcx> {
fn default() -> Self {
$(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
bug!("tcx.maps.{}({:?}) unsupported by its crate",
bug!("tcx.{}({:?}) unsupported by its crate",
stringify!($name), key);
})*
Providers { $($name),* }
@ -960,11 +976,11 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
profq_msg!(tcx,
ProfileQueriesMsg::QueryBegin(
DUMMY_SP.data(),
profq_query_msg!(::ty::maps::queries::$query::NAME, tcx, $key),
profq_query_msg!(::ty::query::queries::$query::NAME, tcx, $key),
)
);
match tcx.force_query::<::ty::maps::queries::$query>($key, DUMMY_SP, *dep_node) {
match tcx.force_query::<::ty::query::queries::$query>($key, DUMMY_SP, *dep_node) {
Ok(_) => {},
Err(e) => {
tcx.report_cycle(e).emit();
@ -1201,15 +1217,15 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
// FIXME(#45015): Another piece of boilerplate code that could be generated in
// a combined define_dep_nodes!()/define_maps!() macro.
// a combined define_dep_nodes!()/define_queries!() macro.
macro_rules! impl_load_from_cache {
($($dep_kind:ident => $query_name:ident,)*) => {
impl DepNode {
// Check whether the query invocation corresponding to the given
// DepNode is eligible for on-disk-caching.
pub fn cache_on_disk(&self, tcx: TyCtxt) -> bool {
use ty::maps::queries;
use ty::maps::QueryDescription;
use ty::query::queries;
use ty::query::QueryDescription;
match self.kind {
$(DepKind::$dep_kind => {

View File

@ -18,7 +18,7 @@ use ich::NodeIdHashingMode;
use traits::{self, ObligationCause};
use ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable};
use ty::subst::{Substs, UnpackedKind};
use ty::maps::TyCtxtAt;
use ty::query::TyCtxtAt;
use ty::TypeVariants::*;
use ty::layout::{Integer, IntegerExt};
use util::common::ErrorReported;
@ -415,7 +415,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
return None;
};
ty::maps::queries::coherent_trait::ensure(self, drop_trait);
ty::query::queries::coherent_trait::ensure(self, drop_trait);
let mut dtor_did = None;
let ty = self.type_of(adt_did);
@ -883,7 +883,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let (param_env, ty) = query.into_parts();
let needs_drop = |ty: Ty<'tcx>| -> bool {
match tcx.try_get_query::<ty::queries::needs_drop_raw>(DUMMY_SP, param_env.and(ty)) {
match tcx.try_needs_drop_raw(DUMMY_SP, param_env.and(ty)) {
Ok(v) => v,
Err(mut bug) => {
// Cycles should be reported as an error by `check_representable`.
@ -1014,8 +1014,8 @@ impl<'tcx> ExplicitSelf<'tcx> {
}
}
pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
is_copy_raw,
is_sized_raw,
is_freeze_raw,

View File

@ -37,7 +37,7 @@ use rustc::middle::mem_categorization::ImmutabilityBlame;
use rustc::middle::region;
use rustc::middle::free_region::RegionRelations;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
use rustc::util::nodemap::FxHashSet;
@ -128,7 +128,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
// Note that `mir_validated` is a "stealable" result; the
// thief, `optimized_mir()`, forces borrowck, so we know that
// is not yet stolen.
ty::maps::queries::mir_validated::ensure(tcx, owner_def_id);
ty::query::queries::mir_validated::ensure(tcx, owner_def_id);
// option dance because you can't capture an uninitialized variable
// by mut-ref.

View File

@ -17,7 +17,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::session::Session;
use rustc::session::config::Sanitizer;
use rustc::ty::TyCtxt;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::PanicStrategy;

View File

@ -19,7 +19,7 @@ use rustc::ich::Fingerprint;
use rustc::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol, metadata_symbol_name};
use rustc::session::config;
use rustc::ty::{TyCtxt, SymbolName};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::util::nodemap::{FxHashMap, DefIdMap};
use rustc_allocator::ALLOCATOR_METHODS;

View File

@ -41,7 +41,7 @@ use rustc::mir::mono::{Linkage, Visibility, Stats};
use rustc::middle::cstore::{EncodedMetadata};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{self, Align, TyLayout, LayoutOf};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::dep_graph::{DepNode, DepConstructor};
use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
use rustc::middle::exported_symbols;

View File

@ -183,14 +183,14 @@ impl CodegenBackend for LlvmCodegenBackend {
box metadata::LlvmMetadataLoader
}
fn provide(&self, providers: &mut ty::maps::Providers) {
fn provide(&self, providers: &mut ty::query::Providers) {
back::symbol_names::provide(providers);
back::symbol_export::provide(providers);
base::provide(providers);
attributes::provide(providers);
}
fn provide_extern(&self, providers: &mut ty::maps::Providers) {
fn provide_extern(&self, providers: &mut ty::query::Providers) {
back::symbol_export::provide_extern(providers);
base::provide_extern(providers);
attributes::provide_extern(providers);

View File

@ -39,7 +39,7 @@ use rustc::hir::def_id::LOCAL_CRATE;
use rustc::session::{Session, CompileIncomplete};
use rustc::session::config::{CrateType, OutputFilenames, PrintRequest};
use rustc::ty::TyCtxt;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::middle::cstore::EncodedMetadata;
use rustc::middle::cstore::MetadataLoader;
use rustc::dep_graph::DepGraph;

View File

@ -103,7 +103,7 @@ use rustc::hir::map::definitions::DefPathData;
use rustc::ich::NodeIdHashingMode;
use rustc::middle::weak_lang_items;
use rustc::ty::item_path::{self, ItemPathBuffer, RootMode};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::util::common::record_time;

View File

@ -87,7 +87,7 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync::
let config = ThreadPoolBuilder::new()
.num_threads(Session::query_threads_from_opts(&opts))
.deadlock_handler(|| unsafe { ty::maps::handle_deadlock() })
.deadlock_handler(|| unsafe { ty::query::handle_deadlock() })
.stack_size(16 * 1024 * 1024);
let with_pool = move |pool: &ThreadPool| {
@ -399,10 +399,10 @@ pub struct CompileController<'a> {
/// Allows overriding default rustc query providers,
/// after `default_provide` has installed them.
pub provide: Box<Fn(&mut ty::maps::Providers) + 'a>,
pub provide: Box<Fn(&mut ty::query::Providers) + 'a>,
/// Same as `provide`, but only for non-local crates,
/// applied after `default_provide_extern`.
pub provide_extern: Box<Fn(&mut ty::maps::Providers) + 'a>,
pub provide_extern: Box<Fn(&mut ty::query::Providers) + 'a>,
}
impl<'a> CompileController<'a> {
@ -1140,7 +1140,7 @@ where
})
}
pub fn default_provide(providers: &mut ty::maps::Providers) {
pub fn default_provide(providers: &mut ty::query::Providers) {
hir::provide(providers);
borrowck::provide(providers);
mir::provide(providers);
@ -1158,7 +1158,7 @@ pub fn default_provide(providers: &mut ty::maps::Providers) {
lint::provide(providers);
}
pub fn default_provide_extern(providers: &mut ty::maps::Providers) {
pub fn default_provide_extern(providers: &mut ty::query::Providers) {
cstore::provide_extern(providers);
}
@ -1203,7 +1203,7 @@ where
time(sess, "loop checking", || loops::check_crate(sess, &hir_map));
let mut local_providers = ty::maps::Providers::default();
let mut local_providers = ty::query::Providers::default();
default_provide(&mut local_providers);
codegen_backend.provide(&mut local_providers);
(control.provide)(&mut local_providers);

View File

@ -20,7 +20,7 @@ use rustc::middle::region;
use rustc::ty::subst::Subst;
use rustc::traits::ObligationCause;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::ty::maps::OnDiskCache;
use rustc::ty::query::OnDiskCache;
use rustc::infer::{self, InferOk, InferResult};
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::infer::type_variable::TypeVariableOrigin;
@ -157,8 +157,8 @@ fn test_env_with_pool<F>(
};
TyCtxt::create_and_enter(&sess,
&cstore,
ty::maps::Providers::default(),
ty::maps::Providers::default(),
ty::query::Providers::default(),
ty::query::Providers::default(),
&arenas,
resolutions,
hir_map,

View File

@ -385,7 +385,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
// michaelwoerister and vitiral came up with a possible solution,
// to just do this before every query
// ```
// ::rustc::ty::maps::plumbing::force_from_dep_node(tcx, dep_node)
// ::rustc::ty::query::plumbing::force_from_dep_node(tcx, dep_node)
// ```
//
// However, this did not seem to work effectively and more bugs were hit.

View File

@ -14,7 +14,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc::dep_graph::{PreviousDepGraph, SerializedDepGraph, WorkProduct, WorkProductId};
use rustc::session::Session;
use rustc::ty::TyCtxt;
use rustc::ty::maps::OnDiskCache;
use rustc::ty::query::OnDiskCache;
use rustc::util::common::time_ext;
use rustc_serialize::Decodable as RustcDecodable;
use rustc_serialize::opaque::Decoder;

View File

@ -15,7 +15,7 @@ use native_libs;
use foreign_modules;
use schema;
use rustc::ty::maps::QueryConfig;
use rustc::ty::query::QueryConfig;
use rustc::middle::cstore::{CrateStore, DepKind,
MetadataLoader, LinkMeta,
LoadedMacro, EncodedMetadata, NativeLibraryKind};
@ -24,7 +24,7 @@ use rustc::middle::stability::DeprecationEntry;
use rustc::hir::def;
use rustc::session::{CrateDisambiguator, Session};
use rustc::ty::{self, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX};
use rustc::hir::map::{DefKey, DefPath, DefPathHash};
use rustc::hir::map::blocks::FnLikeNode;

View File

@ -16,7 +16,7 @@ use rustc::hir::def_id::DefId;
use rustc::hir::map::definitions::DefPathData;
use rustc::infer::InferCtxt;
use rustc::ty::{self, ParamEnv, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::lint::builtin::UNUSED_MUT;
use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
use rustc::mir::{ClearCrossCrate, Local, Location, Place, Mir, Mutability, Operand};

View File

@ -8,7 +8,7 @@ use rustc::mir;
use rustc::ty::layout::{self, Size, Align, HasDataLayout, IntegerExt, LayoutOf, TyLayout};
use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{self, Ty, TyCtxt, TypeAndMut};
use rustc::ty::maps::TyCtxtAt;
use rustc::ty::query::TyCtxtAt;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc::middle::const_val::FrameInfo;
use syntax::codemap::{self, Span};

View File

@ -4,7 +4,7 @@ use std::ptr;
use rustc::hir::def_id::DefId;
use rustc::ty::Instance;
use rustc::ty::ParamEnv;
use rustc::ty::maps::TyCtxtAt;
use rustc::ty::query::TyCtxtAt;
use rustc::ty::layout::{self, Align, TargetDataLayout, Size};
use syntax::ast::Mutability;
use rustc::middle::const_val::ConstVal;

View File

@ -67,7 +67,7 @@ pub mod interpret;
pub mod monomorphize;
pub use hair::pattern::check_crate as matchck_crate;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
pub fn provide(providers: &mut Providers) {
borrow_check::provide(providers);

View File

@ -14,7 +14,7 @@ use rustc::infer;
use rustc::mir::*;
use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind};
use rustc::ty::subst::{Subst, Substs};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};

View File

@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::sync::Lrc;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::{self, TyCtxt};
use rustc::hir;
use rustc::hir::def_id::DefId;

View File

@ -126,9 +126,8 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
continue;
}
let callee_mir = match self.tcx.try_get_query::<ty::queries::optimized_mir>(
callsite.location.span,
callsite.callee) {
let callee_mir = match self.tcx.try_optimized_mir(callsite.location.span,
callsite.callee) {
Ok(callee_mir) if self.should_inline(callsite, callee_mir) => {
self.tcx.subst_and_normalize_erasing_regions(
&callsite.substs,

View File

@ -13,7 +13,7 @@ use build;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::mir::{Mir, Promoted};
use rustc::ty::TyCtxt;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::steal::Steal;
use rustc::hir;
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};

View File

@ -24,7 +24,7 @@ use rustc::middle::const_val::ConstVal;
use rustc::traits::{self, TraitEngine};
use rustc::ty::{self, TyCtxt, Ty, TypeFoldable};
use rustc::ty::cast::CastTy;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::mir::*;
use rustc::mir::traversal::ReversePostorder;
use rustc::mir::visit::{PlaceContext, Visitor};

View File

@ -32,7 +32,7 @@ extern crate syntax;
extern crate syntax_pos;
extern crate rustc_errors as errors;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
mod diagnostics;

View File

@ -32,7 +32,7 @@ use rustc::middle::expr_use_visitor as euv;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::util::nodemap::{ItemLocalSet, NodeSet};
use rustc::hir;

View File

@ -31,7 +31,7 @@ use rustc::lint;
use rustc::middle::privacy::{AccessLevel, AccessLevels};
use rustc::ty::{self, TyCtxt, Ty, TypeFoldable, GenericParamDefKind};
use rustc::ty::fold::TypeVisitor;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::subst::UnpackedKind;
use rustc::util::nodemap::NodeSet;
use syntax::ast::{self, CRATE_NODE_ID, Ident};

View File

@ -36,7 +36,7 @@ mod normalize_erasing_regions;
mod util;
pub mod lowering;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
pub fn provide(p: &mut Providers) {
*p = Providers {

View File

@ -40,7 +40,7 @@ mod suggest;
use self::probe::{IsSuggestion, ProbeScope};
pub fn provide(providers: &mut ty::maps::Providers) {
pub fn provide(providers: &mut ty::query::Providers) {
suggest::provide(providers);
}

View File

@ -741,7 +741,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
traits
}
pub fn provide(providers: &mut ty::maps::Providers) {
pub fn provide(providers: &mut ty::query::Providers) {
providers.all_traits = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(compute_all_traits(tcx))

View File

@ -99,7 +99,7 @@ use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine};
use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind, Visibility, ToPredicate, RegionKind};
use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
use rustc::ty::fold::TypeFoldable;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::util::{Representability, IntTypeExt, Discr};
use errors::{DiagnosticBuilder, DiagnosticId};
@ -703,7 +703,7 @@ fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum
debug_assert!(crate_num == LOCAL_CRATE);
Ok(tcx.sess.track_errors(|| {
for body_owner_def_id in tcx.body_owners() {
ty::maps::queries::typeck_tables_of::ensure(tcx, body_owner_def_id);
ty::query::queries::typeck_tables_of::ensure(tcx, body_owner_def_id);
}
})?)
}

View File

@ -749,21 +749,21 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> {
fn visit_item(&mut self, i: &hir::Item) {
debug!("visit_item: {:?}", i);
let def_id = self.tcx.hir.local_def_id(i.id);
ty::maps::queries::check_item_well_formed::ensure(self.tcx, def_id);
ty::query::queries::check_item_well_formed::ensure(self.tcx, def_id);
intravisit::walk_item(self, i);
}
fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
debug!("visit_trait_item: {:?}", trait_item);
let def_id = self.tcx.hir.local_def_id(trait_item.id);
ty::maps::queries::check_trait_item_well_formed::ensure(self.tcx, def_id);
ty::query::queries::check_trait_item_well_formed::ensure(self.tcx, def_id);
intravisit::walk_trait_item(self, trait_item)
}
fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) {
debug!("visit_impl_item: {:?}", impl_item);
let def_id = self.tcx.hir.local_def_id(impl_item.id);
ty::maps::queries::check_impl_item_well_formed::ensure(self.tcx, def_id);
ty::query::queries::check_impl_item_well_formed::ensure(self.tcx, def_id);
intravisit::walk_impl_item(self, impl_item)
}
}

View File

@ -18,7 +18,7 @@
use hir::def_id::{DefId, LOCAL_CRATE};
use rustc::traits;
use rustc::ty::{self, TyCtxt, TypeFoldable};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use syntax::ast;
@ -127,15 +127,15 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
ty::maps::queries::coherent_trait::ensure(tcx, trait_def_id);
ty::query::queries::coherent_trait::ensure(tcx, trait_def_id);
}
unsafety::check(tcx);
orphan::check(tcx);
// these queries are executed for side-effects (error reporting):
ty::maps::queries::crate_inherent_impls::ensure(tcx, LOCAL_CRATE);
ty::maps::queries::crate_inherent_impls_overlap_check::ensure(tcx, LOCAL_CRATE);
ty::query::queries::crate_inherent_impls::ensure(tcx, LOCAL_CRATE);
ty::query::queries::crate_inherent_impls_overlap_check::ensure(tcx, LOCAL_CRATE);
}
/// Overlap: No two impls for the same trait are implemented for the

View File

@ -33,7 +33,7 @@ use rustc::mir::mono::Linkage;
use rustc::ty::subst::Substs;
use rustc::ty::{ToPredicate, ReprOptions};
use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::util::IntTypeExt;
use rustc::ty::util::Discr;
use rustc::util::captures::Captures;

View File

@ -104,7 +104,7 @@ use hir::map as hir_map;
use rustc::infer::InferOk;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::traits::{ObligationCause, ObligationCauseCode, TraitEngine};
use session::{CompileIncomplete, config};
use util::common::time;

View File

@ -11,7 +11,7 @@
use hir::map as hir_map;
use rustc::hir;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::ty::subst::UnpackedKind;
use rustc::ty::{self, CratePredicatesMap, TyCtxt};
use rustc_data_structures::sync::Lrc;

View File

@ -17,7 +17,7 @@ use arena;
use rustc::hir;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::{self, CrateVariancesMap, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc_data_structures::sync::Lrc;
/// Defines the `TermsContext` basically houses an arena where we can

View File

@ -20,7 +20,7 @@ use syntax::symbol::Symbol;
use rustc::session::{Session, CompileIncomplete};
use rustc::session::config::OutputFilenames;
use rustc::ty::TyCtxt;
use rustc::ty::maps::Providers;
use rustc::ty::query::Providers;
use rustc::middle::cstore::MetadataLoader;
use rustc::dep_graph::DepGraph;
use rustc_codegen_utils::codegen_backend::{CodegenBackend, MetadataOnlyCodegenBackend};