mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
233d94e72f
To separate `ReifyReason::FnPtr` from `ReifyReason::VTable`, we hyphenated the shims. Hyphens are not actually legal, but underscores are, so use those instead.
30 lines
568 B
Rust
30 lines
568 B
Rust
// Check KCFI extra mangling works correctly on v0
|
|
|
|
//@ needs-sanitizer-kcfi
|
|
//@ no-prefer-dynamic
|
|
//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0
|
|
//@ build-pass
|
|
|
|
trait Foo {
|
|
fn foo(&self);
|
|
}
|
|
|
|
struct Bar;
|
|
impl Foo for Bar {
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
struct Baz;
|
|
impl Foo for Baz {
|
|
#[track_caller]
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
fn main() {
|
|
// Produces `ReifyShim(_, ReifyReason::FnPtr)`
|
|
let f: fn(&Bar) = Bar::foo;
|
|
f(&Bar);
|
|
// Produces `ReifyShim(_, ReifyReason::Vtable)`
|
|
let v: &dyn Foo = &Baz as _;
|
|
v.foo();
|
|
}
|