Simplify checking for GeneratorKind::Async
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
This commit is contained in:
parent
8a09420ac4
commit
2db0dc3297
5 changed files with 10 additions and 22 deletions
|
@ -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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue