Simplify hashing.

This commit is contained in:
Camille GILLOT 2021-02-09 18:53:38 +01:00
parent a87de890fd
commit 903f65f215
3 changed files with 26 additions and 35 deletions

View file

@ -16,8 +16,6 @@ pub use self::config::{QueryAccessors, QueryConfig, QueryDescription};
use crate::dep_graph::{DepNode, DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::Diagnostic;
@ -34,7 +32,8 @@ pub struct QueryStackFrame {
span: Option<Span>,
/// This hash is used to deterministically pick
/// a query to remove cycles in the parallel compiler.
hash: Fingerprint,
#[cfg(parallel_compiler)]
hash: u64,
}
impl QueryStackFrame {
@ -43,9 +42,15 @@ impl QueryStackFrame {
name: &'static str,
description: String,
span: Option<Span>,
hash: Fingerprint,
_hash: impl FnOnce() -> u64,
) -> Self {
Self { name, hash, description, span }
Self {
name,
description,
span,
#[cfg(parallel_compiler)]
hash: _hash(),
}
}
// FIXME(eddyb) Get more valid `Span`s on queries.
@ -58,12 +63,6 @@ impl QueryStackFrame {
}
}
impl<CTX> HashStable<CTX> for QueryStackFrame {
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
self.hash.hash_stable(hcx, hasher)
}
}
pub trait QueryContext: HasDepContext {
/// Get string representation from DefPath.
fn def_path_str(&self, def_id: DefId) -> String;