Skip to content

Commit 5a5c7de

Browse files
committed
rustc: rename ty::maps to ty::query.
1 parent 7f20af0 commit 5a5c7de

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

+1-1
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

+3-3
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+2-2
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

+2-2
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

+11-17
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

src/librustc/ty/erase_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use ty::{self, Ty, TyCtxt};
1212
use ty::fold::{TypeFolder, TypeFoldable};
1313

14-
pub(super) fn provide(providers: &mut ty::maps::Providers) {
15-
*providers = ty::maps::Providers {
14+
pub(super) fn provide(providers: &mut ty::query::Providers) {
15+
*providers = ty::query::Providers {
1616
erase_regions_ty,
1717
..*providers
1818
};

src/librustc/ty/layout.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
194194
})
195195
}
196196

197-
pub fn provide(providers: &mut ty::maps::Providers) {
198-
*providers = ty::maps::Providers {
197+
pub fn provide(providers: &mut ty::query::Providers) {
198+
*providers = ty::query::Providers {
199199
layout_raw,
200200
..*providers
201201
};
@@ -1481,7 +1481,7 @@ impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
14811481
}
14821482
}
14831483

1484-
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
1484+
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'a, 'tcx, 'tcx>> {
14851485
type Ty = Ty<'tcx>;
14861486
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
14871487

@@ -1527,7 +1527,7 @@ impl TyCtxt<'a, 'tcx, '_> {
15271527
}
15281528
}
15291529

1530-
impl ty::maps::TyCtxtAt<'a, 'tcx, '_> {
1530+
impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
15311531
/// Computes the layout of a type. Note that this implicitly
15321532
/// executes in "reveal all" mode.
15331533
#[inline]

src/librustc/ty/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub use self::instance::{Instance, InstanceDef};
8585

8686
pub use self::trait_def::TraitDef;
8787

88-
pub use self::maps::queries;
88+
pub use self::query::queries;
8989

9090
pub mod adjustment;
9191
pub mod binding;
@@ -100,8 +100,8 @@ pub mod inhabitedness;
100100
pub mod item_path;
101101
pub mod layout;
102102
pub mod _match;
103-
pub mod maps;
104103
pub mod outlives;
104+
pub mod query;
105105
pub mod relate;
106106
pub mod steal;
107107
pub mod subst;
@@ -2175,7 +2175,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
21752175
/// Due to normalization being eager, this applies even if
21762176
/// the associated type is behind a pointer, e.g. issue #31299.
21772177
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] {
2178-
match tcx.try_get_query::<queries::adt_sized_constraint>(DUMMY_SP, self.did) {
2178+
match tcx.try_adt_sized_constraint(DUMMY_SP, self.did) {
21792179
Ok(tys) => tys,
21802180
Err(mut bug) => {
21812181
debug!("adt_sized_constraint: {:?} is recursive", self);
@@ -2917,12 +2917,12 @@ fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
29172917
}
29182918
}
29192919

2920-
pub fn provide(providers: &mut ty::maps::Providers) {
2920+
pub fn provide(providers: &mut ty::query::Providers) {
29212921
context::provide(providers);
29222922
erase_regions::provide(providers);
29232923
layout::provide(providers);
29242924
util::provide(providers);
2925-
*providers = ty::maps::Providers {
2925+
*providers = ty::query::Providers {
29262926
associated_item,
29272927
associated_item_def_ids,
29282928
adt_sized_constraint,

src/librustc/ty/maps/README.md renamed to src/librustc/ty/query/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ get to use the nice method-call-style syntax. Instead, you invoke
5555
using the `try_get` method, which looks roughly like this:
5656

5757
```rust
58-
use ty::maps::queries;
58+
use ty::query::queries;
5959
...
6060
match queries::type_of::try_get(tcx, DUMMY_SP, self.did) {
6161
Ok(result) => {
@@ -207,7 +207,7 @@ by the time you read this README, but at present it looks something
207207
like:
208208

209209
```
210-
define_maps! { <'tcx>
210+
define_queries! { <'tcx>
211211
/// Records the type of every item.
212212
[] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
213213
@@ -235,7 +235,7 @@ Let's go over them one by one:
235235
processed.
236236
- **Name of query:** the name of the query method
237237
(`tcx.type_of(..)`). Also used as the name of a struct
238-
(`ty::maps::queries::type_of`) that will be generated to represent
238+
(`ty::query::queries::type_of`) that will be generated to represent
239239
this query.
240240
- **Dep-node constructor:** indicates the constructor function that
241241
connects this query to incremental compilation. Typically, this is a
@@ -247,7 +247,7 @@ Let's go over them one by one:
247247
bottom of the file. This is typically used when the query key is
248248
not a def-id, or just not the type that the dep-node expects.
249249
- **Query key type:** the type of the argument to this query.
250-
This type must implement the `ty::maps::keys::Key` trait, which
250+
This type must implement the `ty::query::keys::Key` trait, which
251251
defines (for example) how to map it to a crate, and so forth.
252252
- **Result type of query:** the type produced by this query. This type
253253
should (a) not use `RefCell` or other interior mutability and (b) be
@@ -260,14 +260,14 @@ Let's go over them one by one:
260260

261261
So, to add a query:
262262

263-
- Add an entry to `define_maps!` using the format above.
263+
- Add an entry to `define_queries!` using the format above.
264264
- Possibly add a corresponding entry to the dep-node macro.
265265
- Link the provider by modifying the appropriate `provide` method;
266266
or add a new one if needed and ensure that `rustc_driver` is invoking it.
267267

268268
#### Query structs and descriptions
269269

270-
For each kind, the `define_maps` macro will generate a "query struct"
270+
For each kind, the `define_queries` macro will generate a "query struct"
271271
named after the query. This struct is a kind of a place-holder
272272
describing the query. Each such struct implements the
273273
`self::config::QueryConfig` trait, which has associated types for the

0 commit comments

Comments
 (0)