1
Fork 0

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
This commit is contained in:
Pietro Albini 2018-08-01 10:12:44 +02:00 committed by GitHub
commit 9e43ebda53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 }
}
}