Bug
simplify_nounwind_call in compiler/rustc_mir_transform/src/instsimplify.rs matches on body_ty.kind() to determine the ABI of a callee, but is missing two arms:
ty::CoroutineClosure(..) => ExternAbi::RustCall
ty::Error(_) => return
The catch-all _ => bug!("unexpected body ty: {body_ty:?}") causes an ICE when the callee is an async closure body (which desugars to CoroutineClosure), or when the type is an error type from a previous compilation error.
Evidence
Three structurally identical functions in the same crate perform the same type_of(def_id).skip_binder() -> body_ty.kind() dispatch and ALL include the missing arms:
validate.rs (lines 57-62): has ty::CoroutineClosure(..) => ExternAbi::RustCall and ty::Error(_) => return
abort_unwinding_calls.rs (lines 55-59): has both arms
ffi_unwind_calls.rs (lines 30-34): has both arms (Error returns false)
Only instsimplify.rs was missed when CoroutineClosure was added to TyKind.
Impact
ICE (Internal Compiler Error) when async closures are used in certain call patterns that reach the simplify_nounwind_call MIR optimization pass. Async closures have been stable since Rust 1.85. The missing ty::Error arm also causes ICE instead of graceful degradation when compilation already has errors.
PR #481
Bug
simplify_nounwind_callincompiler/rustc_mir_transform/src/instsimplify.rsmatches onbody_ty.kind()to determine the ABI of a callee, but is missing two arms:ty::CoroutineClosure(..) => ExternAbi::RustCallty::Error(_) => returnThe catch-all
_ => bug!("unexpected body ty: {body_ty:?}")causes an ICE when the callee is an async closure body (which desugars toCoroutineClosure), or when the type is an error type from a previous compilation error.Evidence
Three structurally identical functions in the same crate perform the same
type_of(def_id).skip_binder()->body_ty.kind()dispatch and ALL include the missing arms:validate.rs(lines 57-62): hasty::CoroutineClosure(..) => ExternAbi::RustCallandty::Error(_) => returnabort_unwinding_calls.rs(lines 55-59): has both armsffi_unwind_calls.rs(lines 30-34): has both arms (Error returnsfalse)Only
instsimplify.rswas missed whenCoroutineClosurewas added to TyKind.Impact
ICE (Internal Compiler Error) when async closures are used in certain call patterns that reach the
simplify_nounwind_callMIR optimization pass. Async closures have been stable since Rust 1.85. The missingty::Errorarm also causes ICE instead of graceful degradation when compilation already has errors.PR #481