| 1 |
//! The futures-rs procedural macro implementations. |
| 2 |
|
| 3 |
#![warn(rust_2018_idioms, single_use_lifetimes, unreachable_pub)] |
| 4 |
#![doc(test( |
| 5 |
no_crate_inject, |
| 6 |
attr( |
| 7 |
deny(warnings, rust_2018_idioms, single_use_lifetimes), |
| 8 |
allow(dead_code, unused_assignments, unused_variables) |
| 9 |
) |
| 10 |
))] |
| 11 |
|
| 12 |
// Since https://github.com/rust-lang/cargo/pull/7700 `proc_macro` is part of the prelude for |
| 13 |
// proc-macro crates, but to support older compilers we still need this explicit `extern crate`. |
| 14 |
#[allow(unused_extern_crates)] |
| 15 |
extern crate proc_macro; |
| 16 |
|
| 17 |
use proc_macro::TokenStream; |
| 18 |
|
| 19 |
mod executor; |
| 20 |
mod join; |
| 21 |
mod select; |
| 22 |
mod stream_select; |
| 23 |
|
| 24 |
/// The `join!` macro. |
| 25 |
#[proc_macro] |
| 26 |
pub fn join_internal(input: TokenStream) -> TokenStream { |
| 27 |
crate::join::join(input) |
| 28 |
} |
| 29 |
|
| 30 |
/// The `try_join!` macro. |
| 31 |
#[proc_macro] |
| 32 |
pub fn try_join_internal(input: TokenStream) -> TokenStream { |
| 33 |
crate::join::try_join(input) |
| 34 |
} |
| 35 |
|
| 36 |
/// The `select!` macro. |
| 37 |
#[proc_macro] |
| 38 |
pub fn select_internal(input: TokenStream) -> TokenStream { |
| 39 |
crate::select::select(input) |
| 40 |
} |
| 41 |
|
| 42 |
/// The `select_biased!` macro. |
| 43 |
#[proc_macro] |
| 44 |
pub fn select_biased_internal(input: TokenStream) -> TokenStream { |
| 45 |
crate::select::select_biased(input) |
| 46 |
} |
| 47 |
|
| 48 |
// TODO: Change this to doc comment once rustdoc bug fixed: https://github.com/rust-lang/futures-rs/pull/2435 |
| 49 |
// The `test` attribute. |
| 50 |
#[proc_macro_attribute] |
| 51 |
pub fn test_internal(input: TokenStream, item: TokenStream) -> TokenStream { |
| 52 |
crate::executor::test(input, item) |
| 53 |
} |
| 54 |
|
| 55 |
/// The `stream_select!` macro. |
| 56 |
#[proc_macro] |
| 57 |
pub fn stream_select_internal(input: TokenStream) -> TokenStream { |
| 58 |
crate::stream_select::stream_select(input.into()) |
| 59 |
.unwrap_or_else(syn::Error::into_compile_error) |
| 60 |
.into() |
| 61 |
} |