about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGnomedDev <david2005thomas@gmail.com>2024-02-20 18:59:56 +0000
committerGnomedDev <david2005thomas@gmail.com>2024-02-20 19:01:44 +0000
commitc5aa659832334dca7cc9b27074bdc686b9650c12 (patch)
tree69d3ce63acd0e6850fc22bc4e0e415e8abc97f5d
parentbb594538fc6e84213a6b8d5e165442570aa48923 (diff)
downloadrust-c5aa659832334dca7cc9b27074bdc686b9650c12.tar.gz
rust-c5aa659832334dca7cc9b27074bdc686b9650c12.zip
Reduce alignment of TypeId to u64 alignment
-rw-r--r--library/core/src/any.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/library/core/src/any.rs b/library/core/src/any.rs
index e8f00e8760e..7efbabb7257 100644
--- a/library/core/src/any.rs
+++ b/library/core/src/any.rs
@@ -605,7 +605,8 @@ impl dyn Any + Send + Sync {
 #[derive(Clone, Copy, Debug, Eq, PartialOrd, Ord)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct TypeId {
-    t: u128,
+    // See #115620 for this representation.
+    t: (u64, u64),
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -637,7 +638,10 @@ impl TypeId {
     #[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
     pub const fn of<T: ?Sized + 'static>() -> TypeId {
         let t: u128 = intrinsics::type_id::<T>();
-        TypeId { t }
+
+        let t1 = (t >> 64) as u64;
+        let t2 = t as u64;
+        TypeId { t: (t1, t2) }
     }
 }
 
@@ -657,7 +661,7 @@ impl hash::Hash for TypeId {
         // - It is correct to do so -- only hashing a subset of `self` is still
         //   with an `Eq` implementation that considers the entire value, as
         //   ours does.
-        (self.t as u64).hash(state);
+        self.t.0.hash(state);
     }
 }