1
Fork 0

Rollup merge of #111625 - Zoxc:rustc_middle-query-move, r=cjgillot

Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs

This just keeps the query modules together.

r? `@cjgillot`
This commit is contained in:
Dylan DPC 2023-05-17 19:11:55 +05:30 committed by GitHub
commit 3df55382d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 29 additions and 33 deletions

View file

@ -3,7 +3,8 @@ use std::fmt;
use rustc_errors::Diagnostic; use rustc_errors::Diagnostic;
use rustc_middle::mir::AssertKind; use rustc_middle::mir::AssertKind;
use rustc_middle::ty::{layout::LayoutError, query::TyCtxtAt, ConstInt}; use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::{layout::LayoutError, ConstInt};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use super::InterpCx; use super::InterpCx;

View file

@ -8,13 +8,12 @@ use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::mir::interpret::{ErrorHandled, InterpError, ReportedErrorInfo}; use rustc_middle::mir::interpret::{ErrorHandled, InterpError, ReportedErrorInfo};
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::{ use rustc_middle::ty::layout::{
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers, self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers,
TyAndLayout, TyAndLayout,
}; };
use rustc_middle::ty::{ use rustc_middle::ty::{self, subst::SubstsRef, ParamEnv, Ty, TyCtxt, TypeFoldable};
self, query::TyCtxtAt, subst::SubstsRef, ParamEnv, Ty, TyCtxt, TypeFoldable,
};
use rustc_mir_dataflow::storage::always_storage_live_locals; use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_session::Limit; use rustc_session::Limit;
use rustc_span::Span; use rustc_span::Span;

View file

@ -95,7 +95,6 @@ pub mod middle;
pub mod mir; pub mod mir;
pub mod thir; pub mod thir;
pub mod traits; pub mod traits;
#[macro_use]
pub mod ty; pub mod ty;
pub mod util; pub mod util;
mod values; mod values;

View file

@ -1,7 +1,8 @@
use super::{AllocId, AllocRange, ConstAlloc, Pointer, Scalar}; use super::{AllocId, AllocRange, ConstAlloc, Pointer, Scalar};
use crate::mir::interpret::ConstValue; use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, Ty, ValTree}; use crate::query::TyCtxtAt;
use crate::ty::{layout, tls, Ty, ValTree};
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_errors::{pluralize, struct_span_err, DiagnosticBuilder, ErrorGuaranteed}; use rustc_errors::{pluralize, struct_span_err, DiagnosticBuilder, ErrorGuaranteed};

View file

@ -1,9 +1,10 @@
use super::{ErrorHandled, EvalToConstValueResult, EvalToValTreeResult, GlobalId}; use super::{ErrorHandled, EvalToConstValueResult, EvalToValTreeResult, GlobalId};
use crate::mir; use crate::mir;
use crate::query::{TyCtxtAt, TyCtxtEnsure};
use crate::ty::subst::InternalSubsts; use crate::ty::subst::InternalSubsts;
use crate::ty::visit::TypeVisitableExt; use crate::ty::visit::TypeVisitableExt;
use crate::ty::{self, query::TyCtxtAt, query::TyCtxtEnsure, TyCtxt}; use crate::ty::{self, TyCtxt};
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_session::lint; use rustc_session::lint;

View file

