Skip to content

Commit 7a11cfd

Browse files
authored
chore: update async_send_sync test (#3943)
1 parent 6610ba9 commit 7a11cfd

File tree

2 files changed

+565
-276
lines changed

2 files changed

+565
-276
lines changed

tokio/src/task/task_local.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use pin_project_lite::pin_project;
22
use std::cell::RefCell;
33
use std::error::Error;
44
use std::future::Future;
5+
use std::marker::PhantomPinned;
56
use std::pin::Pin;
67
use std::task::{Context, Poll};
78
use std::{fmt, thread};
@@ -123,6 +124,7 @@ impl<T: 'static> LocalKey<T> {
123124
local: &self,
124125
slot: Some(value),
125126
future: f,
127+
_pinned: PhantomPinned,
126128
}
127129
}
128130

@@ -147,12 +149,14 @@ impl<T: 'static> LocalKey<T> {
147149
where
148150
F: FnOnce() -> R,
149151
{
150-
let mut scope = TaskLocalFuture {
152+
let scope = TaskLocalFuture {
151153
local: &self,
152154
slot: Some(value),
153155
future: (),
156+
_pinned: PhantomPinned,
154157
};
155-
Pin::new(&mut scope).with_task(|_| f())
158+
crate::pin!(scope);
159+
scope.with_task(|_| f())
156160
}
157161

158162
/// Accesses the current task-local and runs the provided closure.
@@ -234,6 +238,8 @@ pin_project! {
234238
slot: Option<T>,
235239
#[pin]
236240
future: F,
241+
#[pin]
242+
_pinned: PhantomPinned,
237243
}
238244
}
239245

0 commit comments

Comments
 (0)