From 22ec5f4af7b5a85ad375d672ed727571b49f3cad Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 24 Jul 2015 03:04:55 +0200 Subject: Replace many uses of `mem::transmute` with more specific functions 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`. --- src/libstd/sys/unix/backtrace.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index ae8bfb07aaf..4128431ee64 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -90,7 +90,6 @@ use io::prelude::*; use ffi::CStr; use io; use libc; -use mem; use str; use sync::StaticMutex; @@ -168,7 +167,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { extern fn trace_fn(ctx: *mut uw::_Unwind_Context, arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx: &mut Context = unsafe { mem::transmute(arg) }; + let cx: &mut Context = unsafe { &mut *(arg as *mut Context) }; let mut ip_before_insn = 0; let mut ip = unsafe { uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void -- cgit 1.4.1-3-g733a5