Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move non-stable Rust features behind Cargo features #1555

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ matrix:
- cargo bench --all
- cargo bench --manifest-path futures-util/Cargo.toml --features=bench

- name: cargo build --no-default-features
- name: cargo +stable build --no-default-features
rust: nightly
env:
- RUSTFLAGS="-Z allow-features="
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --manifest-path futures/Cargo.toml --no-default-features
- cargo build --manifest-path futures-core/Cargo.toml --no-default-features
- cargo build --manifest-path futures-channel/Cargo.toml --no-default-features
Expand All @@ -54,22 +57,31 @@ matrix:
- cargo build --manifest-path futures-sink/Cargo.toml --no-default-features
- cargo build --manifest-path futures-util/Cargo.toml --no-default-features

- name: cargo build (alloc)
- name: cargo +stable build (alloc)
rust: nightly
env:
- RUSTFLAGS="-Z allow-features="
script:
- cargo build --manifest-path futures/Cargo.toml --no-default-features --features alloc,nightly
- cargo build --manifest-path futures-core/Cargo.toml --no-default-features --features alloc,nightly
- cargo build --manifest-path futures-sink/Cargo.toml --no-default-features --features alloc,nightly
- cargo build --manifest-path futures-util/Cargo.toml --no-default-features --features alloc,nightly
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --manifest-path futures/Cargo.toml --no-default-features --features alloc
- cargo build --manifest-path futures-core/Cargo.toml --no-default-features --features alloc
- cargo build --manifest-path futures-sink/Cargo.toml --no-default-features --features alloc
- cargo build --manifest-path futures-util/Cargo.toml --no-default-features --features alloc

- name: cargo build (default features)
- name: cargo +stable build (default features)
rust: nightly
env:
- RUSTFLAGS="-Z allow-features="
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --all

- name: cargo build (compat feature)
- name: cargo +stable build (compat feature)
rust: nightly
env:
- RUSTFLAGS="-Z allow-features="
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --manifest-path futures/Cargo.toml --features io-compat

- name: cargo build --target=thumbv6m-none-eabi
Expand Down
1 change: 0 additions & 1 deletion futures-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Utilities to make testing [`Future`s](futures_core::Future) easier

#![feature(async_await, await_macro)]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![doc(
html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.5/futures_test"
Expand Down
11 changes: 6 additions & 5 deletions futures-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Common utilities and extension traits for the futures-rs library.
name = "futures_util"

[features]
std = ["alloc", "futures-core-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "futures-select-macro-preview/std", "rand", "rand_core", "slab", "memchr"]
std = ["alloc", "futures-core-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "slab", "memchr"]
default = ["std"]
async-await = ["std", "futures-select-macro-preview", "proc-macro-hack", "proc-macro-nested", "rand", "rand_core"]
compat = ["std", "futures_01"]
io-compat = ["compat", "tokio-io"]
bench = []
Expand All @@ -30,9 +31,9 @@ futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.14",
futures-channel-preview = { path = "../futures-channel", version = "=0.3.0-alpha.14", default-features = false }
futures-io-preview = { path = "../futures-io", version = "=0.3.0-alpha.14", default-features = false }
futures-sink-preview = { path = "../futures-sink", version = "=0.3.0-alpha.14", default-features = false}
futures-select-macro-preview = { path = "../futures-select-macro", version = "=0.3.0-alpha.14", default-features = false }
proc-macro-hack = "0.5"
proc-macro-nested = "0.1.2"
futures-select-macro-preview = { path = "../futures-select-macro", version = "=0.3.0-alpha.14", default-features = false, optional = true }
proc-macro-hack = { version = "0.5", optional = true }
proc-macro-nested = { version = "0.1.2", optional = true }
rand = { version = "0.6.4", optional = true }
rand_core = { version = ">=0.2.2, <0.4", optional = true } # See https://github.com/rust-random/rand/issues/645
slab = { version = "0.4", optional = true }
Expand All @@ -42,7 +43,7 @@ tokio-io = { version = "0.1.9", optional = true }
pin-utils = "0.1.0-alpha.4"

[dev-dependencies]
futures-preview = { path = "../futures", version = "=0.3.0-alpha.14" }
futures-preview = { path = "../futures", version = "=0.3.0-alpha.14", features = ["async-await", "nightly"] }
futures-executor-preview = { path = "../futures-executor", version = "=0.3.0-alpha.14" }
futures-test-preview = { path = "../futures-test", version = "=0.3.0-alpha.14" }
tokio = "0.1.11"
2 changes: 1 addition & 1 deletion futures-util/src/future/join_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ where
I::Item: Future,
{
let elems: Box<[_]> = i.into_iter().map(ElemState::Pending).collect();
JoinAll { elems: Box::into_pin(elems) }
JoinAll { elems: elems.into() }
}

impl<F> Future for JoinAll<F>
Expand Down
12 changes: 7 additions & 5 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Combinators and utilities for working with `Future`s, `Stream`s, `Sink`s,
//! and the `AsyncRead` and `AsyncWrite` traits.

#![cfg_attr(feature = "alloc", feature(box_into_pin))]
#![cfg_attr(feature = "std", feature(async_await, await_macro))]
#![cfg_attr(feature = "async-await", feature(async_await, await_macro))]
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]
#![cfg_attr(feature = "never-type", feature(never_type))]

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

#[cfg(all(feature = "async-await", not(feature = "nightly")))]
compile_error!("The `async-await` feature requires the `nightly` feature as an explicit opt-in to unstable features");

#[cfg(feature = "alloc")]
extern crate alloc;

#[macro_use]
mod macros;

#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
#[macro_use]
#[doc(hidden)]
pub mod async_await;
#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
#[doc(hidden)]
pub use self::async_await::*;

#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
#[doc(hidden)]
pub mod rand_reexport { // used by select!
pub use rand::*;
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/try_future/try_join_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ where
{
let elems: Box<[_]> = i.into_iter().map(ElemState::Pending).collect();
TryJoinAll {
elems: Box::into_pin(elems),
elems: elems.into(),
}
}

Expand Down
1 change: 1 addition & 0 deletions futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tokio = "0.1.11"
[features]
nightly = ["futures-core-preview/nightly", "futures-sink-preview/nightly", "futures-util-preview/nightly"]
std = ["alloc", "futures-core-preview/std", "futures-executor-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "futures-util-preview/std"]
async-await = ["futures-util-preview/async-await"]
default = ["std"]
compat = ["std", "futures-util-preview/compat"]
io-compat = ["compat", "futures-util-preview/io-compat"]
Expand Down
11 changes: 7 additions & 4 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

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

#[cfg(all(feature = "async-await", not(feature = "nightly")))]
compile_error!("The `async-await` feature requires the `nightly` feature as an explicit opt-in to unstable features");

#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
compile_error!("The `cfg-target-has-atomic` feature requires the `nightly` feature as an explicit opt-in to unstable features");

Expand Down Expand Up @@ -58,7 +61,7 @@ pub use futures_util::{
// Error/readiness propagation
try_ready, ready,
};
#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
pub use futures_util::{
// Async-await
join, try_join, pending, poll,
Expand Down Expand Up @@ -455,17 +458,17 @@ pub mod task {

// `select!` re-export --------------------------------------

#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
#[doc(hidden)]
pub use futures_util::rand_reexport;

#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
#[doc(hidden)]
pub mod inner_select {
pub use futures_util::select;
}

#[cfg(feature = "std")]
#[cfg(feature = "async-await")]
futures_util::document_select_macro! {
#[macro_export]
macro_rules! select { // replace `::futures_util` with `::futures` as the crate path
Expand Down