Skip to content

Commit d2dc425

Browse files
committed
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 #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](#92103 (comment))). I'll try to send the PR again with a fix for this issue. r? `@the8472`
2 parents ef119d7 + 50f8062 commit d2dc425

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

compiler/rustc_data_structures/src/sip128.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -409,20 +409,6 @@ impl SipHasher128 {
409409
}
410410
}
411411

412-
macro_rules! dispatch_value {
413-
($target: expr, $value:expr) => {
414-
let value = $value;
415-
#[allow(unreachable_patterns)]
416-
#[allow(overflowing_literals)]
417-
match value {
418-
0..=0xFF => $target.short_write(value as u8),
419-
0x100..=0xFFFF => $target.short_write(value as u16),
420-
0x10000..=0xFFFFFFFF => $target.short_write(value as u32),
421-
_ => $target.short_write(value as u64),
422-
}
423-
};
424-
}
425-
426412
impl Hasher for SipHasher128 {
427413
#[inline]
428414
fn write_u8(&mut self, i: u8) {
@@ -436,7 +422,7 @@ impl Hasher for SipHasher128 {
436422

437423
#[inline]
438424
fn write_u32(&mut self, i: u32) {
439-
dispatch_value!(self, i);
425+
self.short_write(i);
440426
}
441427

442428
#[inline]
@@ -466,7 +452,7 @@ impl Hasher for SipHasher128 {
466452

467453
#[inline]
468454
fn write_i64(&mut self, i: i64) {
469-
dispatch_value!(self, i as u64);
455+
self.short_write(i as u64);
470456
}
471457

472458
#[inline]

src/test/debuginfo/function-names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Const generic parameter
3838
// gdb-command:info functions -q function_names::const_generic_fn.*
3939
// gdb-check:[...]static fn function_names::const_generic_fn_bool<false>();
40-
// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#3fcd7c34c1555be6}>();
40+
// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>();
4141
// gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>();
4242
// gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>();
4343

@@ -76,7 +76,7 @@
7676
// Const generic parameter
7777
// cdb-command:x a!function_names::const_generic_fn*
7878
// cdb-check:[...] a!function_names::const_generic_fn_bool<false> (void)
79-
// cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST$3fcd7c34c1555be6> (void)
79+
// cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST$fe3cfa0214ac55c7> (void)
8080
// cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void)
8181
// cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void)
8282

src/test/ui/symbol-names/basic.legacy.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: symbol-name(_ZN5basic4main17h13492e1c4157543fE)
1+
error: symbol-name(_ZN5basic4main17h7c2c715a9b77648bE)
22
--> $DIR/basic.rs:8:1
33
|
44
LL | #[rustc_symbol_name]
55
| ^^^^^^^^^^^^^^^^^^^^
66

7-
error: demangling(basic::main::h13492e1c4157543f)
7+
error: demangling(basic::main::h7c2c715a9b77648b)
88
--> $DIR/basic.rs:8:1
99
|
1010
LL | #[rustc_symbol_name]

src/test/ui/symbol-names/issue-60925.legacy.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hd250581ce0d79d13E)
1+
error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h419983d0842a72aeE)
22
--> $DIR/issue-60925.rs:21:9
33
|
44
LL | #[rustc_symbol_name]
55
| ^^^^^^^^^^^^^^^^^^^^
66

7-
error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::hd250581ce0d79d13)
7+
error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h419983d0842a72ae)
88
--> $DIR/issue-60925.rs:21:9
99
|
1010
LL | #[rustc_symbol_name]

0 commit comments

Comments
 (0)