Skip to content

Commit bb35981

Browse files
committed
Keep going
1 parent c115470 commit bb35981

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ impl<CTX> HashStable<CTX> for ::std::num::NonZeroUsize {
268268
}
269269
}
270270

271+
impl HashStableEq for ::std::num::NonZeroUsize {
272+
fn hash_stable_eq(&self, other: &Self) -> bool {
273+
self.get().hash_stable_eq(&other.get())
274+
}
275+
}
276+
271277
impl<CTX> HashStable<CTX> for f32 {
272278
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
273279
let val: u32 = unsafe { ::std::mem::transmute(*self) };
@@ -335,6 +341,9 @@ where
335341

336342
impl<T: HashStableEq> HashStableEq for [T] {
337343
fn hash_stable_eq(&self, other: &Self) -> bool {
344+
if self.len() != other.len() {
345+
return false;
346+
}
338347
for (first, second) in self.iter().zip(other.iter()) {
339348
if !first.hash_stable_eq(second) {
340349
return false;
@@ -383,6 +392,13 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
383392
}
384393
}
385394

395+
impl<T: HashStableEq> HashStableEq for Vec<T> {
396+
#[inline]
397+
fn hash_stable_eq(&self, other: &Self) -> bool {
398+
(&self[..]).hash_stable_eq(other)
399+
}
400+
}
401+
386402
impl<K, V, R, CTX> HashStable<CTX> for indexmap::IndexMap<K, V, R>
387403
where
388404
K: HashStable<CTX> + Eq + Hash,
@@ -469,6 +485,20 @@ impl<CTX> HashStable<CTX> for String {
469485
}
470486
}
471487

488+
impl HashStableEq for str {
489+
#[inline]
490+
fn hash_stable_eq(&self, other: &Self) -> bool {
491+
self.as_bytes().hash_stable_eq(other.as_bytes())
492+
}
493+
}
494+
495+
impl HashStableEq for String {
496+
#[inline]
497+
fn hash_stable_eq(&self, other: &Self) -> bool {
498+
(&self[..]).hash_stable_eq(other)
499+
}
500+
}
501+
472502
impl<HCX> ToStableHashKey<HCX> for String {
473503
type KeyType = String;
474504
#[inline]
@@ -570,6 +600,12 @@ where
570600
}
571601
}
572602

603+
impl<I: vec::Idx, T: HashStableEq> HashStableEq for vec::IndexVec<I, T> {
604+
fn hash_stable_eq(&self, other: &Self) -> bool {
605+
self.iter().as_slice().hash_stable_eq(other.iter().as_slice())
606+
}
607+
}
608+
573609
impl<I: vec::Idx, CTX> HashStable<CTX> for bit_set::BitSet<I> {
574610
fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) {
575611
::std::hash::Hash::hash(self, hasher);

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
462462
/// Information about how to pass an argument to,
463463
/// or return a value from, a function, under some ABI.
464464
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
465+
#[stable_hasher(no_hash_stable_eq)]
465466
pub struct ArgAbi<'a, Ty> {
466467
pub layout: TyAndLayout<'a, Ty>,
467468

@@ -608,6 +609,7 @@ pub enum Conv {
608609
/// I will do my best to describe this structure, but these
609610
/// comments are reverse-engineered and may be inaccurate. -NDM
610611
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
612+
#[stable_hasher(no_hash_stable_eq)]
611613
pub struct FnAbi<'a, Ty> {
612614
/// The LLVM types of each argument.
613615
pub args: Vec<ArgAbi<'a, Ty>>,

compiler/rustc_target/src/abi/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@ rustc_index::newtype_index! {
10271027
}
10281028

10291029
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
1030+
#[stable_hasher(no_hash_stable_eq)]
10301031
pub enum Variants {
10311032
/// Single enum variants, structs/tuples, unions, and all non-ADTs.
10321033
Single { index: VariantIdx },
@@ -1046,6 +1047,7 @@ pub enum Variants {
10461047
}
10471048

10481049
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
1050+
#[stable_hasher(no_hash_stable_eq)]
10491051
pub enum TagEncoding {
10501052
/// The tag directly stores the discriminant, but possibly with a smaller layout
10511053
/// (so converting the tag to the discriminant can require sign extension).
@@ -1150,6 +1152,7 @@ impl Niche {
11501152
}
11511153

11521154
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
1155+
#[stable_hasher(no_hash_stable_eq)]
11531156
pub struct Layout {
11541157
/// Says where the fields are located within the layout.
11551158
pub fields: FieldsShape,
@@ -1204,6 +1207,7 @@ impl Layout {
12041207
/// layouts for which Rust types do not exist, such as enum variants
12051208
/// or synthetic fields of enums (i.e., discriminants) and fat pointers.
12061209
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable_Generic)]
1210+
#[stable_hasher(no_hash_stable_eq)]
12071211
pub struct TyAndLayout<'a, Ty> {
12081212
pub ty: Ty,
12091213
pub layout: &'a Layout,

0 commit comments

Comments
 (0)