-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as not planned
Description
Just a small note, but the repr(Rust)
memory layout does not guarantee that two similarly defined structs are laid out the exact same way in memory. Thus, transmutes between repr(Rust)
types are UB.
For reference, please see this nomicon article here:
https://doc.rust-lang.org/nomicon/repr-rust.html
Rust does guarantee that two instances of A have their data laid out in exactly the same way. However Rust does not currently guarantee that an instance of A has the same field ordering or padding as an instance of B.
The struct in question requires a repr(transparent)
or repr(C)
to be safe. However, ThreadId
does not have any of these on it, so putting it only on one will do little good.
Line 120 in 156eff9
std::mem::transmute::<std::thread::ThreadId, FakeThreadId>(thread::current().id()).0 |
Metadata
Metadata
Assignees
Labels
No labels