Skip to content

Commit

Permalink
Merge pull request #1072 from mkroening/unchecked-pin
Browse files Browse the repository at this point in the history
fix(executor): replace `Pin::new_unchecked` with `pin!`
  • Loading branch information
mkroening authored Feb 19, 2024
2 parents d0439ea + e4ceb3f commit b52073d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub(crate) mod task;
use alloc::sync::Arc;
use alloc::task::Wake;
use core::future::Future;
use core::pin::pin;
use core::sync::atomic::AtomicU32;
use core::task::{Context, Poll, Waker};
use core::time::Duration;
Expand Down Expand Up @@ -127,8 +128,7 @@ where
let start = now();
let waker = core::task::Waker::noop();
let mut cx = Context::from_waker(&waker);
let mut future = future;
let mut future = unsafe { core::pin::Pin::new_unchecked(&mut future) };
let mut future = pin!(future);

loop {
// run background tasks
Expand Down Expand Up @@ -197,8 +197,7 @@ where
let task_notify = Arc::new(TaskNotify::new());
let waker = task_notify.clone().into();
let mut cx = Context::from_waker(&waker);
let mut future = future;
let mut future = unsafe { core::pin::Pin::new_unchecked(&mut future) };
let mut future = pin!(future);

loop {
// run background tasks
Expand Down

0 comments on commit b52073d

Please sign in to comment.