Closed as not planned
Description
[Edit: Removed a bunch of things that don't matter because this doesn't do what was intended:]
use core::{any::TypeId, marker::PhantomData};
fn type_id_of<T: ?Sized>() -> TypeId {
trait Marker {}
impl<T: ?Sized> Marker for T {}
fn hack<T: ?Sized + Marker + 'static>(_: *const T) -> TypeId {
TypeId::of::<T>()
}
let p = &PhantomData::<T>;
let p = &raw const *p as *const (dyn Marker + 'static);
hack(p)
}
fn type_id_of_val<T: ?Sized>(_: &T) -> TypeId {
type_id_of::<T>()
}
fn main() {
let x = ();
dbg!(type_id_of_val(&x));
}