diff options
Diffstat (limited to 'compiler/rustc_query_system')
| -rw-r--r-- | compiler/rustc_query_system/src/cache.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/debug.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/dep_node.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/edges.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/mod.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/serialized.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/ich/hcx.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/ich/impls_syntax.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/ich/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/caches.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/config.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/job.rs | 19 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 31 |
16 files changed, 89 insertions, 83 deletions
diff --git a/compiler/rustc_query_system/src/cache.rs b/compiler/rustc_query_system/src/cache.rs index d8a5bdba7b8..1b8332ad9e0 100644 --- a/compiler/rustc_query_system/src/cache.rs +++ b/compiler/rustc_query_system/src/cache.rs @@ -1,11 +1,11 @@ //! Cache for candidate selection. -use crate::dep_graph::{DepContext, DepNodeIndex}; +use std::hash::Hash; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lock; -use std::hash::Hash; +use crate::dep_graph::{DepContext, DepNodeIndex}; pub struct Cache<Key, Value> { hashmap: Lock<FxHashMap<Key, WithDepNode<Value>>>, diff --git a/compiler/rustc_query_system/src/dep_graph/debug.rs b/compiler/rustc_query_system/src/dep_graph/debug.rs index 103a6c01bd2..4d009d63de5 100644 --- a/compiler/rustc_query_system/src/dep_graph/debug.rs +++ b/compiler/rustc_query_system/src/dep_graph/debug.rs @@ -1,9 +1,11 @@ //! Code for debugging the dep-graph. -use super::{DepNode, DepNodeIndex}; +use std::error::Error; + use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lock; -use std::error::Error; + +use super::{DepNode, DepNodeIndex}; /// A dep-node filter goes from a user-defined string to a query over /// nodes. Right now the format is like this: diff --git a/compiler/rustc_query_system/src/dep_graph/dep_node.rs b/compiler/rustc_query_system/src/dep_graph/dep_node.rs index f2a68e35671..dfd0527252d 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -42,16 +42,17 @@ //! `DefId` it was computed from. In other cases, too much information gets //! lost during fingerprint computation. -use super::{DepContext, FingerprintStyle}; -use crate::ich::StableHashingContext; +use std::fmt; +use std::hash::Hash; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; use rustc_data_structures::AtomicRef; use rustc_hir::definitions::DefPathHash; use rustc_macros::{Decodable, Encodable}; -use std::fmt; -use std::hash::Hash; + +use super::{DepContext, FingerprintStyle}; +use crate::ich::StableHashingContext; /// This serves as an index into arrays built by `make_dep_kind_array`. #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -312,8 +313,9 @@ impl StableOrd for WorkProductId { // Some types are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts { - use super::*; use rustc_data_structures::static_assert_size; + + use super::*; // tidy-alphabetical-start static_assert_size!(DepKind, 2); #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/compiler/rustc_query_system/src/dep_graph/edges.rs b/compiler/rustc_query_system/src/dep_graph/edges.rs index 63d46f47f5c..9a3763bd4ee 100644 --- a/compiler/rustc_query_system/src/dep_graph/edges.rs +++ b/compiler/rustc_query_system/src/dep_graph/edges.rs @@ -1,8 +1,10 @@ -use crate::dep_graph::DepNodeIndex; -use smallvec::SmallVec; use std::hash::{Hash, Hasher}; use std::ops::Deref; +use smallvec::SmallVec; + +use crate::dep_graph::DepNodeIndex; + #[derive(Default, Debug)] pub(crate) struct EdgesVec { max: u32, diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 66fb3136805..b6aa1d5a43b 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1,3 +1,11 @@ +use std::assert_matches::assert_matches; +use std::collections::hash_map::Entry; +use std::fmt::Debug; +use std::hash::Hash; +use std::marker::PhantomData; +use std::sync::atomic::Ordering; +use std::sync::Arc; + use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef}; @@ -8,14 +16,9 @@ use rustc_data_structures::unord::UnordMap; use rustc_index::IndexVec; use rustc_macros::{Decodable, Encodable}; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; -use std::assert_matches::assert_matches; -use std::collections::hash_map::Entry; -use std::fmt::Debug; -use std::hash::Hash; -use std::marker::PhantomData; -use std::sync::atomic::Ordering; -use std::sync::Arc; use tracing::{debug, instrument}; +#[cfg(debug_assertions)] +use {super::debug::EdgeFilter, std::env}; use super::query::DepGraphQuery; use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; @@ -24,9 +27,6 @@ use crate::dep_graph::edges::EdgesVec; use crate::ich::StableHashingContext; use crate::query::{QueryContext, QuerySideEffects}; -#[cfg(debug_assertions)] -use {super::debug::EdgeFilter, std::env}; - #[derive(Clone)] pub struct DepGraph<D: Deps> { data: Option<Lrc<DepGraphData<D>>>, diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index cfb25ec905f..291f275ef3c 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -5,18 +5,19 @@ mod graph; mod query; mod serialized; +use std::panic; + pub use dep_node::{DepKind, DepKindStruct, DepNode, DepNodeParams, WorkProductId}; pub(crate) use graph::DepGraphData; pub use graph::{hash_result, DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap}; pub use query::DepGraphQuery; +use rustc_data_structures::profiling::SelfProfilerRef; +use rustc_session::Session; pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex}; +use tracing::instrument; use self::graph::{print_markframe_trace, MarkFrame}; use crate::ich::StableHashingContext; -use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_session::Session; -use std::panic; -use tracing::instrument; pub trait DepContext: Copy { type Deps: Deps; diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index 8e91d9dd60b..ff1c3431b7c 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -35,11 +35,11 @@ //! If the number of edges in this node does not fit in the bits available in the header, we //! store it directly after the header with leb128. -use super::query::DepGraphQuery; -use super::{DepKind, DepNode, DepNodeIndex, Deps}; -use crate::dep_graph::edges::EdgesVec; -use rustc_data_structures::fingerprint::Fingerprint; -use rustc_data_structures::fingerprint::PackedFingerprint; +use std::iter; +use std::marker::PhantomData; +use std::sync::Arc; + +use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::outline; use rustc_data_structures::profiling::SelfProfilerRef; @@ -48,11 +48,12 @@ use rustc_data_structures::unhash::UnhashMap; use rustc_index::{Idx, IndexVec}; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use std::iter; -use std::marker::PhantomData; -use std::sync::Arc; use tracing::{debug, instrument}; +use super::query::DepGraphQuery; +use super::{DepKind, DepNode, DepNodeIndex, Deps}; +use crate::dep_graph::edges::EdgesVec; + // The maximum value of `SerializedDepNodeIndex` leaves the upper two bits // unused so that we can store multiple index types in `CompressedHybridIndex`, // and use those bits to encode which index type it contains. diff --git a/compiler/rustc_query_system/src/ich/hcx.rs b/compiler/rustc_query_system/src/ich/hcx.rs index e7eb9694f47..756ad3b1a2d 100644 --- a/compiler/rustc_query_system/src/ich/hcx.rs +++ b/compiler/rustc_query_system/src/ich/hcx.rs @@ -1,5 +1,3 @@ -use crate::ich; - use rustc_ast as ast; use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher}; use rustc_data_structures::sync::Lrc; @@ -11,6 +9,8 @@ use rustc_span::source_map::SourceMap; use rustc_span::symbol::Symbol; use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData, DUMMY_SP}; +use crate::ich; + /// This is the context state available during incr. comp. hashing. It contains /// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e., /// a reference to the `TyCtxt`) and it holds a few caches for speeding up various diff --git a/compiler/rustc_query_system/src/ich/impls_syntax.rs b/compiler/rustc_query_system/src/ich/impls_syntax.rs index 39da5e395c4..8d7a6e4fa9b 100644 --- a/compiler/rustc_query_system/src/ich/impls_syntax.rs +++ b/compiler/rustc_query_system/src/ich/impls_syntax.rs @@ -1,15 +1,15 @@ //! This module contains `HashStable` implementations for various data types //! from `rustc_ast` in no particular order. -use crate::ich::StableHashingContext; +use std::assert_matches::assert_matches; use rustc_ast as ast; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_span::SourceFile; -use std::assert_matches::assert_matches; - use smallvec::SmallVec; +use crate::ich::StableHashingContext; + impl<'ctx> rustc_target::HashStableContext for StableHashingContext<'ctx> {} impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] { diff --git a/compiler/rustc_query_system/src/ich/mod.rs b/compiler/rustc_query_system/src/ich/mod.rs index 86e3ecb1edd..bae76885141 100644 --- a/compiler/rustc_query_system/src/ich/mod.rs +++ b/compiler/rustc_query_system/src/ich/mod.rs @@ -1,8 +1,9 @@ //! ICH - Incremental Compilation Hash -pub use self::hcx::StableHashingContext; use rustc_span::symbol::{sym, Symbol}; +pub use self::hcx::StableHashingContext; + mod hcx; mod impls_syntax; diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index 41222e83f7c..7a50a9534c2 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -14,9 +14,7 @@ pub mod ich; pub mod query; mod values; -pub use error::HandleCycleError; -pub use error::LayoutOfDepth; -pub use error::QueryOverflow; +pub use error::{HandleCycleError, LayoutOfDepth, QueryOverflow}; pub use values::Value; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_query_system/src/query/caches.rs b/compiler/rustc_query_system/src/query/caches.rs index acc29b67ccc..a4ced3d2c24 100644 --- a/compiler/rustc_query_system/src/query/caches.rs +++ b/compiler/rustc_query_system/src/query/caches.rs @@ -1,14 +1,14 @@ -use crate::dep_graph::DepNodeIndex; +use std::fmt::Debug; +use std::hash::Hash; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sharded::{self, Sharded}; use rustc_data_structures::sync::{Lock, OnceLock}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_index::{Idx, IndexVec}; -use rustc_span::def_id::DefId; -use rustc_span::def_id::DefIndex; -use std::fmt::Debug; -use std::hash::Hash; +use rustc_span::def_id::{DefId, DefIndex}; + +use crate::dep_graph::DepNodeIndex; pub trait QueryCache: Sized { type Key: Hash + Eq + Copy + Debug; diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index 958d9fdb52a..371b896400a 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -1,16 +1,16 @@ //! Query configuration and description traits. +use std::fmt::Debug; +use std::hash::Hash; + +use rustc_data_structures::fingerprint::Fingerprint; +use rustc_span::ErrorGuaranteed; + use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex}; use crate::error::HandleCycleError; use crate::ich::StableHashingContext; use crate::query::caches::QueryCache; -use crate::query::DepNodeIndex; -use crate::query::{CycleError, QueryContext, QueryState}; - -use rustc_data_structures::fingerprint::Fingerprint; -use rustc_span::ErrorGuaranteed; -use std::fmt::Debug; -use std::hash::Hash; +use crate::query::{CycleError, DepNodeIndex, QueryContext, QueryState}; pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>; diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 3f44b11850e..761d6acdbae 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -1,18 +1,12 @@ -use crate::dep_graph::DepContext; -use crate::error::CycleStack; -use crate::query::plumbing::CycleError; -use crate::query::DepKind; -use crate::query::{QueryContext, QueryStackFrame}; +use std::hash::Hash; +use std::io::Write; +use std::num::NonZero; + use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diag, DiagCtxtHandle}; use rustc_hir::def::DefKind; use rustc_session::Session; use rustc_span::Span; - -use std::hash::Hash; -use std::io::Write; -use std::num::NonZero; - #[cfg(parallel_compiler)] use { parking_lot::{Condvar, Mutex}, @@ -23,6 +17,11 @@ use { std::sync::Arc, }; +use crate::dep_graph::DepContext; +use crate::error::CycleStack; +use crate::query::plumbing::CycleError; +use crate::query::{DepKind, QueryContext, QueryStackFrame}; + /// Represents a span and a query key. #[derive(Clone, Debug)] pub struct QueryInfo { diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index ab4f48fcd32..db00c265159 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -12,10 +12,6 @@ mod caches; pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache}; mod config; -pub use self::config::{HashResult, QueryConfig}; - -use crate::dep_graph::DepKind; -use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; use rustc_data_structures::stable_hasher::Hash64; use rustc_data_structures::sync::Lock; use rustc_errors::DiagInner; @@ -25,6 +21,9 @@ use rustc_span::def_id::DefId; use rustc_span::Span; use thin_vec::ThinVec; +pub use self::config::{HashResult, QueryConfig}; +use crate::dep_graph::{DepKind, DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; + /// Description of a frame in the query stack. /// /// This is mostly used in case of cycles for error reporting. diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index d37d5bce9cc..8ef680cdb6c 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -2,16 +2,12 @@ //! generate the actual methods on tcx which find and execute the provider, //! manage the caches, and so forth. -use crate::dep_graph::DepGraphData; -use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams}; -use crate::ich::StableHashingContext; -use crate::query::caches::QueryCache; -#[cfg(parallel_compiler)] -use crate::query::job::QueryLatch; -use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo}; -use crate::query::SerializedDepNodeIndex; -use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame}; -use crate::HandleCycleError; +use std::cell::Cell; +use std::collections::hash_map::Entry; +use std::fmt::Debug; +use std::hash::Hash; +use std::mem; + use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sharded::Sharded; @@ -21,15 +17,20 @@ use rustc_data_structures::sync::Lock; use rustc_data_structures::{outline, sync}; use rustc_errors::{Diag, FatalError, StashKey}; use rustc_span::{Span, DUMMY_SP}; -use std::cell::Cell; -use std::collections::hash_map::Entry; -use std::fmt::Debug; -use std::hash::Hash; -use std::mem; use thin_vec::ThinVec; use tracing::instrument; use super::QueryConfig; +use crate::dep_graph::{DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams}; +use crate::ich::StableHashingContext; +use crate::query::caches::QueryCache; +#[cfg(parallel_compiler)] +use crate::query::job::QueryLatch; +use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo}; +use crate::query::{ + QueryContext, QueryMap, QuerySideEffects, QueryStackFrame, SerializedDepNodeIndex, +}; +use crate::HandleCycleError; pub struct QueryState<K> { active: Sharded<FxHashMap<K, QueryResult>>, |
