feat: do not require default feature for unstable

split-by-pattern
dignifiedquire 5 years ago
parent 1f78efec64
commit 5bf3d95313

@ -34,8 +34,8 @@ default = [
"num_cpus", "num_cpus",
"pin-project-lite", "pin-project-lite",
] ]
docs = ["attributes", "unstable"] docs = ["attributes", "unstable", "default"]
unstable = ["default", "broadcaster"] unstable = ["std", "broadcaster", "futures-timer"]
attributes = ["async-attributes"] attributes = ["async-attributes"]
std = [ std = [
"crossbeam-utils", "crossbeam-utils",

@ -7,7 +7,6 @@ cfg_unstable! {
mod try_join; mod try_join;
use std::time::Duration; use std::time::Duration;
use delay::DelayFuture; use delay::DelayFuture;
use flatten::FlattenFuture; use flatten::FlattenFuture;
use crate::future::IntoFuture; use crate::future::IntoFuture;
@ -15,6 +14,9 @@ cfg_unstable! {
use try_race::TryRace; use try_race::TryRace;
use join::Join; use join::Join;
use try_join::TryJoin; use try_join::TryJoin;
}
cfg_unstable_default! {
use crate::future::timeout::TimeoutFuture; use crate::future::timeout::TimeoutFuture;
} }
@ -149,7 +151,7 @@ extension_trait! {
/// dbg!(a.await); /// dbg!(a.await);
/// # }) /// # })
/// ``` /// ```
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>] fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>]
where where
@ -383,7 +385,7 @@ extension_trait! {
# }); # });
``` ```
"#] "#]
#[cfg(any(feature = "unstable", feature = "docs"))] #[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn timeout(self, dur: Duration) -> impl Future<Output = Self::Output> [TimeoutFuture<Self>] fn timeout(self, dur: Duration) -> impl Future<Output = Self::Output> [TimeoutFuture<Self>]
where Self: Sized where Self: Sized

@ -321,7 +321,7 @@ cfg_default! {
mod stdout; mod stdout;
} }
cfg_unstable! { cfg_unstable_default! {
pub use stderr::StderrLock; pub use stderr::StderrLock;
pub use stdin::StdinLock; pub use stdin::StdinLock;
pub use stdout::StdoutLock; pub use stdout::StdoutLock;

@ -32,7 +32,7 @@ impl<T: Read + Unpin> Stream for Bytes<T> {
} }
} }
#[cfg(test)] #[cfg(all(test, default))]
mod tests { mod tests {
use crate::io; use crate::io;
use crate::prelude::*; use crate::prelude::*;

@ -165,7 +165,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
} }
} }
#[cfg(test)] #[cfg(all(test, default))]
mod tests { mod tests {
use crate::io; use crate::io;
use crate::prelude::*; use crate::prelude::*;

@ -266,7 +266,9 @@ cfg_unstable! {
mod option; mod option;
mod string; mod string;
mod collections; mod collections;
}
cfg_unstable_default! {
#[doc(inline)] #[doc(inline)]
pub use std::{write, writeln}; pub use std::{write, writeln};
} }

@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
#[doc(hidden)] #[doc(hidden)]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct CountFuture<S> { pub struct CountFuture<S> {
#[pin] #[pin]

@ -355,7 +355,7 @@ extension_trait! {
# }) } # }) }
``` ```
"#] "#]
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn throttle(self, d: Duration) -> Throttle<Self> fn throttle(self, d: Duration) -> Throttle<Self>
where where
@ -1507,7 +1507,7 @@ extension_trait! {
# }) } # }) }
``` ```
"#] "#]
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn by_ref(&mut self) -> &mut Self { fn by_ref(&mut self) -> &mut Self {
self self

@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
#[derive(Debug)] #[derive(Debug)]
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct PartitionFuture<S, F, B> { pub struct PartitionFuture<S, F, B> {
#[pin] #[pin]

@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[cfg(all(feature = "default", feature = "unstable"))] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct UnzipFuture<S, FromA, FromB> { pub struct UnzipFuture<S, FromA, FromB> {
#[pin] #[pin]

@ -19,7 +19,6 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
} }
/// Generates a random number in `0..n`. /// Generates a random number in `0..n`.
#[cfg(feature = "default")]
pub fn random(n: u32) -> u32 { pub fn random(n: u32) -> u32 {
use std::cell::Cell; use std::cell::Cell;
use std::num::Wrapping; use std::num::Wrapping;
@ -90,6 +89,18 @@ macro_rules! cfg_unstable {
} }
} }
/// Declares unstable and default items.
#[doc(hidden)]
macro_rules! cfg_unstable_default {
($($item:item)*) => {
$(
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg_attr(feature = "docs", doc(unstable))]
$item
)*
}
}
/// Declares Unix-specific items. /// Declares Unix-specific items.
#[doc(hidden)] #[doc(hidden)]
macro_rules! cfg_unix { macro_rules! cfg_unix {

Loading…
Cancel
Save