File tree 7 files changed +74
-13
lines changed
7 files changed +74
-13
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ proc-macro = true
16
16
17
17
[features ]
18
18
19
+ [build-dependencies ]
20
+ autocfg = " 1"
21
+
19
22
[dependencies ]
20
23
proc-macro2 = " 1.0"
21
24
proc-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 13
13
extern crate proc_macro;
14
14
15
15
use proc_macro:: TokenStream ;
16
- use proc_macro_hack:: proc_macro_hack;
17
16
18
17
mod join;
19
18
mod select;
20
19
21
20
/// 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) ]
23
23
pub fn join_internal ( input : TokenStream ) -> TokenStream {
24
24
crate :: join:: join ( input)
25
25
}
26
26
27
27
/// 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) ]
29
30
pub fn try_join_internal ( input : TokenStream ) -> TokenStream {
30
31
crate :: join:: try_join ( input)
31
32
}
32
33
33
34
/// 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) ]
35
37
pub fn select_internal ( input : TokenStream ) -> TokenStream {
36
38
crate :: select:: select ( input)
37
39
}
38
40
39
41
/// 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) ]
41
44
pub fn select_biased_internal ( input : TokenStream ) -> TokenStream {
42
45
crate :: select:: select_biased ( input)
43
46
}
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ bilock = []
32
32
read-initializer = [" io" , " futures-io/read-initializer" , " futures-io/unstable" ]
33
33
write-all-vectored = [" io" ]
34
34
35
+ [build-dependencies ]
36
+ autocfg = " 1"
37
+
35
38
[dependencies ]
36
39
futures-core = { path = " ../futures-core" , version = " =1.0.0-alpha.0" , default-features = false }
37
40
futures-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 1
1
//! The `join` macro.
2
2
3
- use proc_macro_hack:: proc_macro_hack;
4
-
5
3
macro_rules! document_join_macro {
6
4
( $join: item $try_join: item) => {
7
5
/// Polls multiple futures simultaneously, returning a tuple
@@ -81,12 +79,14 @@ macro_rules! document_join_macro {
81
79
}
82
80
}
83
81
82
+ #[ allow( unreachable_pub) ]
84
83
#[ 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 ) ) ]
86
85
pub use futures_macro:: join_internal;
87
86
87
+ #[ allow( unreachable_pub) ]
88
88
#[ 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 ) ) ]
90
90
pub use futures_macro:: try_join_internal;
91
91
92
92
document_join_macro ! {
Original file line number Diff line number Diff line change 1
1
//! The `select` macro.
2
2
3
- use proc_macro_hack:: proc_macro_hack;
4
-
5
3
macro_rules! document_select_macro {
6
4
// This branch is required for `futures 0.3.1`, from before select_biased was introduced
7
5
( $select: item) => {
@@ -309,12 +307,14 @@ macro_rules! document_select_macro {
309
307
}
310
308
311
309
#[ cfg( feature = "std" ) ]
310
+ #[ allow( unreachable_pub) ]
312
311
#[ 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 ) ) ]
314
313
pub use futures_macro:: select_internal;
315
314
315
+ #[ allow( unreachable_pub) ]
316
316
#[ 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 ) ) ]
318
318
pub use futures_macro:: select_biased_internal;
319
319
320
320
document_select_macro ! {
You can’t perform that action at this time.
0 commit comments