diff options
| author | bors <bors@rust-lang.org> | 2022-01-24 11:20:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-24 11:20:01 +0000 |
| commit | d2dc425721554348d4ed427f7eb89cdb49efefdb (patch) | |
| tree | 4b22bae886375dea54ccdc49bb4c7c986d368369 /compiler/rustc_data_structures | |
| parent | ef119d704d87a05435ea97ef4161529142313a9b (diff) | |
| parent | 50f8062316e37e9be6ee58dc7e5311a5515591da (diff) | |
| download | rust-d2dc425721554348d4ed427f7eb89cdb49efefdb.tar.gz rust-d2dc425721554348d4ed427f7eb89cdb49efefdb.zip | |
Auto merge of #93014 - Kobzol:revert-92103-stable-hash-skip-zero-bytes, r=the8472
Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher" Reverts rust-lang/rust#92103. It had a (in retrospect, obvious) correctness problem where changing the order of two adjacent values would produce identical hashes, which is problematic in stable hashing (see [this comment](https://github.com/rust-lang/rust/pull/92103#issuecomment-1014625442)). I'll try to send the PR again with a fix for this issue. r? `@the8472`
Diffstat (limited to 'compiler/rustc_data_structures')
| -rw-r--r-- | compiler/rustc_data_structures/src/sip128.rs | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/compiler/rustc_data_structures/src/sip128.rs b/compiler/rustc_data_structures/src/sip128.rs index 872b0eb7854..53062b9c20d 100644 --- a/compiler/rustc_data_structures/src/sip128.rs +++ b/compiler/rustc_data_structures/src/sip128.rs @@ -409,20 +409,6 @@ impl SipHasher128 { } } -macro_rules! dispatch_value { - ($target: expr, $value:expr) => { - let value = $value; - #[allow(unreachable_patterns)] - #[allow(overflowing_literals)] - match value { - 0..=0xFF => $target.short_write(value as u8), - 0x100..=0xFFFF => $target.short_write(value as u16), - 0x10000..=0xFFFFFFFF => $target.short_write(value as u32), - _ => $target.short_write(value as u64), - } - }; -} - impl Hasher for SipHasher128 { #[inline] fn write_u8(&mut self, i: u8) { @@ -436,7 +422,7 @@ impl Hasher for SipHasher128 { #[inline] fn write_u32(&mut self, i: u32) { - dispatch_value!(self, i); + self.short_write(i); } #[inline] @@ -466,7 +452,7 @@ impl Hasher for SipHasher128 { #[inline] fn write_i64(&mut self, i: i64) { - dispatch_value!(self, i as u64); + self.short_write(i as u64); } #[inline] |
