Rollup merge of #121617 - compiler-errors:async-closure-kind-check, r=oli-obk

Actually use the right closure kind when checking async Fn goals

Dumb copy-paste mistake on my part from #120712. Sorry!

r? oli-obk

Fixes #121599
This commit is contained in:
Matthias Krüger 2024-02-26 16:06:04 +01:00 committed by GitHub
commit 4f167b4baf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 7 deletions

View file

@ -934,7 +934,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
(trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
}
ty::Closure(_, args) => {
let sig = args.as_closure().sig();
let args = args.as_closure();
let sig = args.sig();
let trait_ref = sig.map_bound(|sig| {
ty::TraitRef::new(
self.tcx(),
@ -950,7 +951,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::TraitRef::new(tcx, future_trait_def_id, [sig.output()])
}),
));
(trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
(trait_ref, args.kind_ty())
}
_ => bug!("expected callable type for AsyncFn candidate"),
};