@@ -3,8 +3,9 @@ use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
3
3
use rustc_errors:: Applicability ;
4
4
use rustc_hir:: intravisit:: FnKind ;
5
5
use rustc_hir:: {
6
- Block , Body , Closure , CoroutineKind , CoroutineSource , CoroutineDesugaring , Expr , ExprKind , FnDecl , FnRetTy , GenericArg , GenericBound ,
7
- ImplItem , Item , ItemKind , LifetimeName , Node , Term , TraitRef , Ty , TyKind , TypeBindingKind ,
6
+ Block , Body , Closure , CoroutineDesugaring , CoroutineKind , CoroutineSource , Expr , ExprKind , FnDecl , FnRetTy ,
7
+ GenericArg , GenericBound , ImplItem , Item , ItemKind , LifetimeName , Node , Term , TraitRef , Ty , TyKind ,
8
+ TypeBindingKind , ClosureKind ,
8
9
} ;
9
10
use rustc_lint:: { LateContext , LateLintPass } ;
10
11
use rustc_session:: declare_lint_pass;
@@ -171,16 +172,25 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
171
172
. all ( |in_lt| output_lifetimes. iter ( ) . any ( |out_lt| in_lt == out_lt) )
172
173
}
173
174
174
- fn desugared_async_block < ' tcx > ( cx : & LateContext < ' tcx > , block : & ' tcx Block < ' tcx > ) -> Option < & ' tcx Body < ' tcx > > {
175
- if let Some ( block_expr) = block. expr
176
- && let Expr {
177
- kind : ExprKind :: Closure ( & Closure { body, .. } ) ,
178
- ..
179
- } = block_expr
180
- && let closure_body = cx. tcx . hir ( ) . body ( body)
181
- && closure_body. coroutine_kind == Some ( CoroutineKind :: Desugared ( CoroutineDesugaring :: Async , CoroutineSource :: Block ) )
175
+ fn desugared_async_block < ' tcx > (
176
+ cx : & LateContext < ' tcx > ,
177
+ block : & ' tcx Block < ' tcx > ,
178
+ ) -> Option < & ' tcx Body < ' tcx > > {
179
+ if let Some ( Expr {
180
+ kind :
181
+ ExprKind :: Closure ( & Closure {
182
+ kind :
183
+ ClosureKind :: Coroutine ( CoroutineKind :: Desugared (
184
+ CoroutineDesugaring :: Async ,
185
+ CoroutineSource :: Block ,
186
+ ) ) ,
187
+ body,
188
+ ..
189
+ } ) ,
190
+ ..
191
+ } ) = block. expr
182
192
{
183
- return Some ( closure_body ) ;
193
+ return Some ( cx . tcx . hir ( ) . body ( body ) ) ;
184
194
}
185
195
186
196
None
0 commit comments