-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support #[track_caller]
on async fns
#104219
Conversation
This patch allows the usage of the `track_caller` annotation on generators, as well as sets them conditionally if the parent also has `track_caller` set. Also add this annotation on the `GenFuture`'s `poll()` function.
r? @jackh726 (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @eholk |
@@ -86,7 +86,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> { | |||
impl_trait_defs: Vec::new(), | |||
impl_trait_bounds: Vec::new(), | |||
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()), | |||
allow_gen_future: Some([sym::gen_future][..].into()), | |||
allow_gen_future: Some([sym::gen_future, sym::closure_track_caller][..].into()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it makes sense to split gen_future
and closure_track_caller
into separate entires?
I think it's fine like this, since allow_gen_future
is only used in one place and since we want track caller to work we also need the closure_track_caller
feature. Separating them seems like extra work with little benefit.
@bors r+ |
… r=eholk Support `#[track_caller]` on async fns Adds `#[track_caller]` to the generator that is created when we desugar the async fn. Fixes rust-lang#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.
The failure
|
@matthiaskrgr @eholk do we need to ignore the wasm target? I just noticed this on a few other UI tests
|
@bryangarza Please use (Alternatively you might be able to let the process abort instead of catching the panic, and assert that the panic output itself contains the desired file/line; not sure how well it will work though.) |
oh okay thanks, I’ll update it to |
715fb31
to
79c06fc
Compare
@eholk - I think we can try adding it to the rollup again |
@bors r+ rollup=never |
@bors p=1 going to close the tree for non-nevers for a while so they can drain out |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b6097f2): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
let parent_has_track_caller = self | ||
.attrs | ||
.values() | ||
.find(|attrs| attrs.into_iter().find(|attr| attr.has_name(sym::track_caller)).is_some()) | ||
.is_some(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is very broken, the parent here might be just a normal function, not necessarily the desugaring of an async fn
, see #105134
…=eholk Support `#[track_caller]` on async fns Adds `#[track_caller]` to the generator that is created when we desugar the async fn. Fixes rust-lang#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.
Adds
#[track_caller]
to the generator that is created when we desugar the async fn.Fixes #78840
Open questions:
#[track_caller]
to everyGenFuture
'spoll(...)
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.