about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-08-06 23:23:26 +0000
committerbors <bors@rust-lang.org>2025-08-06 23:23:26 +0000
commit6bcdcc73bd11568fd85f5a38b58e1eda054ad1cd (patch)
tree7404b3b99695ca9e1343e7ae067f38a3aae59a2a /compiler/rustc_ast_lowering/src
parent7d82b83ed57d188ab3f2441a765a6419685a88a3 (diff)
parentd369a1fe5e7fbf17cc3ed74057928b875fe40ce7 (diff)
downloadrust-6bcdcc73bd11568fd85f5a38b58e1eda054ad1cd.tar.gz
rust-6bcdcc73bd11568fd85f5a38b58e1eda054ad1cd.zip
Auto merge of #145020 - GuillaumeGomez:rollup-5prs9kw, r=GuillaumeGomez
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#144195 (Parser: Recover from attributes applied to types and generic args)
 - rust-lang/rust#144794 (Port `#[coroutine]` to the new attribute system)
 - rust-lang/rust#144835 (Anonymize binders in tail call sig)
 - rust-lang/rust#144861 (Stabilize `panic_payload_as_str` feature)
 - rust-lang/rust#144917 (Enforce tail call type is related to body return type in borrowck)
 - rust-lang/rust#144948 (we only merge candidates for trait and normalizes-to goals)
 - rust-lang/rust#144956 (Gate const trait syntax)
 - rust-lang/rust#144970 (rustdoc: fix caching of intra-doc links on reexports)
 - rust-lang/rust#144972 (add code example showing that file_prefix treats dotfiles as the name of a file, not an extension)
 - rust-lang/rust#144975 (`File::set_times`: Update documentation and example to support setting timestamps on directories)
 - rust-lang/rust#144977 (Fortify generic param default checks)
 - rust-lang/rust#144996 (simplifycfg: Mark as changed when start is modified in collapse goto chain)
 - rust-lang/rust#144998 (mir: Do not modify NonUse in `super_projection_elem`)
 - rust-lang/rust#145000 (Remove unneeded `stage` parameter when setting up stdlib Cargo)
 - rust-lang/rust#145008 (Fix rustdoc scrape examples crash)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 1245d489754..fb42cfea30b 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
             }
 
             let expr_hir_id = self.lower_node_id(e.id);
-            self.lower_attrs(expr_hir_id, &e.attrs, e.span);
+            let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span);
 
             let kind = match &e.kind {
                 ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
@@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
                         *fn_arg_span,
                     ),
                     None => self.lower_expr_closure(
+                        attrs,
                         binder,
                         *capture_clause,
                         e.id,
-                        expr_hir_id,
                         *constness,
                         *movability,
                         fn_decl,
@@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
 
     fn lower_expr_closure(
         &mut self,
+        attrs: &[rustc_hir::Attribute],
         binder: &ClosureBinder,
         capture_clause: CaptureBy,
         closure_id: NodeId,
-        closure_hir_id: hir::HirId,
         constness: Const,
         movability: Movability,
         decl: &FnDecl,
@@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
         let (binder_clause, generic_params) = self.lower_closure_binder(binder);
 
         let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
-            let mut coroutine_kind = if this
-                .attrs
-                .get(&closure_hir_id.local_id)
-                .is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
-            {
-                Some(hir::CoroutineKind::Coroutine(Movability::Movable))
-            } else {
-                None
-            };
+
+            let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
+
             // FIXME(contracts): Support contracts on closures?
             let body_id = this.lower_fn_body(decl, None, |this| {
                 this.coroutine_kind = coroutine_kind;