@@ -3,7 +3,6 @@ use std::convert::Infallible;
33use std:: fmt;
44use std:: future:: Future ;
55use std:: mem:: { forget, MaybeUninit } ;
6- use std:: pin:: Pin ;
76use std:: ptr;
87use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
98use std:: task:: { Context , Poll , RawWaker , RawWakerVTable , Waker } ;
@@ -750,7 +749,7 @@ impl<T> Drop for OnceCell<T> {
750749}
751750
752751/// Either return the result of a future now, or panic.
753- fn now_or_never < T > ( mut f : impl Future < Output = T > ) -> T {
752+ fn now_or_never < T > ( f : impl Future < Output = T > ) -> T {
754753 const NOOP_WAKER : RawWakerVTable = RawWakerVTable :: new ( clone, wake, wake_by_ref, drop) ;
755754
756755 unsafe fn wake ( _: * const ( ) ) { }
@@ -760,15 +759,14 @@ fn now_or_never<T>(mut f: impl Future<Output = T>) -> T {
760759 }
761760 unsafe fn drop ( _: * const ( ) ) { }
762761
763- // SAFETY: We don't move the future after we pin it here.
764- let future = unsafe { Pin :: new_unchecked ( & mut f) } ;
762+ pin ! ( f) ;
765763
766764 let waker = unsafe { Waker :: from_raw ( RawWaker :: new ( ptr:: null ( ) , & NOOP_WAKER ) ) } ;
767765
768766 // Poll the future exactly once.
769767 let mut cx = Context :: from_waker ( & waker) ;
770768
771- match future . poll ( & mut cx) {
769+ match f . poll ( & mut cx) {
772770 Poll :: Ready ( value) => value,
773771 Poll :: Pending => unreachable ! ( "future not ready" ) ,
774772 }
0 commit comments