1
Fork 0

Add missing check for async body when suggesting await on futures.

This commit is contained in:
metamuffin 2025-01-14 17:16:51 +01:00
parent a48e7b0057
commit ab2c8ffda9
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654
4 changed files with 12 additions and 19 deletions

View file

@ -167,6 +167,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
exp_span, exp_found.expected, exp_found.found,
);
match self.tcx.coroutine_kind(cause.body_id) {
Some(hir::CoroutineKind::Desugared(
hir::CoroutineDesugaring::Async | hir::CoroutineDesugaring::AsyncGen,
_,
)) => (),
None
| Some(
hir::CoroutineKind::Coroutine(_)
| hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _),
) => return,
}
if let ObligationCauseCode::CompareImplItem { .. } = cause.code() {
return;
}