Skip to content

Commit 1e042ac

Browse files
committed
---
yaml --- r: 66996 b: refs/heads/master c: 0ce9135 h: refs/heads/master v: v3
1 parent 38ba898 commit 1e042ac

File tree

10 files changed

+93
-18
lines changed

10 files changed

+93
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0c7b220f20367cde776b9e854b905745c9a271e2
2+
refs/heads/master: 0ce9135d71f6fd59da133e1cc685cf606582ae87
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/librustc/middle/trans/closure.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ 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+
177187
// Allocate and initialize the box:
178188
match sigil {
179189
ast::ManagedSigil => {
@@ -185,6 +195,7 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
185195
ast::BorrowedSigil => {
186196
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
187197
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
198+
nuke_ref_count(bcx, llbox);
188199
rslt(bcx, llbox)
189200
}
190201
}

trunk/src/libstd/ptr.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
8080
#[inline]
8181
#[cfg(target_word_size = "32")]
8282
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
83-
intrinsics::memmove32(dst, src as *T, count as u32);
83+
use unstable::intrinsics::memmove32;
84+
memmove32(dst, src as *T, count as u32);
8485
}
8586

8687
/**
@@ -92,7 +93,8 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
9293
#[inline]
9394
#[cfg(target_word_size = "64")]
9495
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
95-
intrinsics::memmove64(dst, src as *T, count as u64);
96+
use unstable::intrinsics::memmove64;
97+
memmove64(dst, src as *T, count as u64);
9698
}
9799

98100
/**
@@ -104,7 +106,8 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
104106
#[inline]
105107
#[cfg(target_word_size = "32")]
106108
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
107-
intrinsics::memcpy32(dst, src as *T, count as u32);
109+
use unstable::intrinsics::memcpy32;
110+
memcpy32(dst, src as *T, count as u32);
108111
}
109112

110113
/**
@@ -116,7 +119,8 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
116119
#[inline]
117120
#[cfg(target_word_size = "64")]
118121
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
119-
intrinsics::memcpy64(dst, src as *T, count as u64);
122+
use unstable::intrinsics::memcpy64;
123+
memcpy64(dst, src as *T, count as u64);
120124
}
121125

122126
/**
@@ -126,7 +130,8 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
126130
#[inline]
127131
#[cfg(target_word_size = "32")]
128132
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
129-
intrinsics::memset32(dst, c, count as u32);
133+
use unstable::intrinsics::memset32;
134+
memset32(dst, c, count as u32);
130135
}
131136

132137
/**
@@ -136,17 +141,34 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
136141
#[inline]
137142
#[cfg(target_word_size = "64")]
138143
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
139-
intrinsics::memset64(dst, c, count as u64);
144+
use unstable::intrinsics::memset64;
145+
memset64(dst, c, count as u64);
140146
}
141147

142148
/**
143149
* Zeroes out `count * size_of::<T>` bytes of memory at `dst`
144150
*/
145151
#[inline]
152+
#[cfg(not(stage0))]
146153
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
147154
set_memory(dst, 0, count);
148155
}
149156

157+
/**
158+
* Zeroes out `count * size_of::<T>` bytes of memory at `dst`
159+
*/
160+
#[inline]
161+
#[cfg(stage0)]
162+
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
163+
let mut count = count * sys::size_of::<T>();
164+
let mut dst = dst as *mut u8;
165+
while count > 0 {
166+
*dst = 0;
167+
dst = mut_offset(dst, 1);
168+
count -= 1;
169+
}
170+
}
171+
150172
/**
151173
* Swap the values at two mutable locations of the same type, without
152174
* deinitialising or copying either one.

trunk/src/libstd/reflect.rs

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

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

trunk/src/libstd/repr.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ impl TyVisitor for ReprVisitor {
269269
}
270270

271271
// Type no longer exists, vestigial function.
272-
#[cfg(stage0)]
273272
fn visit_str(&self) -> bool { fail!(); }
274273

275274
fn visit_estr_box(&self) -> bool {
@@ -353,15 +352,6 @@ impl TyVisitor for ReprVisitor {
353352
}
354353
}
355354

356-
#[cfg(stage0)]
357-
fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool {
358-
do self.get::<&VecRepr> |b| {
359-
self.writer.write_char('~');
360-
self.write_unboxed_vec_repr(mtbl, &b.unboxed, inner);
361-
}
362-
}
363-
364-
#[cfg(not(stage0))]
365355
fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool {
366356
do self.get::<&UnboxedVecRepr> |b| {
367357
self.writer.write_char('~');

trunk/src/libstd/unstable/intrinsics.rs

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

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

8687
fn visit_estr_box(&self) -> bool;
8788
fn visit_estr_uniq(&self) -> bool;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::io;
12+
13+
struct Struct {
14+
r: io::Reader //~ ERROR reference to trait `io::Reader` where a type is expected
15+
}
16+
17+
fn new_struct(r: io::Reader) -> Struct { //~ ERROR reference to trait `io::Reader` where a type is expected
18+
Struct { r: r }
19+
}
20+
21+
trait Curve {}
22+
enum E {X(Curve)} //~ ERROR reference to trait `Curve` where a type is expected
23+
fn main() {}

trunk/src/test/run-pass/issue-6153.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn swap(f: &fn(~[int]) -> ~[int]) -> ~[int] {
12+
let x = ~[1, 2, 3];
13+
f(x)
14+
}
15+
16+
fn main() {
17+
let v = swap(|mut x| { x.push(4); x });
18+
let w = do swap |mut x| { x.push(4); x };
19+
assert_eq!(v, w);
20+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ 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+
184191
fn visit_estr_box(&self) -> bool {
185192
self.align_to::<@str>();
186193
if ! self.inner.visit_estr_box() { return false; }
@@ -549,6 +556,7 @@ impl TyVisitor for my_visitor {
549556
fn visit_f64(&self) -> bool { true }
550557

551558
fn visit_char(&self) -> bool { true }
559+
fn visit_str(&self) -> bool { true }
552560

553561
fn visit_estr_box(&self) -> bool { true }
554562
fn visit_estr_uniq(&self) -> bool { true }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ 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 }
6263

6364
fn visit_estr_box(&self) -> bool { true }
6465
fn visit_estr_uniq(&self) -> bool { true }

0 commit comments

Comments
 (0)