Rollup merge of #123478 - maurer:cfi-call-once-addr-taken, r=compiler-errors

CFI: Add test for `call_once` addr taken

One of the proposed ways to reduce the non-passed argument erasure would cause this test to fail. Adding this now ensures that any attempt to reduce non-passed argument erasure won't make the same mistake.

r? `@compiler-errors`

cc `@rcvalle`
This commit is contained in:
Jacob Pratt 2024-04-04 21:16:59 -04:00 committed by GitHub
commit e8b0c30578
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -77,3 +77,14 @@ fn closure_addr_taken() {
let call = Fn::<()>::call;
use_closure(call, &f);
}
fn use_closure_once<C>(call: extern "rust-call" fn(C, ()) -> i32, f: C) -> i32 {
call(f, ())
}
#[test]
fn closure_once_addr_taken() {
let g = || 3;
let call2 = FnOnce::<()>::call_once;
use_closure_once(call2, g);
}