Open
Description
vtable addresses may differ cross codegen units. To mitigate this, it would be good to have a lint that warns against comparing wide pointers with vtables.
Original report
This is a regression from the 2/27 to 2/28 nightly.
pub trait Trait {}
impl Trait for i32 {}
pub struct Obj<'a, T: 'static + Trait> {
ptr: &'a T,
trait_ptr: *const dyn Trait,
}
impl<'a, T: Trait + 'static> Drop for Obj<'a, T> {
fn drop(&mut self) {
assert_eq!(self.trait_ptr, self.ptr as *const dyn Trait);
}
}
fn main() {
let ptr = 5;
let _name = Obj {
ptr: &ptr,
trait_ptr: &ptr,
};
}
When this program is built with rustc main.rs
, it runs without any trouble. When it's built with rustc main.rs -C incremental=
, I receive the following output:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `0x7ffee7d23864`,
right: `0x7ffee7d23864`', main.rs:11:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
From the regression window, I suspect #67332.