2024-03-27 10:50:53 -05:00
|
|
|
// Check various forms of dynamic closure calls
|
|
|
|
|
|
|
|
//@ edition: 2021
|
|
|
|
//@ revisions: cfi kcfi
|
|
|
|
// FIXME(#122848) Remove only-linux once OSX CFI binaries work
|
|
|
|
//@ only-linux
|
|
|
|
//@ [cfi] needs-sanitizer-cfi
|
|
|
|
//@ [kcfi] needs-sanitizer-kcfi
|
|
|
|
//@ compile-flags: -C target-feature=-crt-static
|
|
|
|
//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
|
|
|
|
//@ [cfi] compile-flags: -Z sanitizer=cfi
|
|
|
|
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
|
2024-03-26 12:00:57 -05:00
|
|
|
//@ [kcfi] compile-flags: -C panic=abort -Z panic-abort-tests -C prefer-dynamic=off
|
2024-03-27 10:50:53 -05:00
|
|
|
//@ run-pass
|
|
|
|
|
|
|
|
#![feature(async_closure)]
|
|
|
|
#![feature(async_fn_traits)]
|
|
|
|
|
|
|
|
use std::ops::AsyncFn;
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
fn identity<T>(x: T) -> T { x }
|
|
|
|
|
2024-10-09 16:31:01 -05:00
|
|
|
// We can't actually create a `dyn AsyncFn()`, because it's dyn-incompatible, but we should check
|
2024-03-27 10:50:53 -05:00
|
|
|
// that we don't bug out when we encounter one.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let f = identity(async || ());
|
|
|
|
let _ = f.async_call(());
|
|
|
|
let _ = f();
|
2024-03-26 12:00:57 -05:00
|
|
|
let g: Box<dyn FnOnce() -> _> = Box::new(f) as _;
|
|
|
|
let _ = g();
|
2024-03-27 10:50:53 -05:00
|
|
|
}
|