diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 910176a0689c7..62f1744502368 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -4,7 +4,7 @@ use rustc_errors::{Applicability, StashKey, Suggestions}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::VisitorExt; use rustc_hir::{self as hir, AmbigArg, HirId}; -use rustc_middle::query::plumbing::CyclePlaceholder; +use rustc_middle::query::system::CyclePlaceholder; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, DefiningScopeKind, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/macros.rs similarity index 57% rename from compiler/rustc_middle/src/query/plumbing.rs rename to compiler/rustc_middle/src/query/macros.rs index b21db6eeeea07..bd0b1f666f35c 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/macros.rs @@ -1,179 +1,3 @@ -use std::ops::Deref; - -use rustc_data_structures::sync::{AtomicU64, WorkerLocal}; -use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::hir_id::OwnerId; -use rustc_macros::HashStable; -use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; -pub(crate) use rustc_query_system::query::QueryJobId; -use rustc_query_system::query::{CycleError, CycleErrorHandling, HashResult, QueryCache}; -use rustc_span::{ErrorGuaranteed, Span}; -pub use sealed::IntoQueryParam; - -use crate::dep_graph; -use crate::dep_graph::DepKind; -use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; -use crate::query::{ - ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, -}; -use crate::ty::TyCtxt; - -pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool; - -pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn( - tcx: TyCtxt<'tcx>, - key: &Key, - prev_index: SerializedDepNodeIndex, - index: DepNodeIndex, -) -> Option; - -pub type IsLoadableFromDiskFn<'tcx, Key> = - fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool; - -/// Stores function pointers and other metadata for a particular query. -/// -/// Used indirectly by query plumbing in `rustc_query_system`, via a trait. -pub struct QueryVTable<'tcx, C: QueryCache> { - pub name: &'static str, - pub eval_always: bool, - pub dep_kind: DepKind, - /// How this query deals with query cycle errors. - pub cycle_error_handling: CycleErrorHandling, - // Offset of this query's state field in the QueryStates struct - pub query_state: usize, - // Offset of this query's cache field in the QueryCaches struct - pub query_cache: usize, - pub will_cache_on_disk_for_key_fn: Option>, - pub execute_query: fn(tcx: TyCtxt<'tcx>, k: C::Key) -> C::Value, - pub compute: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value, - pub try_load_from_disk_fn: Option>, - pub is_loadable_from_disk_fn: Option>, - pub hash_result: HashResult, - pub value_from_cycle_error: - fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value, - pub format_value: fn(&C::Value) -> String, -} - -pub struct QuerySystemFns { - pub engine: QueryEngine, - pub local_providers: Providers, - pub extern_providers: ExternProviders, - pub encode_query_results: for<'tcx> fn( - tcx: TyCtxt<'tcx>, - encoder: &mut CacheEncoder<'_, 'tcx>, - query_result_index: &mut EncodedDepNodeIndex, - ), - pub try_mark_green: for<'tcx> fn(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool, -} - -pub struct QuerySystem<'tcx> { - pub states: QueryStates<'tcx>, - pub arenas: WorkerLocal>, - pub caches: QueryCaches<'tcx>, - pub query_vtables: PerQueryVTables<'tcx>, - - /// This provides access to the incremental compilation 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. - /// This is `None` if we are not incremental compilation mode - pub on_disk_cache: Option, - - pub fns: QuerySystemFns, - - pub jobs: AtomicU64, -} - -#[derive(Copy, Clone)] -pub struct TyCtxtAt<'tcx> { - pub tcx: TyCtxt<'tcx>, - pub span: Span, -} - -impl<'tcx> Deref for TyCtxtAt<'tcx> { - type Target = TyCtxt<'tcx>; - #[inline(always)] - fn deref(&self) -> &Self::Target { - &self.tcx - } -} - -#[derive(Copy, Clone)] -#[must_use] -pub struct TyCtxtEnsureOk<'tcx> { - pub tcx: TyCtxt<'tcx>, -} - -#[derive(Copy, Clone)] -#[must_use] -pub struct TyCtxtEnsureDone<'tcx> { - pub tcx: TyCtxt<'tcx>, -} - -impl<'tcx> TyCtxt<'tcx> { - /// Wrapper that calls queries in a special "ensure OK" mode, for callers - /// that don't need the return value and just want to invoke a query for - /// its potential side-effect of emitting fatal errors. - /// - /// This can be more efficient than a normal query call, because if the - /// query's inputs are all green, the call can return immediately without - /// needing to obtain a value (by decoding one from disk or by executing - /// the query). - /// - /// (As with all query calls, execution is also skipped if the query result - /// is already cached in memory.) - /// - /// ## WARNING - /// A subsequent normal call to the same query might still cause it to be - /// executed! This can occur when the inputs are all green, but the query's - /// result is not cached on disk, so the query must be executed to obtain a - /// return value. - /// - /// Therefore, this call mode is not appropriate for callers that want to - /// ensure that the query is _never_ executed in the future. - /// - /// ## `return_result_from_ensure_ok` - /// If a query has the `return_result_from_ensure_ok` modifier, calls via - /// `ensure_ok` will instead return `Result<(), ErrorGuaranteed>`. If the - /// query needs to be executed, and execution returns an error, that error - /// is returned to the caller. - #[inline(always)] - pub fn ensure_ok(self) -> TyCtxtEnsureOk<'tcx> { - TyCtxtEnsureOk { tcx: self } - } - - /// Wrapper that calls queries in a special "ensure done" mode, for callers - /// that don't need the return value and just want to guarantee that the - /// query won't be executed in the future, by executing it now if necessary. - /// - /// This is useful for queries that read from a [`Steal`] value, to ensure - /// that they are executed before the query that will steal the value. - /// - /// Unlike [`Self::ensure_ok`], a query with all-green inputs will only be - /// skipped if its return value is stored in the disk-cache. This is still - /// more efficient than a regular query, because in that situation the - /// return value doesn't necessarily need to be decoded. - /// - /// (As with all query calls, execution is also skipped if the query result - /// is already cached in memory.) - /// - /// [`Steal`]: rustc_data_structures::steal::Steal - #[inline(always)] - pub fn ensure_done(self) -> TyCtxtEnsureDone<'tcx> { - TyCtxtEnsureDone { tcx: self } - } - - /// Returns a transparent wrapper for `TyCtxt` which uses - /// `span` as the location of queries performed through it. - #[inline(always)] - pub fn at(self, span: Span) -> TyCtxtAt<'tcx> { - TyCtxtAt { tcx: self, span } - } - - pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool { - (self.query_system.fns.try_mark_green)(self, dep_node) - } -} - /// Calls either `query_ensure` or `query_ensure_error_guaranteed`, depending /// on whether the list of modifiers contains `return_result_from_ensure_ok`. macro_rules! query_ensure_select { @@ -252,7 +76,7 @@ macro_rules! separate_provide_extern_default { () }; ([(separate_provide_extern) $($rest:tt)*][$name:ident]) => { - |_, key| $crate::query::plumbing::default_extern_query(stringify!($name), &key) + |_, key| $crate::query::system::default_extern_query(stringify!($name), &key) }; ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { separate_provide_extern_default!([$($modifiers)*][$($args)*]) @@ -438,7 +262,7 @@ macro_rules! define_callbacks { /// ("Per" just makes this pluralized name more visually distinct.) pub struct PerQueryVTables<'tcx> { $( - pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, queries::$name::Storage<'tcx>>, + pub $name: ::rustc_middle::query::system::QueryVTable<'tcx, queries::$name::Storage<'tcx>>, )* } @@ -463,7 +287,7 @@ macro_rules! define_callbacks { impl Default for Providers { fn default() -> Self { Providers { - $($name: |_, key| $crate::query::plumbing::default_query(stringify!($name), &key)),* + $($name: |_, key| $crate::query::system::default_query(stringify!($name), &key)),* } } } @@ -548,94 +372,3 @@ macro_rules! define_feedable { // (error) value if the query resulted in a query cycle. // Queries marked with `cycle_fatal` do not need the latter implementation, // as they will raise an fatal error on query cycles instead. - -mod sealed { - use rustc_hir::def_id::{LocalModDefId, ModDefId}; - - use super::{DefId, LocalDefId, OwnerId}; - - /// An analogue of the `Into` trait that's intended only for query parameters. - /// - /// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the - /// user call `to_def_id` to convert between them everywhere else. - pub trait IntoQueryParam

{ - fn into_query_param(self) -> P; - } - - impl

IntoQueryParam

for P { - #[inline(always)] - fn into_query_param(self) -> P { - self - } - } - - impl<'a, P: Copy> IntoQueryParam

for &'a P { - #[inline(always)] - fn into_query_param(self) -> P { - *self - } - } - - impl IntoQueryParam for OwnerId { - #[inline(always)] - fn into_query_param(self) -> LocalDefId { - self.def_id - } - } - - impl IntoQueryParam for LocalDefId { - #[inline(always)] - fn into_query_param(self) -> DefId { - self.to_def_id() - } - } - - impl IntoQueryParam for OwnerId { - #[inline(always)] - fn into_query_param(self) -> DefId { - self.to_def_id() - } - } - - impl IntoQueryParam for ModDefId { - #[inline(always)] - fn into_query_param(self) -> DefId { - self.to_def_id() - } - } - - impl IntoQueryParam for LocalModDefId { - #[inline(always)] - fn into_query_param(self) -> DefId { - self.to_def_id() - } - } - - impl IntoQueryParam for LocalModDefId { - #[inline(always)] - fn into_query_param(self) -> LocalDefId { - self.into() - } - } -} - -#[derive(Copy, Clone, Debug, HashStable)] -pub struct CyclePlaceholder(pub ErrorGuaranteed); - -#[cold] -pub(crate) fn default_query(name: &str, key: &dyn std::fmt::Debug) -> ! { - bug!( - "`tcx.{name}({key:?})` is not supported for this key;\n\ - hint: Queries can be either made to the local crate, or the external crate. \ - This error means you tried to use it for one that's not supported.\n\ - If that's not the case, {name} was likely never assigned to a provider function.\n", - ) -} - -#[cold] -pub(crate) fn default_extern_query(name: &str, key: &dyn std::fmt::Debug) -> ! { - bug!( - "`tcx.{name}({key:?})` unsupported by its crate; \ - perhaps the `{name}` query was never assigned a provider function", - ) -} diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index cea50f95df4b4..2c4bc63139371 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -102,7 +102,7 @@ use rustc_target::spec::PanicStrategy; use {rustc_abi as abi, rustc_ast as ast, rustc_hir as hir}; pub use self::keys::{AsLocalKey, Key, LocalCrate}; -pub use self::plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk}; +pub use self::system::{IntoQueryParam, TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk}; use crate::infer::canonical::{self, Canonical}; use crate::lint::LintExpectation; use crate::metadata::ModChild; @@ -121,7 +121,7 @@ use crate::mir::interpret::{ use crate::mir::mono::{ CodegenUnit, CollectionMode, MonoItem, MonoItemPartitions, NormalizationErrorInMono, }; -use crate::query::plumbing::CyclePlaceholder; +use crate::query::system::CyclePlaceholder; use crate::traits::query::{ CanonicalAliasGoal, CanonicalDropckOutlivesGoal, CanonicalImpliedOutlivesBoundsGoal, CanonicalMethodAutoderefStepsGoal, CanonicalPredicateGoal, CanonicalTypeOpAscribeUserTypeGoal, @@ -148,8 +148,9 @@ pub mod erase; pub(crate) mod inner; mod keys; pub mod on_disk_cache; +pub mod system; #[macro_use] -pub mod plumbing; +pub mod macros; // Each of these queries corresponds to a function pointer field in the // `Providers` struct for requesting a value of that type, and a method diff --git a/compiler/rustc_middle/src/query/system.rs b/compiler/rustc_middle/src/query/system.rs new file mode 100644 index 0000000000000..10d157d6dc356 --- /dev/null +++ b/compiler/rustc_middle/src/query/system.rs @@ -0,0 +1,266 @@ +use std::ops::Deref; + +use rustc_data_structures::sync::{AtomicU64, WorkerLocal}; +use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::hir_id::OwnerId; +use rustc_macros::HashStable; +use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; +pub(crate) use rustc_query_system::query::QueryJobId; +use rustc_query_system::query::{CycleError, CycleErrorHandling, HashResult, QueryCache}; +use rustc_span::{ErrorGuaranteed, Span}; +pub use sealed::IntoQueryParam; + +use crate::dep_graph; +use crate::dep_graph::DepKind; +use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; +use crate::query::{ + ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, +}; +use crate::ty::TyCtxt; + +pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool; + +pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn( + tcx: TyCtxt<'tcx>, + key: &Key, + prev_index: SerializedDepNodeIndex, + index: DepNodeIndex, +) -> Option; + +pub type IsLoadableFromDiskFn<'tcx, Key> = + fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool; + +/// Stores function pointers and other metadata for a particular query. +/// +/// Used indirectly by query plumbing in `rustc_query_system`, via a trait. +pub struct QueryVTable<'tcx, C: QueryCache> { + pub name: &'static str, + pub eval_always: bool, + pub dep_kind: DepKind, + /// How this query deals with query cycle errors. + pub cycle_error_handling: CycleErrorHandling, + // Offset of this query's state field in the QueryStates struct + pub query_state: usize, + // Offset of this query's cache field in the QueryCaches struct + pub query_cache: usize, + pub will_cache_on_disk_for_key_fn: Option>, + pub execute_query: fn(tcx: TyCtxt<'tcx>, k: C::Key) -> C::Value, + pub compute: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value, + pub try_load_from_disk_fn: Option>, + pub is_loadable_from_disk_fn: Option>, + pub hash_result: HashResult, + pub value_from_cycle_error: + fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value, + pub format_value: fn(&C::Value) -> String, +} + +pub struct QuerySystemFns { + pub engine: QueryEngine, + pub local_providers: Providers, + pub extern_providers: ExternProviders, + pub encode_query_results: for<'tcx> fn( + tcx: TyCtxt<'tcx>, + encoder: &mut CacheEncoder<'_, 'tcx>, + query_result_index: &mut EncodedDepNodeIndex, + ), + pub try_mark_green: for<'tcx> fn(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool, +} + +pub struct QuerySystem<'tcx> { + pub states: QueryStates<'tcx>, + pub arenas: WorkerLocal>, + pub caches: QueryCaches<'tcx>, + pub query_vtables: PerQueryVTables<'tcx>, + + /// This provides access to the incremental compilation 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. + /// This is `None` if we are not incremental compilation mode + pub on_disk_cache: Option, + + pub fns: QuerySystemFns, + + pub jobs: AtomicU64, +} + +#[derive(Copy, Clone)] +pub struct TyCtxtAt<'tcx> { + pub tcx: TyCtxt<'tcx>, + pub span: Span, +} + +impl<'tcx> Deref for TyCtxtAt<'tcx> { + type Target = TyCtxt<'tcx>; + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.tcx + } +} + +#[derive(Copy, Clone)] +#[must_use] +pub struct TyCtxtEnsureOk<'tcx> { + pub tcx: TyCtxt<'tcx>, +} + +#[derive(Copy, Clone)] +#[must_use] +pub struct TyCtxtEnsureDone<'tcx> { + pub tcx: TyCtxt<'tcx>, +} + +impl<'tcx> TyCtxt<'tcx> { + /// Wrapper that calls queries in a special "ensure OK" mode, for callers + /// that don't need the return value and just want to invoke a query for + /// its potential side-effect of emitting fatal errors. + /// + /// This can be more efficient than a normal query call, because if the + /// query's inputs are all green, the call can return immediately without + /// needing to obtain a value (by decoding one from disk or by executing + /// the query). + /// + /// (As with all query calls, execution is also skipped if the query result + /// is already cached in memory.) + /// + /// ## WARNING + /// A subsequent normal call to the same query might still cause it to be + /// executed! This can occur when the inputs are all green, but the query's + /// result is not cached on disk, so the query must be executed to obtain a + /// return value. + /// + /// Therefore, this call mode is not appropriate for callers that want to + /// ensure that the query is _never_ executed in the future. + /// + /// ## `return_result_from_ensure_ok` + /// If a query has the `return_result_from_ensure_ok` modifier, calls via + /// `ensure_ok` will instead return `Result<(), ErrorGuaranteed>`. If the + /// query needs to be executed, and execution returns an error, that error + /// is returned to the caller. + #[inline(always)] + pub fn ensure_ok(self) -> TyCtxtEnsureOk<'tcx> { + TyCtxtEnsureOk { tcx: self } + } + + /// Wrapper that calls queries in a special "ensure done" mode, for callers + /// that don't need the return value and just want to guarantee that the + /// query won't be executed in the future, by executing it now if necessary. + /// + /// This is useful for queries that read from a [`Steal`] value, to ensure + /// that they are executed before the query that will steal the value. + /// + /// Unlike [`Self::ensure_ok`], a query with all-green inputs will only be + /// skipped if its return value is stored in the disk-cache. This is still + /// more efficient than a regular query, because in that situation the + /// return value doesn't necessarily need to be decoded. + /// + /// (As with all query calls, execution is also skipped if the query result + /// is already cached in memory.) + /// + /// [`Steal`]: rustc_data_structures::steal::Steal + #[inline(always)] + pub fn ensure_done(self) -> TyCtxtEnsureDone<'tcx> { + TyCtxtEnsureDone { tcx: self } + } + + /// Returns a transparent wrapper for `TyCtxt` which uses + /// `span` as the location of queries performed through it. + #[inline(always)] + pub fn at(self, span: Span) -> TyCtxtAt<'tcx> { + TyCtxtAt { tcx: self, span } + } + + pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool { + (self.query_system.fns.try_mark_green)(self, dep_node) + } +} + +mod sealed { + use rustc_hir::def_id::{LocalModDefId, ModDefId}; + + use super::{DefId, LocalDefId, OwnerId}; + + /// An analogue of the `Into` trait that's intended only for query parameters. + /// + /// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the + /// user call `to_def_id` to convert between them everywhere else. + pub trait IntoQueryParam

{ + fn into_query_param(self) -> P; + } + + impl

IntoQueryParam

for P { + #[inline(always)] + fn into_query_param(self) -> P { + self + } + } + + impl<'a, P: Copy> IntoQueryParam

for &'a P { + #[inline(always)] + fn into_query_param(self) -> P { + *self + } + } + + impl IntoQueryParam for OwnerId { + #[inline(always)] + fn into_query_param(self) -> LocalDefId { + self.def_id + } + } + + impl IntoQueryParam for LocalDefId { + #[inline(always)] + fn into_query_param(self) -> DefId { + self.to_def_id() + } + } + + impl IntoQueryParam for OwnerId { + #[inline(always)] + fn into_query_param(self) -> DefId { + self.to_def_id() + } + } + + impl IntoQueryParam for ModDefId { + #[inline(always)] + fn into_query_param(self) -> DefId { + self.to_def_id() + } + } + + impl IntoQueryParam for LocalModDefId { + #[inline(always)] + fn into_query_param(self) -> DefId { + self.to_def_id() + } + } + + impl IntoQueryParam for LocalModDefId { + #[inline(always)] + fn into_query_param(self) -> LocalDefId { + self.into() + } + } +} + +#[derive(Copy, Clone, Debug, HashStable)] +pub struct CyclePlaceholder(pub ErrorGuaranteed); + +#[cold] +pub(crate) fn default_query(name: &str, key: &dyn std::fmt::Debug) -> ! { + bug!( + "`tcx.{name}({key:?})` is not supported for this key;\n\ + hint: Queries can be either made to the local crate, or the external crate. \ + This error means you tried to use it for one that's not supported.\n\ + If that's not the case, {name} was likely never assigned to a provider function.\n", + ) +} + +#[cold] +pub(crate) fn default_extern_query(name: &str, key: &dyn std::fmt::Debug) -> ! { + bug!( + "`tcx.{name}({key:?})` unsupported by its crate; \ + perhaps the `{name}` query was never assigned a provider function", + ) +} diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 41e1388e31464..ea41bad16622f 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -67,7 +67,7 @@ use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature}; use crate::middle::resolve_bound_vars; use crate::mir::interpret::{self, Allocation, ConstAllocation}; use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted}; -use crate::query::plumbing::QuerySystem; +use crate::query::system::QuerySystem; use crate::query::{IntoQueryParam, LocalCrate, Providers, TyCtxtAt}; use crate::thir::Thir; use crate::traits; @@ -1990,7 +1990,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn needs_crate_hash(self) -> bool { // Why is the crate hash needed for these configurations? // - debug_assertions: for the "fingerprint the result" check in - // `rustc_query_system::query::plumbing::execute_job`. + // `rustc_query_system::query::execution::execute_job`. // - incremental: for query lookups. // - needs_metadata: for putting into crate metadata. // - instrument_coverage: for putting into coverage data (see diff --git a/compiler/rustc_middle/src/ty/context/tls.rs b/compiler/rustc_middle/src/ty/context/tls.rs index fa9995898ac20..91a77c06179c2 100644 --- a/compiler/rustc_middle/src/ty/context/tls.rs +++ b/compiler/rustc_middle/src/ty/context/tls.rs @@ -4,7 +4,7 @@ use rustc_data_structures::sync; use super::{GlobalCtxt, TyCtxt}; use crate::dep_graph::TaskDepsRef; -use crate::query::plumbing::QueryJobId; +use crate::query::system::QueryJobId; /// This is the implicit state of rustc. It contains the current /// `TyCtxt` and query. It is updated when creating a local interner or @@ -17,7 +17,7 @@ pub struct ImplicitCtxt<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, /// The current query job, if any. This is updated by `JobOwner::start` in - /// `ty::query::plumbing` when executing a query. + /// `rustc_query_system::query::execution` when executing a query. pub query: Option, /// Used to prevent queries from calling too deeply. diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index bc73d36216ef4..a2c6081e18952 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -13,7 +13,7 @@ use rustc_span::def_id::LocalDefId; use rustc_span::{ErrorGuaranteed, Span}; use crate::dep_graph::dep_kinds; -use crate::query::plumbing::CyclePlaceholder; +use crate::query::system::CyclePlaceholder; use crate::ty::{self, Representability, Ty, TyCtxt}; impl<'tcx> Value> for Ty<'_> { diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index 4e79d0842da22..44c7a83d265c5 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -11,7 +11,7 @@ use rustc_data_structures::sync::AtomicU64; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::{self, DepKind, DepKindVTable, DepNodeIndex}; use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; -use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable}; +use rustc_middle::query::system::{QuerySystem, QuerySystemFns, QueryVTable}; use rustc_middle::query::{ AsLocalKey, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, queries, }; diff --git a/compiler/rustc_query_system/src/query/dispatcher.rs b/compiler/rustc_query_system/src/query/dispatcher.rs index ac6c38dd7db55..e6370b79a4d3a 100644 --- a/compiler/rustc_query_system/src/query/dispatcher.rs +++ b/compiler/rustc_query_system/src/query/dispatcher.rs @@ -21,7 +21,7 @@ type DepContextOf<'tcx, This: QueryDispatcher<'tcx>> = /// and metadata for that query. /// /// Implemented by `rustc_query_impl::SemiDynamicQueryDispatcher`, which -/// mostly delegates to `rustc_middle::query::plumbing::QueryVTable`. +/// mostly delegates to `rustc_middle::query::system::QueryVTable`. /// Those types are not visible from this `rustc_query_system` crate. /// /// "Dispatcher" should be understood as a near-synonym of "vtable". diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/execution.rs similarity index 100% rename from compiler/rustc_query_system/src/query/plumbing.rs rename to compiler/rustc_query_system/src/query/execution.rs diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 177bcd63cbc62..0328758dfb22e 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -15,7 +15,7 @@ use rustc_span::{DUMMY_SP, Span}; use super::{QueryStackDeferred, QueryStackFrameExtra}; use crate::dep_graph::DepContext; use crate::error::CycleStack; -use crate::query::plumbing::CycleError; +use crate::query::execution::CycleError; use crate::query::{QueryContext, QueryStackFrame}; /// Represents a span and a query key. diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index 63202429679d2..6ecf17567810e 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -14,17 +14,17 @@ use rustc_span::def_id::DefId; pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache}; pub use self::dispatcher::{HashResult, QueryDispatcher}; +pub use self::execution::*; pub use self::job::{ QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryMap, break_query_cycles, print_query_stack, report_cycle, }; -pub use self::plumbing::*; use crate::dep_graph::{DepKind, DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; mod caches; mod dispatcher; +mod execution; mod job; -mod plumbing; /// How a particular query deals with query cycle errors. ///