-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement #[async_send] attribute for async fns #107056
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
Conversation
This gives a potential solution for the spawning from generics issue with async functions in traits. The goal here is to make something that users can experiment with and provide feedback on, but this is not intended to be the final syntax or even final design.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
This needs several test, both for functionality and for the feature gate (proving that adding this attribute requires enabling a feature gate) |
Oh, d'oh! I forgot to add the file with my functional test. I need to add one for the feature gate too though. |
@@ -1967,6 +1968,31 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { | |||
)); | |||
debug!("lower_async_fn_ret_ty: generic_params={:#?}", generic_params); | |||
|
|||
let is_async_send = this.tcx.features().async_fn_in_trait | |||
&& (true |
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.
is this needed?
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.
The true
definitely isn't! (Sorry, that was left over from by debugging attempts).
The async_fn_in_trait check is probably not needed either since you can't even type this attribute without it. I'll try and remove it.
@rustbot author |
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
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.
The implementation looks fine to me, though I was curious if there was some support from @rust-lang/wg-async or @rust-lang/lang for adding this. I was unsure if this was the direction that we wanted to go with adding support for Send, etc. to futures.
I'd also love to hear other opinions from @rust-lang/wg-async. I did talk with @yoshuawuyts about this idea earlier this week and he seemed supportive of it, although mostly for experimentation and not as the final version. As for me, I'll admit I don't particularly like this solution. I'd rather land on something like I think this question of |
I think this is fine for experimentation. I think we'll want other syntax in the future, but for now, this is fine. |
Based on some of the objections raised by @Dirbaio in the Zulip thread, I'm kind of inclined to hold off on merging this for now. There's not really any harm in merging it for experimentation, but if we aren't confident that this or something like it is something we'll want long term, there's not a lot of point in merging something that we'll have to remove later. |
Gonna mark this as S-blocked for now then. @rustbot blocked |
☔ The latest upstream changes (presumably #111169) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm gonna close this since it's gone somewhat stale, and I'm not sure if this is the approach we're looking at experimenting with anymore... Obviously this doesn't delete the branch or anything so please feel free to reopen a new PR and request review from me if wg-async does decide that this is worth landing experimentally... |
This gives a potential solution for the spawning from generics issue with async functions in traits. The goal here is to make something that users can experiment with and provide feedback on, but this is not intended to be the final syntax or even final design.
r? @compiler-errors
cc @rust-lang/wg-async