Merge pull request #680 from k-nasa/no_std

Some modules support no_std
pull/690/head
Yoshua Wuyts 5 years ago committed by GitHub
commit 125fa5b0a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,6 +40,7 @@ jobs:
with: with:
command: check command: check
args: --features unstable --all --bins --examples --tests args: --features unstable --all --bins --examples --tests
- name: check bench - name: check bench
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
if: matrix.rust == 'nightly' if: matrix.rust == 'nightly'
@ -71,6 +72,24 @@ jobs:
command: test command: test
args: --doc --features "unstable attributes" args: --doc --features "unstable attributes"
build__with_no_std:
name: Build with no-std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: setup
run: |
rustup default nightly
rustup target add thumbv7m-none-eabi
- name: check no_std
uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features --features alloc --target thumbv7m-none-eabi -Z avoid-dev-deps
check_fmt_and_docs: check_fmt_and_docs:
name: Checking fmt and docs name: Checking fmt and docs
runs-on: ubuntu-latest runs-on: ubuntu-latest

@ -38,15 +38,19 @@ docs = ["attributes", "unstable", "default"]
unstable = ["std", "broadcaster", "futures-timer"] unstable = ["std", "broadcaster", "futures-timer"]
attributes = ["async-attributes"] attributes = ["async-attributes"]
std = [ std = [
"alloc",
"crossbeam-utils", "crossbeam-utils",
"futures-core", "futures-core/std",
"futures-io", "futures-io",
"memchr", "memchr",
"once_cell", "once_cell",
"pin-project-lite",
"pin-utils", "pin-utils",
"slab", "slab",
] ]
alloc = [
"futures-core/alloc",
"pin-project-lite",
]
[dependencies] [dependencies]
async-attributes = { version = "1.1.1", optional = true } async-attributes = { version = "1.1.1", optional = true }
@ -55,7 +59,7 @@ broadcaster = { version = "1.0.0", optional = true }
crossbeam-channel = { version = "0.4.0", optional = true } crossbeam-channel = { version = "0.4.0", optional = true }
crossbeam-deque = { version = "0.7.2", optional = true } crossbeam-deque = { version = "0.7.2", optional = true }
crossbeam-utils = { version = "0.7.0", optional = true } crossbeam-utils = { version = "0.7.0", optional = true }
futures-core = { version = "0.3.1", optional = true } futures-core = { version = "0.3.1", optional = true, default-features = false }
futures-io = { version = "0.3.1", optional = true } futures-io = { version = "0.3.1", optional = true }
futures-timer = { version = "2.0.2", optional = true } futures-timer = { version = "2.0.2", optional = true }
kv-log-macro = { version = "1.0.4", optional = true } kv-log-macro = { version = "1.0.4", optional = true }

