Skip to content

Commit a385095

Browse files
committed
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
2 parents 01fb32b + 5a5c7de commit a385095

File tree

57 files changed

+247
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+247
-209
lines changed

src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This directory contains the source code of the rust project, including:
66
For more information on how various parts of the compiler work, see the [rustc guide].
77

88
Their is also useful content in the following READMEs, which are gradually being moved over to the guide:
9-
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/maps
9+
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query
1010
- https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
1111
- https://github.com/rust-lang/rust/blob/master/src/librustc/infer/region_constraints
1212
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked

src/librustc/dep_graph/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl DepGraph {
656656
// We failed to mark it green, so we try to force the query.
657657
debug!("try_mark_green({:?}) --- trying to force \
658658
dependency {:?}", dep_node, dep_dep_node);
659-
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
659+
if ::ty::query::force_from_dep_node(tcx, dep_dep_node) {
660660
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node_index);
661661

662662
match dep_dep_node_color {
@@ -742,14 +742,14 @@ impl DepGraph {
742742
// and emit other diagnostics before these diagnostics are emitted.
743743
// Such diagnostics should be emitted after these.
744744
// See https://github.com/rust-lang/rust/issues/48685
745-
let diagnostics = tcx.on_disk_query_result_cache
745+
let diagnostics = tcx.queries.on_disk_cache
746746
.load_diagnostics(tcx, prev_dep_node_index);
747747

748748
if diagnostics.len() > 0 {
749749
let handle = tcx.sess.diagnostic();
750750

751751
// Promote the previous diagnostics to the current session.
752-
tcx.on_disk_query_result_cache
752+
tcx.queries.on_disk_cache
753753
.store_diagnostics(dep_node_index, diagnostics.clone());
754754

755755
for diagnostic in diagnostics {

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use syntax::tokenstream::TokenStream;
4545
use syntax::util::ThinVec;
4646
use syntax::util::parser::ExprPrecedence;
4747
use ty::AdtKind;
48-
use ty::maps::Providers;
48+
use ty::query::Providers;
4949

5050
use rustc_data_structures::indexed_vec;
5151
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};

src/librustc/lint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use syntax::symbol::Symbol;
4747
use syntax::visit as ast_visit;
4848
use syntax_pos::Span;
4949
use ty::TyCtxt;
50-
use ty::maps::Providers;
50+
use ty::query::Providers;
5151
use util::nodemap::NodeMap;
5252

5353
pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore,

src/librustc/middle/const_val.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use hir::def_id::DefId;
1212
use ty;
1313
use ty::subst::Substs;
14-
use ty::maps::TyCtxtAt;
14+
use ty::query::TyCtxtAt;
1515
use mir::interpret::ConstValue;
1616
use errors::DiagnosticBuilder;
1717

src/librustc/middle/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use hir::def::Def;
2121
use hir::def_id::{DefId, CrateNum};
2222
use rustc_data_structures::sync::Lrc;
2323
use ty::{self, TyCtxt};
24-
use ty::maps::Providers;
24+
use ty::query::Providers;
2525
use middle::privacy;
2626
use session::config;
2727
use util::nodemap::{NodeSet, FxHashSet};

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use syntax::codemap;
2727
use syntax::ast;
2828
use syntax_pos::{Span, DUMMY_SP};
2929
use ty::TyCtxt;
30-
use ty::maps::Providers;
30+
use ty::query::Providers;
3131

3232
use hir;
3333
use hir::def_id::DefId;

src/librustc/middle/resolve_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ type ScopeRef<'a> = &'a Scope<'a>;
349349

350350
const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
351351

352-
pub fn provide(providers: &mut ty::maps::Providers) {
353-
*providers = ty::maps::Providers {
352+
pub fn provide(providers: &mut ty::query::Providers) {
353+
*providers = ty::query::Providers {
354354
resolve_lifetimes,
355355

356356
named_region_map: |tcx, id| {

src/librustc/traits/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,8 @@ impl<'tcx> TraitObligation<'tcx> {
991991
}
992992
}
993993

994-
pub fn provide(providers: &mut ty::maps::Providers) {
995-
*providers = ty::maps::Providers {
994+
pub fn provide(providers: &mut ty::query::Providers) {
995+
*providers = ty::query::Providers {
996996
is_object_safe: object_safety::is_object_safe_provider,
997997
specialization_graph_of: specialize::specialization_graph_provider,
998998
specializes: specialize::specializes,

src/librustc/ty/context.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
4646
use ty::TypeVariants::*;
4747
use ty::GenericParamDefKind;
4848
use ty::layout::{LayoutDetails, TargetDataLayout};
49-
use ty::maps;
49+
use ty::query;
5050
use ty::steal::Steal;
5151
use ty::BindingMode;
5252
use ty::CanonicalTy;
@@ -863,11 +863,6 @@ pub struct GlobalCtxt<'tcx> {
863863

864864
pub dep_graph: DepGraph,
865865

866-
/// This provides access to the incr. comp. on-disk cache for query results.
867-
/// Do not access this directly. It is only meant to be used by
868-
/// `DepGraph::try_mark_green()` and the query infrastructure in `ty::maps`.
869-
pub(crate) on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
870-
871866
/// Common types, pre-interned for your convenience.
872867
pub types: CommonTypes<'tcx>,
873868

@@ -886,7 +881,7 @@ pub struct GlobalCtxt<'tcx> {
886881
/// as well as all upstream crates. Only populated in incremental mode.
887882
pub def_path_hash_to_def_id: Option<FxHashMap<DefPathHash, DefId>>,
888883

889-
pub maps: maps::Maps<'tcx>,
884+
pub(crate) queries: query::Queries<'tcx>,
890885

891886
// Records the free variables refrenced by every closure
892887
// expression. Do not track deps for this, just recompute it from
@@ -1074,12 +1069,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10741069
/// reference to the context, to allow formatting values that need it.
10751070
pub fn create_and_enter<F, R>(s: &'tcx Session,
10761071
cstore: &'tcx CrateStoreDyn,
1077-
local_providers: ty::maps::Providers<'tcx>,
1078-
extern_providers: ty::maps::Providers<'tcx>,
1072+
local_providers: ty::query::Providers<'tcx>,
1073+
extern_providers: ty::query::Providers<'tcx>,
10791074
arenas: &'tcx AllArenas<'tcx>,
10801075
resolutions: ty::Resolutions,
10811076
hir: hir_map::Map<'tcx>,
1082-
on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
1077+
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
10831078
crate_name: &str,
10841079
tx: mpsc::Sender<Box<dyn Any + Send>>,
10851080
output_filenames: &OutputFilenames,
@@ -1144,7 +1139,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11441139
global_arenas: &arenas.global,
11451140
global_interners: interners,
11461141
dep_graph: dep_graph.clone(),
1147-
on_disk_query_result_cache,
11481142
types: common_types,
11491143
trait_map,
11501144
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
@@ -1165,7 +1159,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11651159
.collect(),
11661160
hir,
11671161
def_path_hash_to_def_id,
1168-
maps: maps::Maps::new(providers),
1162+
queries: query::Queries::new(providers, on_disk_query_result_cache),
11691163
rcache: Lock::new(FxHashMap()),
11701164
selection_cache: traits::SelectionCache::new(),
11711165
evaluation_cache: traits::EvaluationCache::new(),
@@ -1343,7 +1337,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13431337
-> Result<(), E::Error>
13441338
where E: ty::codec::TyEncoder
13451339
{
1346-
self.on_disk_query_result_cache.serialize(self.global_tcx(), encoder)
1340+
self.queries.on_disk_cache.serialize(self.global_tcx(), encoder)
13471341
}
13481342

13491343
/// If true, we should use a naive AST walk to determine if match
@@ -1702,7 +1696,7 @@ pub mod tls {
17021696
use std::fmt;
17031697
use std::mem;
17041698
use syntax_pos;
1705-
use ty::maps;
1699+
use ty::query;
17061700
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
17071701
use rustc_data_structures::OnDrop;
17081702
use rustc_data_structures::sync::{self, Lrc, Lock};
@@ -1726,8 +1720,8 @@ pub mod tls {
17261720
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
17271721

17281722
/// The current query job, if any. This is updated by start_job in
1729-
/// ty::maps::plumbing when executing a query
1730-
pub query: Option<Lrc<maps::QueryJob<'gcx>>>,
1723+
/// ty::query::plumbing when executing a query
1724+
pub query: Option<Lrc<query::QueryJob<'gcx>>>,
17311725

17321726
/// Used to prevent layout from recursing too deeply.
17331727
pub layout_depth: usize,
@@ -2792,7 +2786,7 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
27922786
}
27932787
}
27942788

2795-
pub fn provide(providers: &mut ty::maps::Providers) {
2789+
pub fn provide(providers: &mut ty::query::Providers) {
27962790
// FIXME(#44234) - almost all of these queries have no sub-queries and
27972791
// therefore no actual inputs, they're just reading tables calculated in
27982792
// resolve! Does this work? Unsure! That's what the issue is about

0 commit comments

Comments
 (0)