about summary refs log tree commit diff
path: root/compiler/rustc_abi/src
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2023-04-07 23:11:20 -0400
committerBen Kimock <kimockb@gmail.com>2023-04-18 10:52:47 -0400
commit0445fbdd835c92156e4d06e42ce99a39e9315343 (patch)
tree98214d1ae76737d58e423427cd7384b1f276230c /compiler/rustc_abi/src
parentde96f3d8735b70d5dc1ca178aaee198b329b8f3d (diff)
Store hashes in special types so they aren't accidentally encoded as numbers
Diffstat (limited to 'compiler/rustc_abi/src')
-rw-r--r--compiler/rustc_abi/src/layout.rs3
-rw-r--r--compiler/rustc_abi/src/lib.rs7
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs
index 2b01aca2ee4..f3af031ade4 100644
--- a/compiler/rustc_abi/src/layout.rs
+++ b/compiler/rustc_abi/src/layout.rs
@@ -79,7 +79,8 @@ pub trait LayoutCalculator {
                 {
                     // `ReprOptions.layout_seed` is a deterministic seed that we can use to
                     // randomize field ordering with
-                    let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
+                    let mut rng =
+                        Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed.as_u64());
 
                     // Shuffle the ordering of the fields
                     optimizing.shuffle(&mut rng);
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs
index 402ea6ff48f..a5cdaa547d8 100644
--- a/compiler/rustc_abi/src/lib.rs
+++ b/compiler/rustc_abi/src/lib.rs
@@ -9,6 +9,7 @@ use std::str::FromStr;
 
 use bitflags::bitflags;
 use rustc_data_structures::intern::Interned;
+use rustc_data_structures::stable_hasher::Hash64;
 #[cfg(feature = "nightly")]
 use rustc_data_structures::stable_hasher::StableOrd;
 use rustc_index::vec::{IndexSlice, IndexVec};
@@ -77,12 +78,12 @@ pub struct ReprOptions {
     pub flags: ReprFlags,
     /// The seed to be used for randomizing a type's layout
     ///
-    /// Note: This could technically be a `[u8; 16]` (a `u128`) which would
+    /// Note: This could technically be a `Hash128` which would
     /// be the "most accurate" hash as it'd encompass the item and crate
     /// hash without loss, but it does pay the price of being larger.
-    /// Everything's a tradeoff, a `u64` seed should be sufficient for our
+    /// Everything's a tradeoff, a 64-bit seed should be sufficient for our
     /// purposes (primarily `-Z randomize-layout`)
-    pub field_shuffle_seed: u64,
+    pub field_shuffle_seed: Hash64,
 }
 
 impl ReprOptions {