@ -21,8 +21,8 @@ cfg_unstable_default! {
} }
extension_trait! { extension_trait! {
use std::pin::Pin; use core::pin::Pin;
use std::ops::{Deref, DerefMut}; use core::ops::{Deref, DerefMut};
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
@ -136,7 +136,7 @@ extension_trait! {
[`Future`]: ../future/trait.Future.html [`Future`]: ../future/trait.Future.html
"#] "#]
pub trait FutureExt: std::future::Future { pub trait FutureExt: core::future::Future {
/// Returns a Future that delays execution for a specified time. /// Returns a Future that delays execution for a specified time.
/// ///
/// # Examples /// # Examples

@ -46,15 +46,20 @@
//! [`Future::race`]: trait.Future.html#method.race //! [`Future::race`]: trait.Future.html#method.race
//! [`Future::try_race`]: trait.Future.html#method.try_race //! [`Future::try_race`]: trait.Future.html#method.try_race
cfg_alloc! {
pub use future::Future; pub use future::Future;
pub(crate) mod future;
}
cfg_std! {
pub use pending::pending; pub use pending::pending;
pub use poll_fn::poll_fn; pub use poll_fn::poll_fn;
pub use ready::ready; pub use ready::ready;
pub(crate) mod future;
mod pending; mod pending;
mod poll_fn; mod poll_fn;
mod ready; mod ready;
}
cfg_default! { cfg_default! {
pub use timeout::{timeout, TimeoutError}; pub use timeout::{timeout, TimeoutError};

@ -221,6 +221,7 @@
//! features = ["std"] //! features = ["std"]
//! ``` //! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "docs", feature(doc_cfg))] #![cfg_attr(feature = "docs", feature(doc_cfg))]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![allow(clippy::mutex_atomic, clippy::module_inception)] #![allow(clippy::mutex_atomic, clippy::module_inception)]
@ -229,6 +230,8 @@
#![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")]
#![recursion_limit = "2048"] #![recursion_limit = "2048"]
extern crate alloc;
#[macro_use] #[macro_use]
mod utils; mod utils;
@ -240,14 +243,17 @@ pub use async_attributes::{main, test};
#[cfg(feature = "std")] #[cfg(feature = "std")]
mod macros; mod macros;
cfg_std! { cfg_alloc! {
pub mod task;
pub mod future; pub mod future;
pub mod stream;
}
cfg_std! {
pub mod io; pub mod io;
pub mod os; pub mod os;
pub mod prelude; pub mod prelude;
pub mod stream;
pub mod sync; pub mod sync;
pub mod task;
} }
cfg_default! { cfg_default! {

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use crate::stream::DoubleEndedStream; use crate::stream::DoubleEndedStream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use crate::stream::DoubleEndedStream; use crate::stream::DoubleEndedStream;

@ -1,6 +1,6 @@
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::DoubleEndedStream; use crate::stream::DoubleEndedStream;

@ -1,6 +1,6 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use crate::future::Future; use crate::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::pin::Pin; use core::pin::Pin;
use core::future::Future;
use crate::prelude::*;
use crate::stream::IntoStream; use crate::stream::IntoStream;
/// Extends a collection with the contents of a stream. /// Extends a collection with the contents of a stream.

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::IntoStream; use crate::stream::IntoStream;

@ -2,10 +2,10 @@ use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::future::Future;
use crate::stream::Stream;
use futures_timer::Delay; use futures_timer::Delay;
use crate::prelude::*;
/// Creates a new stream that yields at a set interval. /// Creates a new stream that yields at a set interval.
/// ///
/// The stream first yields after `dur`, and continues to yield every /// The stream first yields after `dur`, and continues to yield every

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use crate::stream::{DoubleEndedStream, ExactSizeStream, FusedStream, Stream}; use crate::stream::{DoubleEndedStream, ExactSizeStream, FusedStream, Stream};

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use crate::stream::Stream; use crate::stream::Stream;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,9 +1,10 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::fuse::Fuse; use super::fuse::Fuse;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
pin_project! { pin_project! {

@ -1,7 +1,7 @@
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use std::pin::Pin; use core::pin::Pin;
pin_project! { pin_project! {
/// A stream that clones the elements of an underlying stream. /// A stream that clones the elements of an underlying stream.

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::fuse::Fuse; use super::fuse::Fuse;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,7 +1,7 @@
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use std::pin::Pin; use core::pin::Pin;
pin_project! { pin_project! {
/// A stream that copies the elements of an underlying stream. /// A stream that copies the elements of an underlying stream.

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::mem::ManuallyDrop; use core::mem::ManuallyDrop;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use std::time::Duration; use core::time::Duration;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,10 +1,10 @@
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::fuse::Fuse; use super::fuse::Fuse;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use crate::stream::Stream; use crate::stream::Stream;

@ -1,9 +1,9 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use crate::prelude::*;
use crate::stream::stream::map::Map; use crate::stream::stream::map::Map;
use crate::stream::stream::StreamExt;
use crate::stream::{IntoStream, Stream}; use crate::stream::{IntoStream, Stream};
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::fmt; use core::fmt;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture; use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture; use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture; use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture; use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,7 +1,7 @@
use std::cmp::{Ord, Ordering}; use core::cmp::{Ord, Ordering};
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,10 +1,11 @@
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Fuse; use crate::stream::Fuse;
use crate::stream::Stream;
use crate::utils; use crate::utils;
pin_project! { pin_project! {

@ -1,7 +1,7 @@
use std::cmp::{Ord, Ordering}; use core::cmp::{Ord, Ordering};
use std::marker::PhantomData; use core::marker::PhantomData;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -110,12 +110,12 @@ pub use take::Take;
pub use take_while::TakeWhile; pub use take_while::TakeWhile;
pub use zip::Zip; pub use zip::Zip;
use std::cmp::Ordering; use core::cmp::Ordering;
cfg_unstable! { cfg_unstable! {
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use std::time::Duration; use core::time::Duration;
use crate::stream::into_stream::IntoStream; use crate::stream::into_stream::IntoStream;
use crate::stream::{FromStream, Product, Sum}; use crate::stream::{FromStream, Product, Sum};

@ -1,10 +1,10 @@
use std::pin::Pin; use core::future::Future;
use std::future::Future; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::fuse::Fuse; use super::fuse::Fuse;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::future::Future; use core::future::Future;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use std::future::Future; use core::future::Future;
use crate::stream::Stream; use crate::stream::Stream;

@ -1,11 +1,11 @@
use std::cmp::Ordering; use core::cmp::Ordering;
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use super::fuse::Fuse; use super::fuse::Fuse;
use crate::prelude::*; use crate::stream::stream::StreamExt;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,7 +1,7 @@
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use std::default::Default; use core::default::Default;
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin; use core::pin::Pin;
use std::task::{Context, Poll}; use core::task::{Context, Poll};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,8 +1,8 @@
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::time::Duration; use std::time::Duration;
use std::future::Future;
use futures_timer::Delay; use futures_timer::Delay;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin; use core::pin::Pin;
use crate::future::Future; use crate::future::Future;
use crate::stream::Stream; use crate::stream::Stream;

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::fmt; use core::fmt;
use std::pin::Pin; use core::pin::Pin;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::mem; use core::mem;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future; use core::future::Future;
use std::pin::Pin; use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;

@ -117,13 +117,16 @@
//! [`task_local!`]: ../macro.task_local.html //! [`task_local!`]: ../macro.task_local.html
//! [`with`]: struct.LocalKey.html#method.with //! [`with`]: struct.LocalKey.html#method.with
cfg_std! { cfg_alloc! {
#[doc(inline)] #[doc(inline)]
pub use std::task::{Context, Poll, Waker}; pub use core::task::{Context, Poll, Waker};
pub use ready::ready; pub use ready::ready;
pub use yield_now::yield_now;
mod ready; mod ready;
}
cfg_std! {
pub use yield_now::yield_now;
mod yield_now; mod yield_now;
} }

@ -1,3 +1,5 @@
use alloc::string::String;
/// Calls a function and aborts if it panics. /// Calls a function and aborts if it panics.
/// ///
/// This is useful in unsafe code where we can't recover from panics. /// This is useful in unsafe code where we can't recover from panics.
@ -104,6 +106,7 @@ macro_rules! cfg_unstable_default {
/// Declares Unix-specific items. /// Declares Unix-specific items.
#[doc(hidden)] #[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_unix { macro_rules! cfg_unix {
($($item:item)*) => { ($($item:item)*) => {
$( $(
@ -116,6 +119,7 @@ macro_rules! cfg_unix {
/// Declares Windows-specific items. /// Declares Windows-specific items.
#[doc(hidden)] #[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_windows { macro_rules! cfg_windows {
($($item:item)*) => { ($($item:item)*) => {
$( $(
@ -128,6 +132,7 @@ macro_rules! cfg_windows {
/// Declares items when the "docs" feature is enabled. /// Declares items when the "docs" feature is enabled.
#[doc(hidden)] #[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_docs { macro_rules! cfg_docs {
($($item:item)*) => { ($($item:item)*) => {
$( $(
@ -139,6 +144,7 @@ macro_rules! cfg_docs {
/// Declares items when the "docs" feature is disabled. /// Declares items when the "docs" feature is disabled.
#[doc(hidden)] #[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_not_docs { macro_rules! cfg_not_docs {
($($item:item)*) => { ($($item:item)*) => {
$( $(
@ -160,6 +166,18 @@ macro_rules! cfg_std {
} }
} }
/// Declares no-std items.
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! cfg_alloc {
($($item:item)*) => {
$(
#[cfg(feature = "alloc")]
$item
)*
}
}
/// Declares default items. /// Declares default items.
#[allow(unused_macros)] #[allow(unused_macros)]
#[doc(hidden)] #[doc(hidden)]
@ -180,6 +198,7 @@ macro_rules! cfg_default {
/// ///
/// Inside invocations of this macro, we write a definitions that looks similar to the final /// Inside invocations of this macro, we write a definitions that looks similar to the final
/// rendered docs, and the macro then generates all the boilerplate for us. /// rendered docs, and the macro then generates all the boilerplate for us.
#[allow(unused_macros)]
#[doc(hidden)] #[doc(hidden)]
macro_rules! extension_trait { macro_rules! extension_trait {
( (
@ -204,14 +223,14 @@ macro_rules! extension_trait {
#[allow(dead_code)] #[allow(dead_code)]
mod owned { mod owned {
#[doc(hidden)] #[doc(hidden)]
pub struct ImplFuture<T>(std::marker::PhantomData<T>); pub struct ImplFuture<T>(core::marker::PhantomData<T>);
} }
// A fake `impl Future` type that borrows its environment. // A fake `impl Future` type that borrows its environment.
#[allow(dead_code)] #[allow(dead_code)]
mod borrowed { mod borrowed {
#[doc(hidden)] #[doc(hidden)]
pub struct ImplFuture<'a, T>(std::marker::PhantomData<&'a T>); pub struct ImplFuture<'a, T>(core::marker::PhantomData<&'a T>);
} }
// Render a fake trait combining the bodies of the base trait and the extension trait. // Render a fake trait combining the bodies of the base trait and the extension trait.

Loading…
Cancel
Save