From 6031a58a208d9b1912095ff05846d4119a023c95 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Sat, 17 Oct 2015 20:15:26 -0400 Subject: [PATCH] Remove some trivial `transmute`s `rbml::writer::Encoder::unsafe_clone` had no users across the entire repo. --- src/liballoc/boxed.rs | 2 +- src/librbml/lib.rs | 9 --------- src/librustc_llvm/lib.rs | 4 ++-- src/librustc_trans/trans/base.rs | 7 +------ src/libstd/dynamic_lib.rs | 3 +-- 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index e85b7d2d496..4783b4339da 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -137,7 +137,7 @@ pub struct IntermediateBox { impl Place for IntermediateBox { fn pointer(&mut self) -> *mut T { - unsafe { ::core::mem::transmute(self.ptr) } + self.ptr as *mut T } } diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 4f7bbe9e027..1c6cb06d54a 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -932,15 +932,6 @@ pub fn new(w: &'a mut Cursor>) -> Encoder<'a> { } } - /// FIXME(pcwalton): Workaround for badness in trans. DO NOT USE ME. - pub unsafe fn unsafe_clone(&self) -> Encoder<'a> { - Encoder { - writer: mem::transmute_copy(&self.writer), - size_positions: self.size_positions.clone(), - relax_limit: self.relax_limit, - } - } - pub fn start_tag(&mut self, tag_id: usize) -> EncodeResult { debug!("Start tag {:?}", tag_id); assert!(tag_id >= NUM_IMPLICIT_TAGS); diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index aa3a991b8b6..fe84cffa8c6 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -60,7 +60,7 @@ use std::ffi::CString; use std::cell::RefCell; -use std::{slice, mem}; +use std::slice; use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char}; use libc::{c_longlong, c_ulonglong, c_void}; use debuginfo::{DIBuilderRef, DIDescriptor, @@ -2307,7 +2307,7 @@ pub enum RustString_opaque {} size: size_t) { let slice = slice::from_raw_parts(ptr as *const u8, size as usize); - let sr: RustStringRepr = mem::transmute(sr); + let sr = sr as RustStringRepr; (*sr).borrow_mut().push_all(slice); } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 9fa1aaf76f8..9bedc0cefb1 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -89,7 +89,6 @@ use std::ffi::{CStr, CString}; use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; -use std::mem; use std::str; use std::{i8, i16, i32, i64}; use syntax::abi::{Rust, RustCall, RustIntrinsic, PlatformIntrinsic, Abi}; @@ -2661,11 +2660,7 @@ impl Iterator for ValueIter { fn next(&mut self) -> Option { let old = self.cur; if !old.is_null() { - self.cur = unsafe { - let step: unsafe extern "C" fn(ValueRef) -> ValueRef = - mem::transmute_copy(&self.step); - step(old) - }; + self.cur = unsafe { (self.step)(old) }; Some(old) } else { None diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 7801662ff25..5629cba1e0b 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -22,7 +22,6 @@ use env; use ffi::{CString, OsString}; -use mem; use path::{Path, PathBuf}; pub struct DynamicLibrary { @@ -114,7 +113,7 @@ pub unsafe fn symbol(&self, symbol: &str) -> Result<*mut T, String> { // the destructor does not run. match maybe_symbol_value { Err(err) => Err(err), - Ok(symbol_value) => Ok(mem::transmute(symbol_value)) + Ok(symbol_value) => Ok(symbol_value as *mut T) } } }