avoid transmuting Box when we can just cast raw pointers instead
This commit is contained in:
parent
3071e0aef6
commit
f2172ea4e2
@ -2183,7 +2183,7 @@ pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn E
|
||||
let err: Box<dyn Error> = self;
|
||||
<dyn Error>::downcast(err).map_err(|s| unsafe {
|
||||
// Reapply the `Send` marker.
|
||||
mem::transmute::<Box<dyn Error>, Box<dyn Error + Send>>(s)
|
||||
Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -2197,7 +2197,7 @@ pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>
|
||||
let err: Box<dyn Error> = self;
|
||||
<dyn Error>::downcast(err).map_err(|s| unsafe {
|
||||
// Reapply the `Send + Sync` marker.
|
||||
mem::transmute::<Box<dyn Error>, Box<dyn Error + Send + Sync>>(s)
|
||||
Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send + Sync))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user