Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 11 additions & 17 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>,

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

pub maps: maps::Maps<'tcx>,
pub(crate) queries: query::Queries<'tcx>,

// Records the free variables refrenced by every closure
// expression. Do not track deps for this, just recompute it from
Expand Down Expand Up @@ -1074,12 +1069,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// reference to the context, to allow formatting values that need it.
pub fn create_and_enter<F, R>(s: &'tcx Session,
cstore: &'tcx CrateStoreDyn,
local_providers: ty::maps::Providers<'tcx>,
extern_providers: ty::maps::Providers<'tcx>,
local_providers: ty::query::Providers<'tcx>,
extern_providers: ty::query::Providers<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
resolutions: ty::Resolutions,
hir: hir_map::Map<'tcx>,
on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
crate_name: &str,
tx: mpsc::Sender<Box<dyn Any + Send>>,
output_filenames: &OutputFilenames,
Expand Down Expand Up @@ -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)| {
Expand All @@ -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(),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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};
Expand All @@ -1726,8 +1720,8 @@ pub mod tls {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,

/// The current query job, if any. This is updated by start_job in
/// ty::maps::plumbing when executing a query
pub query: Option<Lrc<maps::QueryJob<'gcx>>>,
/// ty::query::plumbing when executing a query
pub query: Option<Lrc<query::QueryJob<'gcx>>>,

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

pub fn provide(providers: &mut ty::maps::Providers) {
pub fn provide(providers: &mut ty::query::Providers) {
// FIXME(#44234) - almost all of these queries have no sub-queries and
// therefore no actual inputs, they're just reading tables calculated in
// resolve! Does this work? Unsure! That's what the issue is about
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -1481,7 +1481,7 @@ impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}
}

impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'a, 'tcx, 'tcx>> {
type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;

Expand Down Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -2175,7 +2175,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
/// Due to normalization being eager, this applies even if
/// the associated type is behind a pointer, e.g. issue #31299.
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] {
match tcx.try_get_query::<queries::adt_sized_constraint>(DUMMY_SP, self.did) {
match tcx.try_adt_sized_constraint(DUMMY_SP, self.did) {
Ok(tys) => tys,
Err(mut bug) => {
debug!("adt_sized_constraint: {:?} is recursive", self);
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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>,

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading