Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #137095 - saethlin:use-hash64-for-hashes, r=workingjubilee
Replace some u64 hashes with Hash64 I introduced the Hash64 and Hash128 types in https://github.com/rust-lang/rust/pull/110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64. This reverts part of https://github.com/rust-lang/rust/pull/117603, which turned an encoded Hash64 into a u64. Based on https://github.com/rust-lang/rust/pull/110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
Matthias Krüger 2025-02-17
parent 1aac875 · parent b4b1e77 · commit 425df42
-rw-r--r--crates/hir-def/src/data/adt.rs3
-rw-r--r--crates/hir-def/src/lib.rs6
-rw-r--r--crates/hir-ty/src/layout.rs9
-rw-r--r--crates/hir-ty/src/lib.rs6
4 files changed, 19 insertions, 5 deletions
diff --git a/crates/hir-def/src/data/adt.rs b/crates/hir-def/src/data/adt.rs
index 8fc1985403..5d1834a864 100644
--- a/crates/hir-def/src/data/adt.rs
+++ b/crates/hir-def/src/data/adt.rs
@@ -9,6 +9,7 @@ use hir_expand::name::Name;
use intern::sym;
use la_arena::Arena;
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
+use rustc_hashes::Hash64;
use triomphe::Arc;
use tt::iter::TtElement;
@@ -172,7 +173,7 @@ fn parse_repr_tt(tt: &TopSubtree) -> Option<ReprOptions> {
}
}
- Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: 0 })
+ Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: Hash64::ZERO })
}
impl StructData {
diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs
index c8efd90432..9c947df35e 100644
--- a/crates/hir-def/src/lib.rs
+++ b/crates/hir-def/src/lib.rs
@@ -18,9 +18,15 @@ extern crate ra_ap_rustc_parse_format as rustc_parse_format;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_abi;
+#[cfg(feature = "in-rust-tree")]
+extern crate rustc_hashes;
+
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_abi as rustc_abi;
+#[cfg(not(feature = "in-rust-tree"))]
+extern crate ra_ap_rustc_hashes as rustc_hashes;
+
pub mod db;
pub mod attr;
diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs
index 108171586e..b6f7c44c2a 100644
--- a/crates/hir-ty/src/layout.rs
+++ b/crates/hir-ty/src/layout.rs
@@ -15,6 +15,7 @@ use hir_def::{
use la_arena::{Idx, RawIdx};
use rustc_abi::AddressSpace;
use rustc_index::{IndexSlice, IndexVec};
+use rustc_hashes::Hash64;
use triomphe::Arc;
@@ -197,7 +198,7 @@ fn layout_of_simd_ty(
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
- randomization_seed: 0,
+ randomization_seed: Hash64::ZERO,
}))
}
@@ -314,7 +315,7 @@ pub fn layout_of_ty_query(
size,
max_repr_align: None,
unadjusted_abi_align: element.align.abi,
- randomization_seed: 0,
+ randomization_seed: Hash64::ZERO,
}
}
TyKind::Slice(element) => {
@@ -328,7 +329,7 @@ pub fn layout_of_ty_query(
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: element.align.abi,
- randomization_seed: 0,
+ randomization_seed: Hash64::ZERO,
}
}
TyKind::Str => Layout {
@@ -340,7 +341,7 @@ pub fn layout_of_ty_query(
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align.abi,
- randomization_seed: 0,
+ randomization_seed: Hash64::ZERO,
},
// Potentially-wide pointers.
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index 55d81875a2..daddcf0b24 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -12,6 +12,9 @@ extern crate ra_ap_rustc_index as rustc_index;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_abi;
+#[cfg(feature = "in-rust-tree")]
+extern crate rustc_hashes;
+
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_abi as rustc_abi;
@@ -21,6 +24,9 @@ extern crate rustc_pattern_analysis;
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_pattern_analysis as rustc_pattern_analysis;
+#[cfg(not(feature = "in-rust-tree"))]
+extern crate ra_ap_rustc_hashes as rustc_hashes;
+
mod builder;
mod chalk_db;
mod chalk_ext;