diff options
| author | Ralf Jung <post@ralfj.de> | 2023-08-14 10:15:25 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-08-14 10:15:25 +0200 |
| commit | f2172ea4e25021cae0efb9ef078373a8cca43885 (patch) | |
| tree | 4690ede0f5f6134918761e3ec36c46b86a4caaba | |
| parent | 3071e0aef6dfd0a150c3fb1da0abad4ec86ca0aa (diff) | |
| download | rust-f2172ea4e25021cae0efb9ef078373a8cca43885.tar.gz rust-f2172ea4e25021cae0efb9ef078373a8cca43885.zip | |
avoid transmuting Box when we can just cast raw pointers instead
| -rw-r--r-- | library/alloc/src/boxed.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 8697a77db3b..96b93830f96 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2183,7 +2183,7 @@ impl dyn Error + Send { 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 @@ impl dyn Error + Send + Sync { 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)) }) } } |
