Skip to content

Commit b432c41

Browse files
committed
Move async-await behind a feature flag
1 parent bbbfbb7 commit b432c41

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ matrix:
6565
- name: cargo build (default features)
6666
rust: nightly
6767
script:
68+
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
6869
- cargo build --all
6970

7071
- name: cargo build (compat feature)

futures-test/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Utilities to make testing [`Future`s](futures_core::Future) easier
22
3-
#![feature(async_await, await_macro)]
43
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
54
#![doc(
65
html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.5/futures_test"

futures-util/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Common utilities and extension traits for the futures-rs library.
1515
name = "futures_util"
1616

1717
[features]
18-
std = ["alloc", "futures-core-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "futures-select-macro-preview/std", "rand", "rand_core", "slab"]
18+
std = ["alloc", "futures-core-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "slab"]
1919
default = ["std"]
20+
async-await = ["std", "futures-select-macro-preview", "proc-macro-hack", "proc-macro-nested", "rand", "rand_core"]
2021
compat = ["std", "futures_01"]
2122
io-compat = ["compat", "tokio-io"]
2223
bench = []
@@ -30,9 +31,9 @@ futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.14",
3031
futures-channel-preview = { path = "../futures-channel", version = "=0.3.0-alpha.14", default-features = false }
3132
futures-io-preview = { path = "../futures-io", version = "=0.3.0-alpha.14", default-features = false }
3233
futures-sink-preview = { path = "../futures-sink", version = "=0.3.0-alpha.14", default-features = false}
33-
futures-select-macro-preview = { path = "../futures-select-macro", version = "=0.3.0-alpha.14", default-features = false }
34-
proc-macro-hack = "0.5"
35-
proc-macro-nested = "0.1.2"
34+
futures-select-macro-preview = { path = "../futures-select-macro", version = "=0.3.0-alpha.14", default-features = false, optional = true }
35+
proc-macro-hack = { version = "0.5", optional = true }
36+
proc-macro-nested = { version = "0.1.2", optional = true }
3637
rand = { version = "0.6.4", optional = true }
3738
rand_core = { version = ">=0.2.2, <0.4", optional = true } # See https://github.com/rust-random/rand/issues/645
3839
slab = { version = "0.4", optional = true }
@@ -41,7 +42,7 @@ tokio-io = { version = "0.1.9", optional = true }
4142
pin-utils = "0.1.0-alpha.4"
4243

4344
[dev-dependencies]
44-
futures-preview = { path = "../futures", version = "=0.3.0-alpha.14" }
45+
futures-preview = { path = "../futures", version = "=0.3.0-alpha.14", features = ["async-await", "nightly"] }
4546
futures-executor-preview = { path = "../futures-executor", version = "=0.3.0-alpha.14" }
4647
futures-test-preview = { path = "../futures-test", version = "=0.3.0-alpha.14" }
4748
tokio = "0.1.11"

futures-util/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! and the `AsyncRead` and `AsyncWrite` traits.
33
44
#![cfg_attr(feature = "alloc", feature(box_into_pin))]
5-
#![cfg_attr(feature = "std", feature(async_await, await_macro))]
5+
#![cfg_attr(feature = "async-await", feature(async_await, await_macro))]
66
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]
77
#![cfg_attr(feature = "never-type", feature(never_type))]
88

@@ -17,21 +17,24 @@ compile_error!("The `cfg-target-has-atomic` feature requires the `nightly` featu
1717
#[cfg(all(feature = "never-type", not(feature = "nightly")))]
1818
compile_error!("The `never-type` feature requires the `nightly` feature as an explicit opt-in to unstable features");
1919

20+
#[cfg(all(feature = "async-await", not(feature = "nightly")))]
21+
compile_error!("The `async-await` feature requires the `nightly` feature as an explicit opt-in to unstable features");
22+
2023
#[cfg(feature = "alloc")]
2124
extern crate alloc;
2225

2326
#[macro_use]
2427
mod macros;
2528

26-
#[cfg(feature = "std")]
29+
#[cfg(feature = "async-await")]
2730
#[macro_use]
2831
#[doc(hidden)]
2932
pub mod async_await;
30-
#[cfg(feature = "std")]
33+
#[cfg(feature = "async-await")]
3134
#[doc(hidden)]
3235
pub use self::async_await::*;
3336

34-
#[cfg(feature = "std")]
37+
#[cfg(feature = "async-await")]
3538
#[doc(hidden)]
3639
pub mod rand_reexport { // used by select!
3740
pub use rand::*;

futures/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tokio = "0.1.11"
3838
[features]
3939
nightly = ["futures-core-preview/nightly", "futures-sink-preview/nightly", "futures-util-preview/nightly"]
4040
std = ["alloc", "futures-core-preview/std", "futures-executor-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "futures-util-preview/std"]
41+
async-await = ["futures-util-preview/async-await"]
4142
default = ["std"]
4243
compat = ["std", "futures-util-preview/compat"]
4344
io-compat = ["compat", "futures-util-preview/io-compat"]

futures/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures")]
3232

33+
#[cfg(all(feature = "async-await", not(feature = "nightly")))]
34+
compile_error!("The `async-await` feature requires the `nightly` feature as an explicit opt-in to unstable features");
35+
3336
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
3437
compile_error!("The `cfg-target-has-atomic` feature requires the `nightly` feature as an explicit opt-in to unstable features");
3538

@@ -58,7 +61,7 @@ pub use futures_util::{
5861
// Error/readiness propagation
5962
try_ready, ready,
6063
};
61-
#[cfg(feature = "std")]
64+
#[cfg(feature = "async-await")]
6265
pub use futures_util::{
6366
// Async-await
6467
join, try_join, pending, poll,
@@ -453,17 +456,17 @@ pub mod task {
453456

454457
// `select!` re-export --------------------------------------
455458

456-
#[cfg(feature = "std")]
459+
#[cfg(feature = "async-await")]
457460
#[doc(hidden)]
458461
pub use futures_util::rand_reexport;
459462

460-
#[cfg(feature = "std")]
463+
#[cfg(feature = "async-await")]
461464
#[doc(hidden)]
462465
pub mod inner_select {
463466
pub use futures_util::select;
464467
}
465468

466-
#[cfg(feature = "std")]
469+
#[cfg(feature = "async-await")]
467470
futures_util::document_select_macro! {
468471
#[macro_export]
469472
macro_rules! select { // replace `::futures_util` with `::futures` as the crate path

0 commit comments

Comments
 (0)