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

Make macro_rules (try_)join! always available #5626

Closed
wants to merge 1 commit into from
Closed

Make macro_rules (try_)join! always available #5626

wants to merge 1 commit into from

Conversation

NobodyXu
Copy link
Contributor

Motivation

It does not use anything from tokio-macros, thus gating it behind feature macros does not make sense.

It forces users who have to use tokio::{try_join, join} to enable feature macros and pull in crate tokio-macros, which is unnecessary.

Solution

Make tokio::{try_join, join} always available regardless of whether feature macros is enabled.

It does not use anything from `tokio-macros`, thus gating it behind
feature `macros` does not make sense.

It forces users who have to use `tokio::{try_join, join}` to enable
feature `macros` and pull in crate tokio-macros, which is unnecessary.

Signed-off-by: Jiahao XU <[email protected]>
@taiki-e
Copy link
Member

taiki-e commented Apr 15, 2023

This will prevent {try_,}join from relying on tokio-macros in the future.

Historically, we have used tokio-macros to handle problems that cannot be handled well by declarative macros (#4211), but I'm not certain that {try_,}join will not encounter such problems in the future.

See also #4804.

@taiki-e taiki-e added the M-macros Module: macros in the main Tokio crate label Apr 15, 2023
@NobodyXu
Copy link
Contributor Author

Historically, we have used tokio-macros to handle problems that cannot be handled well by declarative macros (#4211), but I'm not certain that {try_,}join will not encounter such problems in the future.

I don't think so, given that tokio already reaches v1.0.0, I don't think it will change the semantics of tokio::{try_, }join that will require such dramatic change to the point of requiring proc-macro.

@taiki-e
Copy link
Member

taiki-e commented Apr 15, 2023

I meant bugfixes like #4211 (tokio-1.14.0), not semantics changes.

That said, as long as it is not breaking, we can add a new syntax or feature in 1.x, like #3603 (tokio-1.4.0).

@NobodyXu
Copy link
Contributor Author

I meant bugfixes like #4211 (tokio-1.14.0), not semantics changes.

That said, as long as it is not breaking, we can add a new syntax or feature in 1.x, like #3603 (tokio-1.4.0).

I don't think tokio::{try, }join will need a proc-macro to fix a bug, given that it is actually not that complicated compared to tokio::select!.

tokio::select! needs to be able to parse pattern, branches, etc, but join! and try_join! does not.

They just need to take futures (expressions), polling for all of them to complete and for try_join! it also needs to propagate the error, but it really doesn't sound like they would need proc-macro for parsing.

Though futures-util does seem to forward their {try, }join! straight to futures-macro.

@Darksonn Darksonn added the A-tokio Area: The main tokio crate label Apr 15, 2023
@carllerche
Copy link
Member

There is more than just fixing bugs. We may, in the future, want to use proc macros to provide better errors or additional features. If you wish to use the macro as is today w/o syn, you can always pull it out yourself in a separate crate or just copy the code in your app/crate.

@carllerche carllerche closed this May 8, 2023
@NobodyXu NobodyXu deleted the tokio-macros branch May 8, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-macros Module: macros in the main Tokio crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants