From a86e7036610fbb7b952358aa7c04980b50bb365d Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 10 Nov 2020 14:18:07 +0100 Subject: [PATCH] tools::runtime: pin_mut instead of unsafe block Signed-off-by: Wolfgang Bumiller --- src/tools/runtime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/runtime.rs b/src/tools/runtime.rs index 4ef5ebeb..1953e202 100644 --- a/src/tools/runtime.rs +++ b/src/tools/runtime.rs @@ -7,6 +7,7 @@ use std::task::{Context, Poll, RawWaker, Waker}; use std::thread::{self, Thread}; use lazy_static::lazy_static; +use pin_utils::pin_mut; use tokio::runtime::{self, Runtime}; thread_local! { @@ -154,9 +155,8 @@ pub fn main(fut: F) -> F::Output { block_on(fut) } -fn block_on_local_future(mut fut: F) -> F::Output { - use std::pin::Pin; - let mut fut = unsafe { Pin::new_unchecked(&mut fut) }; +fn block_on_local_future(fut: F) -> F::Output { + pin_mut!(fut); let waker = Arc::new(thread::current()); let waker = thread_waker_clone(Arc::into_raw(waker) as *const ());