File tree Expand file tree Collapse file tree 7 files changed +74
-13
lines changed Expand file tree Collapse file tree 7 files changed +74
-13
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ proc-macro = true
1616
1717[features ]
1818
19+ [build-dependencies ]
20+ autocfg = " 1"
21+
1922[dependencies ]
2023proc-macro2 = " 1.0"
2124proc-macro-hack = " 0.5.19"
Original file line number Diff line number Diff line change 1+ #![ warn( rust_2018_idioms, single_use_lifetimes) ]
2+
3+ use autocfg:: AutoCfg ;
4+
5+ // The rustc-cfg strings below are *not* public API. Please let us know by
6+ // opening a GitHub issue if your build environment requires some way to enable
7+ // these cfgs other than by executing our build script.
8+ fn main ( ) {
9+ let cfg = match AutoCfg :: new ( ) {
10+ Ok ( cfg) => cfg,
11+ Err ( e) => {
12+ println ! (
13+ "cargo:warning={}: unable to determine rustc version: {}" ,
14+ env!( "CARGO_PKG_NAME" ) ,
15+ e
16+ ) ;
17+ return ;
18+ }
19+ } ;
20+
21+ // Function like procedural macros in expressions patterns statements stabilized in Rust 1.45:
22+ // https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#stabilizing-function-like-procedural-macros-in-expressions-patterns-and-statements
23+ if cfg. probe_rustc_version ( 1 , 45 ) {
24+ println ! ( "cargo:rustc-cfg=fn_like_proc_macro" ) ;
25+ }
26+ }
Original file line number Diff line number Diff line change 1313extern crate proc_macro;
1414
1515use proc_macro:: TokenStream ;
16- use proc_macro_hack:: proc_macro_hack;
1716
1817mod join;
1918mod select;
2019
2120/// The `join!` macro.
22- #[ proc_macro_hack]
21+ #[ cfg_attr( fn_like_proc_macro, proc_macro) ]
22+ #[ cfg_attr( not( fn_like_proc_macro) , proc_macro_hack:: proc_macro_hack) ]
2323pub fn join_internal ( input : TokenStream ) -> TokenStream {
2424 crate :: join:: join ( input)
2525}
2626
2727/// The `try_join!` macro.
28- #[ proc_macro_hack]
28+ #[ cfg_attr( fn_like_proc_macro, proc_macro) ]
29+ #[ cfg_attr( not( fn_like_proc_macro) , proc_macro_hack:: proc_macro_hack) ]
2930pub fn try_join_internal ( input : TokenStream ) -> TokenStream {
3031 crate :: join:: try_join ( input)
3132}
3233
3334/// The `select!` macro.
34- #[ proc_macro_hack]
35+ #[ cfg_attr( fn_like_proc_macro, proc_macro) ]
36+ #[ cfg_attr( not( fn_like_proc_macro) , proc_macro_hack:: proc_macro_hack) ]
3537pub fn select_internal ( input : TokenStream ) -> TokenStream {
3638 crate :: select:: select ( input)
3739}
3840
3941/// The `select_biased!` macro.
40- #[ proc_macro_hack]
42+ #[ cfg_attr( fn_like_proc_macro, proc_macro) ]
43+ #[ cfg_attr( not( fn_like_proc_macro) , proc_macro_hack:: proc_macro_hack) ]
4144pub fn select_biased_internal ( input : TokenStream ) -> TokenStream {
4245 crate :: select:: select_biased ( input)
4346}
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ bilock = []
3232read-initializer = [" io" , " futures-io/read-initializer" , " futures-io/unstable" ]
3333write-all-vectored = [" io" ]
3434
35+ [build-dependencies ]
36+ autocfg = " 1"
37+
3538[dependencies ]
3639futures-core = { path = " ../futures-core" , version = " =1.0.0-alpha.0" , default-features = false }
3740futures-task = { path = " ../futures-task" , version = " =0.4.0-alpha.0" , default-features = false }
Original file line number Diff line number Diff line change 1+ #![ warn( rust_2018_idioms, single_use_lifetimes) ]
2+
3+ use autocfg:: AutoCfg ;
4+
5+ // The rustc-cfg strings below are *not* public API. Please let us know by
6+ // opening a GitHub issue if your build environment requires some way to enable
7+ // these cfgs other than by executing our build script.
8+ fn main ( ) {
9+ let cfg = match AutoCfg :: new ( ) {
10+ Ok ( cfg) => cfg,
11+ Err ( e) => {
12+ println ! (
13+ "cargo:warning={}: unable to determine rustc version: {}" ,
14+ env!( "CARGO_PKG_NAME" ) ,
15+ e
16+ ) ;
17+ return ;
18+ }
19+ } ;
20+
21+ // Function like procedural macros in expressions patterns statements stabilized in Rust 1.45:
22+ // https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#stabilizing-function-like-procedural-macros-in-expressions-patterns-and-statements
23+ if cfg. probe_rustc_version ( 1 , 45 ) {
24+ println ! ( "cargo:rustc-cfg=fn_like_proc_macro" ) ;
25+ }
26+ }
Original file line number Diff line number Diff line change 11//! The `join` macro.
22
3- use proc_macro_hack:: proc_macro_hack;
4-
53macro_rules! document_join_macro {
64 ( $join: item $try_join: item) => {
75 /// Polls multiple futures simultaneously, returning a tuple
@@ -81,12 +79,14 @@ macro_rules! document_join_macro {
8179 }
8280}
8381
82+ #[ allow( unreachable_pub) ]
8483#[ doc( hidden) ]
85- #[ proc_macro_hack ( support_nested , only_hack_old_rustc ) ]
84+ #[ cfg_attr ( not ( fn_like_proc_macro ) , proc_macro_hack :: proc_macro_hack ( support_nested ) ) ]
8685pub use futures_macro:: join_internal;
8786
87+ #[ allow( unreachable_pub) ]
8888#[ doc( hidden) ]
89- #[ proc_macro_hack ( support_nested , only_hack_old_rustc ) ]
89+ #[ cfg_attr ( not ( fn_like_proc_macro ) , proc_macro_hack :: proc_macro_hack ( support_nested ) ) ]
9090pub use futures_macro:: try_join_internal;
9191
9292document_join_macro ! {
Original file line number Diff line number Diff line change 11//! The `select` macro.
22
3- use proc_macro_hack:: proc_macro_hack;
4-
53macro_rules! document_select_macro {
64 // This branch is required for `futures 0.3.1`, from before select_biased was introduced
75 ( $select: item) => {
@@ -309,12 +307,14 @@ macro_rules! document_select_macro {
309307}
310308
311309#[ cfg( feature = "std" ) ]
310+ #[ allow( unreachable_pub) ]
312311#[ doc( hidden) ]
313- #[ proc_macro_hack ( support_nested , only_hack_old_rustc ) ]
312+ #[ cfg_attr ( not ( fn_like_proc_macro ) , proc_macro_hack :: proc_macro_hack ( support_nested ) ) ]
314313pub use futures_macro:: select_internal;
315314
315+ #[ allow( unreachable_pub) ]
316316#[ doc( hidden) ]
317- #[ proc_macro_hack ( support_nested , only_hack_old_rustc ) ]
317+ #[ cfg_attr ( not ( fn_like_proc_macro ) , proc_macro_hack :: proc_macro_hack ( support_nested ) ) ]
318318pub use futures_macro:: select_biased_internal;
319319
320320document_select_macro ! {
You can’t perform that action at this time.
0 commit comments