Auto merge of #29131 - apasel422:transmute, r=bluss
This commit is contained in:
commit
140e793854
@ -137,7 +137,7 @@ pub struct IntermediateBox<T: ?Sized> {
|
||||
|
||||
impl<T> Place<T> for IntermediateBox<T> {
|
||||
fn pointer(&mut self) -> *mut T {
|
||||
unsafe { ::core::mem::transmute(self.ptr) }
|
||||
self.ptr as *mut T
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -932,15 +932,6 @@ pub fn new(w: &'a mut Cursor<Vec<u8>>) -> 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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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};
|
||||
@ -2664,11 +2663,7 @@ impl Iterator for ValueIter {
|
||||
fn next(&mut self) -> Option<ValueRef> {
|
||||
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
|
||||
|
@ -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<T>(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user