Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_mir_transform/src/instsimplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,9 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
let body_abi = match body_ty.kind() {
ty::FnDef(..) => body_ty.fn_sig(self.tcx).abi(),
ty::Closure(..) => ExternAbi::RustCall,
ty::CoroutineClosure(..) => ExternAbi::RustCall,
ty::Coroutine(..) => ExternAbi::Rust,
ty::Error(_) => return,
_ => bug!("unexpected body ty: {body_ty:?}"),
};

Expand Down
20 changes: 20 additions & 0 deletions tests/ui/async-await/async-closures/instsimplify-nounwind.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Regression test for #477: simplify_nounwind_call missing CoroutineClosure arm.
// Before the fix, the MIR instsimplify pass would ICE (bug!("unexpected body ty"))
// when encountering an async closure body type during nounwind simplification.

//@ edition:2021
//@ build-pass

async fn call_once(f: impl std::future::Future<Output = ()>) {
f.await;
}

fn main() {
let _ = async {
let x = 1i32;
let c = async move || {
let _ = x;
};
call_once(c()).await;
};
}