File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use crate::{
55use core:: {
66 future:: Future ,
77 marker:: Sized ,
8- mem:: { self , ManuallyDrop } ,
8+ mem:: ManuallyDrop ,
99 pin:: Pin ,
1010 task:: { Context , Poll } ,
1111} ;
@@ -359,12 +359,11 @@ impl<T> Instrumented<T> {
359359 ///
360360 /// Note that this drops the span.
361361 pub fn into_inner ( self ) -> T {
362- // To manually destructure `Instrumented` without `Drop`, we save
363- // pointers to the fields and use `mem::forget` to leave those pointers
364- // valid.
365- let span: * const Span = & self . span ;
366- let inner: * const ManuallyDrop < T > = & self . inner ;
367- mem:: forget ( self ) ;
362+ // To manually destructure `Instrumented` without `Drop`, we
363+ // move it into a ManuallyDrop and use pointers to its fields
364+ let this = ManuallyDrop :: new ( self ) ;
365+ let span: * const Span = & this. span ;
366+ let inner: * const ManuallyDrop < T > = & this. inner ;
368367 // SAFETY: Those pointers are valid for reads, because `Drop` didn't
369368 // run, and properly aligned, because `Instrumented` isn't
370369 // `#[repr(packed)]`.
You can’t perform that action at this time.
0 commit comments