about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-08-01 10:12:44 +0200
committerGitHub <noreply@github.com>2018-08-01 10:12:44 +0200
commit9e43ebda534c14885124fbde2915083f43ec1c99 (patch)
tree7bda4a733049b213efd1c5c5386e0216b2682cb2 /src/libcore
parent39406ee241714085bfcd2aa0bec2a6c75c28c01a (diff)
parentea25cf1cc6da92c85e7c17753e6b1defd8effee9 (diff)
Rollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj
Fix From<LocalWaker>

This is a follow-up to https://github.com/rust-lang/rust/pull/52640

Fixes `From<LocalWaker>` which is affected by the same accidental drop bug (unless I'm totally mistaken)

r? @cramertj
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/task/wake.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs
index 321b432d3f4..d770536ef42 100644
--- a/src/libcore/task/wake.rs
+++ b/src/libcore/task/wake.rs
@@ -42,7 +42,7 @@ impl Waker {
     /// `Arc` type and the safe `Wake` trait.
     #[inline]
     pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
-        Waker { inner: inner }
+        Waker { inner }
     }
 
     /// Wake up the task associated with this `Waker`.
@@ -120,7 +120,7 @@ impl LocalWaker {
     /// on the current thread.
     #[inline]
     pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
-        LocalWaker { inner: inner }
+        LocalWaker { inner }
     }
 
     /// Wake up the task associated with this `LocalWaker`.
@@ -159,7 +159,9 @@ impl LocalWaker {
 impl From<LocalWaker> for Waker {
     #[inline]
     fn from(local_waker: LocalWaker) -> Self {
-        Waker { inner: local_waker.inner }
+        let inner = local_waker.inner;
+        mem::forget(local_waker);
+        Waker { inner }
     }
 }