Skip to content

Commit 5b38af9

Browse files
committed
AsyncCallFuture is Unpin
1 parent 54907f8 commit 5b38af9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/function.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {
1818
crate::traits::LuaNativeAsyncFn,
1919
crate::types::AsyncCallback,
2020
std::future::{self, Future},
21-
std::pin::Pin,
21+
std::pin::{pin, Pin},
2222
std::task::{Context, Poll},
2323
};
2424

@@ -669,13 +669,9 @@ impl<R: FromLuaMulti> Future for AsyncCallFuture<R> {
669669
type Output = Result<R>;
670670

671671
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
672-
// Safety: We're not moving any pinned data
673-
let this = unsafe { self.get_unchecked_mut() };
672+
let this = self.get_mut();
674673
match &mut this.0 {
675-
Ok(thread) => {
676-
let pinned_thread = unsafe { Pin::new_unchecked(thread) };
677-
pinned_thread.poll(cx)
678-
}
674+
Ok(thread) => pin!(thread).poll(cx),
679675
Err(err) => Poll::Ready(Err(err.clone())),
680676
}
681677
}

0 commit comments

Comments
 (0)