Skip to content

Commit 9e43ebd

Browse files
authored
Rollup merge of rust-lang#52822 - MajorBreakfast:fix-from-local-waker, 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
2 parents 39406ee + ea25cf1 commit 9e43ebd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libcore/task/wake.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Waker {
4242
/// `Arc` type and the safe `Wake` trait.
4343
#[inline]
4444
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
45-
Waker { inner: inner }
45+
Waker { inner }
4646
}
4747

4848
/// Wake up the task associated with this `Waker`.
@@ -120,7 +120,7 @@ impl LocalWaker {
120120
/// on the current thread.
121121
#[inline]
122122
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
123-
LocalWaker { inner: inner }
123+
LocalWaker { inner }
124124
}
125125

126126
/// Wake up the task associated with this `LocalWaker`.
@@ -159,7 +159,9 @@ impl LocalWaker {
159159
impl From<LocalWaker> for Waker {
160160
#[inline]
161161
fn from(local_waker: LocalWaker) -> Self {
162-
Waker { inner: local_waker.inner }
162+
let inner = local_waker.inner;
163+
mem::forget(local_waker);
164+
Waker { inner }
163165
}
164166
}
165167

0 commit comments

Comments
 (0)