about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-02-14 04:22:35 +0000
committerbors <bors@rust-lang.org>2019-02-14 04:22:35 +0000
commitc67d4749a547a0c937e257ad9e0248075178ddc4 (patch)
treefd070f430bac8a7e503c2a8d59302a1bbb987b8f /src/liballoc
parent4772dc8087b1d0f2bab6d064fd930e596c82d439 (diff)
parenta0767d6096e2da69381b4d925f3f22887f754aef (diff)
downloadrust-c67d4749a547a0c937e257ad9e0248075178ddc4.tar.gz
rust-c67d4749a547a0c937e257ad9e0248075178ddc4.zip
Auto merge of #58446 - Centril:rollup, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #57451 (suggestion-diagnostics: as_ref improve snippet)
 - #57856 (Convert old first edition links to current edition one)
 - #57992 (Update the future/task API)
 - #58258 (Reduce the size of `hir::Expr`.)
 - #58267 (Tweak "incompatible match arms" error)
 - #58296 (Hidden suggestion support)
 - #58301 (Enable comparing fat pointers)
 - #58308 (Extract block to insert an intrinsic into its own function)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs6
-rw-r--r--src/liballoc/lib.rs4
-rw-r--r--src/liballoc/task.rs130
3 files changed, 3 insertions, 137 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 8e01e12e0b8..51549f92d4d 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -71,7 +71,7 @@ use core::ops::{
     CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState
 };
 use core::ptr::{self, NonNull, Unique};
-use core::task::{LocalWaker, Poll};
+use core::task::{Waker, Poll};
 
 use crate::vec::Vec;
 use crate::raw_vec::RawVec;
@@ -896,7 +896,7 @@ impl<G: ?Sized + Generator> Generator for Pin<Box<G>> {
 impl<F: ?Sized + Future + Unpin> Future for Box<F> {
     type Output = F::Output;
 
-    fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
-        F::poll(Pin::new(&mut *self), lw)
+    fn poll(mut self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
+        F::poll(Pin::new(&mut *self), waker)
     }
 }
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index d4ee428a3b5..95b9dacf856 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -132,10 +132,6 @@ mod macros;
 
 pub mod alloc;
 
-#[unstable(feature = "futures_api",
-           reason = "futures in libcore are unstable",
-           issue = "50547")]
-pub mod task;
 // Primitive types using the heaps above
 
 // Need to conditionally define the mod from `boxed.rs` to avoid
diff --git a/src/liballoc/task.rs b/src/liballoc/task.rs
deleted file mode 100644
index 2261dabe277..00000000000
--- a/src/liballoc/task.rs
+++ /dev/null
@@ -1,130 +0,0 @@
-//! Types and Traits for working with asynchronous tasks.
-
-pub use core::task::*;
-
-#[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
-pub use if_arc::*;
-
-#[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
-mod if_arc {
-    use super::*;
-    use core::marker::PhantomData;
-    use core::mem;
-    use core::ptr::{self, NonNull};
-    use crate::sync::Arc;
-
-    /// A way of waking up a specific task.
-    ///
-    /// Any task executor must provide a way of signaling that a task it owns
-    /// is ready to be `poll`ed again. Executors do so by implementing this trait.
-    pub trait Wake: Send + Sync {
-        /// Indicates that the associated task is ready to make progress and should
-        /// be `poll`ed.
-        ///
-        /// Executors generally maintain a queue of "ready" tasks; `wake` should place
-        /// the associated task onto this queue.
-        fn wake(arc_self: &Arc<Self>);
-
-        /// Indicates that the associated task is ready to make progress and should
-        /// be `poll`ed. This function is like `wake`, but can only be called from the
-        /// thread on which this `Wake` was created.
-        ///
-        /// Executors generally maintain a queue of "ready" tasks; `wake_local` should place
-        /// the associated task onto this queue.
-        #[inline]
-        unsafe fn wake_local(arc_self: &Arc<Self>) {
-            Self::wake(arc_self);
-        }
-    }
-
-    #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
-    struct ArcWrapped<T>(PhantomData<T>);
-
-    unsafe impl<T: Wake + 'static> UnsafeWake for ArcWrapped<T> {
-        #[inline]
-        unsafe fn clone_raw(&self) -> Waker {
-            let me: *const ArcWrapped<T> = self;
-            let arc = (*(&me as *const *const ArcWrapped<T> as *const Arc<T>)).clone();
-            Waker::from(arc)
-        }
-
-        #[inline]
-        unsafe fn drop_raw(&self) {
-            let mut me: *const ArcWrapped<T> = self;
-            let me = &mut me as *mut *const ArcWrapped<T> as *mut Arc<T>;
-            ptr::drop_in_place(me);
-        }
-
-        #[inline]
-        unsafe fn wake(&self) {
-            let me: *const ArcWrapped<T> = self;
-            T::wake(&*(&me as *const *const ArcWrapped<T> as *const Arc<T>))
-        }
-
-        #[inline]
-        unsafe fn wake_local(&self) {
-            let me: *const ArcWrapped<T> = self;
-            T::wake_local(&*(&me as *const *const ArcWrapped<T> as *const Arc<T>))
-        }
-    }
-
-    impl<T> From<Arc<T>> for Waker
-        where T: Wake + 'static,
-    {
-        fn from(rc: Arc<T>) -> Self {
-            unsafe {
-                let ptr = mem::transmute::<Arc<T>, NonNull<ArcWrapped<T>>>(rc);
-                Waker::new(ptr)
-            }
-        }
-    }
-
-    /// Creates a `LocalWaker` from a local `wake`.
-    ///
-    /// This function requires that `wake` is "local" (created on the current thread).
-    /// The resulting `LocalWaker` will call `wake.wake_local()` when awoken, and
-    /// will call `wake.wake()` if awoken after being converted to a `Waker`.
-    #[inline]
-    pub unsafe fn local_waker<W: Wake + 'static>(wake: Arc<W>) -> LocalWaker {
-        let ptr = mem::transmute::<Arc<W>, NonNull<ArcWrapped<W>>>(wake);
-        LocalWaker::new(ptr)
-    }
-
-    struct NonLocalAsLocal<T>(ArcWrapped<T>);
-
-    unsafe impl<T: Wake + 'static> UnsafeWake for NonLocalAsLocal<T> {
-        #[inline]
-        unsafe fn clone_raw(&self) -> Waker {
-            self.0.clone_raw()
-        }
-
-        #[inline]
-        unsafe fn drop_raw(&self) {
-            self.0.drop_raw()
-        }
-
-        #[inline]
-        unsafe fn wake(&self) {
-            self.0.wake()
-        }
-
-        #[inline]
-        unsafe fn wake_local(&self) {
-            // Since we're nonlocal, we can't call wake_local
-            self.0.wake()
-        }
-    }
-
-    /// Creates a `LocalWaker` from a non-local `wake`.
-    ///
-    /// This function is similar to `local_waker`, but does not require that `wake`
-    /// is local to the current thread. The resulting `LocalWaker` will call
-    /// `wake.wake()` when awoken.
-    #[inline]
-    pub fn local_waker_from_nonlocal<W: Wake + 'static>(wake: Arc<W>) -> LocalWaker {
-        unsafe {
-            let ptr = mem::transmute::<Arc<W>, NonNull<NonLocalAsLocal<W>>>(wake);
-            LocalWaker::new(ptr)
-        }
-    }
-}