Skip to content

Commit 559d2ef

Browse files
committed
auto merge of #7842 : thestinger/rust/closure, r=huonw
2 parents babf741 + ce16644 commit 559d2ef

File tree

7 files changed

+24
-57
lines changed

7 files changed

+24
-57
lines changed

src/librustc/middle/trans/closure.rs

-11
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,6 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
174174
let ccx = bcx.ccx();
175175
let tcx = ccx.tcx;
176176

177-
fn nuke_ref_count(bcx: block, llbox: ValueRef) {
178-
let _icx = push_ctxt("closure::nuke_ref_count");
179-
// Initialize ref count to arbitrary value for debugging:
180-
let ccx = bcx.ccx();
181-
let llbox = PointerCast(bcx, llbox, Type::opaque_box(ccx).ptr_to());
182-
let ref_cnt = GEPi(bcx, llbox, [0u, abi::box_field_refcnt]);
183-
let rc = C_int(ccx, 0x12345678);
184-
Store(bcx, rc, ref_cnt);
185-
}
186-
187177
// Allocate and initialize the box:
188178
match sigil {
189179
ast::ManagedSigil => {
@@ -195,7 +185,6 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
195185
ast::BorrowedSigil => {
196186
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
197187
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
198-
nuke_ref_count(bcx, llbox);
199188
rslt(bcx, llbox)
200189
}
201190
}

src/libstd/ptr.rs

+6-28
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
8787
#[inline]
8888
#[cfg(target_word_size = "32")]
8989
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
90-
use unstable::intrinsics::memmove32;
91-
memmove32(dst, src as *T, count as u32);
90+
intrinsics::memmove32(dst, src as *T, count as u32);
9291
}
9392

9493
/**
@@ -100,8 +99,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
10099
#[inline]
101100
#[cfg(target_word_size = "64")]
102101
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
103-
use unstable::intrinsics::memmove64;
104-
memmove64(dst, src as *T, count as u64);
102+
intrinsics::memmove64(dst, src as *T, count as u64);
105103
}
106104

107105
/**
@@ -113,8 +111,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
113111
#[inline]
114112
#[cfg(target_word_size = "32")]
115113
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
116-
use unstable::intrinsics::memcpy32;
117-
memcpy32(dst, src as *T, count as u32);
114+
intrinsics::memcpy32(dst, src as *T, count as u32);
118115
}
119116

120117
/**
@@ -126,8 +123,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
126123
#[inline]
127124
#[cfg(target_word_size = "64")]
128125
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
129-
use unstable::intrinsics::memcpy64;
130-
memcpy64(dst, src as *T, count as u64);
126+
intrinsics::memcpy64(dst, src as *T, count as u64);
131127
}
132128

133129
/**
@@ -137,8 +133,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
137133
#[inline]
138134
#[cfg(target_word_size = "32")]
139135
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
140-
use unstable::intrinsics::memset32;
141-
memset32(dst, c, count as u32);
136+
intrinsics::memset32(dst, c, count as u32);
142137
}
143138

144139
/**
@@ -148,34 +143,17 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
148143
#[inline]
149144
#[cfg(target_word_size = "64")]
150145
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
151-
use unstable::intrinsics::memset64;
152-
memset64(dst, c, count as u64);
146+
intrinsics::memset64(dst, c, count as u64);
153147
}
154148

155149
/**
156150
* Zeroes out `count * size_of::<T>` bytes of memory at `dst`
157151
*/
158152
#[inline]
159-
#[cfg(not(stage0))]
160153
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
161154
set_memory(dst, 0, count);
162155
}
163156

