Skip to content

Commit

Permalink
Implement HashStable directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 27, 2020
1 parent 222d010 commit 2d7bbda
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/librustc/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,3 @@ fn def_id_corresponds_to_hir_dep_node(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
def_id.index == hir_id.owner.local_def_index
}

impl rustc_query_system::HashStableContext for StableHashingContext<'_> {}
9 changes: 7 additions & 2 deletions src/librustc_query_system/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use super::{DepContext, DepKind};

use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_macros::HashStable_Generic;

use std::fmt;
use std::hash::Hash;
Expand Down Expand Up @@ -127,7 +126,6 @@ where
/// the need to be mapped or unmapped. (This ensures we can serialize
/// them even in the absence of a tcx.)
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(HashStable_Generic)]
pub struct WorkProductId {
hash: Fingerprint,
}
Expand All @@ -144,3 +142,10 @@ impl WorkProductId {
WorkProductId { hash: fingerprint }
}
}

impl<HCX> HashStable<HCX> for WorkProductId {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
self.hash.hash_stable(hcx, hasher)
}
}
2 changes: 1 addition & 1 deletion src/librustc_query_system/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::hash::Hash;

pub trait DepContext: Copy {
type DepKind: self::DepKind;
type StableHashingContext: crate::HashStableContext;
type StableHashingContext;

/// Create a hashing context for hashing new results.
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_query_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ extern crate rustc_data_structures;

pub mod dep_graph;
pub mod query;

pub trait HashStableContext {}

0 comments on commit 2d7bbda

Please sign in to comment.