File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed
Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -709,6 +709,11 @@ impl dyn Any + Send + Sync {
709709#[ stable( feature = "rust1" , since = "1.0.0" ) ]
710710#[ lang = "type_id" ]
711711pub struct TypeId {
712+ /// This needs to be an array of pointers, since there is provenance
713+ /// in the first array field. This provenance knows exactly which type
714+ /// the TypeId actually is, allowing CTFE and miri to operate based off it.
715+ /// At runtime all the pointers in the array contain bits of the hash, making
716+ /// the entire `TypeId` actually just be a `u128` hash of the type.
712717 pub ( crate ) data : [ * const ( ) ; 16 / size_of :: < usize > ( ) ] ,
713718}
714719
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::any::TypeId;
44
55const _: ( ) = {
66 let id = TypeId :: of :: < u8 > ( ) ;
7- let id: u8 = unsafe { ( & id as * const TypeId ) . cast :: < u8 > ( ) . read ( ) } ;
7+ let id: u8 = unsafe { ( & raw const id ) . cast :: < u8 > ( ) . read ( ) } ;
88 //~^ ERROR: unable to turn pointer into integer
99} ;
1010
Original file line number Diff line number Diff line change 11error[E0080]: unable to turn pointer into integer
22 --> $DIR/const_transmute_type_id.rs:7:27
33 |
4- LL | let id: u8 = unsafe { (&id as * const TypeId ).cast::<u8>().read() };
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
4+ LL | let id: u8 = unsafe { (&raw const id ).cast::<u8>().read() };
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
66 |
77 = help: this code performed an operation that depends on the underlying bytes representing a pointer
88 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
You can’t perform that action at this time.
0 commit comments