@@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
98
98
}
99
99
100
100
let expr_hir_id = self . lower_node_id ( e. id ) ;
101
- self . lower_attrs ( expr_hir_id, & e. attrs , e. span ) ;
101
+ let attrs = self . lower_attrs ( expr_hir_id, & e. attrs , e. span ) ;
102
102
103
103
let kind = match & e. kind {
104
104
ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
@@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
232
232
* fn_arg_span,
233
233
) ,
234
234
None => self . lower_expr_closure (
235
+ attrs,
235
236
binder,
236
237
* capture_clause,
237
238
e. id ,
238
- expr_hir_id,
239
239
* constness,
240
240
* movability,
241
241
fn_decl,
@@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
1052
1052
1053
1053
fn lower_expr_closure (
1054
1054
& mut self ,
1055
+ attrs : & [ rustc_hir:: Attribute ] ,
1055
1056
binder : & ClosureBinder ,
1056
1057
capture_clause : CaptureBy ,
1057
1058
closure_id : NodeId ,
1058
- closure_hir_id : hir:: HirId ,
1059
1059
constness : Const ,
1060
1060
movability : Movability ,
1061
1061
decl : & FnDecl ,
@@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1067
1067
let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
1068
1068
1069
1069
let ( body_id, closure_kind) = self . with_new_scopes ( fn_decl_span, move |this| {
1070
- let mut coroutine_kind = if this
1071
- . attrs
1072
- . get ( & closure_hir_id. local_id )
1073
- . is_some_and ( |attrs| attrs. iter ( ) . any ( |attr| attr. has_name ( sym:: coroutine) ) )
1074
- {
1075
- Some ( hir:: CoroutineKind :: Coroutine ( Movability :: Movable ) )
1076
- } else {
1077
- None
1078
- } ;
1070
+
1071
+ let mut coroutine_kind = find_attr ! ( attrs, AttributeKind :: Coroutine ( _) => hir:: CoroutineKind :: Coroutine ( Movability :: Movable ) ) ;
1072
+
1079
1073
// FIXME(contracts): Support contracts on closures?
1080
1074
let body_id = this. lower_fn_body ( decl, None , |this| {
1081
1075
this. coroutine_kind = coroutine_kind;
0 commit comments