Skip to content

Commit

Permalink
Auto merge of rust-lang#127479 - Urgau:rustc-stable-hash, r=<try>
Browse files Browse the repository at this point in the history
Use rustc-stable-hash in the compiler

cc `@michaelwoerister`
r? ghost
  • Loading branch information
bors committed Jul 8, 2024
2 parents 7fdefb8 + 56e0384 commit 22a9c26
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 1,043 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3514,6 +3514,11 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be1bdc7edf596692617627bbfeaba522131b18e06ca4df2b6b689e3c5d5ce84"

[[package]]
name = "rustc-stable-hash"
version = "0.1.0"
source = "git+https://github.com/rust-lang/rustc-stable-hash?rev=refs/pull/8/head#f2780d22c5370b430fb44848c4e12c636a5fee60"

[[package]]
name = "rustc-std-workspace-alloc"
version = "1.99.0"
Expand Down Expand Up @@ -3852,6 +3857,7 @@ dependencies = [
"portable-atomic",
"rustc-hash",
"rustc-rayon",
"rustc-stable-hash",
"rustc_arena",
"rustc_graphviz",
"rustc_index",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobserver_crate = { version = "0.1.28", package = "jobserver" }
measureme = "11"
rustc-hash = "1.1.0"
rustc-rayon = { version = "0.5.0", optional = true }
rustc-stable-hash = { git = "https://github.com/rust-lang/rustc-stable-hash", rev = "refs/pull/8/head", features = ["nightly"] }
rustc_arena = { path = "../rustc_arena" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_index = { path = "../rustc_index", package = "rustc_index" }
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_data_structures/src/fingerprint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::stable_hasher::impl_stable_traits_for_trivial_type;
use crate::stable_hasher::{Hash64, StableHasher, StableHasherResult};
use crate::stable_hasher::{Hash64, StableHasherResult};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use std::hash::{Hash, Hasher};

Expand Down Expand Up @@ -155,9 +155,10 @@ impl FingerprintHasher for crate::unhash::Unhasher {
}

impl StableHasherResult for Fingerprint {
type Hash = [u64; 2];

#[inline]
fn finish(hasher: StableHasher) -> Self {
let (_0, _1) = hasher.finalize();
fn finish([_0, _1]: Self::Hash) -> Self {
Fingerprint(_0, _1)
}
}
Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_data_structures/src/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! connect the fact that they can only be produced by a `StableHasher` to their
//! `Encode`/`Decode` impls.
use crate::stable_hasher::{StableHasher, StableHasherResult};
use crate::stable_hasher::StableHasherResult;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use std::fmt;
use std::ops::BitXorAssign;
Expand Down Expand Up @@ -57,9 +57,11 @@ impl<D: Decoder> Decodable<D> for Hash64 {
}

impl StableHasherResult for Hash64 {
type Hash = [u64; 2];

#[inline]
fn finish(hasher: StableHasher) -> Self {
Self { inner: hasher.finalize().0 }
fn finish([_0, __1]: Self::Hash) -> Self {
Self { inner: _0 }
}
}

Expand Down Expand Up @@ -122,9 +124,10 @@ impl<D: Decoder> Decodable<D> for Hash128 {
}

impl StableHasherResult for Hash128 {
type Hash = [u64; 2];

#[inline]
fn finish(hasher: StableHasher) -> Self {
let (_0, _1) = hasher.finalize();
fn finish([_0, _1]: Self::Hash) -> Self {
Self { inner: u128::from(_0) | (u128::from(_1) << 64) }
}
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#![feature(core_intrinsics)]
#![feature(extend_one)]
#![feature(hash_raw_entry)]
#![feature(hasher_prefixfree_extras)]
#![feature(macro_metavar_expr)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
Expand Down Expand Up @@ -67,7 +66,6 @@ pub mod owned_slice;
pub mod packed;
pub mod profiling;
pub mod sharded;
pub mod sip128;
pub mod small_c_str;
pub mod snapshot_map;
pub mod sorted_map;
Expand Down
Loading

0 comments on commit 22a9c26

Please sign in to comment.