Closed
Description
I tried this code:
use std::any::TypeId;
use std::any::Any;
use std::hint::black_box;
struct A<T:?Sized+'static> {
a: i32,
b: T
}
impl<T:?Sized+'static> A<T> {
fn bb(&self) -> TypeId {
self.b.type_id()
}
}
pub fn main() {
let mut a0 = A{a: 8, b: 9 as i32};
let mut a: &mut A<dyn Any> = &mut a0;
println!("{:?}",a.bb());
println!("{:?}",a.b.type_id());
println!("{:?}",std::any::TypeId::of::<i32>());
}
I expected to see this happen: The three printed TypeIds should be identical, as with the behavior in Rust <=1.70
Instead, this happened:
Program returned: 0
TypeId { t: 2368704253749761200 }
TypeId { t: 5817408772836814867 }
TypeId { t: 5817408772836814867 }
Meta
https://godbolt.org/z/8vvr37Ynf switch between rust versions.
I could not find reference in the 1.71 RELEASES that could explain such behavioral changes.