Skip to content
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

Tracking Issue for #[track_caller] on async fn #110011

Open
1 of 4 tasks
bryangarza opened this issue Apr 6, 2023 · 4 comments
Open
1 of 4 tasks

Tracking Issue for #[track_caller] on async fn #110011

bryangarza opened this issue Apr 6, 2023 · 4 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@bryangarza
Copy link
Contributor

bryangarza commented Apr 6, 2023

This is a tracking issue for #[track_caller] on async fn.
The feature gate #[feature(async_fn_track_caller)] for the issue is not implemented yet (#110009)

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

(Copied over from: #87417 (comment))

It's not 100% clear that tracking the poller, rather than the original caller, is the ideal behavior. That said, we may still be able to resolve the question without an RFC.

Arguments in favor of tracking the poller (current behavior):

  • The user might expect to see the call that's happening now rather than one that happened in the past.
  • Prevents us from having to store the caller in the Future type.
  • Usually poller and caller are the same function, anyway, so we should do the simpler and more performant thing.

Arguments in favor of tracking the original caller instead of the poller:

  • User might expect to see the actual caller; especially given the name track_caller, showing the poller can confusing.
  • A &'static Location is only one pointer; storing it is not so bad.
  • Combinators won't need to add #[track_caller] to "thread through" the caller information.
  • If we tracked the poller, #[track_caller] on a spawned task would show the executor.
    • There's no way today for the executor to save off caller location information (e.g. in spawn) and re-provide it to the polled function, even if it wanted to. We could fix this with a set_caller API.
    • Tracking won't work for &dyn Future. Executors can easily work around this if they have an API with access to the underlying type before coercing to dyn, as most do (playground). But if you happen to already have a dyn Future, you'll be stuck.

Implementation history

@bryangarza bryangarza added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Apr 6, 2023
@bryangarza
Copy link
Contributor Author

bryangarza commented Apr 6, 2023

FYI @tmandry

@bryangarza
Copy link
Contributor Author

@rustbot label +T-lang

@rustbot rustbot added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Apr 6, 2023
@tmandry
Copy link
Member

tmandry commented Apr 10, 2023

It's not 100% clear that tracking the poller, rather than the original caller, is the ideal behavior. That said, we may still be able to resolve the question without an RFC.

@rust-lang/wg-async discussed in this zulip thread. We were leaning toward tracking the original caller rather than the poller, based on the use case we knew about (assertion helpers). If there are other use cases or points of agreement/disagreement with this, please leave them in the linked zulip thread.

@tmandry tmandry added the I-async-nominated Nominated for discussion during an async working group meeting. label Apr 10, 2023
@tmandry tmandry removed the I-async-nominated Nominated for discussion during an async working group meeting. label Apr 24, 2023
@Swatinem
Copy link
Contributor

Another idea worth revisiting here may be:
In #104833, I also added #[track_caller] support for async blocks. Pretty much because it was trivial to do so, and actually supporting it separately would have been more work.

It might still be worth doing that, specifically to split that into its own track_async_block_caller or similar feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants