diff --git a/README.md b/README.md index 3a98753e5d..21b0570040 100644 --- a/README.md +++ b/README.md @@ -26,19 +26,17 @@ ## Usage -First, add this to your `Cargo.toml`: +Add this to your `Cargo.toml`: ```toml [dependencies] futures-preview = "0.3.0-alpha.2" ``` -Next, add this to your crate: +Now, you can use futures-rs: ```rust -extern crate futures; // Note: It's not `futures_preview` - -use futures::future::Future; +use futures::future::Future; // Note: It's not `futures_preview` ``` ### Feature `std` diff --git a/futures-channel/Cargo.toml b/futures-channel/Cargo.toml index 7438d32a37..25f0fb49d8 100644 --- a/futures-channel/Cargo.toml +++ b/futures-channel/Cargo.toml @@ -25,3 +25,4 @@ futures-core-preview = { path = "../futures-core", version = "0.3.0-alpha.2", de [dev-dependencies] futures-preview = { path = "../futures", version = "0.3.0-alpha.2", default-features = true } +pin-utils = "0.1.0-alpha.1" diff --git a/futures-channel/benches/sync_mpsc.rs b/futures-channel/benches/sync_mpsc.rs index 573eca90b2..e881178311 100755 --- a/futures-channel/benches/sync_mpsc.rs +++ b/futures-channel/benches/sync_mpsc.rs @@ -1,19 +1,11 @@ #![feature(test, futures_api, pin, arbitrary_self_types)] -#[macro_use] -extern crate futures; -extern crate test; - -use futures::task::{self, Wake, LocalWaker}; +use futures::ready; +use futures::channel::mpsc::{self, Sender, UnboundedSender}; use futures::executor::LocalPool; -use futures::prelude::*; -use futures::channel::mpsc::{ - unbounded, - channel, - Sender, - UnboundedSender, -}; - +use futures::stream::{Stream, StreamExt}; +use futures::sink::Sink; +use futures::task::{self, Poll, Wake, LocalWaker}; use std::mem::PinMut; use std::sync::Arc; use test::Bencher; @@ -41,7 +33,7 @@ fn noop_cx(f: impl FnOnce(&mut task::Context)) { fn unbounded_1_tx(b: &mut Bencher) { noop_cx(|cx| { b.iter(|| { - let (tx, mut rx) = unbounded(); + let (tx, mut rx) = mpsc::unbounded(); // 1000 iterations to avoid measuring overhead of initialization // Result should be divided by 1000 @@ -64,7 +56,7 @@ fn unbounded_1_tx(b: &mut Bencher) { fn unbounded_100_tx(b: &mut Bencher) { noop_cx(|cx| { b.iter(|| { - let (tx, mut rx) = unbounded(); + let (tx, mut rx) = mpsc::unbounded(); let tx: Vec<_> = (0..100).map(|_| tx.clone()).collect(); @@ -86,7 +78,7 @@ fn unbounded_100_tx(b: &mut Bencher) { fn unbounded_uncontended(b: &mut Bencher) { noop_cx(|cx| { b.iter(|| { - let (tx, mut rx) = unbounded(); + let (tx, mut rx) = mpsc::unbounded(); for i in 0..1000 { UnboundedSender::unbounded_send(&tx, i).expect("send"); @@ -127,7 +119,7 @@ impl Stream for TestSender { fn bounded_1_tx(b: &mut Bencher) { noop_cx(|cx| { b.iter(|| { - let (tx, mut rx) = channel(0); + let (tx, mut rx) = mpsc::channel(0); let mut tx = TestSender { tx, last: 0 }; @@ -146,7 +138,7 @@ fn bounded_100_tx(b: &mut Bencher) { noop_cx(|cx| { b.iter(|| { // Each sender can send one item after specified capacity - let (tx, mut rx) = channel(0); + let (tx, mut rx) = mpsc::channel(0); let mut tx: Vec<_> = (0..100).map(|_| { TestSender { diff --git a/futures-channel/src/lib.rs b/futures-channel/src/lib.rs index 64ab63dfa0..9490e61a18 100644 --- a/futures-channel/src/lib.rs +++ b/futures-channel/src/lib.rs @@ -12,11 +12,6 @@ #![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_channel")] -#[cfg(feature = "std")] -extern crate std; - -extern crate futures_core; - macro_rules! if_std { ($($i:item)*) => ($( #[cfg(feature = "std")] diff --git a/futures-channel/src/oneshot.rs b/futures-channel/src/oneshot.rs index 29392fe907..5eb1a567b3 100644 --- a/futures-channel/src/oneshot.rs +++ b/futures-channel/src/oneshot.rs @@ -84,24 +84,22 @@ struct Inner { /// /// ``` /// use futures::channel::oneshot; -/// use futures::prelude::*; +/// use futures::future::FutureExt; /// use std::thread; /// -/// fn main() { -/// let (sender, receiver) = oneshot::channel::(); +/// let (sender, receiver) = oneshot::channel::(); /// /// # let t = -/// thread::spawn(|| { -/// let future = receiver.map(|i| { -/// println!("got: {:?}", i); -/// }); -/// // ... -/// # return future; +/// thread::spawn(|| { +/// let future = receiver.map(|i| { +/// println!("got: {:?}", i); /// }); +/// // ... +/// # return future; +/// }); /// -/// sender.send(3).unwrap(); +/// sender.send(3).unwrap(); /// # futures::executor::block_on(t.join().unwrap()); -/// } /// ``` pub fn channel() -> (Sender, Receiver) { let inner = Arc::new(Inner::new()); diff --git a/futures-channel/tests/channel.rs b/futures-channel/tests/channel.rs index 1d2ab279c2..a2af8b52f9 100644 --- a/futures-channel/tests/channel.rs +++ b/futures-channel/tests/channel.rs @@ -1,14 +1,12 @@ #![feature(async_await, await_macro, futures_api)] -extern crate futures; - -use std::sync::atomic::*; -use std::thread; - -use futures::prelude::*; -use futures::future::poll_fn; -use futures::executor::block_on; use futures::channel::mpsc; +use futures::executor::block_on; +use futures::future::poll_fn; +use futures::stream::StreamExt; +use futures::sink::SinkExt; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; +use std::thread; #[test] fn sequence() { diff --git a/futures-channel/tests/mpsc-close.rs b/futures-channel/tests/mpsc-close.rs index a2bae4ba57..b8ab5fe6e3 100644 --- a/futures-channel/tests/mpsc-close.rs +++ b/futures-channel/tests/mpsc-close.rs @@ -1,14 +1,12 @@ -extern crate futures; - -use std::thread; - -use futures::prelude::*; -use futures::channel::mpsc::*; +use futures::channel::mpsc; use futures::executor::block_on; +use futures::sink::SinkExt; +use futures::stream::StreamExt; +use std::thread; #[test] fn smoke() { - let (mut sender, receiver) = channel(1); + let (mut sender, receiver) = mpsc::channel(1); let t = thread::spawn(move || { while let Ok(()) = block_on(sender.send(42)) {} diff --git a/futures-channel/tests/mpsc.rs b/futures-channel/tests/mpsc.rs index 9067e40b41..5356a70bd4 100644 --- a/futures-channel/tests/mpsc.rs +++ b/futures-channel/tests/mpsc.rs @@ -1,17 +1,15 @@ #![feature(futures_api, async_await, await_macro, pin)] -#[macro_use] -extern crate futures; - -use std::thread; +use futures::channel::{mpsc, oneshot}; +use futures::executor::{block_on, block_on_stream}; +use futures::future::{FutureExt, poll_fn}; +use futures::stream::{Stream, StreamExt}; +use futures::sink::{Sink, SinkExt}; +use futures::task::Poll; +use pin_utils::pin_mut; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicUsize, Ordering}; - -use futures::prelude::*; -use futures::future::poll_fn; -use futures::channel::mpsc; -use futures::channel::oneshot; -use futures::executor::{block_on, block_on_stream}; +use std::thread; trait AssertSend: Send {} impl AssertSend for mpsc::Sender {} diff --git a/futures-channel/tests/oneshot.rs b/futures-channel/tests/oneshot.rs index 0993482c04..899f0807ac 100644 --- a/futures-channel/tests/oneshot.rs +++ b/futures-channel/tests/oneshot.rs @@ -1,20 +1,16 @@ #![feature(futures_api, arbitrary_self_types, pin)] -extern crate futures; - +use futures::channel::oneshot::{self, Sender}; +use futures::executor::block_on; +use futures::future::{Future, FutureExt, poll_fn}; +use futures::task::{self, Poll}; use std::mem::PinMut; use std::sync::mpsc; use std::thread; -use futures::future::poll_fn; -use futures::prelude::*; -use futures::task; -use futures::channel::oneshot::*; -use futures::executor::block_on; - #[test] fn smoke_poll() { - let (mut tx, rx) = channel::(); + let (mut tx, rx) = oneshot::channel::(); let mut rx = Some(rx); let f = poll_fn(|cx| { assert!(tx.poll_cancel(cx).is_pending()); @@ -30,7 +26,7 @@ fn smoke_poll() { #[test] fn cancel_notifies() { - let (tx, rx) = channel::(); + let (tx, rx) = oneshot::channel::(); let t = thread::spawn(|| { block_on(WaitForCancel { tx: tx }); @@ -62,7 +58,7 @@ fn cancel_lots() { }); for _ in 0..20000 { - let (otx, orx) = channel::(); + let (otx, orx) = oneshot::channel::(); let (tx2, rx2) = mpsc::channel(); tx.send((otx, tx2)).unwrap(); drop(orx); @@ -75,7 +71,7 @@ fn cancel_lots() { #[test] fn close() { - let (mut tx, mut rx) = channel::(); + let (mut tx, mut rx) = oneshot::channel::(); rx.close(); block_on(poll_fn(|cx| { match rx.poll_unpin(cx) { @@ -89,7 +85,7 @@ fn close() { #[test] fn close_wakes() { - let (tx, mut rx) = channel::(); + let (tx, mut rx) = oneshot::channel::(); let (tx2, rx2) = mpsc::channel(); let t = thread::spawn(move || { rx.close(); @@ -102,7 +98,7 @@ fn close_wakes() { #[test] fn is_canceled() { - let (tx, rx) = channel::(); + let (tx, rx) = oneshot::channel::(); assert!(!tx.is_canceled()); drop(rx); assert!(tx.is_canceled()); @@ -118,7 +114,7 @@ fn cancel_sends() { }); for _ in 0..20000 { - let (otx, mut orx) = channel::(); + let (otx, mut orx) = oneshot::channel::(); tx.send(otx).unwrap(); orx.close(); diff --git a/futures-core/src/lib.rs b/futures-core/src/lib.rs index 9e80a8db4b..1362393988 100644 --- a/futures-core/src/lib.rs +++ b/futures-core/src/lib.rs @@ -9,12 +9,6 @@ #![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_core")] -#[cfg(feature = "std")] -extern crate std; - -#[cfg(feature = "either")] -extern crate either; - #[doc(hidden)] pub use crate::future::Future; #[doc(hidden)] pub use crate::future::TryFuture; diff --git a/futures-executor/Cargo.toml b/futures-executor/Cargo.toml index 414a74a220..af32442621 100644 --- a/futures-executor/Cargo.toml +++ b/futures-executor/Cargo.toml @@ -26,6 +26,7 @@ futures-util-preview = { path = "../futures-util", version = "0.3.0-alpha.2", de futures-channel-preview = { path = "../futures-channel", version = "0.3.0-alpha.2", default-features = false} num_cpus = { version = "1.0", optional = true } lazy_static = { version = "1.0", optional = true } +pin-utils = "0.1.0-alpha.1" [dev-dependencies] futures-preview = { path = "../futures", version = "0.3.0-alpha.2" } diff --git a/futures-executor/benches/poll.rs b/futures-executor/benches/poll.rs index 25bfab21fd..9255b7f89b 100755 --- a/futures-executor/benches/poll.rs +++ b/futures-executor/benches/poll.rs @@ -1,12 +1,8 @@ #![feature(test, pin, arbitrary_self_types, futures_api)] -extern crate futures; -extern crate test; - -use futures::prelude::*; -use futures::task::{self, Waker, LocalWaker, Wake, local_waker_from_nonlocal}; use futures::executor::LocalPool; - +use futures::future::{Future, FutureExt}; +use futures::task::{self, Poll, Waker, LocalWaker, Wake}; use std::marker::Unpin; use std::mem::PinMut; use std::sync::Arc; @@ -19,7 +15,7 @@ fn notify_noop() -> LocalWaker { fn wake(_: &Arc) {} } - local_waker_from_nonlocal(Arc::new(Noop)) + task::local_waker_from_nonlocal(Arc::new(Noop)) } #[bench] diff --git a/futures-executor/benches/thread_notify.rs b/futures-executor/benches/thread_notify.rs index bee48c6a47..61651f082f 100755 --- a/futures-executor/benches/thread_notify.rs +++ b/futures-executor/benches/thread_notify.rs @@ -1,15 +1,10 @@ #![feature(test, futures_api, pin, arbitrary_self_types)] -extern crate futures; -extern crate test; - +use futures::executor::block_on; +use futures::future::Future; +use futures::task::{self, Poll, Waker}; use std::marker::Unpin; use std::mem::PinMut; - -use futures::prelude::*; -use futures::task::{self, Waker}; -use futures::executor::block_on; - use test::Bencher; #[bench] diff --git a/futures-executor/src/enter.rs b/futures-executor/src/enter.rs index e46264cfec..0697c07e25 100644 --- a/futures-executor/src/enter.rs +++ b/futures-executor/src/enter.rs @@ -25,15 +25,12 @@ pub struct EnterError { /// execute a tasks, and drop the returned [`Enter`](Enter) value after /// completing task execution: /// -/// ```rust -/// # extern crate futures; -/// # use futures::executor::enter; +/// ``` +/// use futures::executor::enter; /// -/// # fn main() { /// let enter = enter().expect("..."); /// /* run task */ /// drop(enter); -/// # } /// ``` /// /// Doing so ensures that executors aren't diff --git a/futures-executor/src/lib.rs b/futures-executor/src/lib.rs index d4f18f206f..0817dc1f40 100644 --- a/futures-executor/src/lib.rs +++ b/futures-executor/src/lib.rs @@ -9,10 +9,6 @@ #![doc(html_root_url = "https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures_executor")] -#[cfg(feature = "std")] -#[macro_use] -extern crate futures_util; - macro_rules! if_std { ($($i:item)*) => ($( #[cfg(feature = "std")] @@ -21,9 +17,6 @@ macro_rules! if_std { } if_std! { - #[macro_use] - extern crate lazy_static; - mod local_pool; pub use crate::local_pool::{block_on, block_on_stream, BlockingStream, LocalPool, LocalExecutor}; diff --git a/futures-executor/src/local_pool.rs b/futures-executor/src/local_pool.rs index 6b12a7849a..996e753876 100644 --- a/futures-executor/src/local_pool.rs +++ b/futures-executor/src/local_pool.rs @@ -1,3 +1,4 @@ +use crate::{enter, ThreadPool}; use futures_core::future::{Future, FutureObj, LocalFutureObj}; use futures_core::stream::{Stream}; use futures_core::task::{ @@ -6,6 +7,8 @@ use futures_core::task::{ }; use futures_util::stream::FuturesUnordered; use futures_util::stream::StreamExt; +use lazy_static::lazy_static; +use pin_utils::pin_mut; use std::cell::{RefCell}; use std::marker::Unpin; use std::ops::{Deref, DerefMut}; @@ -14,9 +17,6 @@ use std::rc::{Rc, Weak}; use std::sync::Arc; use std::thread::{self, Thread}; -use crate::enter; -use crate::ThreadPool; - /// A single-threaded task pool for polling futures to completion. /// /// This executor allows you to multiplex any number of tasks onto a single @@ -101,10 +101,8 @@ impl LocalPool { /// the `LocalPool` by using its executor handle: /// /// ``` - /// # extern crate futures; - /// # use futures::executor::LocalPool; + /// use futures::executor::LocalPool; /// - /// # fn main() { /// let mut pool = LocalPool::new(); /// let mut exec = pool.executor(); /// @@ -112,7 +110,6 @@ impl LocalPool { /// /// // run *all* tasks in the pool to completion, including any newly-spawned ones. /// pool.run(&mut exec); - /// # } /// ``` /// /// The function will block the calling thread until *all* tasks in the pool @@ -128,12 +125,10 @@ impl LocalPool { /// the `LocalPool` by using its executor handle: /// /// ``` - /// # #![feature(pin, arbitrary_self_types, futures_api)] - /// # extern crate futures; - /// # use futures::executor::LocalPool; - /// # use futures::future::ready; + /// #![feature(pin, arbitrary_self_types, futures_api)] + /// use futures::executor::LocalPool; + /// use futures::future::ready; /// - /// # fn main() { /// let mut pool = LocalPool::new(); /// let mut exec = pool.executor(); /// # let my_app = ready(()); @@ -141,7 +136,6 @@ impl LocalPool { /// // run tasks in the pool until `my_app` completes, by default spawning /// // further tasks back onto the pool /// pool.run_until(my_app, &mut exec); - /// # } /// ``` /// /// The function will block the calling thread *only* until the future `f` diff --git a/futures-executor/tests/local_pool.rs b/futures-executor/tests/local_pool.rs index ab03b9b2c0..2f755a8df2 100755 --- a/futures-executor/tests/local_pool.rs +++ b/futures-executor/tests/local_pool.rs @@ -1,23 +1,13 @@ -#![allow(unused_imports)] - #![feature(pin, arbitrary_self_types, futures_api)] -extern crate futures; -extern crate futures_executor; -extern crate futures_channel; - +use futures::channel::oneshot; +use futures::executor::LocalPool; +use futures::future::{Future, lazy}; +use futures::task::{self, Poll, Executor}; use std::boxed::PinBox; use std::cell::{Cell, RefCell}; use std::mem::PinMut; use std::rc::Rc; -use std::thread; -use std::time::Duration; - -use futures::future::lazy; -use futures::prelude::*; -use futures::task::{self, Executor}; -use futures_executor::*; -use futures_channel::oneshot; struct Pending(Rc<()>); diff --git a/futures-sink/src/lib.rs b/futures-sink/src/lib.rs index e7f102bcbc..c4da8748e5 100644 --- a/futures-sink/src/lib.rs +++ b/futures-sink/src/lib.rs @@ -9,13 +9,6 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[cfg(feature = "std")] -extern crate std; - -extern crate futures_core; -#[cfg(feature = "std")] -extern crate futures_channel; - macro_rules! if_std { ($($i:item)*) => ($( #[cfg(feature = "std")] @@ -242,8 +235,6 @@ if_std! { } } -#[cfg(feature = "either")] -extern crate either; #[cfg(feature = "either")] use either::Either; #[cfg(feature = "either")] diff --git a/futures-util/Cargo.toml b/futures-util/Cargo.toml index adf45c3721..28b8936625 100644 --- a/futures-util/Cargo.toml +++ b/futures-util/Cargo.toml @@ -33,6 +33,7 @@ either = { version = "1.4", default-features = false } slab = { version = "0.4", optional = true } futures = { version = "0.1", optional = true } tokio-executor = { version = "0.1.2", optional = true } +pin-utils = "0.1.0-alpha.1" [dev-dependencies] futures-preview = { path = "../futures", version = "0.3.0-alpha.2" } diff --git a/futures-util/benches/futures_unordered.rs b/futures-util/benches/futures_unordered.rs index e0b3502415..759021741a 100755 --- a/futures-util/benches/futures_unordered.rs +++ b/futures-util/benches/futures_unordered.rs @@ -1,20 +1,13 @@ #![feature(test, futures_api)] -extern crate futures; -extern crate futures_channel; -extern crate futures_executor; -extern crate test; - -use futures::prelude::*; +use futures::channel::oneshot; +use futures::executor::block_on; use futures::future; -use futures::stream::FuturesUnordered; -use futures_channel::oneshot; -use futures_executor::block_on; - -use test::Bencher; - +use futures::stream::{StreamExt, FuturesUnordered}; +use futures::task::Poll; use std::collections::VecDeque; use std::thread; +use test::Bencher; #[bench] fn oneshots(b: &mut Bencher) { diff --git a/futures-util/benches_disabled/bilock.rs b/futures-util/benches_disabled/bilock.rs index 8d9f6c6f5e..f6963ca49a 100755 --- a/futures-util/benches_disabled/bilock.rs +++ b/futures-util/benches_disabled/bilock.rs @@ -1,12 +1,7 @@ #![feature(test)] -extern crate futures; -extern crate futures_util; -extern crate test; - #[cfg(feature = "bench")] mod bench { -use futures::prelude::*; use futures::task::{self, Wake, Waker}; use futures::executor::LocalPool; use futures_util::lock::BiLock; diff --git a/futures-util/bilock.rs b/futures-util/bilock.rs index 3678ae8cb8..c935535ef6 100644 --- a/futures-util/bilock.rs +++ b/futures-util/bilock.rs @@ -1,12 +1,8 @@ -extern crate futures; - -use std::thread; - -use futures::prelude::*; use futures::task; use futures::stream; use futures::future; use futures_util::lock::BiLock; +use std::thread; mod support; use support::*; diff --git a/futures-util/src/async_await/spawn.rs b/futures-util/src/async_await/spawn.rs index 85b520155a..32dbc42c05 100644 --- a/futures-util/src/async_await/spawn.rs +++ b/futures-util/src/async_await/spawn.rs @@ -10,8 +10,8 @@ /// /// ``` /// #![feature(async_await, await_macro, futures_api)] -/// #[macro_use] extern crate futures; /// # futures::executor::block_on(async { +/// use futures::spawn; /// /// let future = async { /* ... */ }; /// spawn!(future).unwrap(); @@ -41,9 +41,8 @@ macro_rules! spawn { /// /// ``` /// #![feature(async_await, await_macro, futures_api)] -/// #[macro_use] extern crate futures; /// # futures::executor::block_on(async { -/// use futures::future; +/// use futures::{future, spawn_with_handle}; /// /// let future = future::ready(1); /// let join_handle = spawn_with_handle!(future).unwrap(); diff --git a/futures-util/src/compat/tokio.rs b/futures-util/src/compat/tokio.rs index 57176b8c4b..36b0e9353f 100644 --- a/futures-util/src/compat/tokio.rs +++ b/futures-util/src/compat/tokio.rs @@ -15,7 +15,7 @@ use tokio_executor::{DefaultExecutor, Executor as TokioExecutor}; /// /// ```ignore /// #![feature(async_await, await_macro, futures_api, pin)] -/// #[macro_use] extern crate futures; +/// use futures::spawn; /// use futures::channel::oneshot; /// use futures::compat::TokioDefaultExecutor; /// use futures::executor::block_on; diff --git a/futures-util/src/future/abortable.rs b/futures-util/src/future/abortable.rs index cc49d61678..f4786a6721 100644 --- a/futures-util/src/future/abortable.rs +++ b/futures-util/src/future/abortable.rs @@ -1,6 +1,7 @@ +use crate::task::AtomicWaker; use futures_core::future::Future; use futures_core::task::{self, Poll}; -use crate::task::AtomicWaker; +use pin_utils::unsafe_pinned; use std::marker::Unpin; use std::mem::PinMut; use std::sync::Arc; @@ -28,18 +29,14 @@ impl Abortable where Fut: Future { /// /// Example: /// - /// ```rust - /// # extern crate futures; - /// use futures::prelude::*; + /// ``` /// use futures::future::{ready, Abortable, AbortHandle, Aborted}; /// use futures::executor::block_on; /// - /// # fn main() { /// let (abort_handle, abort_registration) = AbortHandle::new_pair(); /// let future = Abortable::new(ready(2), abort_registration); /// abort_handle.abort(); /// assert_eq!(block_on(future), Err(Aborted)); - /// # } /// ``` pub fn new(future: Fut, reg: AbortRegistration) -> Self { Abortable { @@ -71,18 +68,14 @@ impl AbortHandle { /// /// Example: /// - /// ```rust - /// # extern crate futures; - /// use futures::prelude::*; + /// ``` /// use futures::future::{ready, Abortable, AbortHandle, Aborted}; /// use futures::executor::block_on; /// - /// # fn main() { /// let (abort_handle, abort_registration) = AbortHandle::new_pair(); /// let future = Abortable::new(ready(2), abort_registration); /// abort_handle.abort(); /// assert_eq!(block_on(future), Err(Aborted)); - /// # } pub fn new_pair() -> (Self, AbortRegistration) { let inner = Arc::new(AbortInner { waker: AtomicWaker::new(), diff --git a/futures-util/src/future/catch_unwind.rs b/futures-util/src/future/catch_unwind.rs index f66e34d72e..6c6263c63b 100644 --- a/futures-util/src/future/catch_unwind.rs +++ b/futures-util/src/future/catch_unwind.rs @@ -1,5 +1,6 @@ use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; use std::any::Any; use std::mem::PinMut; use std::panic::{catch_unwind, UnwindSafe, AssertUnwindSafe}; diff --git a/futures-util/src/future/disabled/join_all.rs b/futures-util/src/future/disabled/join_all.rs index 72cfec76af..d9ae0cd7dc 100644 --- a/futures-util/src/future/disabled/join_all.rs +++ b/futures-util/src/future/disabled/join_all.rs @@ -49,12 +49,8 @@ impl fmt::Debug for JoinAll /// # Examples /// /// ``` -/// # extern crate futures; -/// use futures::prelude::*; /// use futures::future::{join_all, ok, err}; /// -/// # fn main() { -/// # /// let f = join_all(vec![ /// ok::(1), /// ok::(2), @@ -73,7 +69,6 @@ impl fmt::Debug for JoinAll /// assert_eq!(x, Err(2)); /// x /// }); -/// # } /// ``` pub fn join_all(i: I) -> JoinAll<::Future> where I: IntoIterator, diff --git a/futures-util/src/future/flatten.rs b/futures-util/src/future/flatten.rs index 13a93058e6..58b36ab828 100644 --- a/futures-util/src/future/flatten.rs +++ b/futures-util/src/future/flatten.rs @@ -1,9 +1,9 @@ +use super::chain::Chain; use core::fmt; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; - -use super::chain::Chain; +use pin_utils::unsafe_pinned; /// Future for the `flatten` combinator. /// diff --git a/futures-util/src/future/fuse.rs b/futures-util/src/future/fuse.rs index b7d0a6f899..1655534a88 100644 --- a/futures-util/src/future/fuse.rs +++ b/futures-util/src/future/fuse.rs @@ -1,6 +1,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// A future which "fuses" a future once it's been resolved. /// diff --git a/futures-util/src/future/inspect.rs b/futures-util/src/future/inspect.rs index 67a4b07acd..2680c29ca7 100644 --- a/futures-util/src/future/inspect.rs +++ b/futures-util/src/future/inspect.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Do something with the item of a future, passing it on. /// diff --git a/futures-util/src/future/into_stream.rs b/futures-util/src/future/into_stream.rs index 7bdde1e96d..0bc388efac 100644 --- a/futures-util/src/future/into_stream.rs +++ b/futures-util/src/future/into_stream.rs @@ -2,6 +2,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// A type which converts a `Future` into a `Stream` /// containing a single element. diff --git a/futures-util/src/future/join.rs b/futures-util/src/future/join.rs index d95f9373a4..e2e66a6fef 100644 --- a/futures-util/src/future/join.rs +++ b/futures-util/src/future/join.rs @@ -5,6 +5,7 @@ use core::fmt; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; macro_rules! generate { ($( diff --git a/futures-util/src/future/map.rs b/futures-util/src/future/map.rs index c11842143c..569de00b82 100644 --- a/futures-util/src/future/map.rs +++ b/futures-util/src/future/map.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Future for the `map` combinator, changing the type of a future. /// diff --git a/futures-util/src/future/maybe_done.rs b/futures-util/src/future/maybe_done.rs index df4be7c10c..7611424e6e 100644 --- a/futures-util/src/future/maybe_done.rs +++ b/futures-util/src/future/maybe_done.rs @@ -29,7 +29,8 @@ impl Unpin for MaybeDone {} /// ``` /// #![feature(async_await, await_macro, futures_api, use_extern_macros, pin)] /// # futures::executor::block_on(async { -/// use futures::{future, pin_mut}; +/// use futures::future; +/// use pin_utils::pin_mut; /// /// let future = future::maybe_done(future::ready(5)); /// pin_mut!(future); diff --git a/futures-util/src/future/mod.rs b/futures-util/src/future/mod.rs index a364c79643..091e64e968 100644 --- a/futures-util/src/future/mod.rs +++ b/futures-util/src/future/mod.rs @@ -176,8 +176,6 @@ pub trait FutureExt: Future { /// # Examples /// /// ``` - /// # extern crate futures; - /// use futures::prelude::*; /// use futures::future::{self, Either}; /// /// // A poor-man's join implemented on top of select @@ -196,7 +194,6 @@ pub trait FutureExt: Future { /// } /// })) /// } - /// # fn main() {} /// ``` fn select(self, other: B) -> Select where B: IntoFuture, Self: Sized @@ -349,11 +346,8 @@ pub trait FutureExt: Future { /// # Examples /// /// ``` - /// # extern crate futures; /// use futures::executor::block_on; - /// use futures::future::*; /// - /// # fn main() { /// let x = 6; /// let future = if x < 10 { /// ready(true).left_future() @@ -362,7 +356,6 @@ pub trait FutureExt: Future { /// }; /// /// assert_eq!(true, block_on(future)); - /// # } /// ``` fn left_future(self) -> Either where B: Future, @@ -380,11 +373,8 @@ pub trait FutureExt: Future { /// # Examples /// /// ``` - /// # extern crate futures; /// use futures::executor::block_on; - /// use futures::future::*; /// - /// # fn main() { /// let x = 6; /// let future = if x < 10 { /// ready(true).left_future() @@ -393,7 +383,7 @@ pub trait FutureExt: Future { /// }; /// /// assert_eq!(false, block_on(future)); - /// # } + /// ``` fn right_future(self) -> Either where A: Future, Self: Sized, @@ -561,7 +551,7 @@ pub trait FutureExt: Future { /// // TODO: minimize and open rust-lang/rust ticket, currently errors: // 'assertion failed: !value.has_escaping_regions()' - /// ```rust,ignore + /// ```ignore /// #![feature(async_await, await_macro, futures_api)] /// # futures::executor::block_on(async { /// use futures::future::{self, FutureExt, Ready}; @@ -616,8 +606,7 @@ pub trait FutureExt: Future { /// // synchronous function to better illustrate the cross-thread aspect of /// // the `shared` combinator. /// - /// use futures::prelude::*; - /// use futures::future; + /// use futures::future::{self, FutureExt}; /// use futures::executor::block_on; /// use std::thread; /// @@ -659,8 +648,8 @@ pub trait FutureExt: Future { /// /// ``` /// #![feature(async_await, await_macro, futures_api)] - /// #[macro_use] extern crate futures; /// # futures::executor::block_on(async { + /// use futures::spawn; /// use futures::executor::ThreadPool; /// use futures::future::FutureExt; /// use std::thread; diff --git a/futures-util/src/future/option.rs b/futures-util/src/future/option.rs index 3c9c8f852a..1b059500c5 100644 --- a/futures-util/src/future/option.rs +++ b/futures-util/src/future/option.rs @@ -1,8 +1,9 @@ //! Definition of the `Option` (optional step) combinator +use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; -use core::mem::PinMut; +use pin_utils::unsafe_pinned; /// A future representing a value which may or may not be present. /// diff --git a/futures-util/src/future/shared.rs b/futures-util/src/future/shared.rs index e872dd7c35..1e7ebf8aca 100644 --- a/futures-util/src/future/shared.rs +++ b/futures-util/src/future/shared.rs @@ -1,23 +1,3 @@ -//! Definition of the Shared combinator, a future that is cloneable, -//! and can be polled in multiple threads. -//! -//! # Examples -//! -//! ``` -//! # extern crate futures; -//! use futures::prelude::*; -//! use futures::future; -//! use futures::executor::block_on; -//! -//! # fn main() { -//! let future = future::ready(6); -//! let shared1 = future.shared(); -//! let shared2 = shared1.clone(); -//! assert_eq!(6, *block_on(shared1)); -//! assert_eq!(6, *block_on(shared2)); -//! # } -//! ``` - use futures_core::future::Future; use futures_core::task::{self, Poll, Wake, Waker}; use slab::Slab; diff --git a/futures-util/src/future/then.rs b/futures-util/src/future/then.rs index 6e6188e982..ad0400f098 100644 --- a/futures-util/src/future/then.rs +++ b/futures-util/src/future/then.rs @@ -2,6 +2,7 @@ use super::Chain; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the `then` combinator, chaining computations on the end of /// another future regardless of its outcome. diff --git a/futures-util/src/future/unit_error.rs b/futures-util/src/future/unit_error.rs index 608a044ac9..5a2974b0d5 100644 --- a/futures-util/src/future/unit_error.rs +++ b/futures-util/src/future/unit_error.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the `unit_error` combinator, turning a `Future` into a `TryFuture`. /// diff --git a/futures-util/src/macros/mod.rs b/futures-util/src/macros/mod.rs index 932898b79c..f0e9f05edc 100644 --- a/futures-util/src/macros/mod.rs +++ b/futures-util/src/macros/mod.rs @@ -1,5 +1,2 @@ -#[macro_use] -mod pin; - #[macro_use] mod poll; diff --git a/futures-util/src/macros/pin.rs b/futures-util/src/macros/pin.rs deleted file mode 100644 index 36f0d6f8e0..0000000000 --- a/futures-util/src/macros/pin.rs +++ /dev/null @@ -1,108 +0,0 @@ -/// A pinned projection of a struct field. -/// -/// To make using this macro safe, two things need to be ensured: -/// - If the struct implements [`Drop`], the [`drop`] method is not allowed to -/// move the value of the field. -/// - If the struct wants to implement [`Unpin`], it has to do so conditionally: -/// The struct can only implement [`Unpin`] if the field's type is [`Unpin`]. -/// -/// ``` -/// # #![feature(pin, arbitrary_self_types)] -/// # #[macro_use] extern crate futures; -/// # use core::mem::PinMut; -/// # use core::marker::Unpin; -/// struct Foo { -/// field: T, -/// } -/// -/// impl Foo { -/// unsafe_pinned!(field: T); -/// -/// fn baz(mut self: PinMut) { -/// let _: PinMut = self.field(); // Pinned reference to the field -/// } -/// } -/// -/// impl Unpin for Foo {}; // Conditional Unpin impl -/// ``` -/// -/// [`Unpin`]: std::marker::Unpin -/// [`drop`]: Drop::drop -#[macro_export] -macro_rules! unsafe_pinned { - ($f:tt: $t:ty) => ( - fn $f<'__a>( - self: &'__a mut $crate::core_reexport::mem::PinMut - ) -> $crate::core_reexport::mem::PinMut<'__a, $t> { - unsafe { - $crate::core_reexport::mem::PinMut::map_unchecked( - self.reborrow(), |x| &mut x.$f - ) - } - } - ) -} - -/// An unpinned projection of a struct field. -/// -/// This macro is unsafe because it creates a method that returns a normal -/// non-pin reference to the struct field. It is up to the programmer to ensure -/// that the contained value can be considered not pinned in the current -/// context. -/// -/// ``` -/// # #![feature(pin, arbitrary_self_types)] -/// # #[macro_use] extern crate futures; -/// # use core::mem::PinMut; -/// # struct Bar; -/// struct Foo { -/// field: Bar, -/// } -/// -/// impl Foo { -/// unsafe_unpinned!(field: Bar); -/// -/// fn baz(mut self: PinMut) { -/// let _: &mut Bar = self.field(); // Normal reference to the field -/// } -/// } -/// ``` -#[macro_export] -macro_rules! unsafe_unpinned { - ($f:tt: $t:ty) => ( - fn $f<'__a>( - self: &'__a mut $crate::core_reexport::mem::PinMut - ) -> &'__a mut $t { - unsafe { - &mut $crate::core_reexport::mem::PinMut::get_mut_unchecked( - self.reborrow() - ).$f - } - } - ) -} - -/// Pins a value on the stack. -/// -/// ``` -/// # #![feature(pin, arbitrary_self_types)] -/// # #[macro_use] extern crate futures; -/// # use core::mem::PinMut; -/// # struct Foo {} -/// let foo = Foo { /* ... */ }; -/// pin_mut!(foo); -/// let _: PinMut = foo; -/// ``` -#[macro_export] -macro_rules! pin_mut { - ($($x:ident),*) => { $( - // Move the value to ensure that it is owned - let mut $x = $x; - // Shadow the original binding so that it can't be directly accessed - // ever again. - #[allow(unused_mut)] - let mut $x = unsafe { - $crate::core_reexport::mem::PinMut::new_unchecked(&mut $x) - }; - )* } -} diff --git a/futures-util/src/sink/buffer.rs b/futures-util/src/sink/buffer.rs index 7507b511f3..792fc741a5 100644 --- a/futures-util/src/sink/buffer.rs +++ b/futures-util/src/sink/buffer.rs @@ -1,6 +1,7 @@ use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::collections::VecDeque; use std::marker::Unpin; use std::mem::PinMut; diff --git a/futures-util/src/sink/err_into.rs b/futures-util/src/sink/err_into.rs index a9fad13820..d30dd45cbd 100644 --- a/futures-util/src/sink/err_into.rs +++ b/futures-util/src/sink/err_into.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::{Sink}; +use pin_utils::unsafe_pinned; /// A sink combinator to change the error type of a sink. /// diff --git a/futures-util/src/sink/fanout.rs b/futures-util/src/sink/fanout.rs index 2770a9288e..875cd4d9f0 100644 --- a/futures-util/src/sink/fanout.rs +++ b/futures-util/src/sink/fanout.rs @@ -2,6 +2,7 @@ use core::fmt::{Debug, Formatter, Result as FmtResult}; use core::mem::PinMut; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::unsafe_pinned; /// Sink that clones incoming items and forwards them to two sinks at the same time. /// diff --git a/futures-util/src/sink/map_err.rs b/futures-util/src/sink/map_err.rs index 38f0fb73ea..f4e379d3e0 100644 --- a/futures-util/src/sink/map_err.rs +++ b/futures-util/src/sink/map_err.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::{Sink}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Sink for the `Sink::sink_map_err` combinator. #[derive(Debug)] diff --git a/futures-util/src/sink/mod.rs b/futures-util/src/sink/mod.rs index 15e2826162..01b4d397c4 100644 --- a/futures-util/src/sink/mod.rs +++ b/futures-util/src/sink/mod.rs @@ -90,13 +90,12 @@ pub trait SinkExt: Sink { /// # Examples /// /// ``` - /// # extern crate futures; - /// use futures::prelude::*; /// use futures::channel::mpsc; /// use futures::executor::block_on; + /// use futures::sink::SinkExt; + /// use futures::stream::StreamExt; /// use std::collections::VecDeque; /// - /// # fn main() { /// let (mut tx, rx) = mpsc::channel(5); /// /// let mut tx = tx.with_flat_map(|x| { @@ -107,7 +106,6 @@ pub trait SinkExt: Sink { /// drop(tx); /// let received: Vec = block_on(rx.collect()); /// assert_eq!(received, vec![42, 42, 42, 42, 42]); - /// # } /// ``` fn with_flat_map(self, f: F) -> WithFlatMap where F: FnMut(U) -> St, diff --git a/futures-util/src/sink/with.rs b/futures-util/src/sink/with.rs index 313f0ae499..3ea1a863b5 100644 --- a/futures-util/src/sink/with.rs +++ b/futures-util/src/sink/with.rs @@ -4,6 +4,7 @@ use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Sink for the `Sink::with` combinator, chaining a computation to run *prior* /// to pushing a value into the underlying sink. diff --git a/futures-util/src/sink/with_flat_map.rs b/futures-util/src/sink/with_flat_map.rs index b4f4128baf..e29a920980 100644 --- a/futures-util/src/sink/with_flat_map.rs +++ b/futures-util/src/sink/with_flat_map.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Sink for the `Sink::with_flat_map` combinator, chaining a computation that /// returns an iterator to run prior to pushing a value into the underlying diff --git a/futures-util/src/stream/buffer_unordered.rs b/futures-util/src/stream/buffer_unordered.rs index 090ee46309..b1349c6a85 100644 --- a/futures-util/src/stream/buffer_unordered.rs +++ b/futures-util/src/stream/buffer_unordered.rs @@ -3,6 +3,7 @@ use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::fmt; use std::marker::Unpin; use std::mem::PinMut; diff --git a/futures-util/src/stream/buffered.rs b/futures-util/src/stream/buffered.rs index 034f0e7b9e..27d2dce2f3 100644 --- a/futures-util/src/stream/buffered.rs +++ b/futures-util/src/stream/buffered.rs @@ -3,6 +3,7 @@ use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::fmt; use std::marker::Unpin; use std::mem::PinMut; diff --git a/futures-util/src/stream/catch_unwind.rs b/futures-util/src/stream/catch_unwind.rs index a6fc576f3d..6785a33496 100644 --- a/futures-util/src/stream/catch_unwind.rs +++ b/futures-util/src/stream/catch_unwind.rs @@ -1,5 +1,6 @@ use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::any::Any; use std::mem::PinMut; use std::panic::{catch_unwind, UnwindSafe, AssertUnwindSafe}; diff --git a/futures-util/src/stream/chain.rs b/futures-util/src/stream/chain.rs index 397dfef237..8f11e7803f 100644 --- a/futures-util/src/stream/chain.rs +++ b/futures-util/src/stream/chain.rs @@ -1,6 +1,7 @@ use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// An adapter for chaining the output of two streams. /// diff --git a/futures-util/src/stream/chunks.rs b/futures-util/src/stream/chunks.rs index 2455338c0f..3f28c3b480 100644 --- a/futures-util/src/stream/chunks.rs +++ b/futures-util/src/stream/chunks.rs @@ -1,6 +1,7 @@ use crate::stream::Fuse; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::marker::Unpin; use std::mem::{self, PinMut}; use std::prelude::v1::*; diff --git a/futures-util/src/stream/collect.rs b/futures-util/src/stream/collect.rs index 69a76a07de..c3dda9dad5 100644 --- a/futures-util/src/stream/collect.rs +++ b/futures-util/src/stream/collect.rs @@ -1,6 +1,7 @@ use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::marker::Unpin; use std::mem::{self, PinMut}; use std::prelude::v1::*; diff --git a/futures-util/src/stream/concat.rs b/futures-util/src/stream/concat.rs index 9ceabdbe4f..384f01b311 100644 --- a/futures-util/src/stream/concat.rs +++ b/futures-util/src/stream/concat.rs @@ -5,6 +5,7 @@ use core::default::Default; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator to concatenate the results of a stream into the first /// yielded item. diff --git a/futures-util/src/stream/filter.rs b/futures-util/src/stream/filter.rs index 6525f828e8..f1b7132265 100644 --- a/futures-util/src/stream/filter.rs +++ b/futures-util/src/stream/filter.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator used to filter the results of a stream and only yield /// some values. diff --git a/futures-util/src/stream/filter_map.rs b/futures-util/src/stream/filter_map.rs index c66960110b..35d2c57190 100644 --- a/futures-util/src/stream/filter_map.rs +++ b/futures-util/src/stream/filter_map.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A combinator used to filter the results of a stream and simultaneously map /// them to a different type. diff --git a/futures-util/src/stream/flatten.rs b/futures-util/src/stream/flatten.rs index 4cec850e79..b027b5b86b 100644 --- a/futures-util/src/stream/flatten.rs +++ b/futures-util/src/stream/flatten.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// A combinator used to flatten a stream-of-streams into one long stream of /// elements. diff --git a/futures-util/src/stream/fold.rs b/futures-util/src/stream/fold.rs index 16adc3f281..e65a23dc9d 100644 --- a/futures-util/src/stream/fold.rs +++ b/futures-util/src/stream/fold.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A future used to collect all the results of a stream into one generic type. /// diff --git a/futures-util/src/stream/for_each.rs b/futures-util/src/stream/for_each.rs index 55c85b853d..5dcfd1a48b 100644 --- a/futures-util/src/stream/for_each.rs +++ b/futures-util/src/stream/for_each.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which executes a unit closure over each item on a /// stream. diff --git a/futures-util/src/stream/forward.rs b/futures-util/src/stream/forward.rs index 9d31092d48..603612e7e6 100644 --- a/futures-util/src/stream/forward.rs +++ b/futures-util/src/stream/forward.rs @@ -5,6 +5,7 @@ use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; const INVALID_POLL: &str = "polled `Forward` after completion"; diff --git a/futures-util/src/stream/fuse.rs b/futures-util/src/stream/fuse.rs index cebbde8a4d..c13e0d0ba7 100644 --- a/futures-util/src/stream/fuse.rs +++ b/futures-util/src/stream/fuse.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; use futures_sink::Sink; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream which "fuse"s a stream once it's terminated. /// diff --git a/futures-util/src/stream/futures_ordered.rs b/futures-util/src/stream/futures_ordered.rs index 10666e7a11..5e77051542 100644 --- a/futures-util/src/stream/futures_ordered.rs +++ b/futures-util/src/stream/futures_ordered.rs @@ -2,6 +2,7 @@ use crate::stream::FuturesUnordered; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; use std::cmp::{Eq, PartialEq, PartialOrd, Ord, Ordering}; use std::collections::binary_heap::{BinaryHeap, PeekMut}; use std::fmt::{self, Debug}; diff --git a/futures-util/src/stream/inspect.rs b/futures-util/src/stream/inspect.rs index 68f8156665..02c96a4d6f 100644 --- a/futures-util/src/stream/inspect.rs +++ b/futures-util/src/stream/inspect.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Do something with the items of a stream, passing it on. /// diff --git a/futures-util/src/stream/iter.rs b/futures-util/src/stream/iter.rs index 6619a6ec2c..375db18021 100644 --- a/futures-util/src/stream/iter.rs +++ b/futures-util/src/stream/iter.rs @@ -20,11 +20,9 @@ impl Unpin for Iter {} /// Iterators in Rust don't express the ability to block, so this adapter /// simply always calls `iter.next()` and returns that. /// -/// ```rust -/// # extern crate futures; -/// use futures::prelude::*; -/// use futures::stream; +/// ``` /// use futures::executor::block_on; +/// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::iter(vec![17, 19]); /// assert_eq!(vec![17, 19], block_on(stream.collect::>())); diff --git a/futures-util/src/stream/map.rs b/futures-util/src/stream/map.rs index f063e326fa..7473dc9a9f 100644 --- a/futures-util/src/stream/map.rs +++ b/futures-util/src/stream/map.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which will change the type of a stream from one /// type to another. diff --git a/futures-util/src/stream/mod.rs b/futures-util/src/stream/mod.rs index 7bb65af69a..b358600f66 100644 --- a/futures-util/src/stream/mod.rs +++ b/futures-util/src/stream/mod.rs @@ -141,10 +141,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// # #![feature(pin)] - /// #[macro_use] extern crate futures; + /// #![feature(pin)] /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::iter(1..=3); /// @@ -174,10 +173,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// # #![feature(pin)] - /// #[macro_use] extern crate futures; + /// #![feature(pin)] /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=3); /// @@ -208,7 +206,7 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=3); /// let stream = stream.map(|x| x + 3); @@ -239,7 +237,8 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10); /// let evens = stream.filter(|x| future::ready(x % 2 == 0)); @@ -269,7 +268,8 @@ pub trait StreamExt: Stream { /// # Examples /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10); /// let evens = stream.filter_map(|x| { @@ -301,7 +301,8 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=3); /// let stream = stream.then(|x| future::ready(x + 3)); @@ -327,9 +328,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::channel::mpsc; /// use futures::executor::block_on; + /// use futures::stream::StreamExt; /// use std::thread; /// /// let (mut tx, rx) = mpsc::unbounded(); @@ -363,9 +364,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::channel::mpsc; /// use futures::executor::block_on; + /// use futures::stream::StreamExt; /// use std::thread; /// /// let (mut tx, rx) = mpsc::unbounded(); @@ -401,8 +402,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::executor::block_on; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let number_stream = stream::iter(0..6); /// let sum = number_stream.fold(0, |acc, x| future::ready(acc + x)); @@ -421,9 +423,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::channel::mpsc; /// use futures::executor::block_on; + /// use futures::stream::StreamExt; /// use std::thread; /// /// let (tx1, rx1) = mpsc::unbounded(); @@ -464,8 +466,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::executor::block_on; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10); /// @@ -491,8 +494,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::executor::block_on; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10); /// @@ -525,7 +529,8 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let mut x = 0; /// @@ -556,7 +561,7 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10).take(3); /// @@ -577,7 +582,7 @@ pub trait StreamExt: Stream { /// /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(1..=10).skip(5); /// @@ -606,10 +611,10 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// # #![feature(futures_api)] - /// #[macro_use] extern crate futures; + /// #![feature(futures_api)] /// use futures::executor::block_on_stream; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; + /// use futures::task::Poll; /// /// let mut x = 0; /// let stream = stream::poll_fn(|_| { @@ -642,8 +647,9 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::executor::block_on; + /// use futures::future; + /// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::iter(1..5); /// @@ -683,9 +689,9 @@ pub trait StreamExt: Stream { /// /// # Examples /// - /// ```rust + /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream = stream::iter(vec![Some(10), None, Some(11)]); /// // Panic on second element @@ -781,8 +787,8 @@ pub trait StreamExt: Stream { /// # Examples /// /// ``` - /// use futures::prelude::*; /// use futures::executor::block_on; + /// use futures::stream::{self, StreamExt}; /// /// let mut stream1 = stream::iter(1..=3); /// let mut stream2 = stream::iter(5..=10); @@ -804,9 +810,9 @@ pub trait StreamExt: Stream { /// The resulting stream emits elements from the first stream, and when /// first stream reaches the end, emits the elements from the second stream. /// - /// ```rust + /// ``` /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::stream::{self, StreamExt}; /// /// let stream1 = stream::iter(vec![Ok(10), Err(false)]); /// let stream2 = stream::iter(vec![Err(true), Ok(20)]); diff --git a/futures-util/src/stream/once.rs b/futures-util/src/stream/once.rs index 755e14ba33..fc655cd7f7 100644 --- a/futures-util/src/stream/once.rs +++ b/futures-util/src/stream/once.rs @@ -3,15 +3,14 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Creates a stream of single element /// -/// ```rust -/// # extern crate futures; -/// use futures::prelude::*; +/// ``` /// use futures::future; /// use futures::executor::block_on; -/// use futures::stream; +/// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::once(future::ready(17)); /// let collected = block_on(stream.collect::>()); diff --git a/futures-util/src/stream/peek.rs b/futures-util/src/stream/peek.rs index 4e501d6da0..ca3de304db 100644 --- a/futures-util/src/stream/peek.rs +++ b/futures-util/src/stream/peek.rs @@ -3,6 +3,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A `Stream` that implements a `peek` method. /// diff --git a/futures-util/src/stream/poll_fn.rs b/futures-util/src/stream/poll_fn.rs index fb766a465a..1c55239023 100644 --- a/futures-util/src/stream/poll_fn.rs +++ b/futures-util/src/stream/poll_fn.rs @@ -23,10 +23,9 @@ impl Unpin for PollFn {} /// # Examples /// /// ``` -/// # #![feature(futures_api)] -/// # extern crate futures; -/// use futures::prelude::*; +/// #![feature(futures_api)] /// use futures::stream::poll_fn; +/// use futures::task::Poll; /// /// let mut counter = 1usize; /// diff --git a/futures-util/src/stream/repeat.rs b/futures-util/src/stream/repeat.rs index a45fab10af..aeaccb0799 100644 --- a/futures-util/src/stream/repeat.rs +++ b/futures-util/src/stream/repeat.rs @@ -18,11 +18,9 @@ pub struct Repeat { /// usage of `collect` or such on the returned stream as it will exhaust /// available memory as it tries to just fill up all RAM. /// -/// ```rust -/// # extern crate futures; -/// use futures::prelude::*; -/// use futures::stream; +/// ``` /// use futures::executor::block_on; +/// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::repeat(9); /// assert_eq!(vec![9, 9, 9], block_on(stream.take(3).collect::>())); diff --git a/futures-util/src/stream/skip.rs b/futures-util/src/stream/skip.rs index d13bdba8a5..ac718dc620 100644 --- a/futures-util/src/stream/skip.rs +++ b/futures-util/src/stream/skip.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which skips a number of elements before continuing. /// diff --git a/futures-util/src/stream/skip_while.rs b/futures-util/src/stream/skip_while.rs index a4e29c1fac..4bf4d0e226 100644 --- a/futures-util/src/stream/skip_while.rs +++ b/futures-util/src/stream/skip_while.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which skips elements of a stream while a predicate /// holds. diff --git a/futures-util/src/stream/take.rs b/futures-util/src/stream/take.rs index 9b2f9e92e1..af96be6fe9 100644 --- a/futures-util/src/stream/take.rs +++ b/futures-util/src/stream/take.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which returns a maximum number of elements. /// diff --git a/futures-util/src/stream/take_while.rs b/futures-util/src/stream/take_while.rs index 6ac835003c..6455958f15 100644 --- a/futures-util/src/stream/take_while.rs +++ b/futures-util/src/stream/take_while.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which takes elements from a stream while a predicate /// holds. diff --git a/futures-util/src/stream/then.rs b/futures-util/src/stream/then.rs index 80e71a05b3..5411884eac 100644 --- a/futures-util/src/stream/then.rs +++ b/futures-util/src/stream/then.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which chains a computation onto each item produced by a /// stream. diff --git a/futures-util/src/stream/unfold.rs b/futures-util/src/stream/unfold.rs index fe5cadf519..cbb4e58e0d 100644 --- a/futures-util/src/stream/unfold.rs +++ b/futures-util/src/stream/unfold.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Creates a `Stream` from a seed and a closure returning a `Future`. /// @@ -29,13 +30,10 @@ use futures_core::task::{self, Poll}; /// /// # Example /// -/// ```rust -/// # extern crate futures; -/// -/// use futures::prelude::*; -/// use futures::stream; -/// use futures::future; +/// ``` /// use futures::executor::block_on; +/// use futures::future; +/// use futures::stream::{self, StreamExt}; /// /// let mut stream = stream::unfold(0, |state| { /// if state <= 2 { diff --git a/futures-util/src/stream/zip.rs b/futures-util/src/stream/zip.rs index d7be91be0b..d5e5af6280 100644 --- a/futures-util/src/stream/zip.rs +++ b/futures-util/src/stream/zip.rs @@ -3,6 +3,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::Stream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// An adapter for merging the output of two streams. /// diff --git a/futures-util/src/task/atomic_waker.rs b/futures-util/src/task/atomic_waker.rs index 7c9e00dc76..272b239854 100755 --- a/futures-util/src/task/atomic_waker.rs +++ b/futures-util/src/task/atomic_waker.rs @@ -169,13 +169,13 @@ impl AtomicWaker { /// Here is how `register` is used when implementing a flag. /// /// ``` - /// # #![feature(pin, arbitrary_self_types, futures_api)] - /// # use futures_core::future::Future; - /// # use futures_core::task::{self, Poll}; - /// # use futures_util::task::AtomicWaker; - /// # use std::sync::atomic::AtomicBool; - /// # use std::sync::atomic::Ordering::SeqCst; - /// # use std::mem::PinMut; + /// #![feature(pin, arbitrary_self_types, futures_api)] + /// use futures::future::Future; + /// use futures::task::{self, Poll, AtomicWaker}; + /// use std::sync::atomic::AtomicBool; + /// use std::sync::atomic::Ordering::SeqCst; + /// use std::mem::PinMut; + /// /// struct Flag { /// waker: AtomicWaker, /// set: AtomicBool, diff --git a/futures-util/src/task/executor/spawn_with_handle.rs b/futures-util/src/task/executor/spawn_with_handle.rs index cb246dca9c..05d84e74df 100644 --- a/futures-util/src/task/executor/spawn_with_handle.rs +++ b/futures-util/src/task/executor/spawn_with_handle.rs @@ -3,6 +3,7 @@ use super::SpawnError; use futures_channel::oneshot::{self, Sender, Receiver}; use futures_core::future::Future; use futures_core::task::{self, Poll, Executor, SpawnObjError}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::marker::Unpin; use std::mem::PinMut; use std::panic::{self, AssertUnwindSafe}; diff --git a/futures-util/src/try_future/and_then.rs b/futures-util/src/try_future/and_then.rs index 8406baad9e..e9c380d5ea 100644 --- a/futures-util/src/try_future/and_then.rs +++ b/futures-util/src/try_future/and_then.rs @@ -2,6 +2,7 @@ use super::{TryChain, TryChainAction}; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the [`and_then`](super::TryFutureExt::and_then) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/err_into.rs b/futures-util/src/try_future/err_into.rs index 36ad64c6bb..26f5e734b4 100644 --- a/futures-util/src/try_future/err_into.rs +++ b/futures-util/src/try_future/err_into.rs @@ -2,6 +2,7 @@ use core::marker::{PhantomData, Unpin}; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the [`err_into`](super::TryFutureExt::err_into) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/into_future.rs b/futures-util/src/try_future/into_future.rs index 46f51eb655..1bf56e4012 100644 --- a/futures-util/src/try_future/into_future.rs +++ b/futures-util/src/try_future/into_future.rs @@ -1,6 +1,7 @@ use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the [`into_future`](super::TryFutureExt::into_future) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/map_err.rs b/futures-util/src/try_future/map_err.rs index d2d4368ce3..2c47ff1833 100644 --- a/futures-util/src/try_future/map_err.rs +++ b/futures-util/src/try_future/map_err.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Future for the [`map_err`](super::TryFutureExt::map_err) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/map_ok.rs b/futures-util/src/try_future/map_ok.rs index ce3046d8df..b23d1129be 100644 --- a/futures-util/src/try_future/map_ok.rs +++ b/futures-util/src/try_future/map_ok.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Future for the [`map_ok`](super::TryFutureExt::map_ok) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/mod.rs b/futures-util/src/try_future/mod.rs index 16d6ea7ea5..1febcc8b04 100644 --- a/futures-util/src/try_future/mod.rs +++ b/futures-util/src/try_future/mod.rs @@ -342,8 +342,6 @@ pub trait TryFutureExt: TryFuture { /// # Examples /// /// ``` - /// # extern crate futures; - /// use futures::prelude::*; /// use futures::future::{self, Either}; /// /// // A poor-man's join implemented on top of select @@ -385,8 +383,6 @@ pub trait TryFutureExt: TryFuture { /// # Examples /// /// ``` - /// # extern crate futures; - /// use futures::prelude::*; /// use futures::future; /// use futures::executor::block_on; /// @@ -402,10 +398,8 @@ pub trait TryFutureExt: TryFuture { /// `Future` will be errored: /// /// ``` - /// # extern crate futures; - /// use futures::prelude::*; - /// use futures::future; /// use futures::executor::block_on; + /// use futures::future::{self, FutureExt}; /// /// let a = future::ok::(1); /// let b = future::err::(2); @@ -488,9 +482,9 @@ pub trait TryFutureExt: TryFuture { /// Wraps a [`TryFuture`] into a future compatable with libraries using /// futures 0.1 future definitons. Requires the `compat` feature to enable. - /// + /// #[cfg(feature = "compat")] - fn compat(self, executor: E) -> Compat + fn compat(self, executor: E) -> Compat where Self: Sized + Unpin, E: Executor, { @@ -518,7 +512,7 @@ pub trait TryFutureExt: TryFuture { /// fn take_future(future: impl Future>) { /* ... */ } /// /// take_future(make_try_future().into_future()); - /// ``` + /// ``` fn into_future(self) -> IntoFuture where Self: Sized, { diff --git a/futures-util/src/try_future/or_else.rs b/futures-util/src/try_future/or_else.rs index a31c568de7..35e4713002 100644 --- a/futures-util/src/try_future/or_else.rs +++ b/futures-util/src/try_future/or_else.rs @@ -2,6 +2,7 @@ use super::{TryChain, TryChainAction}; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Future for the [`or_else`](super::TryFutureExt::or_else) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_future/try_join.rs b/futures-util/src/try_future/try_join.rs index bf52f73d62..23f09b903a 100644 --- a/futures-util/src/try_future/try_join.rs +++ b/futures-util/src/try_future/try_join.rs @@ -6,6 +6,7 @@ use core::fmt; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; macro_rules! generate { ($( diff --git a/futures-util/src/try_future/unwrap_or_else.rs b/futures-util/src/try_future/unwrap_or_else.rs index 8b943e8c0e..a229accb0d 100644 --- a/futures-util/src/try_future/unwrap_or_else.rs +++ b/futures-util/src/try_future/unwrap_or_else.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Future for the [`unwrap_or_else`](super::TryFutureExt::unwrap_or_else) /// combinator. diff --git a/futures-util/src/try_stream/err_into.rs b/futures-util/src/try_stream/err_into.rs index 2285bc4c69..3c1fe28c2c 100644 --- a/futures-util/src/try_stream/err_into.rs +++ b/futures-util/src/try_stream/err_into.rs @@ -2,6 +2,7 @@ use core::marker::{PhantomData, Unpin}; use core::mem::PinMut; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Stream for the [`err_into`](super::TryStreamExt::err_into) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_stream/into_stream.rs b/futures-util/src/try_stream/into_stream.rs index 328e7854ec..428d52dcde 100644 --- a/futures-util/src/try_stream/into_stream.rs +++ b/futures-util/src/try_stream/into_stream.rs @@ -1,6 +1,7 @@ use core::mem::PinMut; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::unsafe_pinned; /// Stream for the [`into_stream`](super::TryStreamExt::into_stream) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_stream/map_err.rs b/futures-util/src/try_stream/map_err.rs index 576b1e708b..57f6ccb8a8 100644 --- a/futures-util/src/try_stream/map_err.rs +++ b/futures-util/src/try_stream/map_err.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Stream for the [`map_err`](super::TryStreamExt::map_err) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_stream/map_ok.rs b/futures-util/src/try_stream/map_ok.rs index 1913037638..9236fdb80c 100644 --- a/futures-util/src/try_stream/map_ok.rs +++ b/futures-util/src/try_stream/map_ok.rs @@ -2,6 +2,7 @@ use core::marker::Unpin; use core::mem::PinMut; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// Stream for the [`map_ok`](super::TryStreamExt::map_ok) combinator. #[derive(Debug)] diff --git a/futures-util/src/try_stream/mod.rs b/futures-util/src/try_stream/mod.rs index 2ff44f0dd9..021c0703b6 100644 --- a/futures-util/src/try_stream/mod.rs +++ b/futures-util/src/try_stream/mod.rs @@ -282,7 +282,8 @@ pub trait TryStreamExt: TryStream { /// #![feature(async_await, await_macro)] /// # futures::executor::block_on(async { /// use futures::executor::block_on; - /// use futures::prelude::*; + /// use futures::future; + /// use futures::stream::{self, StreamExt, TryStreamExt}; /// /// let stream = stream::iter(vec![Ok(1i32), Ok(6i32), Err("error")]); /// let mut halves = stream.try_filter_map(|x| { diff --git a/futures-util/src/try_stream/try_buffer_unordered.rs b/futures-util/src/try_stream/try_buffer_unordered.rs index 52e45a2887..c6032427e9 100644 --- a/futures-util/src/try_stream/try_buffer_unordered.rs +++ b/futures-util/src/try_stream/try_buffer_unordered.rs @@ -4,6 +4,7 @@ use crate::try_stream::IntoStream; use futures_core::future::TryFuture; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::marker::Unpin; use std::mem::PinMut; diff --git a/futures-util/src/try_stream/try_collect.rs b/futures-util/src/try_stream/try_collect.rs index b8c35ffd98..16aa403842 100644 --- a/futures-util/src/try_stream/try_collect.rs +++ b/futures-util/src/try_stream/try_collect.rs @@ -1,6 +1,7 @@ use futures_core::future::Future; use futures_core::stream::TryStream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::marker::Unpin; use std::mem::{self, PinMut}; use std::prelude::v1::*; diff --git a/futures-util/src/try_stream/try_filter_map.rs b/futures-util/src/try_stream/try_filter_map.rs index 0e3696f404..4532e87aca 100644 --- a/futures-util/src/try_stream/try_filter_map.rs +++ b/futures-util/src/try_stream/try_filter_map.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::{TryFuture}; use futures_core::stream::{Stream, TryStream}; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A combinator that attempts to filter the results of a stream /// and simultaneously map them to a different type. diff --git a/futures-util/src/try_stream/try_for_each.rs b/futures-util/src/try_stream/try_for_each.rs index 9c14e2527a..c3409ee86d 100644 --- a/futures-util/src/try_stream/try_for_each.rs +++ b/futures-util/src/try_stream/try_for_each.rs @@ -3,6 +3,7 @@ use core::mem::PinMut; use futures_core::future::{Future, TryFuture}; use futures_core::stream::TryStream; use futures_core::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; /// A stream combinator which attempts to execute an async closure over each /// future in a stream. diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 3e67477c56..8103a0785a 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -32,6 +32,9 @@ futures-io-preview = { path = "../futures-io", version = "0.3.0-alpha.2", defaul futures-sink-preview = { path = "../futures-sink", version = "0.3.0-alpha.2", default-features = false } futures-util-preview = { path = "../futures-util", version = "0.3.0-alpha.2", default-features = false } +[dev-dependencies] +pin-utils = "0.1.0-alpha.1" + [features] nightly = ["futures-util-preview/nightly"] std = ["futures-core-preview/std", "futures-executor-preview/std", "futures-io-preview/std", "futures-sink-preview/std", "futures-util-preview/std"] diff --git a/futures/src/lib.rs b/futures/src/lib.rs index 768fcd290b..acdf2bb38c 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -52,8 +52,6 @@ // Macro reexports pub use futures_util::{ - // Pinning - pin_mut, unsafe_pinned, unsafe_unpinned, // Error/readiness propagation try_ready, try_poll, ready, }; @@ -117,7 +115,7 @@ pub mod executor { //! can then spawn further tasks back onto the pool to complete its work: //! //! ``` - //! # #![feature(pin, arbitrary_self_types, futures_api)] + //! #![feature(pin, arbitrary_self_types, futures_api)] //! use futures::executor::ThreadPool; //! # use futures::future::{Future, lazy}; //! # let my_app = lazy(|_| 42); diff --git a/futures/testcrate/tests/ui.rs b/futures/testcrate/tests/ui.rs index 2cd96e0e08..dc1f49044a 100644 --- a/futures/testcrate/tests/ui.rs +++ b/futures/testcrate/tests/ui.rs @@ -1,10 +1,8 @@ -extern crate compiletest_rs as compiletest; - fn run_mode(mode: &'static str) { use std::env; use std::path::PathBuf; - let mut config = compiletest::Config::default(); + let mut config = compiletest_rs::Config::default(); config.mode = mode.parse().expect("invalid mode"); let mut me = env::current_exe().unwrap(); me.pop(); @@ -15,7 +13,7 @@ fn run_mode(mode: &'static str) { me.pop(); me.pop(); config.build_base = me.join("tests").join(mode); - compiletest::run_tests(&config); + compiletest_rs::run_tests(&config); } fn main() { diff --git a/futures/testcrate/ui/bad-return-type.rs b/futures/testcrate/ui/bad-return-type.rs index 5be93f5285..c115405e69 100644 --- a/futures/testcrate/ui/bad-return-type.rs +++ b/futures/testcrate/ui/bad-return-type.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async] fn foobar() -> Result, ()> { let val = Some(42); diff --git a/futures/testcrate/ui/forget-ok.rs b/futures/testcrate/ui/forget-ok.rs index fac5f5410a..8abafb8145 100644 --- a/futures/testcrate/ui/forget-ok.rs +++ b/futures/testcrate/ui/forget-ok.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async] fn foo() -> Result<(), ()> { } diff --git a/futures/testcrate/ui/missing-item.rs b/futures/testcrate/ui/missing-item.rs index 3417aa09e2..5f0c17bdda 100644 --- a/futures/testcrate/ui/missing-item.rs +++ b/futures/testcrate/ui/missing-item.rs @@ -1,10 +1,6 @@ #![allow(warnings)] #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async_stream] fn foos(a: String) -> Result<(), u32> { Ok(()) diff --git a/futures/testcrate/ui/move-captured-variable.rs b/futures/testcrate/ui/move-captured-variable.rs index 52d1d192b9..d1eab20fc9 100644 --- a/futures/testcrate/ui/move-captured-variable.rs +++ b/futures/testcrate/ui/move-captured-variable.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - fn foo(_f: F) {} fn main() { diff --git a/futures/testcrate/ui/not-a-result.rs b/futures/testcrate/ui/not-a-result.rs index 9b962d810e..18dd32901d 100644 --- a/futures/testcrate/ui/not-a-result.rs +++ b/futures/testcrate/ui/not-a-result.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async] fn foo() -> u32 { 3 diff --git a/futures/testcrate/ui/type_error.rs b/futures/testcrate/ui/type_error.rs index 6d56591d38..5254afc24a 100644 --- a/futures/testcrate/ui/type_error.rs +++ b/futures/testcrate/ui/type_error.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async] fn foo() -> Result { let a: i32 = "a"; //~ ERROR: mismatched types diff --git a/futures/testcrate/ui/unresolved-type.rs b/futures/testcrate/ui/unresolved-type.rs index d980a8a8dc..a6edaa4339 100644 --- a/futures/testcrate/ui/unresolved-type.rs +++ b/futures/testcrate/ui/unresolved-type.rs @@ -1,9 +1,5 @@ #![feature(proc_macro, generators, pin)] -extern crate futures; - -use futures::prelude::*; - #[async] fn foo() -> Result { Err(3) diff --git a/futures/tests/abortable.rs b/futures/tests/abortable.rs index 733fede0db..fc9368694b 100644 --- a/futures/tests/abortable.rs +++ b/futures/tests/abortable.rs @@ -1,7 +1,5 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] extern crate futures; - use futures::FutureExt; use futures::channel::oneshot; use futures::executor::block_on; diff --git a/futures/tests/async_await_macros.rs b/futures/tests/async_await_macros.rs index 8760189d39..1df4a82178 100644 --- a/futures/tests/async_await_macros.rs +++ b/futures/tests/async_await_macros.rs @@ -1,8 +1,9 @@ #![feature(async_await, await_macro, pin, arbitrary_self_types, futures_api)] -use futures::{Poll, future, pending, poll, pin_mut, join, try_join, select}; +use futures::{Poll, future, pending, poll, join, try_join, select}; use futures::channel::oneshot; use futures::executor::block_on; +use pin_utils::pin_mut; #[test] fn poll_and_pending() { diff --git a/futures/tests/basic_combinators.rs b/futures/tests/basic_combinators.rs index bfd8cf23e6..cff77a4ab4 100644 --- a/futures/tests/basic_combinators.rs +++ b/futures/tests/basic_combinators.rs @@ -1,10 +1,6 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - -use futures::future; -use futures::prelude::*; +use futures::future::{self, FutureExt, TryFutureExt}; use std::sync::mpsc; mod support; diff --git a/futures/tests/eager_drop.rs b/futures/tests/eager_drop.rs index cb9e8f4b49..2b97b7b2fa 100644 --- a/futures/tests/eager_drop.rs +++ b/futures/tests/eager_drop.rs @@ -1,11 +1,9 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::channel::oneshot; -use futures::future; -use futures::prelude::*; +use futures::future::{self, Future, FutureExt, TryFutureExt}; +use futures::task::{self, Poll}; +use pin_utils::unsafe_pinned; use std::mem::PinMut; use std::sync::mpsc; diff --git a/futures/tests/fuse.rs b/futures/tests/fuse.rs index 5fa9e89efe..67c672e877 100644 --- a/futures/tests/fuse.rs +++ b/futures/tests/fuse.rs @@ -1,10 +1,6 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - -use futures::future; -use futures::prelude::*; +use futures::future::{self, FutureExt}; mod support; diff --git a/futures/tests/futures_ordered.rs b/futures/tests/futures_ordered.rs index e0f3b824f9..a98a32dfe2 100644 --- a/futures/tests/futures_ordered.rs +++ b/futures/tests/futures_ordered.rs @@ -1,13 +1,9 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::channel::oneshot; use futures::executor::{block_on, block_on_stream}; -use futures::future::{self, FutureObj}; -use futures::prelude::*; -use futures::stream::{futures_ordered, FuturesOrdered}; +use futures::future::{self, FutureExt, FutureObj}; +use futures::stream::{StreamExt, futures_ordered, FuturesOrdered}; mod support; diff --git a/futures/tests/futures_unordered.rs b/futures/tests/futures_unordered.rs index 7de102dc76..de958c94f2 100644 --- a/futures/tests/futures_unordered.rs +++ b/futures/tests/futures_unordered.rs @@ -1,13 +1,10 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::channel::oneshot; use futures::executor::{block_on, block_on_stream}; -use futures::future::{self, FutureObj}; -use futures::stream::{futures_unordered, FuturesUnordered}; -use futures::prelude::*; +use futures::future::{self, FutureExt, FutureObj}; +use futures::stream::{StreamExt, futures_unordered, FuturesUnordered}; +use futures::task::Poll; use std::boxed::Box; mod support; diff --git a/futures/tests/inspect.rs b/futures/tests/inspect.rs index 231c83d081..8e13868153 100644 --- a/futures/tests/inspect.rs +++ b/futures/tests/inspect.rs @@ -1,8 +1,7 @@ #![feature(pin, arbitrary_self_types, futures_api)] use futures::executor::block_on; -use futures::future; -use futures::prelude::*; +use futures::future::{self, FutureExt}; #[test] fn smoke() { diff --git a/futures/tests/io_read_exact.rs b/futures/tests/io_read_exact.rs index 0909c6abfe..a95773663b 100644 --- a/futures/tests/io_read_exact.rs +++ b/futures/tests/io_read_exact.rs @@ -1,6 +1,5 @@ #![feature(pin, arbitrary_self_types, futures_api)] -extern crate futures; use futures::executor::block_on; use futures::io::AsyncReadExt; diff --git a/futures/tests/oneshot.rs b/futures/tests/oneshot.rs index 9477d9fa9a..b74a7c1a58 100644 --- a/futures/tests/oneshot.rs +++ b/futures/tests/oneshot.rs @@ -1,10 +1,7 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::channel::oneshot; -use futures::prelude::*; +use futures::future::{FutureExt, TryFutureExt}; use std::sync::mpsc; use std::thread; diff --git a/futures/tests/recurse.rs b/futures/tests/recurse.rs index ac16fe70ce..e3bb63372b 100644 --- a/futures/tests/recurse.rs +++ b/futures/tests/recurse.rs @@ -1,8 +1,7 @@ #![feature(pin, arbitrary_self_types, futures_api)] use futures::executor::block_on; -use futures::future::{self, FutureObj}; -use futures::prelude::*; +use futures::future::{self, FutureExt, FutureObj}; use std::sync::mpsc; use std::thread; diff --git a/futures/tests/shared.rs b/futures/tests/shared.rs index 869f85cb65..91d3f41198 100644 --- a/futures/tests/shared.rs +++ b/futures/tests/shared.rs @@ -2,8 +2,7 @@ use futures::channel::oneshot; use futures::executor::{block_on, LocalPool}; -use futures::future::{self, LocalFutureObj}; -use futures::prelude::*; +use futures::future::{self, FutureExt, LocalFutureObj}; use std::cell::RefCell; use std::rc::Rc; use std::thread; diff --git a/futures/tests/split.rs b/futures/tests/split.rs index bd2716658c..cb8419024b 100644 --- a/futures/tests/split.rs +++ b/futures/tests/split.rs @@ -1,11 +1,10 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::executor::block_on; -use futures::prelude::*; -use futures::stream; +use futures::sink::{Sink, SinkExt}; +use futures::stream::{self, Stream, StreamExt}; +use futures::task::{self, Poll}; +use pin_utils::unsafe_pinned; use std::mem::PinMut; struct Join { diff --git a/futures/tests/support/assert.rs b/futures/tests/support/assert.rs index d17aef9a79..d72a6fbebc 100644 --- a/futures/tests/support/assert.rs +++ b/futures/tests/support/assert.rs @@ -1,4 +1,5 @@ -use futures::prelude::*; +use futures::stream::Stream; +use futures::task::Poll; use std::fmt; use std::mem::PinMut; diff --git a/futures/tests/support/counter_waker_context.rs b/futures/tests/support/counter_waker_context.rs index 7960af6035..1a875acc17 100644 --- a/futures/tests/support/counter_waker_context.rs +++ b/futures/tests/support/counter_waker_context.rs @@ -1,11 +1,8 @@ +use super::panic_executor::PanicExecutor; +use futures::task::{self, Wake}; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; -use futures::task::Wake; -use futures::prelude::*; - -use super::panic_executor::PanicExecutor; - pub struct CounterWaker(AtomicUsize); impl CounterWaker { diff --git a/futures/tests/support/delayed.rs b/futures/tests/support/delayed.rs index 50c9702140..82c7ed962e 100644 --- a/futures/tests/support/delayed.rs +++ b/futures/tests/support/delayed.rs @@ -1,4 +1,6 @@ -use futures::prelude::*; +use futures::future::Future; +use futures::task::{self, Poll}; +use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::mem::PinMut; pub struct Delayed { diff --git a/futures/tests/support/noop_waker_context.rs b/futures/tests/support/noop_waker_context.rs index 673e5962a5..44cfed035f 100644 --- a/futures/tests/support/noop_waker_context.rs +++ b/futures/tests/support/noop_waker_context.rs @@ -1,9 +1,6 @@ -use std::sync::Arc; - -use futures::task::Wake; -use futures::prelude::*; - use super::panic_executor::PanicExecutor; +use futures::task::{self, Wake}; +use std::sync::Arc; pub fn with_noop_waker_context(f: F) -> R where F: FnOnce(&mut task::Context) -> R diff --git a/futures/tests/support/panic_waker_context.rs b/futures/tests/support/panic_waker_context.rs index 3792a5ccad..134c536499 100644 --- a/futures/tests/support/panic_waker_context.rs +++ b/futures/tests/support/panic_waker_context.rs @@ -1,9 +1,6 @@ -use std::sync::Arc; - -use futures::task::Wake; -use futures::prelude::*; - use super::panic_executor::PanicExecutor; +use futures::task::{self, Wake}; +use std::sync::Arc; pub fn with_panic_waker_context(f: F) -> R where F: FnOnce(&mut task::Context) -> R diff --git a/futures/tests/support/run_in_background.rs b/futures/tests/support/run_in_background.rs index f2ed9b7b59..16634b1f2e 100644 --- a/futures/tests/support/run_in_background.rs +++ b/futures/tests/support/run_in_background.rs @@ -1,5 +1,5 @@ -use futures::prelude::*; use futures::executor::block_on; +use futures::future::Future; use std::thread; pub trait RunInBackgroundExt { diff --git a/futures/tests/unfold.rs b/futures/tests/unfold.rs index 1a3f8e3787..d7f15d8799 100644 --- a/futures/tests/unfold.rs +++ b/futures/tests/unfold.rs @@ -1,10 +1,8 @@ #![feature(pin, arbitrary_self_types, futures_api)] -#[macro_use] -extern crate futures; - use futures::future; use futures::stream; +use pin_utils::pin_mut; mod support; use self::support::assert::*; diff --git a/futures/tests_disabled/all.rs b/futures/tests_disabled/all.rs index 60022c1b66..661b9609b7 100644 --- a/futures/tests_disabled/all.rs +++ b/futures/tests_disabled/all.rs @@ -1,11 +1,7 @@ -extern crate futures; - -use std::sync::mpsc::{channel, TryRecvError}; - -use futures::future::*; use futures::future; use futures::executor::block_on; use futures::channel::oneshot::{self, Canceled}; +use std::sync::mpsc::{channel, TryRecvError}; mod support; use support::*; diff --git a/futures/tests_disabled/async_await/elisions.rs b/futures/tests_disabled/async_await/elisions.rs index 53a0363403..15c3a88ca0 100644 --- a/futures/tests_disabled/async_await/elisions.rs +++ b/futures/tests_disabled/async_await/elisions.rs @@ -1,5 +1,4 @@ use futures::stable::block_on_stable; -use futures::prelude::*; struct Ref<'a, T: 'a>(&'a T); diff --git a/futures/tests_disabled/async_await/pinned.rs b/futures/tests_disabled/async_await/pinned.rs index 0a3114fff9..eabfca4a7c 100644 --- a/futures/tests_disabled/async_await/pinned.rs +++ b/futures/tests_disabled/async_await/pinned.rs @@ -1,6 +1,5 @@ use futures::stable::block_on_stable; use futures::executor::{block_on, ThreadPool}; -use futures::prelude::*; #[async] fn foo() -> Result { diff --git a/futures/tests_disabled/async_await/smoke.rs b/futures/tests_disabled/async_await/smoke.rs index f3f1b28451..f102f3c52e 100644 --- a/futures/tests_disabled/async_await/smoke.rs +++ b/futures/tests_disabled/async_await/smoke.rs @@ -11,7 +11,6 @@ use std::io; use futures::Never; use futures::future::poll_fn; -use futures::prelude::*; #[async] fn foo() -> Result { diff --git a/futures/tests_disabled/async_await_tests.rs b/futures/tests_disabled/async_await_tests.rs index 5d27629f39..81a50a71b7 100644 --- a/futures/tests_disabled/async_await_tests.rs +++ b/futures/tests_disabled/async_await_tests.rs @@ -1,6 +1,4 @@ #![cfg_attr(feature = "nightly", feature(proc_macro, generators, pin))] -extern crate futures; - #[cfg(feature = "nightly")] mod async_await; diff --git a/futures/tests_disabled/buffer_unordered.rs b/futures/tests_disabled/buffer_unordered.rs index 1d2d53aca6..bcc012fed3 100644 --- a/futures/tests_disabled/buffer_unordered.rs +++ b/futures/tests_disabled/buffer_unordered.rs @@ -1,13 +1,10 @@ -extern crate futures; - -use std::sync::mpsc as std_mpsc; -use std::thread; - use futures::SinkExt; use futures::executor::{block_on, block_on_stream}; use futures::stream::StreamExt; use futures::channel::oneshot; use futures::channel::mpsc; +use std::sync::mpsc as std_mpsc; +use std::thread; #[test] fn works() { diff --git a/futures/tests_disabled/eventual.rs b/futures/tests_disabled/eventual.rs index e962e93c7c..c68828ec12 100644 --- a/futures/tests_disabled/eventual.rs +++ b/futures/tests_disabled/eventual.rs @@ -1,14 +1,11 @@ -extern crate futures; +use futures::channel::oneshot; +use futures::future::{ok, err}; +use std::sync::mpsc; +use std::thread; mod support; use support::*; -use std::sync::mpsc; -use std::thread; - -use futures::prelude::*; -use futures::future::{ok, err}; -use futures::channel::oneshot; #[test] fn join1() { diff --git a/futures/tests_disabled/future_flatten_stream.rs b/futures/tests_disabled/future_flatten_stream.rs index 8398976d93..4930ff5f23 100644 --- a/futures/tests_disabled/future_flatten_stream.rs +++ b/futures/tests_disabled/future_flatten_stream.rs @@ -1,12 +1,8 @@ -extern crate core; -extern crate futures; - -use core::marker; use futures::executor::block_on_stream; -use futures::prelude::*; use futures::future::{ok, err}; use futures::stream; +use core::marker; #[test] fn successful_future() { diff --git a/futures/tests_disabled/ready_queue.rs b/futures/tests_disabled/ready_queue.rs index c9671f4d0a..6face1eb14 100644 --- a/futures/tests_disabled/ready_queue.rs +++ b/futures/tests_disabled/ready_queue.rs @@ -1,13 +1,9 @@ -extern crate futures; - -use std::panic::{self, AssertUnwindSafe}; - -use futures::prelude::*; use futures::executor::{block_on, block_on_stream}; use futures::Async::*; use futures::future; use futures::stream::FuturesUnordered; use futures::channel::oneshot; +use std::panic::{self, AssertUnwindSafe}; mod support; diff --git a/futures/tests_disabled/select_all.rs b/futures/tests_disabled/select_all.rs index a5e9e50dac..2bd5108831 100644 --- a/futures/tests_disabled/select_all.rs +++ b/futures/tests_disabled/select_all.rs @@ -1,5 +1,3 @@ -extern crate futures; - use futures::executor::block_on; use futures::future::{ok, select_all, err}; diff --git a/futures/tests_disabled/select_ok.rs b/futures/tests_disabled/select_ok.rs index df9a12ba79..933e4bd52c 100644 --- a/futures/tests_disabled/select_ok.rs +++ b/futures/tests_disabled/select_ok.rs @@ -1,6 +1,3 @@ -extern crate futures; - -use futures::future::*; use futures::executor::block_on; #[test] diff --git a/futures/tests_disabled/sink.rs b/futures/tests_disabled/sink.rs index 89cf77866c..44f4e37de5 100644 --- a/futures/tests_disabled/sink.rs +++ b/futures/tests_disabled/sink.rs @@ -1,19 +1,15 @@ -#[macro_use] extern crate futures; - -use std::mem; -use std::sync::Arc; -use std::rc::Rc; -use std::cell::{Cell, RefCell}; -use std::sync::atomic::{Ordering, AtomicBool}; -use std::collections::VecDeque; - -use futures::prelude::*; use futures::future::ok; use futures::stream; use futures::channel::{oneshot, mpsc}; use futures::task::{self, Wake, Waker}; use futures::executor::block_on; use futures::sink::SinkErrInto; +use std::cell::{Cell, RefCell}; +use std::collections::VecDeque; +use std::mem; +use std::rc::Rc; +use std::sync::Arc; +use std::sync::atomic::{Ordering, AtomicBool}; mod support; use support::*; diff --git a/futures/tests_disabled/stream.rs b/futures/tests_disabled/stream.rs index 25bf8b8110..7f604c791b 100644 --- a/futures/tests_disabled/stream.rs +++ b/futures/tests_disabled/stream.rs @@ -1,7 +1,3 @@ -#[macro_use] -extern crate futures; - -use futures::prelude::*; use futures::executor::{block_on, block_on_stream}; use futures::future::{err, ok}; use futures::stream::{empty, iter_ok, poll_fn, Peekable}; diff --git a/futures/tests_disabled/stream_catch_unwind.rs b/futures/tests_disabled/stream_catch_unwind.rs index 1bef3dfb43..54d7cf4b0c 100644 --- a/futures/tests_disabled/stream_catch_unwind.rs +++ b/futures/tests_disabled/stream_catch_unwind.rs @@ -1,8 +1,5 @@ -extern crate futures; - use futures::executor::block_on_stream; use futures::stream; -use futures::prelude::*; #[test] fn panic_in_the_middle_of_the_stream() { diff --git a/futures/tests_disabled/stream_select_all.rs b/futures/tests_disabled/stream_select_all.rs index 8081b51719..b728492b41 100644 --- a/futures/tests_disabled/stream_select_all.rs +++ b/futures/tests_disabled/stream_select_all.rs @@ -1,10 +1,7 @@ -extern crate futures; - -use std::mem; - use futures::executor::block_on_stream; use futures::channel::mpsc; use futures::stream::select_all; +use std::mem; mod support;