summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2022-10-11 16:37:54 -0700
committerEric Holk <ericholk@microsoft.com>2022-10-11 16:37:54 -0700
commit3db41d13f08db377c9bc516d8f285f61ed668edd (patch)
tree5bc25889c5eeeeafcd5bc33e281df24f2341bcd8 /compiler/rustc_ast_lowering/src/expr.rs
parent0c158f0e9d708e7705249bca8e38757ebf2e5c8c (diff)
downloadrust-3db41d13f08db377c9bc516d8f285f61ed668edd.tar.gz
rust-3db41d13f08db377c9bc516d8f285f61ed668edd.zip
wip: trying to enable #[track_caller] on async fn
Diffstat (limited to 'compiler/rustc_ast_lowering/src/expr.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 46886c518af..61d91874e61 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -617,8 +617,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
 
             hir::ExprKind::Closure(c)
         };
+        let generator_hir_id = self.lower_node_id(closure_node_id);
+        // FIXME: only add track caller if the parent is track_caller
+        self.lower_attrs(
+            generator_hir_id,
+            &[Attribute {
+                kind: AttrKind::Normal(ptr::P(NormalAttr {
+                    item: AttrItem {
+                        path: Path::from_ident(Ident::new(sym::track_caller, span)),
+                        args: MacArgs::Empty,
+                        tokens: None,
+                    },
+                    tokens: None,
+                })),
+                id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
+                style: AttrStyle::Outer,
+                span,
+            }],
+        );
         let generator = hir::Expr {
-            hir_id: self.lower_node_id(closure_node_id),
+            hir_id: generator_hir_id,
             kind: generator_kind,
             span: self.lower_span(span),
         };