1
Fork 0

Rollup merge of #104951 - Swatinem:async-kind, r=compiler-errors

Simplify checking for `GeneratorKind::Async`

Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
Matthias Krüger 2022-11-29 05:24:21 +01:00 committed by GitHub
commit c81605ca91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 },