Skip to content

Commit 876483d

Browse files
committed
test: Fix tests.
1 parent f30f54e commit 876483d

31 files changed

+114
-190
lines changed

src/libcore/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ mod tests {
178178
let box = @~"box box box"; // refcount 1
179179
bump_box_refcount(box); // refcount 2
180180
let ptr: *int = transmute(box); // refcount 2
181-
let _box1: @~str = reinterpret_cast(&ptr);
182-
let _box2: @~str = reinterpret_cast(&ptr);
181+
let _box1: @~str = ::cast::transmute_copy(&ptr);
182+
let _box2: @~str = ::cast::transmute_copy(&ptr);
183183
assert!(*_box1 == ~"box box box");
184184
assert!(*_box2 == ~"box box box");
185185
// Will destroy _box1 and _box2. Without the bump, this would

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,10 @@ pub impl<T:Copy + Zero> Option<T> {
482482
fn test_unwrap_ptr() {
483483
unsafe {
484484
let x = ~0;
485-
let addr_x: *int = transmute(&*x);
485+
let addr_x: *int = ::cast::transmute(&*x);
486486
let opt = Some(x);
487487
let y = opt.unwrap();
488-
let addr_y: *int = transmute(&*y);
488+
let addr_y: *int = ::cast::transmute(&*y);
489489
assert!(addr_x == addr_y);
490490
}
491491
}

src/libcore/rt/thread.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ pub struct Thread {
2121

2222
pub impl Thread {
2323
fn start(main: ~fn()) -> Thread {
24-
fn substart(main: &fn()) -> *raw_thread {
25-
unsafe { rust_raw_thread_start(&main) }
24+
fn substart(main: &~fn()) -> *raw_thread {
25+
unsafe { rust_raw_thread_start(main) }
2626
}
27-
let raw = substart(main);
27+
let raw = substart(&main);
2828
Thread {
2929
main: main,
3030
raw_thread: raw
@@ -39,6 +39,6 @@ impl Drop for Thread {
3939
}
4040

4141
extern {
42-
pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread;
42+
pub unsafe fn rust_raw_thread_start(f: &(~fn())) -> *raw_thread;
4343
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
4444
}

src/libcore/rt/uv/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,15 @@ pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
366366
367367
/// Transmute an owned vector to a Buf
368368
pub fn vec_to_uv_buf(v: ~[u8]) -> Buf {
369-
let data = unsafe { malloc(v.len() as size_t) } as *u8;
370-
assert!(data.is_not_null());
371-
do vec::as_imm_buf(v) |b, l| {
372-
let data = data as *mut u8;
373-
unsafe { ptr::copy_memory(data, b, l) }
369+
unsafe {
370+
let data = malloc(v.len() as size_t) as *u8;
371+
assert!(data.is_not_null());
372+
do vec::as_imm_buf(v) |b, l| {
373+
let data = data as *mut u8;
374+
ptr::copy_memory(data, b, l)
375+
}
376+
uvll::buf_init(data, v.len())
374377
}
375-
let buf = unsafe { uvll::buf_init(data, v.len()) };
376-
return buf;
377378
}
378379
379380
/// 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]> {
384385
return Some(v);
385386
} else {
386387
// No buffer
388+
rtdebug!("No buffer!");
387389
return None;
388390
}
389391
}

src/libcore/sys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn pref_align_of_val<T>(_val: &T) -> uint {
154154
#[inline(always)]
155155
pub fn refcount<T>(t: @T) -> uint {
156156
unsafe {
157-
let ref_ptr: *uint = cast::transmute(t);
157+
let ref_ptr: *uint = cast::transmute_copy(&t);
158158
*ref_ptr - 1
159159
}
160160
}

src/librustc/middle/trans/foreign.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -729,16 +729,16 @@ pub fn trans_intrinsic(ccx: @CrateContext,
729729
_ => fail!(~"transmute has non-expr arg"),
730730
};
731731
let pluralize = |n| if 1u == n { "" } else { "s" };
732-
ccx.sess.span_err(sp,
733-
fmt!("transmute called on types with \
734-
different sizes: %s (%u bit%s) to \
735-
%s (%u bit%s)",
736-
ty_to_str(ccx.tcx, in_type),
737-
in_type_size,
738-
pluralize(in_type_size),
739-
ty_to_str(ccx.tcx, out_type),
740-
out_type_size,
741-
pluralize(out_type_size)));
732+
ccx.sess.span_fatal(sp,
733+
fmt!("transmute called on types with \
734+
different sizes: %s (%u bit%s) to \
735+
%s (%u bit%s)",
736+
ty_to_str(ccx.tcx, in_type),
737+
in_type_size,
738+
pluralize(in_type_size),
739+
ty_to_str(ccx.tcx, out_type),
740+
out_type_size,
741+
pluralize(out_type_size)));
742742
}
743743
744744
if !ty::type_is_nil(out_type) {

src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,11 +3467,11 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
34673467
~[
34683468
arg(ty::mk_mut_rptr(tcx,
34693469
ty::re_bound(ty::br_anon(0)),
3470-
ty::mk_int(tcx))),
3470+
ty::mk_int())),
34713471
arg(ty::mk_int()),
34723472
arg(ty::mk_int())
34733473
],
3474-
ty::mk_int(tcx))
3474+
ty::mk_int())
34753475
}
34763476
~"atomic_xchg" | ~"atomic_xadd" | ~"atomic_xsub" |
34773477
~"atomic_xchg_acq" | ~"atomic_xadd_acq" | ~"atomic_xsub_acq" |
@@ -3480,7 +3480,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
34803480
~[
34813481
arg(ty::mk_mut_rptr(tcx,
34823482
ty::re_bound(ty::br_anon(0)),
3483-
ty::mk_int(tcx))),
3483+
ty::mk_int())),
34843484
arg(ty::mk_int())
34853485
],
34863486
ty::mk_int())
@@ -3550,7 +3550,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
35503550
})),
35513551
arg(ty::mk_u64())
35523552
],
3553-
ty::mk_nil(tcx))
3553+
ty::mk_nil())
35543554
}
35553555
~"sqrtf32" => (0, ~[ arg(ty::mk_f32()) ], ty::mk_f32()),
35563556
~"sqrtf64" => (0, ~[ arg(ty::mk_f64()) ], ty::mk_f64()),

