Skip to content

Rewrite select! as a procedural macro #1363

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

Merged
merged 6 commits into from
Dec 10, 2018

Conversation

cramertj
Copy link
Member

@cramertj cramertj commented Dec 4, 2018

This commit removes the old macro_rules tt muncher parser
implementation of the select! macro and replaces it with
a procedural macro that accomplishes the same task, but which
should be dramatically simpler to read and modify.

This commit removes the old macro_rules tt muncher parser
implementation of the select! macro and replaces it with
a procedural macro that accomplishes the same task, but which
should be dramatically simpler to read and modify.
@dtolnay
Copy link
Member

dtolnay commented Dec 4, 2018

Haven't read the implementation of the procedural macro yet (will get to it later today) but a quick idea regarding the duplicated documentation -- you could have futures-util provide:

#[doc(hidden)]
#[macro_export]
macro_rules! with_documentation_of_select_macro {
    ($item:item) => {
        /// Polls multiple futures and streams simultaneously, ...
        $item
    };
}

which both it and futures use.

I forget whether doc comments can be added to an $:item this way. If not, you'll need to make it $($tt:tt)*.

proc-macro = true

[features]
std = []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point I figured we could use this to turn off rand support, though I've left that unimplemented for now. Perhaps we'd require the user to provide a link-time function that could be used to shuffle arrays?

Copy link
Member

@Nemo157 Nemo157 Dec 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, something like that sounds possible. I was thinking I might take a look at getting it working on no_std, then realised it wouldn’t work without await! support.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, await! is the big blocker for getting no-std.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely done.

Copy link
Contributor

@Matthias247 Matthias247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me in general.
Just some questions and further ideas.

@cramertj cramertj merged commit 1126590 into rust-lang:master Dec 10, 2018
@cramertj cramertj deleted the select-procmacro branch December 10, 2018 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants