forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CFI: Only encode Coroutine Parent Args
Fixes rust-lang#122705
- Loading branch information
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 | ||
//@ run-pass | ||
|
||
#![feature(async_closure)] | ||
#![feature(async_fn_traits)] | ||
|
||
use std::ops::AsyncFn; | ||
|
||
#[inline(never)] | ||
fn identity<T>(x: T) -> T { x } | ||
|
||
// We can't actually create a `dyn AsyncFn()`, because it's not object-safe, but we should check | ||
// that we don't bug out when we encounter one. | ||
|
||
fn main() { | ||
let f = identity(async || ()); | ||
let _ = f.async_call(()); | ||
let _ = f(); | ||
} |