about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-17 13:47:03 +0000
committerbors <bors@rust-lang.org>2022-11-17 13:47:03 +0000
commitb6097f2e1b2ca62e188ba53cf43bd66b06b36915 (patch)
tree2e5d5c944967d1a4629252a8016b34df8da1efd9 /library/core
parent36db030a7c3c51cb4484cbd8c8daebcf5057d61c (diff)
parent79c06fc595261a118cea2e5440ed98fbf5659a99 (diff)
downloadrust-b6097f2e1b2ca62e188ba53cf43bd66b06b36915.tar.gz
rust-b6097f2e1b2ca62e188ba53cf43bd66b06b36915.zip
Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholk
Support `#[track_caller]` on async fns

Adds `#[track_caller]` to the generator that is created when we desugar the async fn.

Fixes #78840

Open questions:
- What is the performance impact of adding `#[track_caller]` to every `GenFuture`'s `poll(...)` function, even if it's unused (i.e., the parent span does not set `#[track_caller]`)? We might need to set it only conditionally, if the indirection causes overhead we don't want.
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/future/mod.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs
index 6487aa08859..107cf92c1c0 100644
--- a/library/core/src/future/mod.rs
+++ b/library/core/src/future/mod.rs
@@ -82,6 +82,7 @@ where
 
     impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> {
         type Output = T::Return;
+        #[track_caller]
         fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
             // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection.
             let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };