File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -62,14 +62,11 @@ impl<'tcx> Visitor<'tcx> for ReturnVisitor {
62
62
63
63
/// Checks if the body is owned by an async closure
64
64
fn is_async_closure ( cx : & LateContext < ' _ > , body : & hir:: Body < ' _ > ) -> bool {
65
- if let hir:: ExprKind :: Closure ( desugared_outer_closure) = body. value . kind
66
- && let desugared_outer_closure_body = cx. tcx . hir ( ) . body ( desugared_outer_closure. body )
67
- && let hir:: ExprKind :: Closure ( desugared_inner_closure) = desugared_outer_closure_body. value . kind
68
- // NB: `async || 42` is desugared into `|| |mut __context: #[lang = "ResumeTy"] | 42`; so
69
- // we need to check if the only input was that lang item.
70
- && let [ compiler_generated_resume_ty] = desugared_inner_closure. fn_decl . inputs
71
- && let hir:: TyKind :: Path ( hir:: QPath :: LangItem ( hir:: LangItem :: ResumeTy , ..) ) =
72
- compiler_generated_resume_ty. kind
65
+ // NB: `async || 42` is desugared into `|| |mut __context: #[lang = "ResumeTy"] | 42`; so
66
+ // we need to check if there is inner closure and check GeneratorKind of the inner one.
67
+ if let hir:: ExprKind :: Closure ( desugared_inner_closure) = body. value . kind
68
+ && let desugared_inner_closure_body = cx. tcx . hir ( ) . body ( desugared_inner_closure. body )
69
+ && let Some ( GeneratorKind :: Async ( AsyncGeneratorKind :: Closure ) ) = desugared_inner_closure_body. generator_kind
73
70
{
74
71
true
75
72
} else {
You can’t perform that action at this time.
0 commit comments