src/libstd/sync.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -828,18 +828,22 @@ mod tests {
828828
let m = ~Mutex();
829829
let m2 = m.clone();
830830
let mut sharedstate = ~0;
831-
let ptr: *int = &*sharedstate;
832-
do task::spawn || {
833-
let sharedstate: &mut int =
834-
unsafe { cast::transmute(ptr) };
835-
access_shared(sharedstate, m2, 10);
836-
c.send(());
831+
{
832+
let ptr: *int = &*sharedstate;
833+
do task::spawn || {
834+
let sharedstate: &mut int =
835+
unsafe { cast::transmute(ptr) };
836+
access_shared(sharedstate, m2, 10);
837+
c.send(());
837838
839+
}
838840
}
839-
access_shared(sharedstate, m, 10);
840-
let _ = p.recv();
841+
{
842+
access_shared(sharedstate, m, 10);
843+
let _ = p.recv();
841844
842-
assert!(*sharedstate == 20);
845+
assert!(*sharedstate == 20);
846+
}
843847
844848
fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) {
845849
for n.times {
@@ -1106,17 +1110,21 @@ mod tests {
11061110
let (p,c) = comm::stream();
11071111
let x2 = (*x).clone();
11081112
let mut sharedstate = ~0;
1109-
let ptr: *int = &*sharedstate;
1110-
do task::spawn || {
1111-
let sharedstate: &mut int =
1112-
unsafe { cast::transmute(ptr) };
1113-
access_shared(sharedstate, &x2, mode1, 10);
1114-
c.send(());
1113+
{
1114+
let ptr: *int = &*sharedstate;
1115+
do task::spawn || {
1116+
let sharedstate: &mut int =
1117+
unsafe { cast::transmute(ptr) };
1118+
access_shared(sharedstate, &x2, mode1, 10);
1119+
c.send(());
1120+
}
11151121
}
1116-
access_shared(sharedstate, x, mode2, 10);
1117-
let _ = p.recv();
1122+
{
1123+
access_shared(sharedstate, x, mode2, 10);
1124+
let _ = p.recv();
11181125
1119-
assert!(*sharedstate == 20);
1126+
assert!(*sharedstate == 20);
1127+
}
11201128
11211129
fn access_shared(sharedstate: &mut int, x: &RWlock, mode: RWlockMode,
11221130
n: uint) {

src/libstd/uv_ll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,9 +1396,9 @@ mod test {
13961396
// not set the data on the connect_req
13971397
// until its initialized
13981398
set_data_for_req(connect_req_ptr as *libc::c_void,
1399-
transmute(&client_data));
1399+
&client_data);
14001400
set_data_for_uv_handle(tcp_handle_ptr as *libc::c_void,
1401-
transmute(&client_data));
1401+
&client_data);
14021402
debug!(~"before run tcp req loop");
14031403
run(test_loop);
14041404
debug!(~"after run tcp req loop");

src/libsyntax/ext/pipes/pipec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ impl gen_init for protocol {
365365
|s| ext_cx.parse_stmt(
366366
fmt!("data.%s.set_buffer(buffer)",
367367
s.name))),
368-
ext_cx.parse_expr(fmt!("&(data.%s)", self.states[0].name))));
368+
ext_cx.parse_expr(fmt!(
369+
"::core::ptr::to_unsafe_ptr(&(data.%s))",
370+
self.states[0].name))));
369371
370372
quote_expr!({
371373
let buffer = $buffer;

src/test/bench/graph500-bfs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
225225
}
226226
227227
/// A parallel version of the bfs function.
228-
fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
228+
fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result {
229229
// This works by doing functional updates of a color vector.
230230
231231
enum color {
@@ -236,7 +236,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
236236
black(node_id)
237237
};
238238
239-
let graph_vec = arc::get(&graph); // FIXME #3387 requires this temp
239+
let graph_vec = arc::get(graph); // FIXME #3387 requires this temp
240240
let mut colors = do vec::from_fn(graph_vec.len()) |i| {
241241
if i as node_id == key {
242242
gray(key)
@@ -271,7 +271,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
271271
let color_vec = arc::get(&color); // FIXME #3387 requires this temp
272272
colors = do par::mapi(*color_vec) {
273273
let colors = arc::clone(&color);
274-
let graph = arc::clone(&graph);
274+
let graph = arc::clone(graph);
275275
let result: ~fn(+x: uint, +y: &color) -> color = |i, c| {
276276
let colors = arc::get(&colors);
277277
let graph = arc::get(&graph);
@@ -496,7 +496,7 @@ fn main() {
496496
}
497497
498498
let start = time::precise_time_s();
499-
let bfs_tree = pbfs(graph_arc, *root);
499+
let bfs_tree = pbfs(&graph_arc, *root);
500500
let stop = time::precise_time_s();
501501
502502
total_par += stop - start;

src/test/bench/msgsend-pipes-shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum request {
3434
stop
3535
}
3636

37-
fn server(requests: Port<request>, responses: comm::Chan<uint>) {
37+
fn server(requests: &Port<request>, responses: &comm::Chan<uint>) {
3838
let mut count = 0u;
3939
let mut done = false;
4040
while !done {
@@ -76,7 +76,7 @@ fn run(args: &[~str]) {
7676
};
7777
}
7878
do task::spawn || {
79-
server(from_parent, to_parent);
79+
server(&from_parent, &to_parent);
8080
}
8181

8282
for vec::each(worker_results) |r| {

src/test/bench/msgsend-pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum request {
3030
stop
3131
}
3232

33-
fn server(requests: PortSet<request>, responses: Chan<uint>) {
33+
fn server(requests: &PortSet<request>, responses: &Chan<uint>) {
3434
let mut count = 0;
3535
let mut done = false;
3636
while !done {
@@ -73,7 +73,7 @@ fn run(args: &[~str]) {
7373
};
7474
}
7575
do task::spawn || {
76-
server(from_parent, to_parent);
76+
server(&from_parent, &to_parent);
7777
}
7878

7979
for vec::each(worker_results) |r| {

src/test/bench/shootout-k-nucleotide-pipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ fn windows_with_carry(bb: &[u8], nn: uint,
104104
}
105105

106106
fn make_sequence_processor(sz: uint,
107-
from_parent: comm::Port<~[u8]>,
108-
to_parent: comm::Chan<~str>) {
107+
from_parent: &comm::Port<~[u8]>,
108+
to_parent: &comm::Chan<~str>) {
109109
let mut freqs: HashMap<~[u8], uint> = HashMap::new();
110110
let mut carry: ~[u8] = ~[];
111111
let mut total: uint = 0u;
@@ -140,7 +140,7 @@ fn make_sequence_processor(sz: uint,
140140
// given a FASTA file on stdin, process sequence THREE
141141
fn main() {
142142
let args = os::args();
143-
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
143+
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
144144
// FIXME: Using this compile-time env variable is a crummy way to
145145
// get to this massive data set, but include_bin! chokes on it (#2598)
146146
let path = Path(env!("CFG_SRC_DIR"))
@@ -168,7 +168,7 @@ fn main() {
168168
let (from_parent, to_child) = comm::stream();
169169
170170
do task::spawn_with(from_parent) |from_parent| {
171-
make_sequence_processor(sz, from_parent, to_parent_);
171+
make_sequence_processor(sz, &from_parent, &to_parent_);
172172
};
173173
174174
to_child

src/test/bench/shootout-pfib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ use core::result;
3030
use core::result::{Ok, Err};
3131

3232
fn fib(n: int) -> int {
33-
fn pfib(c: Chan<int>, n: int) {
33+
fn pfib(c: &Chan<int>, n: int) {
3434
if n == 0 {
3535
c.send(0);
3636
} else if n <= 2 {
3737
c.send(1);
3838
} else {
3939
let p = PortSet::new();
4040
let ch = p.chan();
41-
task::spawn(|| pfib(ch, n - 1) );
41+
task::spawn(|| pfib(&ch, n - 1) );
4242
let ch = p.chan();
43-
task::spawn(|| pfib(ch, n - 2) );
43+
task::spawn(|| pfib(&ch, n - 2) );
4444
c.send(p.recv() + p.recv());
4545
}
4646
}
4747

4848
let (p, ch) = stream();
49-
let _t = task::spawn(|| pfib(ch, n) );
49+
let _t = task::spawn(|| pfib(&ch, n) );
5050
p.recv()
5151
}
5252

src/test/compile-fail/arg-style-mismatch.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)