@ -25,6 +25,7 @@ use crate::mir::interpret::{
use crate::mir::interpret::{LitToConstError, LitToConstInput}; use crate::mir::interpret::{LitToConstError, LitToConstInput};
use crate::mir::mono::CodegenUnit; use crate::mir::mono::CodegenUnit;
use crate::query::erase::{erase, restore, Erase}; use crate::query::erase::{erase, restore, Erase};
use crate::query::plumbing::{query_ensure, query_get_at, DynamicQuery};
use crate::thir; use crate::thir;
use crate::traits::query::{ use crate::traits::query::{
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
@ -39,10 +40,6 @@ use crate::traits::specialization_graph;
use crate::traits::{self, ImplSource}; use crate::traits::{self, ImplSource};
use crate::ty::fast_reject::SimplifiedType; use crate::ty::fast_reject::SimplifiedType;
use crate::ty::layout::ValidityRequirement; use crate::ty::layout::ValidityRequirement;
use crate::ty::query::{
query_ensure, query_get_at, DynamicQuery, IntoQueryParam, TyCtxtAt, TyCtxtEnsure,
TyCtxtEnsureWithValue,
};
use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::subst::{GenericArg, SubstsRef};
use crate::ty::util::AlwaysRequiresDrop; use crate::ty::util::AlwaysRequiresDrop;
use crate::ty::GeneratorDiagnosticData; use crate::ty::GeneratorDiagnosticData;
@ -90,8 +87,11 @@ use std::sync::Arc;
pub mod erase; pub mod erase;
mod keys; mod keys;
pub mod on_disk_cache;
pub use keys::{AsLocalKey, Key, LocalCrate}; pub use keys::{AsLocalKey, Key, LocalCrate};
pub mod on_disk_cache;
#[macro_use]
pub mod plumbing;
pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue};
// Each of these queries corresponds to a function pointer field in the // Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method // `Providers` struct for requesting a value of that type, and a method

View file

@ -14,14 +14,14 @@ use crate::middle::resolve_bound_vars;
use crate::middle::stability; use crate::middle::stability;
use crate::mir::interpret::{self, Allocation, ConstAllocation}; use crate::mir::interpret::{self, Allocation, ConstAllocation};
use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted}; use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};
use crate::query::plumbing::QuerySystem;
use crate::query::LocalCrate; use crate::query::LocalCrate;
use crate::query::Providers; use crate::query::Providers;
use crate::query::{IntoQueryParam, TyCtxtAt};
use crate::thir::Thir; use crate::thir::Thir;
use crate::traits; use crate::traits;
use crate::traits::solve; use crate::traits::solve;
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData}; use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
use crate::ty::query::QuerySystem;
use crate::ty::query::{self, TyCtxtAt};
use crate::ty::{ use crate::ty::{
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid, self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid,
GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy, GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
@ -80,8 +80,6 @@ use std::iter;
use std::mem; use std::mem;
use std::ops::{Bound, Deref}; use std::ops::{Bound, Deref};
use super::query::IntoQueryParam;
const TINY_CONST_EVAL_LIMIT: Limit = Limit(20); const TINY_CONST_EVAL_LIMIT: Limit = Limit(20);
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
@ -512,7 +510,7 @@ pub struct GlobalCtxt<'tcx> {
untracked: Untracked, untracked: Untracked,
pub query_system: query::QuerySystem<'tcx>, pub query_system: QuerySystem<'tcx>,
pub(crate) query_kinds: &'tcx [DepKindStruct<'tcx>], pub(crate) query_kinds: &'tcx [DepKindStruct<'tcx>],
// Internal caches for metadata decoding. No need to track deps on this. // Internal caches for metadata decoding. No need to track deps on this.

View file

@ -1,7 +1,7 @@
use super::{GlobalCtxt, TyCtxt}; use super::{GlobalCtxt, TyCtxt};
use crate::dep_graph::TaskDepsRef; use crate::dep_graph::TaskDepsRef;
use crate::ty::query; use crate::query::plumbing::QueryJobId;
use rustc_data_structures::sync::{self, Lock}; use rustc_data_structures::sync::{self, Lock};
use rustc_errors::Diagnostic; use rustc_errors::Diagnostic;
#[cfg(not(parallel_compiler))] #[cfg(not(parallel_compiler))]
@ -22,7 +22,7 @@ pub struct ImplicitCtxt<'a, 'tcx> {
/// The current query job, if any. This is updated by `JobOwner::start` in /// The current query job, if any. This is updated by `JobOwner::start` in
/// `ty::query::plumbing` when executing a query. /// `ty::query::plumbing` when executing a query.
pub query: Option<query::QueryJobId>, pub query: Option<QueryJobId>,
/// Where to store diagnostics for the current query job, if any. /// Where to store diagnostics for the current query job, if any.
/// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query. /// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query.

View file

@ -1,5 +1,6 @@
use crate::fluent_generated as fluent; use crate::fluent_generated as fluent;
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::query::TyCtxtAt;
use crate::ty::normalize_erasing_regions::NormalizationError; use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, ReprOptions, Ty, TyCtxt, TypeVisitableExt}; use crate::ty::{self, ReprOptions, Ty, TyCtxt, TypeVisitableExt};
use rustc_errors::{DiagnosticBuilder, Handler, IntoDiagnostic}; use rustc_errors::{DiagnosticBuilder, Handler, IntoDiagnostic};
@ -543,20 +544,20 @@ impl<'tcx> HasTyCtxt<'tcx> for TyCtxt<'tcx> {
} }
} }
impl<'tcx> HasDataLayout for ty::query::TyCtxtAt<'tcx> { impl<'tcx> HasDataLayout for TyCtxtAt<'tcx> {
#[inline] #[inline]
fn data_layout(&self) -> &TargetDataLayout { fn data_layout(&self) -> &TargetDataLayout {
&self.data_layout &self.data_layout
} }
} }
impl<'tcx> HasTargetSpec for ty::query::TyCtxtAt<'tcx> { impl<'tcx> HasTargetSpec for TyCtxtAt<'tcx> {
fn target_spec(&self) -> &Target { fn target_spec(&self) -> &Target {
&self.sess.target &self.sess.target
} }
} }
impl<'tcx> HasTyCtxt<'tcx> for ty::query::TyCtxtAt<'tcx> { impl<'tcx> HasTyCtxt<'tcx> for TyCtxtAt<'tcx> {
#[inline] #[inline]
fn tcx(&self) -> TyCtxt<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
**self **self
@ -683,7 +684,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for LayoutCx<'tcx, TyCtxt<'tcx>> {
} }
} }
impl<'tcx> LayoutOfHelpers<'tcx> for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> { impl<'tcx> LayoutOfHelpers<'tcx> for LayoutCx<'tcx, TyCtxtAt<'tcx>> {
type LayoutOfResult = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>; type LayoutOfResult = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
#[inline] #[inline]

View file

@ -122,8 +122,6 @@ pub mod inhabitedness;
pub mod layout; pub mod layout;
pub mod normalize_erasing_regions; pub mod normalize_erasing_regions;
pub mod print; pub mod print;
#[macro_use]
pub mod query;
pub mod relate; pub mod relate;
pub mod subst; pub mod subst;
pub mod trait_def; pub mod trait_def;

View file

@ -1,6 +1,6 @@
use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar}; use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar};
use crate::query::IntoQueryParam;
use crate::query::Providers; use crate::query::Providers;
use crate::ty::query::IntoQueryParam;
use crate::ty::{ use crate::ty::{
self, ConstInt, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable, self, ConstInt, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable,
TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,

View file

@ -185,9 +185,9 @@ use rustc_middle::mir::interpret::{ErrorHandled, GlobalAlloc, Scalar};
use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
use rustc_middle::mir::visit::Visitor as MirVisitor; use rustc_middle::mir::visit::Visitor as MirVisitor;
use rustc_middle::mir::{self, Local, Location}; use rustc_middle::mir::{self, Local, Location};
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCast}; use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCast};
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::query::TyCtxtAt;
use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts}; use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, GenericParamDefKind, Instance, InstanceDef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, self, GenericParamDefKind, Instance, InstanceDef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,

