Closed
Description
Take the following code for example (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f1fc9b16c4d0b7cc512fcd33ee2097b6):
trait Trait {
type Assoc;
fn foo(&self) {}
}
impl Trait for bool {
type Assoc = bool;
}
fn main() {
let v: Box<dyn Trait<Assoc = bool>> = Box::new(true);
let _v: Box<dyn Trait<Assoc = ()>> = unsafe { std::mem::transmute(v) };
}
I included an empty function in the trait so its vtable won't be empty which may affect things somehow. AFAIK, changing principal trait (aka. not removing or adding auto traits only) is immediate UB, because the vtable has a validity invariant of being valid, and the compiler will exploit this (e.g. to hoist method loads).
However, Miri does not report this as UB.
Metadata
Metadata
Assignees
Labels
No labels