Skip to content

Commit

Permalink
Rollup merge of rust-lang#52822 - MajorBreakfast:fix-from-local-waker…
Browse files Browse the repository at this point in the history
…, r=cramertj

Fix From<LocalWaker>

This is a follow-up to rust-lang#52640

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

r? @cramertj
  • Loading branch information
Mark-Simulacrum committed Aug 1, 2018
2 parents 16646fd + ea25cf1 commit 16ec9bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libcore/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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 }
}
}

Expand Down

0 comments on commit 16ec9bb

Please sign in to comment.