-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-trait-systemArea: Trait systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
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.
redradist, Aaron1011, Kixunil, stanislav-tkach, kornelski and 1 moreredradistredradist
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-trait-systemArea: Trait systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team