diff --git a/Cargo.lock b/Cargo.lock index 53cac09b7a7ab..d7d19be42c580 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3640,7 +3640,6 @@ dependencies = [ "rustc_macros", "rustc_metadata", "rustc_middle", - "rustc_query_system", "rustc_sanitizers", "rustc_session", "rustc_span", @@ -4243,7 +4242,6 @@ dependencies = [ "rustc_index", "rustc_lint_defs", "rustc_macros", - "rustc_query_system", "rustc_serialize", "rustc_session", "rustc_span", @@ -4507,23 +4505,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rustc_query_system" -version = "0.0.0" -dependencies = [ - "rustc_abi", - "rustc_ast", - "rustc_data_structures", - "rustc_errors", - "rustc_feature", - "rustc_hir", - "rustc_macros", - "rustc_serialize", - "rustc_session", - "rustc_span", - "smallvec", -] - [[package]] name = "rustc_resolve" version = "0.0.0" diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 90c87494c3c50..0ffff2d331b1d 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -31,7 +31,6 @@ rustc_llvm = { path = "../rustc_llvm" } rustc_macros = { path = "../rustc_macros" } rustc_metadata = { path = "../rustc_metadata" } rustc_middle = { path = "../rustc_middle" } -rustc_query_system = { path = "../rustc_query_system" } rustc_sanitizers = { path = "../rustc_sanitizers" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs index 05ddfd1f107a5..4a1da0f50cc23 100644 --- a/compiler/rustc_interface/src/callbacks.rs +++ b/compiler/rustc_interface/src/callbacks.rs @@ -11,9 +11,8 @@ use std::fmt; -use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC}; -use rustc_middle::dep_graph::dep_node::default_dep_kind_debug; -use rustc_middle::dep_graph::{DepKind, DepNode, TaskDepsRef}; +use rustc_errors::DiagInner; +use rustc_middle::dep_graph::TaskDepsRef; use rustc_middle::ty::tls; fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) { @@ -65,49 +64,10 @@ fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) -> write!(f, ")") } -/// This is a callback from `rustc_query_system` as it cannot access the implicit state -/// in `rustc_middle` otherwise. -pub fn dep_kind_debug(kind: DepKind, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - tls::with_opt(|opt_tcx| { - if let Some(tcx) = opt_tcx { - write!(f, "{}", tcx.dep_kind_vtable(kind).name) - } else { - default_dep_kind_debug(kind, f) - } - }) -} - -/// This is a callback from `rustc_query_system` as it cannot access the implicit state -/// in `rustc_middle` otherwise. -pub fn dep_node_debug(node: DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}(", node.kind)?; - - tls::with_opt(|opt_tcx| { - if let Some(tcx) = opt_tcx { - if let Some(def_id) = node.extract_def_id(tcx) { - write!(f, "{}", tcx.def_path_debug_str(def_id))?; - } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(node) { - write!(f, "{s}")?; - } else { - write!(f, "{}", node.hash)?; - } - } else { - write!(f, "{}", node.hash)?; - } - Ok(()) - })?; - - write!(f, ")") -} - /// Sets up the callbacks in prior crates which we want to refer to the /// TyCtxt in. pub fn setup_callbacks() { rustc_span::SPAN_TRACK.swap(&(track_span_parent as fn(_))); rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); - rustc_middle::dep_graph::dep_node::DEP_KIND_DEBUG - .swap(&(dep_kind_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); - rustc_middle::dep_graph::dep_node::DEP_NODE_DEBUG - .swap(&(dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); - TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _)); + rustc_errors::TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _)); } diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index a6396ba687d11..fa67adb406ed2 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -96,7 +96,7 @@ fn hash_stable_derive_with_mode( let context: syn::Type = match mode { HashStableMode::Normal => { - parse_quote!(::rustc_query_system::ich::StableHashingContext<'__ctx>) + parse_quote!(::rustc_middle::ich::StableHashingContext<'__ctx>) } HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX), }; diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 121e77614725f..8bad0e291bf8b 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,6 @@ rustc_hir_pretty = { path = "../rustc_hir_pretty" } rustc_index = { path = "../rustc_index" } rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_macros = { path = "../rustc_macros" } -rustc_query_system = { path = "../rustc_query_system" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 909638b85906c..578277bce593a 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -58,18 +58,17 @@ use std::fmt; use std::hash::Hash; -use rustc_data_structures::AtomicRef; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; use rustc_hir::def_id::DefId; use rustc_hir::definitions::DefPathHash; use rustc_macros::{Decodable, Encodable}; -use rustc_query_system::ich::StableHashingContext; use rustc_span::Symbol; use super::{FingerprintStyle, SerializedDepNodeIndex}; +use crate::ich::StableHashingContext; use crate::mir::mono::MonoItem; -use crate::ty::TyCtxt; +use crate::ty::{TyCtxt, tls}; /// This serves as an index into arrays built by `make_dep_kind_array`. #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -114,16 +113,15 @@ impl DepKind { pub(crate) const MAX: u16 = DEP_KIND_VARIANTS - 1; } -pub fn default_dep_kind_debug(kind: DepKind, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("DepKind").field("variant", &kind.variant).finish() -} - -pub static DEP_KIND_DEBUG: AtomicRef) -> fmt::Result> = - AtomicRef::new(&(default_dep_kind_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); - impl fmt::Debug for DepKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*DEP_KIND_DEBUG)(*self, f) + tls::with_opt(|opt_tcx| { + if let Some(tcx) = opt_tcx { + write!(f, "{}", tcx.dep_kind_vtable(*self).name) + } else { + f.debug_struct("DepKind").field("variant", &self.variant).finish() + } + }) } } @@ -175,16 +173,26 @@ impl DepNode { } } -pub fn default_dep_node_debug(node: DepNode, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("DepNode").field("kind", &node.kind).field("hash", &node.hash).finish() -} - -pub static DEP_NODE_DEBUG: AtomicRef) -> fmt::Result> = - AtomicRef::new(&(default_dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); - impl fmt::Debug for DepNode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*DEP_NODE_DEBUG)(*self, f) + write!(f, "{:?}(", self.kind)?; + + tls::with_opt(|opt_tcx| { + if let Some(tcx) = opt_tcx { + if let Some(def_id) = self.extract_def_id(tcx) { + write!(f, "{}", tcx.def_path_debug_str(def_id))?; + } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) { + write!(f, "{s}")?; + } else { + write!(f, "{}", self.hash)?; + } + } else { + write!(f, "{}", self.hash)?; + } + Ok(()) + })?; + + write!(f, ")") } } diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs index 6b9f18a6bfe1d..6a19c02bb81b1 100644 --- a/compiler/rustc_middle/src/dep_graph/graph.rs +++ b/compiler/rustc_middle/src/dep_graph/graph.rs @@ -15,8 +15,6 @@ use rustc_data_structures::{assert_matches, outline}; use rustc_errors::DiagInner; use rustc_index::IndexVec; use rustc_macros::{Decodable, Encodable}; -use rustc_query_system::ich::StableHashingContext; -use rustc_query_system::query::QuerySideEffect; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use rustc_session::Session; use tracing::{debug, instrument}; @@ -27,9 +25,27 @@ use super::query::DepGraphQuery; use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; use super::{DepKind, DepNode, HasDepContext, WorkProductId, read_deps, with_deps}; use crate::dep_graph::edges::EdgesVec; +use crate::ich::StableHashingContext; use crate::ty::TyCtxt; use crate::verify_ich::incremental_verify_ich; +/// Tracks 'side effects' for a particular query. +/// This struct is saved to disk along with the query result, +/// and loaded from disk if we mark the query as green. +/// This allows us to 'replay' changes to global state +/// that would otherwise only occur if we actually +/// executed the query method. +/// +/// Each side effect gets an unique dep node index which is added +/// as a dependency of the query which had the effect. +#[derive(Debug, Encodable, Decodable)] +pub enum QuerySideEffect { + /// Stores a diagnostic emitted during query execution. + /// This diagnostic will be re-emitted if we mark + /// the query as green, as that query will have the side + /// effect dep node as a dependency. + Diagnostic(DiagInner), +} #[derive(Clone)] pub struct DepGraph { data: Option>, diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index b10f341c71a6d..e8b2f86e5718c 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -7,7 +7,8 @@ pub use self::dep_node::{ label_strs, }; pub use self::graph::{ - DepGraph, DepGraphData, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap, hash_result, + DepGraph, DepGraphData, DepNodeIndex, QuerySideEffect, TaskDepsRef, WorkProduct, + WorkProductMap, hash_result, }; use self::graph::{MarkFrame, print_markframe_trace}; pub use self::query::DepGraphQuery; diff --git a/compiler/rustc_query_system/src/ich/hcx.rs b/compiler/rustc_middle/src/ich/hcx.rs similarity index 100% rename from compiler/rustc_query_system/src/ich/hcx.rs rename to compiler/rustc_middle/src/ich/hcx.rs diff --git a/compiler/rustc_query_system/src/ich/impls_syntax.rs b/compiler/rustc_middle/src/ich/impls_syntax.rs similarity index 99% rename from compiler/rustc_query_system/src/ich/impls_syntax.rs rename to compiler/rustc_middle/src/ich/impls_syntax.rs index 5592f65539716..be4e5333c64b3 100644 --- a/compiler/rustc_query_system/src/ich/impls_syntax.rs +++ b/compiler/rustc_middle/src/ich/impls_syntax.rs @@ -6,7 +6,7 @@ use rustc_span::{SourceFile, Symbol, sym}; use smallvec::SmallVec; use {rustc_ast as ast, rustc_hir as hir}; -use crate::ich::StableHashingContext; +use super::StableHashingContext; impl<'a> HashStable> for ast::NodeId { #[inline] diff --git a/compiler/rustc_query_system/src/ich/mod.rs b/compiler/rustc_middle/src/ich/mod.rs similarity index 100% rename from compiler/rustc_query_system/src/ich/mod.rs rename to compiler/rustc_middle/src/ich/mod.rs diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 1c4c987aee920..5fa6f10865b54 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -72,6 +72,7 @@ pub mod arena; pub mod error; pub mod hir; pub mod hooks; +pub mod ich; pub mod infer; pub mod lint; pub mod metadata; diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index e3e04c9d1800b..0be4c8243d632 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -8,9 +8,9 @@ use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir::def::DefKind; use rustc_macros::HashStable; -use rustc_query_system::ich::StableHashingContext; use rustc_span::def_id::{CRATE_DEF_ID, LocalDefId}; +use crate::ich::StableHashingContext; use crate::ty::{TyCtxt, Visibility}; /// Represents the levels of effective visibility an item can have. diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 418cdea01660b..9d0e4b5e6dfa6 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -911,7 +911,8 @@ pub struct VarBindingIntroduction { mod binding_form_impl { use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; - use rustc_query_system::ich::StableHashingContext; + + use crate::ich::StableHashingContext; impl<'a, 'tcx> HashStable> for super::BindingForm<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 577d226fc9d7a..acebf91b1cbf5 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -12,7 +12,6 @@ use rustc_hir::ItemId; use rustc_hir::attrs::{InlineAttr, Linkage}; use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE}; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_query_system::ich::StableHashingContext; use rustc_session::config::OptLevel; use rustc_span::{Span, Symbol}; use rustc_target::spec::SymbolVisibility; @@ -20,6 +19,7 @@ use tracing::debug; use crate::dep_graph::dep_node::{make_compile_codegen_unit, make_compile_mono_item}; use crate::dep_graph::{DepNode, WorkProduct, WorkProductId}; +use crate::ich::StableHashingContext; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::ty::{self, GenericArgs, Instance, InstanceKind, SymbolName, Ty, TyCtxt}; diff --git a/compiler/rustc_middle/src/query/caches.rs b/compiler/rustc_middle/src/query/caches.rs index 7424492ddc1f3..c1f5e5b670856 100644 --- a/compiler/rustc_middle/src/query/caches.rs +++ b/compiler/rustc_middle/src/query/caches.rs @@ -7,10 +7,10 @@ use rustc_data_structures::stable_hasher::HashStable; pub use rustc_data_structures::vec_cache::VecCache; use rustc_hir::def_id::LOCAL_CRATE; use rustc_index::Idx; -use rustc_query_system::ich::StableHashingContext; use rustc_span::def_id::{DefId, DefIndex}; use crate::dep_graph::DepNodeIndex; +use crate::ich::StableHashingContext; /// Traits that all query keys must satisfy. pub trait QueryCacheKey = Hash + Eq + Copy + Debug + for<'a> HashStable>; diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 5ef0c2500e7a9..e874e7e22b5c9 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -11,7 +11,6 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE, LocalDefId, Stab use rustc_hir::definitions::DefPathHash; use rustc_index::{Idx, IndexVec}; use rustc_macros::{Decodable, Encodable}; -use rustc_query_system::query::QuerySideEffect; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::Session; @@ -24,7 +23,7 @@ use rustc_span::{ SourceFile, Span, SpanDecoder, SpanEncoder, StableSourceFileId, Symbol, }; -use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; +use crate::dep_graph::{DepNodeIndex, QuerySideEffect, SerializedDepNodeIndex}; use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use crate::mir::mono::MonoItem; use crate::mir::{self, interpret}; diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 727e931482510..47b6aea077d17 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -8,12 +8,12 @@ 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::ich::StableHashingContext; use rustc_span::{ErrorGuaranteed, Span}; pub use sealed::IntoQueryParam; use crate::dep_graph; use crate::dep_graph::{DepKind, DepNodeIndex, SerializedDepNodeIndex}; +use crate::ich::StableHashingContext; use crate::queries::{ ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, }; @@ -102,9 +102,6 @@ pub enum QueryMode { } /// Stores function pointers and other metadata for a particular query. -/// -/// Used indirectly by query plumbing in `rustc_query_system` via a trait, -/// and also used directly by query plumbing in `rustc_query_impl`. pub struct QueryVTable<'tcx, C: QueryCache> { pub name: &'static str, pub eval_always: bool, diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 510c546f82a4e..242d3742abad0 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -15,7 +15,6 @@ use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, LangItem, find_attr}; use rustc_index::{IndexSlice, IndexVec}; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_query_system::ich::StableHashingContext; use rustc_session::DataTypeKind; use rustc_type_ir::solve::AdtDestructorKind; use tracing::{debug, info, trace}; @@ -23,6 +22,7 @@ use tracing::{debug, info, trace}; use super::{ AsyncDestructor, Destructor, FieldDef, GenericPredicates, Ty, TyCtxt, VariantDef, VariantDiscr, }; +use crate::ich::StableHashingContext; use crate::mir::interpret::ErrorHandled; use crate::ty; use crate::ty::util::{Discr, IntTypeExt}; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 430890d5a42d8..94a77ce13c14a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -39,7 +39,6 @@ use rustc_hir::lang_items::LangItem; use rustc_hir::limit::Limit; use rustc_hir::{self as hir, HirId, Node, TraitCandidate, find_attr}; use rustc_index::IndexVec; -use rustc_query_system::ich::StableHashingContext; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use rustc_session::Session; use rustc_session::config::CrateType; @@ -55,6 +54,7 @@ use tracing::{debug, instrument}; use crate::arena::Arena; use crate::dep_graph::dep_node::make_metadata; use crate::dep_graph::{DepGraph, DepKindVTable, DepNodeIndex}; +use crate::ich::StableHashingContext; use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind}; use crate::lint::lint_level; use crate::metadata::ModChild; @@ -1220,7 +1220,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_impl::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/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 95a1a1bf5bce5..f06ce7324d4c0 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -9,9 +9,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{ HashStable, HashingControls, StableHasher, ToStableHashKey, }; -use rustc_query_system::ich::StableHashingContext; use tracing::trace; +use crate::ich::StableHashingContext; use crate::middle::region; use crate::{mir, ty}; diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 0363977099254..2c7244187f4fd 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -47,7 +47,6 @@ use rustc_macros::{ BlobDecodable, Decodable, Encodable, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable, extension, }; -use rustc_query_system::ich::StableHashingContext; use rustc_serialize::{Decodable, Encodable}; pub use rustc_session::lint::RegisteredTools; use rustc_span::hygiene::MacroKind; @@ -112,6 +111,7 @@ pub use self::typeck_results::{ Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind, }; use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; +use crate::ich::StableHashingContext; use crate::metadata::{AmbigModChild, ModChild}; use crate::middle::privacy::EffectiveVisibilities; use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo}; diff --git a/compiler/rustc_middle/src/verify_ich.rs b/compiler/rustc_middle/src/verify_ich.rs index 290786d439d4e..ff3c5bb5a9d6b 100644 --- a/compiler/rustc_middle/src/verify_ich.rs +++ b/compiler/rustc_middle/src/verify_ich.rs @@ -1,10 +1,10 @@ use std::cell::Cell; use rustc_data_structures::fingerprint::Fingerprint; -use rustc_query_system::ich::StableHashingContext; use tracing::instrument; use crate::dep_graph::{DepGraphData, SerializedDepNodeIndex}; +use crate::ich::StableHashingContext; use crate::ty::TyCtxt; #[inline] diff --git a/compiler/rustc_query_system/Cargo.toml b/compiler/rustc_query_system/Cargo.toml deleted file mode 100644 index bd12dcbfe0d18..0000000000000 --- a/compiler/rustc_query_system/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "rustc_query_system" -version = "0.0.0" -edition = "2024" - -[dependencies] -# tidy-alphabetical-start -rustc_abi = { path = "../rustc_abi" } -rustc_ast = { path = "../rustc_ast" } -rustc_data_structures = { path = "../rustc_data_structures" } -rustc_errors = { path = "../rustc_errors" } -rustc_feature = { path = "../rustc_feature" } -rustc_hir = { path = "../rustc_hir" } -rustc_macros = { path = "../rustc_macros" } -rustc_serialize = { path = "../rustc_serialize" } -rustc_session = { path = "../rustc_session" } -rustc_span = { path = "../rustc_span" } -smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -# tidy-alphabetical-end diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs deleted file mode 100644 index bb077d02422b9..0000000000000 --- a/compiler/rustc_query_system/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -// tidy-alphabetical-start -#![allow(internal_features)] -#![cfg_attr(bootstrap, feature(assert_matches))] -#![feature(min_specialization)] -// tidy-alphabetical-end - -pub mod ich; -pub mod query; diff --git a/compiler/rustc_query_system/src/query/README.md b/compiler/rustc_query_system/src/query/README.md deleted file mode 100644 index 8ec07b9fdeb78..0000000000000 --- a/compiler/rustc_query_system/src/query/README.md +++ /dev/null @@ -1,3 +0,0 @@ -For more information about how the query system works, see the [rustc dev guide]. - -[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/query.html diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs deleted file mode 100644 index 87be4358fb8ba..0000000000000 --- a/compiler/rustc_query_system/src/query/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::fmt::Debug; - -use rustc_errors::DiagInner; -use rustc_macros::{Decodable, Encodable}; - -/// Tracks 'side effects' for a particular query. -/// This struct is saved to disk along with the query result, -/// and loaded from disk if we mark the query as green. -/// This allows us to 'replay' changes to global state -/// that would otherwise only occur if we actually -/// executed the query method. -/// -/// Each side effect gets an unique dep node index which is added -/// as a dependency of the query which had the effect. -#[derive(Debug, Encodable, Decodable)] -pub enum QuerySideEffect { - /// Stores a diagnostic emitted during query execution. - /// This diagnostic will be re-emitted if we mark - /// the query as green, as that query will have the side - /// effect dep node as a dependency. - Diagnostic(DiagInner), -} diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap index 3adf952d66e07..294623f073864 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap @@ -79,7 +79,6 @@ expression: bench - Set({bench::compiler/rustc_public}) - Set({bench::compiler/rustc_public_bridge}) - Set({bench::compiler/rustc_query_impl}) - - Set({bench::compiler/rustc_query_system}) - Set({bench::compiler/rustc_resolve}) - Set({bench::compiler/rustc_sanitizers}) - Set({bench::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap index 1d6e63696b062..d5da908c8a443 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap @@ -61,7 +61,6 @@ expression: build compiler - Set({build::compiler/rustc_public}) - Set({build::compiler/rustc_public_bridge}) - Set({build::compiler/rustc_query_impl}) - - Set({build::compiler/rustc_query_system}) - Set({build::compiler/rustc_resolve}) - Set({build::compiler/rustc_sanitizers}) - Set({build::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap index 6fc2e190290e4..242a2272b4d16 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap @@ -63,7 +63,6 @@ expression: check - Set({check::compiler/rustc_public}) - Set({check::compiler/rustc_public_bridge}) - Set({check::compiler/rustc_query_impl}) - - Set({check::compiler/rustc_query_system}) - Set({check::compiler/rustc_resolve}) - Set({check::compiler/rustc_sanitizers}) - Set({check::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap index c0456f7f84d33..dab86b792127f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap @@ -63,7 +63,6 @@ expression: check compiler - Set({check::compiler/rustc_public}) - Set({check::compiler/rustc_public_bridge}) - Set({check::compiler/rustc_query_impl}) - - Set({check::compiler/rustc_query_system}) - Set({check::compiler/rustc_resolve}) - Set({check::compiler/rustc_sanitizers}) - Set({check::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap index 10f36ffa67482..e43d5380a398d 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap @@ -63,7 +63,6 @@ expression: check compiletest --include-default-paths - Set({check::compiler/rustc_public}) - Set({check::compiler/rustc_public_bridge}) - Set({check::compiler/rustc_query_impl}) - - Set({check::compiler/rustc_query_system}) - Set({check::compiler/rustc_resolve}) - Set({check::compiler/rustc_sanitizers}) - Set({check::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap index 492a10d3862aa..827f2f8b60acb 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap @@ -78,7 +78,6 @@ expression: clippy - Set({clippy::compiler/rustc_public}) - Set({clippy::compiler/rustc_public_bridge}) - Set({clippy::compiler/rustc_query_impl}) - - Set({clippy::compiler/rustc_query_system}) - Set({clippy::compiler/rustc_resolve}) - Set({clippy::compiler/rustc_sanitizers}) - Set({clippy::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap index 41889cd124801..d380cb416acf8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap @@ -63,7 +63,6 @@ expression: fix - Set({fix::compiler/rustc_public}) - Set({fix::compiler/rustc_public_bridge}) - Set({fix::compiler/rustc_query_impl}) - - Set({fix::compiler/rustc_query_system}) - Set({fix::compiler/rustc_resolve}) - Set({fix::compiler/rustc_sanitizers}) - Set({fix::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 51e2c270e3ba6..ac2f315d39d96 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -129,7 +129,6 @@ expression: test - Set({test::compiler/rustc_public}) - Set({test::compiler/rustc_public_bridge}) - Set({test::compiler/rustc_query_impl}) - - Set({test::compiler/rustc_query_system}) - Set({test::compiler/rustc_resolve}) - Set({test::compiler/rustc_sanitizers}) - Set({test::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index bc828c162bb0e..09adbb0041ae6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -128,7 +128,6 @@ expression: test --skip=coverage - Set({test::compiler/rustc_public}) - Set({test::compiler/rustc_public_bridge}) - Set({test::compiler/rustc_query_impl}) - - Set({test::compiler/rustc_query_system}) - Set({test::compiler/rustc_resolve}) - Set({test::compiler/rustc_sanitizers}) - Set({test::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index ceb910e4cb36e..b5fccfcb966bb 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -92,7 +92,6 @@ expression: test --skip=tests - Set({test::compiler/rustc_public}) - Set({test::compiler/rustc_public_bridge}) - Set({test::compiler/rustc_query_impl}) - - Set({test::compiler/rustc_query_system}) - Set({test::compiler/rustc_resolve}) - Set({test::compiler/rustc_sanitizers}) - Set({test::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index f0e8f1aee2c7f..9ad8914f58e30 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -72,7 +72,6 @@ expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=lib - Set({test::compiler/rustc_public}) - Set({test::compiler/rustc_public_bridge}) - Set({test::compiler/rustc_query_impl}) - - Set({test::compiler/rustc_query_system}) - Set({test::compiler/rustc_resolve}) - Set({test::compiler/rustc_sanitizers}) - Set({test::compiler/rustc_serialize}) diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 61db494c8c188..002fb32dcf0c6 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1815,7 +1815,7 @@ mod snapshot { insta::assert_snapshot!( ctx.config("check") .path("compiler") - .render_steps(), @"[check] rustc 0 -> rustc 1 (74 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] @@ -1841,7 +1841,7 @@ mod snapshot { ctx.config("check") .path("compiler") .stage(1) - .render_steps(), @"[check] rustc 0 -> rustc 1 (74 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] @@ -1851,11 +1851,11 @@ mod snapshot { ctx.config("check") .path("compiler") .stage(2) - .render_steps(), @r" + .render_steps(), @" [build] llvm [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (74 crates) + [check] rustc 1 -> rustc 2 (73 crates) "); } @@ -1866,12 +1866,12 @@ mod snapshot { ctx.config("check") .targets(&[TEST_TRIPLE_1]) .hosts(&[TEST_TRIPLE_1]) - .render_steps(), @r" + .render_steps(), @" [build] llvm [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 [check] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (74 crates) + [check] rustc 1 -> rustc 2 (73 crates) [check] rustc 1 -> rustc 2 [check] rustc 1 -> Rustdoc 2 [check] rustc 1 -> rustc_codegen_cranelift 2 @@ -1967,7 +1967,7 @@ mod snapshot { ctx.config("check") .paths(&["library", "compiler"]) .args(&args) - .render_steps(), @"[check] rustc 0 -> rustc 1 (74 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] diff --git a/src/doc/rustc-dev-guide/src/queries/incremental-compilation-in-detail.md b/src/doc/rustc-dev-guide/src/queries/incremental-compilation-in-detail.md index 46e38832e64d2..cab9f6871f7c5 100644 --- a/src/doc/rustc-dev-guide/src/queries/incremental-compilation-in-detail.md +++ b/src/doc/rustc-dev-guide/src/queries/incremental-compilation-in-detail.md @@ -178,7 +178,7 @@ fn try_mark_green(tcx, current_node) -> bool { > NOTE: > The actual implementation can be found in -> [`compiler/rustc_query_system/src/dep_graph/graph.rs`][try_mark_green] +> [`compiler/rustc_middle/src/dep_graph/graph.rs`][try_mark_green] By using red-green marking we can avoid the devastating cumulative effect of having false positives during change detection. Whenever a query is executed @@ -534,4 +534,4 @@ information. [query-model]: ./query-evaluation-model-in-detail.html -[try_mark_green]: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_query_system/dep_graph/graph.rs.html +[try_mark_green]: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/dep_graph/graph.rs.html diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 4fc183a8c74ef..043f880abcf7e 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -31,10 +31,10 @@ fn main() { let output_bt_full = &concat_stderr_stdout(&rustc_bt_full); // Count how many lines of output mention symbols or paths in - // `rustc_query_system` or `rustc_query_impl`, which are the kinds of + // `rustc_query_impl`, which are the kinds of // stack frames we want to be omitting in short backtraces. - let rustc_query_count_short = count_lines_with(output_bt_short, "rustc_query_"); - let rustc_query_count_full = count_lines_with(output_bt_full, "rustc_query_"); + let rustc_query_count_short = count_lines_with(output_bt_short, "rustc_query_impl"); + let rustc_query_count_full = count_lines_with(output_bt_full, "rustc_query_impl"); // Dump both outputs in full to make debugging easier, especially on CI. // Use `--no-capture --force-rerun` to view output even when the test is passing. diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.rs b/tests/ui-fulldeps/hash-stable-is-unstable.rs index 7f62b60441040..a3dfd7e85ba60 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.rs +++ b/tests/ui-fulldeps/hash-stable-is-unstable.rs @@ -7,7 +7,7 @@ extern crate rustc_macros; //~^ ERROR use of unstable library feature `rustc_private` //~| NOTE: see issue #27812 for more information //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -extern crate rustc_query_system; +extern crate rustc_middle; //~^ ERROR use of unstable library feature `rustc_private` //~| NOTE: see issue #27812 for more information //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.stderr b/tests/ui-fulldeps/hash-stable-is-unstable.stderr index e7740d744b4f8..7c69e8f5e6317 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.stderr +++ b/tests/ui-fulldeps/hash-stable-is-unstable.stderr @@ -21,8 +21,8 @@ LL | extern crate rustc_macros; error[E0658]: use of unstable library feature `rustc_private`: this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:10:1 | -LL | extern crate rustc_query_system; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern crate rustc_middle; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #27812 for more information = help: add `#![feature(rustc_private)]` to the crate attributes to enable diff --git a/triagebot.toml b/triagebot.toml index c9d6c1a730b7f..6c6daac9cf3b1 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -540,7 +540,6 @@ trigger_files = [ [autolabel."A-query-system"] trigger_files = [ - "compiler/rustc_query_system", "compiler/rustc_query_impl", "compiler/rustc_macros/src/query.rs" ] @@ -1557,8 +1556,10 @@ dep-bumps = [ "/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"] "/compiler/rustc_codegen_ssa" = ["compiler", "codegen"] "/compiler/rustc_middle/src/dep_graph" = ["compiler", "incremental", "query-system"] +"/compiler/rustc_middle/src/ich" = ["compiler", "incremental", "query-system"] "/compiler/rustc_middle/src/mir" = ["compiler", "mir"] "/compiler/rustc_middle/src/traits" = ["compiler", "types"] +"/compiler/rustc_middle/src/query" = ["compiler", "query-system"] "/compiler/rustc_middle/src/ty" = ["compiler", "types"] "/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] "/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] @@ -1567,8 +1568,6 @@ dep-bumps = [ "/compiler/rustc_parse" = ["compiler", "parser"] "/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"] "/compiler/rustc_query_impl" = ["compiler", "query-system"] -"/compiler/rustc_query_system" = ["compiler", "query-system"] -"/compiler/rustc_query_system/src/ich" = ["compiler", "incremental", "query-system"] "/compiler/rustc_trait_selection" = ["compiler", "types"] "/compiler/rustc_traits" = ["compiler", "types"] "/compiler/rustc_type_ir" = ["compiler", "types"]