diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index ae0e54585a869..9558944d10613 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -1349,6 +1349,13 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio ty = transform_ty(tcx, fn_ptr, options); } + ty::CoroutineClosure(_, args) => { + // Transform async closures into function pointers + let fn_ptr = args.as_coroutine_closure().signature_parts_ty(); + // Transform fn_sig inputs and output + ty = transform_ty(tcx, fn_ptr, options); + } + ty::Ref(region, ty0, ..) => { // Remove references from function items, closures, Fn trait and Fn subtrait objects if ty0.is_fn_def() @@ -1439,7 +1446,6 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio ty::Bound(..) | ty::Error(..) - | ty::CoroutineClosure(..) | ty::CoroutineWitness(..) | ty::Infer(..) | ty::Placeholder(..) => { diff --git a/tests/ui/sanitizer/cfi-async-closure-issue-122705.rs b/tests/ui/sanitizer/cfi-async-closure-issue-122705.rs new file mode 100644 index 0000000000000..2f86d2e9fe61c --- /dev/null +++ b/tests/ui/sanitizer/cfi-async-closure-issue-122705.rs @@ -0,0 +1,15 @@ +// Verifies that using async closure works. +// +//@ needs-sanitizer-cfi +//@ compile-flags: -Clto -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 --edition=2021 +//@ run-pass + +#![feature(async_closure)] + +#[inline(never)] +fn foo(_: T) {} + +fn main() { + let a = async move |_: i32, _: i32| {}; + foo(a); +}