Skip to content

Commit 23bd32c

Browse files
authored
Unrolled build for rust-lang#121358
Rollup merge of rust-lang#121358 - GnomedDev:lower-align-typeid, r=Mark-Simulacrum Reduce alignment of TypeId to u64 alignment Closes rust-lang#115620
2 parents b054da8 + f142476 commit 23bd32c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

library/core/src/any.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ 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+
// We avoid using `u128` because that imposes higher alignment requirements on many platforms.
609+
// See issue #115620 for more information.
610+
t: (u64, u64),
609611
}
610612

611613
#[stable(feature = "rust1", since = "1.0.0")]
@@ -637,7 +639,10 @@ impl TypeId {
637639
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
638640
pub const fn of<T: ?Sized + 'static>() -> TypeId {
639641
let t: u128 = intrinsics::type_id::<T>();
640-
TypeId { t }
642+
643+
let t1 = (t >> 64) as u64;
644+
let t2 = t as u64;
645+
TypeId { t: (t1, t2) }
641646
}
642647
}
643648

@@ -657,7 +662,7 @@ impl hash::Hash for TypeId {
657662
// - It is correct to do so -- only hashing a subset of `self` is still
658663
// with an `Eq` implementation that considers the entire value, as
659664
// ours does.
660-
(self.t as u64).hash(state);
665+
self.t.1.hash(state);
661666
}
662667
}
663668

0 commit comments

Comments
 (0)