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

Add unpolished, experimental support for AFIDT (async fn in dyn trait) #133122

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 16, 2024

This allows us to begin messing around async fn in dyn Trait. Calling an async fn from a trait object always returns a dyn* Future<Output = ...>.

To make it work, Implementations are currently required to return something that can be coerced to a dyn* Future (see the example in tests/ui/async-await/dyn/works.rs). If it's not the right size, then it'll raise an error at the coercion site (see the example in tests/ui/async-await/dyn/wrong-size.rs). Currently the only practical way of doing this is wrapping the body in Box::pin(async move { .. }).

This PR does not implement a helper type like a "Boxing"1 adapter, and I'll probably follow-up with another PR to improve the error message for the PointerLike trait (something that explains in just normal prose what is happening here, rather than a trait error).

This PR also does not implement new trait solver support for AFIDT; I'll need to think how best to integrate it into candidate assembly, and that's a bit of a matter of taste, but I don't think it will be difficult to do.

This could also be generalized:

  • To work on functions that are -> impl Future (soon).
  • To work on functions that are -> impl Iterator and other "dyn rpitit safe" traits. We still need to nail down exactly what is needed for this to be okay (not soon).

Tracking:

Footnotes

  1. https://rust-lang.github.io/async-fundamentals-initiative/explainer/user_guide_future.html#the-boxing-adapter

@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 16, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@compiler-errors
Copy link
Member Author

r? types

Probably best for a types team review.

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Nov 16, 2024
@rustbot rustbot assigned jackh726 and unassigned nnethercote Nov 16, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 19, 2024

☔ The latest upstream changes (presumably #132460) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants