Skip to content

fix: add CoroutineClosure and Error arms to simplify_nounwind_call#481

Open
SebTardif wants to merge 2 commits into
mainfrom
fix-instsimplify-coroutine-closure
Open

fix: add CoroutineClosure and Error arms to simplify_nounwind_call#481
SebTardif wants to merge 2 commits into
mainfrom
fix-instsimplify-coroutine-closure

Conversation

@SebTardif

Copy link
Copy Markdown
Owner

Summary

Fixes #477

simplify_nounwind_call in instsimplify.rs matches on body_ty.kind() to determine the ABI of a callee, but the match is missing ty::CoroutineClosure(..) => ExternAbi::RustCall and ty::Error(_) => return. The catch-all _ => bug!(...) causes an ICE when the callee is an async closure (which desugars to CoroutineClosure).

Failure scenario

When MIR optimization encounters a Call terminator whose callee is a coroutine closure body, type_of(def_id) returns ty::CoroutineClosure. The match falls through to bug!("unexpected body ty"), causing an Internal Compiler Error. Async closures have been stable since Rust 1.85, making this reachable on stable.

Fix

Add the two missing arms, matching the pattern used by three sibling functions in the same crate (validate.rs:57, abort_unwinding_calls.rs:55, ffi_unwind_calls.rs:30) that all include both CoroutineClosure and Error handling.

Bug origin

The CoroutineClosure variant was added to TyKind as part of the async closures feature. The three sibling functions were updated, but simplify_nounwind_call was missed.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif SebTardif added bug Something isn't working I-crash Unexpected panic or crash P-high High impact: affects correctness on common paths A-mir MIR building and transforms labels Jun 19, 2026
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mir MIR building and transforms bug Something isn't working I-crash Unexpected panic or crash P-high High impact: affects correctness on common paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simplify_nounwind_call missing CoroutineClosure arm causes ICE on async closures

1 participant