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 {
709
709
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
710
710
#[ lang = "type_id" ]
711
711
pub 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.
712
717
pub ( crate ) data : [ * const ( ) ; 16 / size_of :: < usize > ( ) ] ,
713
718
}
714
719
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::any::TypeId;
4
4
5
5
const _: ( ) = {
6
6
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 ( ) } ;
8
8
//~^ ERROR: unable to turn pointer into integer
9
9
} ;
10
10
Original file line number Diff line number Diff line change 1
1
error[E0080]: unable to turn pointer into integer
2
2
--> $DIR/const_transmute_type_id.rs:7:27
3
3
|
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
6
6
|
7
7
= help: this code performed an operation that depends on the underlying bytes representing a pointer
8
8
= 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