futures_macro/
lib.rs

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)]
15extern crate proc_macro;
16
17use proc_macro::TokenStream;
18
19mod executor;
20mod join;
21mod select;
22mod stream_select;
23
24/// The `join!` macro.
25#[proc_macro]
26pub fn join_internal(input: TokenStream) -> TokenStream {
27    crate::join::join(input)
28}
29
30/// The `try_join!` macro.
31#[proc_macro]
32pub fn try_join_internal(input: TokenStream) -> TokenStream {
33    crate::join::try_join(input)
34}
35
36/// The `select!` macro.
37#[proc_macro]
38pub fn select_internal(input: TokenStream) -> TokenStream {
39    crate::select::select(input)
40}
41
42/// The `select_biased!` macro.
43#[proc_macro]
44pub 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]
51pub fn test_internal(input: TokenStream, item: TokenStream) -> TokenStream {
52    crate::executor::test(input, item)
53}
54
55/// The `stream_select!` macro.
56#[proc_macro]
57pub 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}