Access StableHashingContext in rustc_query_system.
This commit is contained in:
parent
471cb5c149
commit
fedd7785fe
6 changed files with 17 additions and 25 deletions
|
@ -90,10 +90,9 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
|
|||
|
||||
impl<'tcx> DepContext for TyCtxt<'tcx> {
|
||||
type DepKind = DepKind;
|
||||
type StableHashingContext = StableHashingContext<'tcx>;
|
||||
|
||||
#[inline]
|
||||
fn create_stable_hashing_context(&self) -> Self::StableHashingContext {
|
||||
fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
|
||||
TyCtxt::create_stable_hashing_context(*self)
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ impl<'tcx> std::ops::Deref for QueryCtxt<'tcx> {
|
|||
|
||||
impl HasDepContext for QueryCtxt<'tcx> {
|
||||
type DepKind = rustc_middle::dep_graph::DepKind;
|
||||
type StableHashingContext = rustc_query_system::ich::StableHashingContext<'tcx>;
|
||||
type DepContext = TyCtxt<'tcx>;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
//! lost during fingerprint computation.
|
||||
|
||||
use super::{DepContext, DepKind};
|
||||
use crate::ich::StableHashingContext;
|
||||
|
||||
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
|
||||
|
@ -119,7 +119,7 @@ pub trait DepNodeParams<Ctxt: DepContext>: fmt::Debug + Sized {
|
|||
|
||||
impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T
|
||||
where
|
||||
T: HashStable<Ctxt::StableHashingContext> + fmt::Debug,
|
||||
T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug,
|
||||
{
|
||||
#[inline]
|
||||
default fn can_reconstruct_query_key() -> bool {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use parking_lot::Mutex;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::profiling::{EventId, QueryInvocationId, SelfProfilerRef};
|
||||
|
@ -7,8 +8,6 @@ use rustc_data_structures::steal::Steal;
|
|||
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fmt::Debug;
|
||||
|
@ -19,6 +18,7 @@ use std::sync::atomic::Ordering::Relaxed;
|
|||
use super::query::DepGraphQuery;
|
||||
use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
|
||||
use super::{DepContext, DepKind, DepNode, HasDepContext, WorkProductId};
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::{QueryContext, QuerySideEffects};
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
@ -96,9 +96,9 @@ struct DepGraphData<K: DepKind> {
|
|||
dep_node_debug: Lock<FxHashMap<DepNode<K>, String>>,
|
||||
}
|
||||
|
||||
pub fn hash_result<HashCtxt, R>(hcx: &mut HashCtxt, result: &R) -> Option<Fingerprint>
|
||||
pub fn hash_result<R>(hcx: &mut StableHashingContext<'_>, result: &R) -> Option<Fingerprint>
|
||||
where
|
||||
R: HashStable<HashCtxt>,
|
||||
R: for<'a> HashStable<StableHashingContext<'a>>,
|
||||
{
|
||||
let mut stable_hasher = StableHasher::new();
|
||||
result.hash_stable(hcx, &mut stable_hasher);
|
||||
|
@ -215,7 +215,7 @@ impl<K: DepKind> DepGraph<K> {
|
|||
cx: Ctxt,
|
||||
arg: A,
|
||||
task: fn(Ctxt, A) -> R,
|
||||
hash_result: fn(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>,
|
||||
hash_result: fn(&mut StableHashingContext<'_>, &R) -> Option<Fingerprint>,
|
||||
) -> (R, DepNodeIndex) {
|
||||
if self.is_fully_enabled() {
|
||||
self.with_task_impl(key, cx, arg, task, hash_result)
|
||||
|
@ -234,7 +234,7 @@ impl<K: DepKind> DepGraph<K> {
|
|||
cx: Ctxt,
|
||||
arg: A,
|
||||
task: fn(Ctxt, A) -> R,
|
||||
hash_result: fn(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>,
|
||||
hash_result: fn(&mut StableHashingContext<'_>, &R) -> Option<Fingerprint>,
|
||||
) -> (R, DepNodeIndex) {
|
||||
// This function is only called when the graph is enabled.
|
||||
let data = self.data.as_ref().unwrap();
|
||||
|
|
|
@ -9,6 +9,7 @@ pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, Wor
|
|||
pub use query::DepGraphQuery;
|
||||
pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
|
||||
|
||||
use crate::ich::StableHashingContext;
|
||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_serialize::{opaque::FileEncoder, Encodable};
|
||||
|
@ -19,10 +20,9 @@ use std::hash::Hash;
|
|||
|
||||
pub trait DepContext: Copy {
|
||||
type DepKind: self::DepKind;
|
||||
type StableHashingContext;
|
||||
|
||||
/// Create a hashing context for hashing new results.
|
||||
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
|
||||
fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
|
||||
|
||||
/// Access the DepGraph.
|
||||
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
|
||||
|
@ -36,18 +36,13 @@ pub trait DepContext: Copy {
|
|||
|
||||
pub trait HasDepContext: Copy {
|
||||
type DepKind: self::DepKind;
|
||||
type StableHashingContext;
|
||||
type DepContext: self::DepContext<
|
||||
DepKind = Self::DepKind,
|
||||
StableHashingContext = Self::StableHashingContext,
|
||||
>;
|
||||
type DepContext: self::DepContext<DepKind = Self::DepKind>;
|
||||
|
||||
fn dep_context(&self) -> &Self::DepContext;
|
||||
}
|
||||
|
||||
impl<T: DepContext> HasDepContext for T {
|
||||
type DepKind = T::DepKind;
|
||||
type StableHashingContext = T::StableHashingContext;
|
||||
type DepContext = Self;
|
||||
|
||||
fn dep_context(&self) -> &Self::DepContext {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use crate::dep_graph::DepNode;
|
||||
use crate::dep_graph::SerializedDepNodeIndex;
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::caches::QueryCache;
|
||||
use crate::query::{QueryCacheStore, QueryContext, QueryState};
|
||||
|
||||
|
@ -23,7 +24,7 @@ pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
|
|||
pub dep_kind: CTX::DepKind,
|
||||
pub eval_always: bool,
|
||||
|
||||
pub hash_result: fn(&mut CTX::StableHashingContext, &V) -> Option<Fingerprint>,
|
||||
pub hash_result: fn(&mut StableHashingContext<'_>, &V) -> Option<Fingerprint>,
|
||||
pub handle_cycle_error: fn(CTX, DiagnosticBuilder<'_>) -> V,
|
||||
pub cache_on_disk: fn(CTX, &K, Option<&V>) -> bool,
|
||||
pub try_load_from_disk: fn(CTX, SerializedDepNodeIndex) -> Option<V>,
|
||||
|
@ -39,7 +40,7 @@ impl<CTX: QueryContext, K, V> QueryVtable<CTX, K, V> {
|
|||
|
||||
pub(crate) fn hash_result(
|
||||
&self,
|
||||
hcx: &mut CTX::StableHashingContext,
|
||||
hcx: &mut StableHashingContext<'_>,
|
||||
value: &V,
|
||||
) -> Option<Fingerprint> {
|
||||
(self.hash_result)(hcx, value)
|
||||
|
@ -74,10 +75,8 @@ pub trait QueryAccessors<CTX: QueryContext>: QueryConfig {
|
|||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||
fn compute_fn(tcx: CTX, key: &Self::Key) -> fn(CTX::DepContext, Self::Key) -> Self::Value;
|
||||
|
||||
fn hash_result(
|
||||
hcx: &mut CTX::StableHashingContext,
|
||||
result: &Self::Value,
|
||||
) -> Option<Fingerprint>;
|
||||
fn hash_result(hcx: &mut StableHashingContext<'_>, result: &Self::Value)
|
||||
-> Option<Fingerprint>;
|
||||
|
||||
fn handle_cycle_error(tcx: CTX, diag: DiagnosticBuilder<'_>) -> Self::Value;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue