diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2024-04-04 21:16:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-04 21:16:59 -0400 |
| commit | e8b0c3057807e50ac1f95fdba36d79b72fbd206d (patch) | |
| tree | 620814cabea55e6e78e086759698b3f0c18a64af | |
| parent | e01d3e0824cd24dc02c0b22db2fa0d4677f1a0c3 (diff) | |
| parent | b53a0f2c9e96778a044cb72472aa898f9804471d (diff) | |
| download | rust-e8b0c3057807e50ac1f95fdba36d79b72fbd206d.tar.gz rust-e8b0c3057807e50ac1f95fdba36d79b72fbd206d.zip | |
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`
| -rw-r--r-- | tests/ui/sanitizer/cfi-closures.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/sanitizer/cfi-closures.rs b/tests/ui/sanitizer/cfi-closures.rs index f3d9be35716..9f9002da674 100644 --- a/tests/ui/sanitizer/cfi-closures.rs +++ b/tests/ui/sanitizer/cfi-closures.rs @@ -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); +} |