View file

@ -12,10 +12,9 @@ extern crate rustc_middle;
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages; use rustc_fluent_macro::fluent_messages;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_middle::query::Providers; use rustc_middle::query::{Providers, TyCtxtAt};
use rustc_middle::traits; use rustc_middle::traits;
use rustc_middle::ty::adjustment::CustomCoerceUnsized; use rustc_middle::ty::adjustment::CustomCoerceUnsized;
use rustc_middle::ty::query::TyCtxtAt;
use rustc_middle::ty::{self, Ty}; use rustc_middle::ty::{self, Ty};
mod collector; mod collector;

View file

@ -24,12 +24,12 @@ use rustc_middle::dep_graph::DepNodeIndex;
use rustc_middle::dep_graph::{self, DepKind, DepKindStruct}; use rustc_middle::dep_graph::{self, DepKind, DepKindStruct};
use rustc_middle::query::erase::{erase, restore, Erase}; use rustc_middle::query::erase::{erase, restore, Erase};
use rustc_middle::query::on_disk_cache::OnDiskCache; use rustc_middle::query::on_disk_cache::OnDiskCache;
use rustc_middle::query::plumbing::{DynamicQuery, QuerySystem, QuerySystemFns};
use rustc_middle::query::AsLocalKey; use rustc_middle::query::AsLocalKey;
use rustc_middle::query::{ use rustc_middle::query::{
query_keys, query_provided, query_provided_to_value, query_storage, query_values, query_keys, query_provided, query_provided_to_value, query_storage, query_values,
DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates,
}; };
use rustc_middle::ty::query::{DynamicQuery, QuerySystem, QuerySystemFns};
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_query_system::dep_graph::SerializedDepNodeIndex; use rustc_query_system::dep_graph::SerializedDepNodeIndex;
use rustc_query_system::ich::StableHashingContext; use rustc_query_system::ich::StableHashingContext;

View file

@ -716,8 +716,7 @@ macro_rules! define_queries {
mod query_structs { mod query_structs {
use super::*; use super::*;
use rustc_middle::ty::query::QueryStruct; use rustc_middle::query::plumbing::{QueryKeyStringCache, QueryStruct};
use rustc_middle::ty::query::QueryKeyStringCache;
use rustc_middle::dep_graph::DepKind; use rustc_middle::dep_graph::DepKind;
use crate::QueryConfigRestored; use crate::QueryConfigRestored;

View file

@ -2,7 +2,7 @@ use measureme::{StringComponent, StringId};
use rustc_data_structures::profiling::SelfProfiler; use rustc_data_structures::profiling::SelfProfiler;
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
use rustc_hir::definitions::DefPathData; use rustc_hir::definitions::DefPathData;
use rustc_middle::ty::query::QueryKeyStringCache; use rustc_middle::query::plumbing::QueryKeyStringCache;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_query_system::query::QueryCache; use rustc_query_system::query::QueryCache;
use std::fmt::Debug; use std::fmt::Debug;