about summary refs log tree commit diff
path: root/src/libstd/error.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-10 18:46:21 +0000
committerbors <bors@rust-lang.org>2015-08-10 18:46:21 +0000
commit3d69bec88119e0471a98cd2075fcf53c43ebca3e (patch)
treeb84fecb519b6883f4d75d521a90f9d476782e4cb /src/libstd/error.rs
parent96a1f40402cdd05d29d1f1c0b62001254db8dcf6 (diff)
parent33af24ca4c2a6edaed0509a5b9ac3fde964a2847 (diff)
downloadrust-3d69bec88119e0471a98cd2075fcf53c43ebca3e.tar.gz
rust-3d69bec88119e0471a98cd2075fcf53c43ebca3e.zip
Auto merge of #27252 - tbu-:pr_less_transmutes, r=alexcrichton
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.

This builds upon #27233.
Diffstat (limited to 'src/libstd/error.rs')
-rw-r--r--src/libstd/error.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 4d08f08bb6e..f0f481d3721 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -192,7 +192,7 @@ impl Error + 'static {
                 let to: TraitObject = transmute(self);
 
                 // Extract the data pointer
-                Some(transmute(to.data))
+                Some(&*(to.data as *const T))
             }
         } else {
             None
@@ -210,7 +210,7 @@ impl Error + 'static {
                 let to: TraitObject = transmute(self);
 
                 // Extract the data pointer
-                Some(transmute(to.data))
+                Some(&mut *(to.data as *const T as *mut T))
             }
         } else {
             None