diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 6b10d53dd41..86d30be7d41 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -174,16 +174,6 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t) let ccx = bcx.ccx(); let tcx = ccx.tcx; - fn nuke_ref_count(bcx: block, llbox: ValueRef) { - let _icx = push_ctxt("closure::nuke_ref_count"); - // Initialize ref count to arbitrary value for debugging: - let ccx = bcx.ccx(); - let llbox = PointerCast(bcx, llbox, Type::opaque_box(ccx).ptr_to()); - let ref_cnt = GEPi(bcx, llbox, [0u, abi::box_field_refcnt]); - let rc = C_int(ccx, 0x12345678); - Store(bcx, rc, ref_cnt); - } - // Allocate and initialize the box: match sigil { ast::ManagedSigil => { @@ -195,7 +185,6 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t) ast::BorrowedSigil => { let cbox_ty = tuplify_box_ty(tcx, cdata_ty); let llbox = alloc_ty(bcx, cbox_ty, "__closure"); - nuke_ref_count(bcx, llbox); rslt(bcx, llbox) } } diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index caf15120bd7..bccdc30a073 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -87,8 +87,7 @@ pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) } #[inline] #[cfg(target_word_size = "32")] pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) { - use unstable::intrinsics::memmove32; - memmove32(dst, src as *T, count as u32); + intrinsics::memmove32(dst, src as *T, count as u32); } /** @@ -100,8 +99,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) { #[inline] #[cfg(target_word_size = "64")] pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) { - use unstable::intrinsics::memmove64; - memmove64(dst, src as *T, count as u64); + intrinsics::memmove64(dst, src as *T, count as u64); } /** @@ -113,8 +111,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) { #[inline] #[cfg(target_word_size = "32")] pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) { - use unstable::intrinsics::memcpy32; - memcpy32(dst, src as *T, count as u32); + intrinsics::memcpy32(dst, src as *T, count as u32); } /** @@ -126,8 +123,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u #[inline] #[cfg(target_word_size = "64")] pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) { - use unstable::intrinsics::memcpy64; - memcpy64(dst, src as *T, count as u64); + intrinsics::memcpy64(dst, src as *T, count as u64); } /** @@ -137,8 +133,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u #[inline] #[cfg(target_word_size = "32")] pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) { - use unstable::intrinsics::memset32; - memset32(dst, c, count as u32); + intrinsics::memset32(dst, c, count as u32); } /** @@ -148,34 +143,17 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) { #[inline] #[cfg(target_word_size = "64")] pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) { - use unstable::intrinsics::memset64; - memset64(dst, c, count as u64); + intrinsics::memset64(dst, c, count as u64); } /** * Zeroes out `count * size_of::<T>` bytes of memory at `dst` */ #[inline] -#[cfg(not(stage0))] pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) { set_memory(dst, 0, count); } -/** - * Zeroes out `count * size_of::<T>` bytes of memory at `dst` - */ -#[inline] -#[cfg(stage0)] -pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) { - let mut count = count * sys::size_of::<T>(); - let mut dst = dst as *mut u8; - while count > 0 { - *dst = 0; - dst = mut_offset(dst, 1); - count -= 1; - } -} - /** * Swap the values at two mutable locations of the same type, without * deinitialising or copying either one. diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index fd16f4e5c69..63d2492bd33 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -197,6 +197,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } + #[cfg(stage0)] fn visit_str(&self) -> bool { self.align_to::<~str>(); if ! self.inner.visit_str() { return false; } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 7707e83a9ce..0aeff2b0b77 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -200,7 +200,7 @@ impl ReprVisitor { } pub fn write_vec_range(&self, - mtbl: uint, + _mtbl: uint, ptr: *u8, len: uint, inner: *TyDesc) @@ -218,7 +218,6 @@ impl ReprVisitor { } else { self.writer.write_str(", "); } - self.write_mut_qualifier(mtbl); self.visit_ptr_inner(p as *c_void, inner); p = align(ptr::offset(p, sz) as uint, al) as *u8; left -= dec; @@ -269,6 +268,7 @@ impl TyVisitor for ReprVisitor { } // Type no longer exists, vestigial function. + #[cfg(stage0)] fn visit_str(&self) -> bool { fail!(); } fn visit_estr_box(&self) -> bool { @@ -302,18 +302,16 @@ impl TyVisitor for ReprVisitor { } } - fn visit_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool { + fn visit_uniq(&self, _mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('~'); - self.write_mut_qualifier(mtbl); do self.get::<*c_void> |b| { self.visit_ptr_inner(*b, inner); } } #[cfg(not(stage0))] - fn visit_uniq_managed(&self, mtbl: uint, inner: *TyDesc) -> bool { + fn visit_uniq_managed(&self, _mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('~'); - self.write_mut_qualifier(mtbl); do self.get::<&managed::raw::BoxRepr> |b| { let p = ptr::to_unsafe_ptr(&b.data) as *c_void; self.visit_ptr_inner(p, inner); @@ -348,10 +346,20 @@ impl TyVisitor for ReprVisitor { fn visit_evec_box(&self, mtbl: uint, inner: *TyDesc) -> bool { do self.get::<&VecRepr> |b| { self.writer.write_char('@'); + self.write_mut_qualifier(mtbl); self.write_unboxed_vec_repr(mtbl, &b.unboxed, inner); } } + #[cfg(stage0)] + fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool { + do self.get::<&VecRepr> |b| { + self.writer.write_char('~'); + self.write_unboxed_vec_repr(mtbl, &b.unboxed, inner); + } + } + + #[cfg(not(stage0))] fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool { do self.get::<&UnboxedVecRepr> |b| { self.writer.write_char('~'); @@ -613,13 +621,14 @@ fn test_repr() { exact_test(&(@"hello"), "@\"hello\""); exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\""); - // FIXME #4210: the mut fields are a bit off here. exact_test(&(@10), "@10"); - exact_test(&(@mut 10), "@10"); + exact_test(&(@mut 10), "@10"); // FIXME: #4210: incorrect + exact_test(&((@mut 10, 2)), "(@mut 10, 2)"); exact_test(&(~10), "~10"); exact_test(&(&10), "&10"); let mut x = 10; exact_test(&(&mut x), "&mut 10"); + exact_test(&(@mut [1, 2]), "@mut [1, 2]"); exact_test(&(1,), "(1,)"); exact_test(&(@[1,2,3,4,5,6,7,8]), diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index 015ecd67c83..796f691dd56 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -82,7 +82,6 @@ pub trait TyVisitor { fn visit_f64(&self) -> bool; fn visit_char(&self) -> bool; - fn visit_str(&self) -> bool; fn visit_estr_box(&self) -> bool; fn visit_estr_uniq(&self) -> bool; diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index faae814821d..88fac13c33e 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -181,13 +181,6 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> { true } - fn visit_str(&self) -> bool { - self.align_to::<~str>(); - if ! self.inner.visit_str() { return false; } - self.bump_past::<~str>(); - true - } - fn visit_estr_box(&self) -> bool { self.align_to::<@str>(); if ! self.inner.visit_estr_box() { return false; } @@ -556,7 +549,6 @@ impl TyVisitor for my_visitor { fn visit_f64(&self) -> bool { true } fn visit_char(&self) -> bool { true } - fn visit_str(&self) -> bool { true } fn visit_estr_box(&self) -> bool { true } fn visit_estr_uniq(&self) -> bool { true } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index d1d8ab7e40b..b3c5acd7dd5 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -59,7 +59,6 @@ impl TyVisitor for MyVisitor { fn visit_f64(&self) -> bool { true } fn visit_char(&self) -> bool { true } - fn visit_str(&self) -> bool { true } fn visit_estr_box(&self) -> bool { true } fn visit_estr_uniq(&self) -> bool { true }