Skip to content

Commit c5aa659

Browse files
committed
Reduce alignment of TypeId to u64 alignment
1 parent bb59453 commit c5aa659

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

library/core/src/any.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ impl dyn Any + Send + Sync {
605605
#[derive(Clone, Copy, Debug, Eq, PartialOrd, Ord)]
606606
#[stable(feature = "rust1", since = "1.0.0")]
607607
pub struct TypeId {
608-
t: u128,
608+
// See #115620 for this representation.
609+
t: (u64, u64),
609610
}
610611

611612
#[stable(feature = "rust1", since = "1.0.0")]
@@ -637,7 +638,10 @@ impl TypeId {
637638
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
638639
pub const fn of<T: ?Sized + 'static>() -> TypeId {
639640
let t: u128 = intrinsics::type_id::<T>();
640-
TypeId { t }
641+
642+
let t1 = (t >> 64) as u64;
643+
let t2 = t as u64;
644+
TypeId { t: (t1, t2) }
641645
}
642646
}
643647

@@ -657,7 +661,7 @@ impl hash::Hash for TypeId {
657661
// - It is correct to do so -- only hashing a subset of `self` is still
658662
// with an `Eq` implementation that considers the entire value, as
659663
// ours does.
660-
(self.t as u64).hash(state);
664+
self.t.0.hash(state);
661665
}
662666
}
663667

0 commit comments

Comments
 (0)