Skip to content

Commit 625b6f5

Browse files
committed
TypeId: make unstable layout/size explicit
Or worded differently, explicitly remark non-stable-guarantee of `TypeId` layout and size.
1 parent bd3ac03 commit 625b6f5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/core/src/any.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,15 @@ impl dyn Any + Send + Sync {
611611
/// noting that the hashes and ordering will vary between Rust releases. Beware
612612
/// of relying on them inside of your code!
613613
///
614+
/// # Layout
615+
///
616+
/// Like other [`Rust`-representation][repr-rust] types, `TypeId`'s size and layout are unstable.
617+
/// In particular, this means that you cannot rely on the size and layout of `TypeId` remaining the
618+
/// same between Rust releases; they are subject to change without prior notice between Rust
619+
/// releases.
620+
///
621+
/// [repr-rust]: https://doc.rust-lang.org/reference/type-layout.html#r-layout.repr.rust.unspecified
622+
///
614623
/// # Danger of Improper Variance
615624
///
616625
/// You might think that subtyping is impossible between two static types,

0 commit comments

Comments
 (0)