diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-04-26 14:04:39 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-04-29 14:30:56 -0700 |
| commit | 876483dcf4bdcd0001cc25812060bc04cf367f60 (patch) | |
| tree | a1e5c6db1359979b0eb3b595740f541f55b8c104 /src/libcore | |
| parent | f30f54e9d062bdb5b3cb10dd7185470280c1c278 (diff) | |
| download | rust-876483dcf4bdcd0001cc25812060bc04cf367f60.tar.gz rust-876483dcf4bdcd0001cc25812060bc04cf367f60.zip | |
test: Fix tests.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cast.rs | 4 | ||||
| -rw-r--r-- | src/libcore/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/rt/thread.rs | 8 | ||||
| -rw-r--r-- | src/libcore/rt/uv/mod.rs | 16 | ||||
| -rw-r--r-- | src/libcore/sys.rs | 2 |
5 files changed, 18 insertions, 16 deletions
diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 0c960d4a308..6fb737d3770 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -178,8 +178,8 @@ mod tests { let box = @~"box box box"; // refcount 1 bump_box_refcount(box); // refcount 2 let ptr: *int = transmute(box); // refcount 2 - let _box1: @~str = reinterpret_cast(&ptr); - let _box2: @~str = reinterpret_cast(&ptr); + let _box1: @~str = ::cast::transmute_copy(&ptr); + let _box2: @~str = ::cast::transmute_copy(&ptr); assert!(*_box1 == ~"box box box"); assert!(*_box2 == ~"box box box"); // Will destroy _box1 and _box2. Without the bump, this would diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 0fae64c0930..17192b4257b 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -482,10 +482,10 @@ pub impl<T:Copy + Zero> Option<T> { fn test_unwrap_ptr() { unsafe { let x = ~0; - let addr_x: *int = transmute(&*x); + let addr_x: *int = ::cast::transmute(&*x); let opt = Some(x); let y = opt.unwrap(); - let addr_y: *int = transmute(&*y); + let addr_y: *int = ::cast::transmute(&*y); assert!(addr_x == addr_y); } } diff --git a/src/libcore/rt/thread.rs b/src/libcore/rt/thread.rs index 910e445f47b..0f1ae09bd94 100644 --- a/src/libcore/rt/thread.rs +++ b/src/libcore/rt/thread.rs @@ -21,10 +21,10 @@ pub struct Thread { pub impl Thread { fn start(main: ~fn()) -> Thread { - fn substart(main: &fn()) -> *raw_thread { - unsafe { rust_raw_thread_start(&main) } + fn substart(main: &~fn()) -> *raw_thread { + unsafe { rust_raw_thread_start(main) } } - let raw = substart(main); + let raw = substart(&main); Thread { main: main, raw_thread: raw @@ -39,6 +39,6 @@ impl Drop for Thread { } extern { - pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread; + pub unsafe fn rust_raw_thread_start(f: &(~fn())) -> *raw_thread; pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread); } diff --git a/src/libcore/rt/uv/mod.rs b/src/libcore/rt/uv/mod.rs index 4cbc8d70569..cb7925abdcd 100644 --- a/src/libcore/rt/uv/mod.rs +++ b/src/libcore/rt/uv/mod.rs @@ -366,14 +366,15 @@ pub fn slice_to_uv_buf(v: &[u8]) -> Buf { /// Transmute an owned vector to a Buf pub fn vec_to_uv_buf(v: ~[u8]) -> Buf { - let data = unsafe { malloc(v.len() as size_t) } as *u8; - assert!(data.is_not_null()); - do vec::as_imm_buf(v) |b, l| { - let data = data as *mut u8; - unsafe { ptr::copy_memory(data, b, l) } + unsafe { + let data = malloc(v.len() as size_t) as *u8; + assert!(data.is_not_null()); + do vec::as_imm_buf(v) |b, l| { + let data = data as *mut u8; + ptr::copy_memory(data, b, l) + } + uvll::buf_init(data, v.len()) } - let buf = unsafe { uvll::buf_init(data, v.len()) }; - return buf; } /// Transmute a Buf that was once a ~[u8] back to ~[u8] @@ -384,6 +385,7 @@ pub fn vec_from_uv_buf(buf: Buf) -> Option<~[u8]> { return Some(v); } else { // No buffer + rtdebug!("No buffer!"); return None; } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 0173620dc51..8cad0a22886 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -154,7 +154,7 @@ pub fn pref_align_of_val<T>(_val: &T) -> uint { #[inline(always)] pub fn refcount<T>(t: @T) -> uint { unsafe { - let ref_ptr: *uint = cast::transmute(t); + let ref_ptr: *uint = cast::transmute_copy(&t); *ref_ptr - 1 } } |