164-
/**
165-
* Zeroes out `count * size_of::<T>` bytes of memory at `dst`
166-
*/
167-
#[inline]
168-
#[cfg(stage0)]
169-
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
170-
let mut count = count * sys::size_of::<T>();
171-
let mut dst = dst as *mut u8;
172-
while count > 0 {
173-
*dst = 0;
174-
dst = mut_offset(dst, 1);
175-
count -= 1;
176-
}
177-
}
178-
179157
/**
180158
* Swap the values at two mutable locations of the same type, without
181159
* deinitialising or copying either one.

src/libstd/reflect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
197197
true
198198
}
199199

200+
#[cfg(stage0)]
200201
fn visit_str(&self) -> bool {
201202
self.align_to::<~str>();
202203
if ! self.inner.visit_str() { return false; }

src/libstd/repr.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl ReprVisitor {
200200
}
201201

202202
pub fn write_vec_range(&self,
203-
mtbl: uint,
203+
_mtbl: uint,
204204
ptr: *u8,
205205
len: uint,
206206
inner: *TyDesc)
@@ -218,7 +218,6 @@ impl ReprVisitor {
218218
} else {
219219
self.writer.write_str(", ");
220220
}
221-
self.write_mut_qualifier(mtbl);
222221
self.visit_ptr_inner(p as *c_void, inner);
223222
p = align(ptr::offset(p, sz) as uint, al) as *u8;
224223
left -= dec;
@@ -269,6 +268,7 @@ impl TyVisitor for ReprVisitor {
269268
}
270269

271270
// Type no longer exists, vestigial function.
271+
#[cfg(stage0)]
272272
fn visit_str(&self) -> bool { fail!(); }
273273

274274
fn visit_estr_box(&self) -> bool {
@@ -302,18 +302,16 @@ impl TyVisitor for ReprVisitor {
302302
}
303303
}
304304

305-
fn visit_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool {
305+
fn visit_uniq(&self, _mtbl: uint, inner: *TyDesc) -> bool {
306306
self.writer.write_char('~');
307-
self.write_mut_qualifier(mtbl);
308307
do self.get::<*c_void> |b| {
309308
self.visit_ptr_inner(*b, inner);
310309
}
311310
}
312311

313312
#[cfg(not(stage0))]
314-
fn visit_uniq_managed(&self, mtbl: uint, inner: *TyDesc) -> bool {
313+
fn visit_uniq_managed(&self, _mtbl: uint, inner: *TyDesc) -> bool {
315314
self.writer.write_char('~');
316-
self.write_mut_qualifier(mtbl);
317315
do self.get::<&managed::raw::BoxRepr> |b| {
318316
let p = ptr::to_unsafe_ptr(&b.data) as *c_void;
319317
self.visit_ptr_inner(p, inner);
@@ -348,10 +346,20 @@ impl TyVisitor for ReprVisitor {
348346
fn visit_evec_box(&self, mtbl: uint, inner: *TyDesc) -> bool {
349347
do self.get::<&VecRepr> |b| {
350348
self.writer.write_char('@');
349+
self.write_mut_qualifier(mtbl);
350+
self.write_unboxed_vec_repr(mtbl, &b.unboxed, inner);
351+
}
352+
}
353+
354+
#[cfg(stage0)]
355+
fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool {
356+
do self.get::<&VecRepr> |b| {
357+
self.writer.write_char('~');
351358
self.write_unboxed_vec_repr(mtbl, &b.unboxed, inner);
352359
}
353360
}
354361

362+
#[cfg(not(stage0))]
355363
fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool {
356364
do self.get::<&UnboxedVecRepr> |b| {
357365
self.writer.write_char('~');
@@ -613,13 +621,14 @@ fn test_repr() {
613621
exact_test(&(@"hello"), "@\"hello\"");
614622
exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\"");
615623

616-
// FIXME #4210: the mut fields are a bit off here.
617624
exact_test(&(@10), "@10");
618-
exact_test(&(@mut 10), "@10");
625+
exact_test(&(@mut 10), "@10"); // FIXME: #4210: incorrect
626+
exact_test(&((@mut 10, 2)), "(@mut 10, 2)");
619627
exact_test(&(~10), "~10");
620628
exact_test(&(&10), "&10");
621629
let mut x = 10;
622630
exact_test(&(&mut x), "&mut 10");
631+
exact_test(&(@mut [1, 2]), "@mut [1, 2]");
623632

624633
exact_test(&(1,), "(1,)");
625634
exact_test(&(@[1,2,3,4,5,6,7,8]),

src/libstd/unstable/intrinsics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ pub trait TyVisitor {
8282
fn visit_f64(&self) -> bool;
8383

8484
fn visit_char(&self) -> bool;
85-
fn visit_str(&self) -> bool;
8685

8786
fn visit_estr_box(&self) -> bool;
8887
fn visit_estr_uniq(&self) -> bool;

src/test/run-pass/reflect-visit-data.rs

-8
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,6 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
181181
true
182182
}
183183

184-
fn visit_str(&self) -> bool {
185-
self.align_to::<~str>();
186-
if ! self.inner.visit_str() { return false; }
187-
self.bump_past::<~str>();
188-
true
189-
}
190-
191184
fn visit_estr_box(&self) -> bool {
192185
self.align_to::<@str>();
193186
if ! self.inner.visit_estr_box() { return false; }
@@ -556,7 +549,6 @@ impl TyVisitor for my_visitor {
556549
fn visit_f64(&self) -> bool { true }
557550

558551
fn visit_char(&self) -> bool { true }
559-
fn visit_str(&self) -> bool { true }
560552

561553
fn visit_estr_box(&self) -> bool { true }
562554
fn visit_estr_uniq(&self) -> bool { true }

src/test/run-pass/reflect-visit-type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ impl TyVisitor for MyVisitor {
5959
fn visit_f64(&self) -> bool { true }
6060

6161
fn visit_char(&self) -> bool { true }
62-
fn visit_str(&self) -> bool { true }
6362

6463
fn visit_estr_box(&self) -> bool { true }
6564
fn visit_estr_uniq(&self) -> bool { true }

0 commit comments

Comments
 (0)