1
Fork 0

Simplify checking for GeneratorKind::Async

Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
Arpad Borsos 2022-11-26 21:33:12 +01:00
parent 8a09420ac4
commit 2db0dc3297
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
5 changed files with 10 additions and 22 deletions

View file

@ -514,12 +514,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
span: *span,
ty_err: match output_ty.kind() {
ty::Closure(_, _) => FnMutReturnTypeErr::ReturnClosure { span: *span },
ty::Generator(def, ..)
if matches!(
self.infcx.tcx.generator_kind(def),
Some(hir::GeneratorKind::Async(_))
) =>
{
ty::Generator(def, ..) if self.infcx.tcx.generator_is_async(*def) => {
FnMutReturnTypeErr::ReturnAsyncBlock { span: *span }
}
_ => FnMutReturnTypeErr::ReturnRef { span: *span },