@@ -216,24 +216,19 @@ where
216216 }
217217 }
218218
219- fn header < ' a > ( ptr : * const ( ) ) -> & ' a Header {
220- let header = ptr as * const Header ;
221- unsafe { & * header }
222- }
223-
224219 /// Runs a task.
225220 ///
226221 /// If polling its future panics, the task will be closed and the panic will be propagated into
227222 /// the caller.
228223 unsafe fn run ( ptr : * const ( ) ) -> bool {
229224 let raw = Self :: from_ptr ( ptr) ;
230- let header = Self :: header ( ptr) ;
225+ let header = ptr as * const Header ;
231226
232227 // Create a context from the raw task pointer and the vtable inside the its header.
233228 let waker = ManuallyDrop :: new ( Waker :: from_raw ( RawWaker :: new ( ptr, & Self :: RAW_WAKER_VTABLE ) ) ) ;
234229 let cx = & mut Context :: from_waker ( & waker) ;
235230
236- let mut state = header. state . load ( Ordering :: Acquire ) ;
231+ let mut state = ( * header) . state . load ( Ordering :: Acquire ) ;
237232
238233 // Update the task's state before polling its future.
239234 loop {
@@ -243,12 +238,12 @@ where
243238 drop_future :: < F > ( ptr, & Self :: TASK_LAYOUT ) ;
244239
245240 // Mark the task as unscheduled.
246- let state = header. state . fetch_and ( !SCHEDULED , Ordering :: AcqRel ) ;
241+ let state = ( * header) . state . fetch_and ( !SCHEDULED , Ordering :: AcqRel ) ;
247242
248243 // Take the awaiter out.
249244 let mut awaiter = None ;
250245 if state & AWAITER != 0 {
251- awaiter = header. take ( None ) ;
246+ awaiter = ( * header) . take ( None ) ;
252247 }
253248
254249 // Drop the task reference.
@@ -262,7 +257,7 @@ where
262257 }
263258
264259 // Mark the task as unscheduled and running.
265- match header. state . compare_exchange_weak (
260+ match ( * header) . state . compare_exchange_weak (
266261 state,
267262 ( state & !SCHEDULED ) | RUNNING ,
268263 Ordering :: AcqRel ,
@@ -280,7 +275,7 @@ where
280275 // Poll the inner future, but surround it with a guard that closes the task in case polling
281276 // panics.
282277 // If available, we should also try to catch the panic so that it is propagated correctly.
283- let guard = Guard :: < F , T > ( raw . header . cast ( ) , & Self :: TASK_LAYOUT , PhantomData ) ;
278+ let guard = Guard :: < F , T > ( ptr , & Self :: TASK_LAYOUT , PhantomData ) ;
284279
285280 // Panic propagation is not available for no_std.
286281 #[ cfg( not( feature = "std" ) ) ]
@@ -289,7 +284,7 @@ where
289284 #[ cfg( feature = "std" ) ]
290285 let poll = {
291286 // Check if we should propagate panics.
292- if header. propagate_panic {
287+ if ( * header) . propagate_panic {
293288 // Use catch_unwind to catch the panic.
294289 match std:: panic:: catch_unwind ( std:: panic:: AssertUnwindSafe ( || {
295290 <F as Future >:: poll ( Pin :: new_unchecked ( & mut * raw. future ) , cx)
@@ -321,7 +316,7 @@ where
321316 } ;
322317
323318 // Mark the task as not running and completed.
324- match header. state . compare_exchange_weak (
319+ match ( * header) . state . compare_exchange_weak (
325320 state,
326321 new,
327322 Ordering :: AcqRel ,
@@ -338,7 +333,7 @@ where
338333 // Take the awaiter out.
339334 let mut awaiter = None ;
340335 if state & AWAITER != 0 {
341- awaiter = header. take ( None ) ;
336+ awaiter = ( * header) . take ( None ) ;
342337 }
343338
344339 // Drop the task reference.
@@ -375,7 +370,7 @@ where
375370 }
376371
377372 // Mark the task as not running.
378- match header. state . compare_exchange_weak (
373+ match ( * header) . state . compare_exchange_weak (
379374 state,
380375 new,
381376 Ordering :: AcqRel ,
@@ -389,7 +384,7 @@ where
389384 // Take the awaiter out.
390385 let mut awaiter = None ;
391386 if state & AWAITER != 0 {
392- awaiter = header. take ( None ) ;
387+ awaiter = ( * header) . take ( None ) ;
393388 }
394389
395390 // Drop the task reference.
0 commit comments