diff --git a/src/README.md b/src/README.md index 690ab674c64..6da4944c392 100644 --- a/src/README.md +++ b/src/README.md @@ -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 diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 26470ddc82a..2390d7eccce 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -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 { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index b7c66398f85..a0952720945 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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}; diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 56b7da4c5da..9338e235c53 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -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, diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs index 88275b3c18c..2fa77be644e 100644 --- a/src/librustc/middle/const_val.rs +++ b/src/librustc/middle/const_val.rs @@ -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; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 249651ef65d..6b47a90079a 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -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}; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 0ba204dc206..e478f493647 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -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; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 14c1993e28e..781d48e2123 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -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| { diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index e284b3fc75a..761de001438 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -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, diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index e66ad242310..4433394d271 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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>, - 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(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>, 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>>, + /// ty::query::plumbing when executing a query + pub query: Option>>, /// Used to prevent layout from recursing too deeply. pub layout_depth: usize, @@ -2792,7 +2786,7 @@ impl InternIteratorElement for Result { } } -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 diff --git a/src/librustc/ty/erase_regions.rs b/src/librustc/ty/erase_regions.rs index f483b4c174a..2fb2154ce6b 100644 --- a/src/librustc/ty/erase_regions.rs +++ b/src/librustc/ty/erase_regions.rs @@ -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 }; diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 499398abcf9..f5c2a0c3f9f 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -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, 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] diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index f947ed45686..2758503c60c 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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::(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, diff --git a/src/librustc/ty/maps/README.md b/src/librustc/ty/query/README.md similarity index 97% rename from src/librustc/ty/maps/README.md rename to src/librustc/ty/query/README.md index 8207c18e677..ca6f0b77b66 100644 --- a/src/librustc/ty/maps/README.md +++ b/src/librustc/ty/query/README.md @@ -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 diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/query/config.rs similarity index 96% rename from src/librustc/ty/maps/config.rs rename to src/librustc/ty/query/config.rs index 19c97a918bb..cc00e9a00ab 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/query/config.rs @@ -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>; +} +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>; + fn query_cache<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock>; 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 { - 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 { - 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 { - 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 { - 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 { let typeck_tables: Option> = 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 { - 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 { - let generics: Option = tcx.on_disk_query_result_cache + let generics: Option = 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 { - tcx.on_disk_query_result_cache.try_load_query_result(tcx, id) + tcx.queries.on_disk_cache.try_load_query_result(tcx, id) } } } diff --git a/src/librustc/ty/maps/job.rs b/src/librustc/ty/query/job.rs similarity index 99% rename from src/librustc/ty/maps/job.rs rename to src/librustc/ty/query/job.rs index 3da73d47a0b..a54deeca293 100644 --- a/src/librustc/ty/maps/job.rs +++ b/src/librustc/ty/query/job.rs @@ -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; diff --git a/src/librustc/ty/maps/keys.rs b/src/librustc/ty/query/keys.rs similarity index 81% rename from src/librustc/ty/maps/keys.rs rename to src/librustc/ty/query/keys.rs index 3510a1b7a02..279d5ebb990 100644 --- a/src/librustc/ty/maps/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -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 } diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/query/mod.rs similarity index 94% rename from src/librustc/ty/maps/mod.rs rename to src/librustc/ty/query/mod.rs index 4aead315a80..f19bc01e198 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -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>, } +// `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::(span, key) + } + pub fn try_needs_drop_raw( + self, + span: Span, + key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, + ) -> Result> { + self.try_get_query::(span, key) + } + pub fn try_optimized_mir( + self, + span: Span, + key: DefId, + ) -> Result<&'tcx mir::Mir<'tcx>, DiagnosticBuilder<'a>> { + self.try_get_query::(span, key) + } +} + ////////////////////////////////////////////////////////////////////// // These functions are little shims used to find the dep-node for a // given query when there is not a *direct* mapping: diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs similarity index 99% rename from src/librustc/ty/maps/on_disk_cache.rs rename to src/librustc/ty/query/on_disk_cache.rs index cd317ff6cdb..3285380c823 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -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::(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()) { diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/query/plumbing.rs similarity index 94% rename from src/librustc/ty/maps/plumbing.rs rename to src/librustc/ty/query/plumbing.rs index 44eb0dfdb8c..4679c265d58 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -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>, pub(super) active: FxHashMap>, } @@ -56,9 +55,9 @@ impl QueryValue { } } -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>, + cache: &'a Lock>, key: Q::Key, job: Lrc>, } @@ -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>(self, key: Q::Key) -> () { + pub(super) fn ensure_query>(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::(key, job, dep_node) } - pub fn try_get_query>( + pub(super) fn try_get_query>( self, span: Span, - key: Q::Key + key: Q::Key, ) -> Result> { match self.try_get_with::(span, key) { Ok(e) => Ok(e), @@ -606,7 +605,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - pub fn get_query>(self, span: Span, key: Q::Key) -> Q::Value { + pub(super) fn get_query>( + self, + span: Span, + key: Q::Key, + ) -> Q::Value { self.try_get_query::(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>) - -> Self { - Maps { + impl<$tcx> Queries<$tcx> { + pub fn new( + providers: IndexVec>, + 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>> { 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> { - &tcx.maps.$name + fn query_cache<'a>(tcx: TyCtxt<'a, $tcx, '_>) -> &'a Lock> { + &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>, - $($(#[$attr])* $name: Lock>>,)* + + $($(#[$attr])* $name: Lock>>,)* } }; } @@ -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 => { diff --git a/src/librustc/ty/maps/values.rs b/src/librustc/ty/query/values.rs similarity index 100% rename from src/librustc/ty/maps/values.rs rename to src/librustc/ty/query/values.rs diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 9ef3308efe6..20ebd620625 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -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::(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, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index e063880028f..11d35def007 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -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. diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index d6806e7afd3..a5d04c5c576 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -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; diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs index 81ac684aee2..28e76a80513 100644 --- a/src/librustc_codegen_llvm/back/symbol_export.rs +++ b/src/librustc_codegen_llvm/back/symbol_export.rs @@ -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; diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 8660c0bcc6c..322924535d1 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -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; diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 0b0bab96dfd..8732e115fd2 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -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); diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 15aab680289..8ba6f30cf16 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -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; diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 123816c1f97..dcb82e5c424 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -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; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 37f8bff964f..5d5baf76549 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -87,7 +87,7 @@ pub fn spawn_thread_pool 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, + pub provide: Box, /// Same as `provide`, but only for non-local crates, /// applied after `default_provide_extern`. - pub provide_extern: Box, + pub provide_extern: Box, } 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); diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 206e58b3e2e..17e0472bda9 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -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( }; 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, diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 1549ef5e928..eeb87e41757 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -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. diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index f846759545e..9ee3b216dcf 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -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; diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 4691027e3b1..b33d97cb1ee 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -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; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index ba0557d062f..c43ea0360ee 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -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}; diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 3e91fa72cae..ea667273ece 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -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}; diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index ec308c2193d..ad571fbe90d 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -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; diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 34eb444fdc0..d815d4a7dba 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -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); diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index d4a9b2cdd1f..f11d80201c2 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -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}; diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 4c282f037a5..5f8f9acae83 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -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; diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index a1845f7ef26..cb57dc572fa 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -126,9 +126,8 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { continue; } - let callee_mir = match self.tcx.try_get_query::( - 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, diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index e2f2312dbd2..06be2bb3734 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -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}; diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index f3fba5b47be..6448ba17e34 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -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}; diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index b6b5edc0940..41f1e782965 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -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; diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 82ac112b534..51b2988023b 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -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; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index f32f6eda8ff..308c5b9f201 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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}; diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index 7fa69cb9833..c3135439204 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -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 { diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 169caf1f672..a51876d7960 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -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); } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 86cd8d0fb2c..90680b4156e 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -741,7 +741,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec 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)) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 533faadc3a4..7dcd6d1a3b3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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); } })?) } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 65725bfb95d..7a2c38468e0 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -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) } } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 07b7c600b9f..e92349040e8 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -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 diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a982724f957..05256be6ec9 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 5b7d92944ed..ce7249bd7b5 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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; diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index b5ba59d64cd..c6c7e8f931f 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -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; diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index fd2b964103a..adea9788b3c 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -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 diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 251fb78a985..439bc017fee 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -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};