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::{
5
5
use core:: {
6
6
future:: Future ,
7
7
marker:: Sized ,
8
- mem:: { self , ManuallyDrop } ,
8
+ mem:: ManuallyDrop ,
9
9
pin:: Pin ,
10
10
task:: { Context , Poll } ,
11
11
} ;
@@ -359,12 +359,11 @@ impl<T> Instrumented<T> {
359
359
///
360
360
/// Note that this drops the span.
361
361
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 ;
368
367
// SAFETY: Those pointers are valid for reads, because `Drop` didn't
369
368
// run, and properly aligned, because `Instrumented` isn't
370
369
// `#[repr(packed)]`.
You can’t perform that action at this time.
0 commit comments