Merge remote-tracking branch 'original/incoming' into incoming
Conflicts: src/libstd/json.rs src/libstd/sort.rs
This commit is contained in:
commit
efcd2385ea
378 changed files with 11486 additions and 8500 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#[legacy_exports];
|
||||
mod kitties {
|
||||
#[legacy_exports];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
mod kitties {
|
||||
#[legacy_exports];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
mod kitties {
|
||||
#[legacy_exports];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[legacy_exports];
|
||||
mod kitties {
|
||||
#[legacy_exports];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
mod kitties {
|
||||
#[legacy_exports];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
use to_str::*;
|
||||
use to_str::ToStr;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// aux-build:crateresolve_calories-2.rs
|
||||
|
||||
// These both have the same version but differ in other metadata
|
||||
#[legacy_exports];
|
||||
mod a {
|
||||
#[legacy_exports];
|
||||
extern mod cr_1 (name = "crateresolve_calories", vers = "0.1", calories="100");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#[link(name="foreign_lib", vers="0.0")];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#[link(name="socketlib", vers="0.0")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
mod socket {
|
||||
#[legacy_exports];
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ struct port_ptr<T:Send> {
|
|||
debug!("in the port_ptr destructor");
|
||||
do task::unkillable {
|
||||
let yield = 0u;
|
||||
let yieldp = ptr::addr_of(yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
rustrt::rust_port_begin_detach(self.po, yieldp);
|
||||
if yield != 0u {
|
||||
task::yield();
|
||||
|
|
@ -66,10 +66,10 @@ fn recv<T: Send>(p: port<T>) -> T { recv_((**p).po) }
|
|||
/// Receive on a raw port pointer
|
||||
fn recv_<T: Send>(p: *rust_port) -> T {
|
||||
let yield = 0u;
|
||||
let yieldp = ptr::addr_of(yield);
|
||||
let yieldp = ptr::addr_of(&yield);
|
||||
let mut res;
|
||||
res = rusti::init::<T>();
|
||||
rustrt::port_recv(ptr::addr_of(res) as *uint, p, yieldp);
|
||||
rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp);
|
||||
|
||||
if yield != 0u {
|
||||
// Data isn't available yet, so res has not been initialized.
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ fn main(++args: ~[~str]) {
|
|||
let seed = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
||||
{
|
||||
let rng = rand::seeded_rng(copy seed);
|
||||
let rng = rand::seeded_rng(&seed);
|
||||
let mut results = empty_results();
|
||||
int_benchmarks::<map::HashMap<uint, uint>>(
|
||||
map::HashMap, rng, num_keys, &mut results);
|
||||
|
|
@ -164,7 +164,7 @@ fn main(++args: ~[~str]) {
|
|||
}
|
||||
|
||||
{
|
||||
let rng = rand::seeded_rng(copy seed);
|
||||
let rng = rand::seeded_rng(&seed);
|
||||
let mut results = empty_results();
|
||||
int_benchmarks::<@Mut<LinearMap<uint, uint>>>(
|
||||
|| @Mut(LinearMap()),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: fn()) {
|
|||
|
||||
if os::getenv(~"RUST_BENCH").is_some() { run_test = true }
|
||||
else if argv.len() > 0 {
|
||||
run_test = argv.contains(~"all") || argv.contains(name)
|
||||
run_test = argv.contains(&~"all") || argv.contains(&name)
|
||||
}
|
||||
|
||||
if !run_test { return }
|
||||
|
|
@ -47,7 +47,7 @@ fn shift_push() {
|
|||
let mut v2 = ~[];
|
||||
|
||||
while v1.len() > 0 {
|
||||
vec::push(v2, vec::shift(v1));
|
||||
v2.push(v1.shift());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ fn read_line() {
|
|||
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
|
||||
|
||||
for int::range(0, 3) |_i| {
|
||||
let reader = result::get(io::file_reader(&path));
|
||||
let reader = result::get(&io::file_reader(&path));
|
||||
while !reader.eof() {
|
||||
reader.read_line();
|
||||
}
|
||||
|
|
@ -122,11 +122,11 @@ fn vec_push_all() {
|
|||
for uint::range(0, 1500) |i| {
|
||||
let mut rv = vec::from_elem(r.gen_uint_range(0, i + 1), i);
|
||||
if r.gen_bool() {
|
||||
vec::push_all(v, rv);
|
||||
v.push_all(rv);
|
||||
}
|
||||
else {
|
||||
v <-> rv;
|
||||
vec::push_all(v, rv);
|
||||
v.push_all(rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use io::WriterUtil;
|
|||
fn collect_raw(num: uint) -> ~[uint] {
|
||||
let mut result = ~[];
|
||||
for uint::range(0u, num) |i| {
|
||||
vec::push(result, i);
|
||||
result.push(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
|
|||
let k = r.gen_uint_range(0u, graph.len());
|
||||
|
||||
if graph[k].len() > 0u && vec::any(graph[k], |i| {
|
||||
i != k as node_id
|
||||
*i != k as node_id
|
||||
}) {
|
||||
map::set_add(keys, k as node_id);
|
||||
}
|
||||
|
|
@ -160,8 +160,8 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
}
|
||||
};
|
||||
|
||||
fn is_gray(c: color) -> bool {
|
||||
match c {
|
||||
fn is_gray(c: &color) -> bool {
|
||||
match *c {
|
||||
gray(_) => { true }
|
||||
_ => { false }
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
let mut color = white;
|
||||
|
||||
do neighbors.each() |k| {
|
||||
if is_gray(colors[*k]) {
|
||||
if is_gray(&colors[*k]) {
|
||||
color = gray(*k);
|
||||
false
|
||||
}
|
||||
|
|
@ -231,18 +231,18 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
};
|
||||
|
||||
#[inline(always)]
|
||||
fn is_gray(c: color) -> bool {
|
||||
match c {
|
||||
fn is_gray(c: &color) -> bool {
|
||||
match *c {
|
||||
gray(_) => { true }
|
||||
_ => { false }
|
||||
}
|
||||
}
|
||||
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while par::any(colors, is_gray) {
|
||||
// Do the BFS.
|
||||
log(info, fmt!("PBFS iteration %?", i));
|
||||
i += 1u;
|
||||
i += 1;
|
||||
let old_len = colors.len();
|
||||
|
||||
let color = arc::ARC(colors);
|
||||
|
|
@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
colors = do par::mapi_factory(*color_vec) {
|
||||
let colors = arc::clone(&color);
|
||||
let graph = arc::clone(&graph);
|
||||
fn~(i: uint, c: color) -> color {
|
||||
fn~(+i: uint, +c: color) -> color {
|
||||
let c : color = c;
|
||||
let colors = arc::get(&colors);
|
||||
let graph = arc::get(&graph);
|
||||
|
|
@ -264,7 +264,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
let mut color = white;
|
||||
|
||||
do neighbors.each() |k| {
|
||||
if is_gray(colors[*k]) {
|
||||
if is_gray(&colors[*k]) {
|
||||
color = gray(*k);
|
||||
false
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
|
||||
// Convert the results.
|
||||
do par::map(colors) |c| {
|
||||
match c {
|
||||
match *c {
|
||||
white => { -1i64 }
|
||||
black(parent) => { parent }
|
||||
_ => { fail ~"Found remaining gray nodes in BFS" }
|
||||
|
|
@ -314,11 +314,11 @@ fn validate(edges: ~[(node_id, node_id)],
|
|||
}
|
||||
else {
|
||||
while parent != root {
|
||||
if vec::contains(path, parent) {
|
||||
if vec::contains(path, &parent) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
vec::push(path, parent);
|
||||
path.push(parent);
|
||||
parent = tree[parent];
|
||||
}
|
||||
|
||||
|
|
@ -336,8 +336,8 @@ fn validate(edges: ~[(node_id, node_id)],
|
|||
log(info, ~"Verifying tree edges...");
|
||||
|
||||
let status = do tree.alli() |k, parent| {
|
||||
if parent != root && parent != -1i64 {
|
||||
level[parent] == level[k] - 1
|
||||
if *parent != root && *parent != -1i64 {
|
||||
level[*parent] == level[k] - 1
|
||||
}
|
||||
else {
|
||||
true
|
||||
|
|
@ -352,7 +352,7 @@ fn validate(edges: ~[(node_id, node_id)],
|
|||
log(info, ~"Verifying graph edges...");
|
||||
|
||||
let status = do edges.all() |e| {
|
||||
let (u, v) = e;
|
||||
let (u, v) = *e;
|
||||
|
||||
abs(level[u] - level[v]) <= 1
|
||||
};
|
||||
|
|
@ -370,11 +370,11 @@ fn validate(edges: ~[(node_id, node_id)],
|
|||
|
||||
let status = do par::alli(tree) |u, v| {
|
||||
let u = u as node_id;
|
||||
if v == -1i64 || u == root {
|
||||
if *v == -1i64 || u == root {
|
||||
true
|
||||
}
|
||||
else {
|
||||
edges.contains((u, v)) || edges.contains((v, u))
|
||||
edges.contains(&(u, *v)) || edges.contains(&(*v, u))
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use io::WriterUtil;
|
|||
use pipes::{Port, Chan, SharedChan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
@ -60,7 +60,7 @@ fn run(args: &[~str]) {
|
|||
for uint::range(0u, workers) |i| {
|
||||
let to_child = to_child.clone();
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(worker_results, r);
|
||||
worker_results.push(r);
|
||||
}).spawn {
|
||||
for uint::range(0u, size / workers) |_i| {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use io::WriterUtil;
|
|||
use pipes::{Port, PortSet, Chan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
@ -57,7 +57,7 @@ fn run(args: &[~str]) {
|
|||
let (to_child, from_parent_) = pipes::stream();
|
||||
from_parent.add(from_parent_);
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(worker_results, r);
|
||||
worker_results.push(r);
|
||||
}).spawn {
|
||||
for uint::range(0u, size / workers) |_i| {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ type pipe = arc::MutexARC<~[uint]>;
|
|||
|
||||
fn send(p: &pipe, msg: uint) {
|
||||
do p.access_cond |state, cond| {
|
||||
vec::push(*state, msg);
|
||||
state.push(msg);
|
||||
cond.signal();
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ fn recv(p: &pipe) -> uint {
|
|||
while vec::is_empty(*state) {
|
||||
cond.wait();
|
||||
}
|
||||
vec::pop(*state)
|
||||
state.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ fn main(++args: ~[~str]) {
|
|||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
});
|
||||
vec::push(futures, new_future);
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ proto! ring (
|
|||
fn macros() {
|
||||
#macro[
|
||||
[#move_out[x],
|
||||
unsafe { let y <- *ptr::addr_of(x); y }]
|
||||
unsafe { let y <- *ptr::addr_of(&x); y }]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ fn main(++args: ~[~str]) {
|
|||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
};
|
||||
vec::push(futures, new_future);
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ type pipe = arc::RWARC<~[uint]>;
|
|||
|
||||
fn send(p: &pipe, msg: uint) {
|
||||
do p.write_cond |state, cond| {
|
||||
vec::push(*state, msg);
|
||||
state.push(msg);
|
||||
cond.signal();
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ fn recv(p: &pipe) -> uint {
|
|||
while vec::is_empty(*state) {
|
||||
cond.wait();
|
||||
}
|
||||
vec::pop(*state)
|
||||
state.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ fn main(++args: ~[~str]) {
|
|||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
};
|
||||
vec::push(futures, new_future);
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ fn main(++args: ~[~str]) {
|
|||
get_chan_chan.send(Chan(p));
|
||||
thread_ring(i, msg_per_task, num_chan, p)
|
||||
};
|
||||
vec::push(futures, new_future);
|
||||
futures.push(new_future);
|
||||
|
||||
num_chan = get_chan.recv();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn run(args: ~[~str]) {
|
|||
let mut worker_results = ~[];
|
||||
for uint::range(0u, workers) |_i| {
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(worker_results, r);
|
||||
worker_results.push(r);
|
||||
}).spawn {
|
||||
for uint::range(0u, size / workers) |_i| {
|
||||
comm::send(to_child, bytes(100u));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ proto! pingpong_unbounded (
|
|||
|
||||
// This stuff should go in libcore::pipes
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { let t <- *ptr::addr_of($x); t }
|
||||
{ $x:expr } => { let t <- *ptr::addr_of(&($x)); t }
|
||||
)
|
||||
|
||||
macro_rules! follow (
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
|||
// save each creature's meeting stats
|
||||
let mut report = ~[];
|
||||
for vec::each(to_creature) |_to_one| {
|
||||
vec::push(report, comm::recv(from_creatures_log));
|
||||
report.push(comm::recv(from_creatures_log));
|
||||
}
|
||||
|
||||
// print each color in the set
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ fn main(++args: ~[~str]) {
|
|||
};
|
||||
|
||||
let writer = if os::getenv(~"RUST_BENCH").is_some() {
|
||||
result::get(io::file_writer(&Path("./shootout-fasta.data"),
|
||||
result::get(&io::file_writer(&Path("./shootout-fasta.data"),
|
||||
~[io::Truncate, io::Create]))
|
||||
} else {
|
||||
io::stdout()
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
|
||||
// map -> [(k,%)]
|
||||
mm.each(fn&(key: ~[u8], val: uint) -> bool {
|
||||
vec::push(pairs, (key, pct(val, total)));
|
||||
pairs.push((key, pct(val, total)));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ fn main(++args: ~[~str]) {
|
|||
// get to this massive data set, but #include_bin chokes on it (#2598)
|
||||
let path = Path(env!("CFG_SRC_DIR"))
|
||||
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
|
||||
result::get(io::file_reader(&path))
|
||||
result::get(&io::file_reader(&path))
|
||||
} else {
|
||||
io::stdin()
|
||||
};
|
||||
|
|
@ -152,7 +152,7 @@ fn main(++args: ~[~str]) {
|
|||
stream <-> streams[ii];
|
||||
let (to_parent_, from_child_) = option::unwrap(stream);
|
||||
|
||||
vec::push(from_child, from_child_);
|
||||
from_child.push(from_child_);
|
||||
|
||||
let (to_child, from_parent) = pipes::stream();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
|
|||
|
||||
// map -> [(k,%)]
|
||||
mm.each(fn&(key: ~[u8], val: uint) -> bool {
|
||||
vec::push(pairs, (key, pct(val, total)));
|
||||
pairs.push((key, pct(val, total)));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ fn main(++args: ~[~str]) {
|
|||
// get to this massive data set, but #include_bin chokes on it (#2598)
|
||||
let path = Path(env!("CFG_SRC_DIR"))
|
||||
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
|
||||
result::get(io::file_reader(&path))
|
||||
result::get(&io::file_reader(&path))
|
||||
} else {
|
||||
io::stdin()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ fn chanmb(i: uint, size: uint, ch: comm::Chan<line>) -> ()
|
|||
let xincr = 8f64*incr;
|
||||
for uint::range(0_u, size/8_u) |j| {
|
||||
let x = cmplx {re: xincr*(j as f64) - 1.5f64, im: y};
|
||||
vec::push(crv, fillbyte(x, incr));
|
||||
crv.push(fillbyte(x, incr));
|
||||
};
|
||||
comm::send(ch, {i:i, b:crv});
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ type devnull = {dn: int};
|
|||
|
||||
impl devnull: io::Writer {
|
||||
fn write(_b: &[const u8]) {}
|
||||
fn seek(_i: int, _s: io::SeekStyle) {}
|
||||
fn seek(+_i: int, +_s: io::SeekStyle) {}
|
||||
fn tell() -> uint {0_u}
|
||||
fn flush() -> int {0}
|
||||
fn get_type() -> io::WriterType { io::File }
|
||||
|
|
@ -114,7 +114,7 @@ fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
|
|||
}
|
||||
_ => {
|
||||
result::get(
|
||||
io::file_writer(&Path(path),
|
||||
&io::file_writer(&Path(path),
|
||||
~[io::Create, io::Truncate]))
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ fn stress(num_tasks: int) {
|
|||
let mut results = ~[];
|
||||
for range(0, num_tasks) |i| {
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(results, r);
|
||||
results.push(r);
|
||||
}).spawn {
|
||||
stress_task(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn calc(children: uint, parent_ch: comm::Chan<msg>) {
|
|||
for iter::repeat (children) {
|
||||
match comm::recv(port) {
|
||||
ready(child_ch) => {
|
||||
vec::push(child_chs, child_ch);
|
||||
child_chs.push(child_ch);
|
||||
}
|
||||
_ => fail ~"task-perf-one-million failed (port not ready)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use option::None;
|
|||
use std::map;
|
||||
use std::map::HashMap;
|
||||
use hash::Hash;
|
||||
use io::WriterUtil;
|
||||
use io::{ReaderUtil, WriterUtil};
|
||||
|
||||
use std::time;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ use cmp::Eq;
|
|||
use to_bytes::IterBytes;
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
trait word_reader {
|
||||
|
|
@ -155,8 +155,8 @@ mod map_reduce {
|
|||
let (ctrl, ctrl_server) = ctrl_proto::init();
|
||||
let ctrl = box(ctrl);
|
||||
let i = copy *i;
|
||||
vec::push(tasks, spawn_joinable(|move i| map_task(map, ctrl, i)));
|
||||
vec::push(ctrls, ctrl_server);
|
||||
tasks.push(spawn_joinable(|move i| map_task(map, ctrl, i)));
|
||||
ctrls.push(ctrl_server);
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
|
@ -270,8 +270,7 @@ mod map_reduce {
|
|||
let p = Port();
|
||||
let ch = Chan(p);
|
||||
let r = reduce, kk = k;
|
||||
vec::push(tasks,
|
||||
spawn_joinable(|| reduce_task(r, kk, ch) ));
|
||||
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
|
||||
c = recv(p);
|
||||
reducers.insert(k, c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
fn compute1() -> float {
|
||||
let v = ~[0f, 1f, 2f, 3f];
|
||||
|
||||
do vec::foldl(0f, v) |x, y| { x + y } - 10f
|
||||
do vec::foldl(0f, v) |x, y| { x + *y } - 10f
|
||||
//~^ ERROR mismatched types: expected `()`
|
||||
}
|
||||
|
||||
|
|
|
|||
9
src/test/compile-fail/deprecated-mode-fn-arg.rs
Normal file
9
src/test/compile-fail/deprecated-mode-fn-arg.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#[forbid(deprecated_mode)];
|
||||
|
||||
fn foo(_f: fn(&i: int)) { //~ ERROR explicit mode
|
||||
}
|
||||
|
||||
type Bar = fn(&i: int); //~ ERROR explicit mode
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
enum bottom { }
|
||||
|
||||
fn main() {
|
||||
let x = ptr::addr_of(()) as *bottom;
|
||||
let x = ptr::p2::addr_of(&()) as *bottom;
|
||||
match x { } //~ ERROR non-exhaustive patterns
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn main() {
|
|||
|
||||
unsafe {
|
||||
let a = 0;
|
||||
let v = ptr::mut_addr_of(a);
|
||||
let v = ptr::mut_addr_of(&a);
|
||||
f(v);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ extern mod std;
|
|||
|
||||
fn main() {
|
||||
let a = ~[0];
|
||||
let v: *mut ~[int] = ptr::mut_addr_of(a);
|
||||
let v: *mut ~[int] = ptr::mut_addr_of(&a);
|
||||
|
||||
fn f(&&v: *mut ~[const int]) {
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
let x : *~[int] = ptr::addr_of(~[1,2,3]);
|
||||
let x : *~[int] = ptr::p2::addr_of(&~[1,2,3]);
|
||||
let y : *libc::c_void = x as *libc::c_void;
|
||||
unsafe {
|
||||
let _z = *y;
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ fn something(f: pure fn()) { f(); }
|
|||
|
||||
fn main() {
|
||||
let mut x = ~[];
|
||||
something(|| vec::push(x, 0) ); //~ ERROR access to impure function prohibited in pure context
|
||||
something(|| x.push(0) ); //~ ERROR access to impure function prohibited in pure context
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn broken() -> int {
|
|||
y += ~[&mut z]; //~ ERROR illegal borrow
|
||||
x += 1;
|
||||
}
|
||||
vec::foldl(0, y, |v, p| v + *p )
|
||||
vec::foldl(0, y, |v, p| v + **p )
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
14
src/test/compile-fail/unnamed_argument_mode.rs
Normal file
14
src/test/compile-fail/unnamed_argument_mode.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//error-pattern: mismatched types
|
||||
|
||||
fn bad(&a: int) {
|
||||
}
|
||||
|
||||
// unnamed argument &int is now parsed x: &int
|
||||
// it's not parsed &x: int anymore
|
||||
|
||||
fn called(f: fn(&int)) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
called(bad);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// xfail-test
|
||||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds
|
||||
|
||||
fn main() {
|
||||
let x = ~[1u,2u,3u];
|
||||
|
|
@ -14,4 +14,4 @@ fn main() {
|
|||
|
||||
// This should fail.
|
||||
error!("ov2 0x%x", x[idx]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// xfail-test
|
||||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds
|
||||
|
||||
#[cfg(target_arch="x86")]
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds
|
||||
|
||||
fn main() {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// error-pattern:explicit failure
|
||||
// Don't double free the string
|
||||
extern mod std;
|
||||
use io::Reader;
|
||||
use io::ReaderUtil;
|
||||
|
||||
fn main() {
|
||||
do io::with_str_reader(~"") |rdr| {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// error-pattern:get called on error result: ~"kitty"
|
||||
fn main() {
|
||||
log(error, result::get(result::Err::<int,~str>(~"kitty")));
|
||||
log(error, result::get(&result::Err::<int,~str>(~"kitty")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds: the len is 1024 but the index is -1
|
||||
fn main() {
|
||||
let v = vec::from_fn(1024u, {|n| n});
|
||||
// this should trip a bounds check
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds: the len is 5 but the index is 5
|
||||
fn main() {
|
||||
let s: ~str = ~"hello";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds: the len is 1 but the index is 2
|
||||
fn main() {
|
||||
let v: ~[int] = ~[10];
|
||||
let x: int = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// error-pattern:bounds check
|
||||
// error-pattern:index out of bounds: the len is 2 but the index is -1
|
||||
fn main() {
|
||||
let v: ~[int] = ~[10, 20];
|
||||
let x: int = 0;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] {
|
|||
assert start < end;
|
||||
let mut i = start;
|
||||
let mut r = ~[];
|
||||
while i <= end { vec::push(r, i as char); i += 1u as u8; }
|
||||
while i <= end { r.push(i as char); i += 1u as u8; }
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] {
|
|||
assert start < end;
|
||||
let mut i = start;
|
||||
let mut r = ~[];
|
||||
while i <= end { vec::push(r, i); i += 1u; }
|
||||
while i <= end { r.push(i); i += 1u; }
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ trait Pushable<T> {
|
|||
|
||||
impl<T> ~[T]: Pushable<T> {
|
||||
fn push_val(&mut self, +t: T) {
|
||||
vec::push(*self, t);
|
||||
self.push(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
163
src/test/run-pass/auto_serialize2.rs
Normal file
163
src/test/run-pass/auto_serialize2.rs
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
extern mod std;
|
||||
|
||||
// These tests used to be separate files, but I wanted to refactor all
|
||||
// the common code.
|
||||
|
||||
use cmp::Eq;
|
||||
use std::ebml2;
|
||||
use io::Writer;
|
||||
use std::serialization2::{Serializable, Deserializable, deserialize};
|
||||
use std::prettyprint2;
|
||||
|
||||
fn test_ser_and_deser<A:Eq Serializable Deserializable>(
|
||||
a1: &A,
|
||||
+expected: ~str
|
||||
) {
|
||||
// check the pretty printer:
|
||||
let s = do io::with_str_writer |w| {
|
||||
a1.serialize(&prettyprint2::Serializer(w))
|
||||
};
|
||||
debug!("s == %?", s);
|
||||
assert s == expected;
|
||||
|
||||
// check the EBML serializer:
|
||||
let bytes = do io::with_bytes_writer |wr| {
|
||||
let ebml_w = &ebml2::Serializer(wr);
|
||||
a1.serialize(ebml_w)
|
||||
};
|
||||
let d = ebml2::Doc(@bytes);
|
||||
let a2: A = deserialize(&ebml2::Deserializer(d));
|
||||
assert *a1 == a2;
|
||||
}
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum Expr {
|
||||
Val(uint),
|
||||
Plus(@Expr, @Expr),
|
||||
Minus(@Expr, @Expr)
|
||||
}
|
||||
|
||||
impl Expr : cmp::Eq {
|
||||
pure fn eq(other: &Expr) -> bool {
|
||||
match self {
|
||||
Val(e0a) => {
|
||||
match *other {
|
||||
Val(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
Plus(e0a, e1a) => {
|
||||
match *other {
|
||||
Plus(e0b, e1b) => e0a == e0b && e1a == e1b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
Minus(e0a, e1a) => {
|
||||
match *other {
|
||||
Minus(e0b, e1b) => e0a == e0b && e1a == e1b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pure fn ne(other: &Expr) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl AnEnum : cmp::Eq {
|
||||
pure fn eq(other: &AnEnum) -> bool {
|
||||
self.v == other.v
|
||||
}
|
||||
pure fn ne(other: &AnEnum) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl Point : cmp::Eq {
|
||||
pure fn eq(other: &Point) -> bool {
|
||||
self.x == other.x && self.y == other.y
|
||||
}
|
||||
pure fn ne(other: &Point) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl<T:cmp::Eq> Quark<T> : cmp::Eq {
|
||||
pure fn eq(other: &Quark<T>) -> bool {
|
||||
match self {
|
||||
Top(ref q) => {
|
||||
match *other {
|
||||
Top(ref r) => q == r,
|
||||
Bottom(_) => false
|
||||
}
|
||||
},
|
||||
Bottom(ref q) => {
|
||||
match *other {
|
||||
Top(_) => false,
|
||||
Bottom(ref r) => q == r
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
pure fn ne(other: &Quark<T>) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
impl CLike : cmp::Eq {
|
||||
pure fn eq(other: &CLike) -> bool {
|
||||
self as int == *other as int
|
||||
}
|
||||
pure fn ne(other: &CLike) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type Spanned<T> = {lo: uint, hi: uint, node: T};
|
||||
|
||||
impl<T:cmp::Eq> Spanned<T> : cmp::Eq {
|
||||
pure fn eq(other: &Spanned<T>) -> bool {
|
||||
self.lo == other.lo && self.hi == other.hi && self.node == other.node
|
||||
}
|
||||
pure fn ne(other: &Spanned<T>) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
type SomeRec = {v: ~[uint]};
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum AnEnum = SomeRec;
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
struct Point {x: uint, y: uint}
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum Quark<T> {
|
||||
Top(T),
|
||||
Bottom(T)
|
||||
}
|
||||
|
||||
#[auto_serialize2]
|
||||
#[auto_deserialize2]
|
||||
enum CLike { A, B, C }
|
||||
|
||||
fn main() {
|
||||
test_ser_and_deser(&Plus(@Minus(@Val(3u), @Val(10u)),
|
||||
@Plus(@Val(22u), @Val(5u))),
|
||||
~"Plus(@Minus(@Val(3u), @Val(10u)), \
|
||||
@Plus(@Val(22u), @Val(5u)))");
|
||||
|
||||
test_ser_and_deser(&{lo: 0u, hi: 5u, node: 22u},
|
||||
~"{lo: 0u, hi: 5u, node: 22u}");
|
||||
|
||||
test_ser_and_deser(&AnEnum({v: ~[1u, 2u, 3u]}),
|
||||
~"AnEnum({v: ~[1u, 2u, 3u]})");
|
||||
|
||||
test_ser_and_deser(&Point {x: 3u, y: 5u}, ~"Point {x: 3u, y: 5u}");
|
||||
|
||||
test_ser_and_deser(&@[1u, 2u, 3u], ~"@[1u, 2u, 3u]");
|
||||
|
||||
test_ser_and_deser(&Top(22u), ~"Top(22u)");
|
||||
test_ser_and_deser(&Bottom(222u), ~"Bottom(222u)");
|
||||
|
||||
test_ser_and_deser(&A, ~"A");
|
||||
test_ser_and_deser(&B, ~"B");
|
||||
}
|
||||
20
src/test/run-pass/autoref-intermediate-types-issue-3585.rs
Normal file
20
src/test/run-pass/autoref-intermediate-types-issue-3585.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
trait Foo {
|
||||
fn foo(&self) -> ~str;
|
||||
}
|
||||
|
||||
impl<T: Foo> @T: Foo {
|
||||
fn foo(&self) -> ~str {
|
||||
fmt!("@%s", (**self).foo())
|
||||
}
|
||||
}
|
||||
|
||||
impl uint: Foo {
|
||||
fn foo(&self) -> ~str {
|
||||
fmt!("%u", *self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @3u;
|
||||
assert x.foo() == ~"@3";
|
||||
}
|
||||
|
|
@ -103,8 +103,8 @@ fn test_class() {
|
|||
|
||||
unsafe {
|
||||
error!("q = %x, r = %x",
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(q))),
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(r))));
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
|
||||
(cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
|
||||
}
|
||||
assert(q == r);
|
||||
r.y = 17;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
let v = ~[-1f, 0f, 1f, 2f, 3f];
|
||||
|
||||
// Trailing expressions don't require parentheses:
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
|
||||
assert y == 15f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
fn w_semi(v: ~[int]) -> int {
|
||||
// the semicolon causes compiler not to
|
||||
// complain about the ignored return value:
|
||||
do vec::foldl(0, v) |x,y| { x+y };
|
||||
do vec::foldl(0, v) |x,y| { x+*y };
|
||||
-10
|
||||
}
|
||||
|
||||
fn w_paren1(v: ~[int]) -> int {
|
||||
(do vec::foldl(0, v) |x,y| { x+y }) - 10
|
||||
(do vec::foldl(0, v) |x,y| { x+*y }) - 10
|
||||
}
|
||||
|
||||
fn w_paren2(v: ~[int]) -> int {
|
||||
(do vec::foldl(0, v) |x,y| { x+y} - 10)
|
||||
(do vec::foldl(0, v) |x,y| { x+*y} - 10)
|
||||
}
|
||||
|
||||
fn w_ret(v: ~[int]) -> int {
|
||||
return do vec::foldl(0, v) |x,y| { x+y } - 10;
|
||||
return do vec::foldl(0, v) |x,y| { x+*y } - 10;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -8,28 +8,28 @@ fn main() {
|
|||
}
|
||||
|
||||
// Usable at all:
|
||||
let mut any_negative = do vec::any(v) |e| { float::is_negative(e) };
|
||||
let mut any_negative = do vec::any(v) |e| { float::is_negative(*e) };
|
||||
assert any_negative;
|
||||
|
||||
// Higher precedence than assignments:
|
||||
any_negative = do vec::any(v) |e| { float::is_negative(e) };
|
||||
any_negative = do vec::any(v) |e| { float::is_negative(*e) };
|
||||
assert any_negative;
|
||||
|
||||
// Higher precedence than unary operations:
|
||||
let abs_v = do vec::map(v) |e| { float::abs(*e) };
|
||||
assert do vec::all(abs_v) |e| { float::is_nonnegative(e) };
|
||||
assert !do vec::any(abs_v) |e| { float::is_negative(e) };
|
||||
assert do vec::all(abs_v) |e| { float::is_nonnegative(*e) };
|
||||
assert !do vec::any(abs_v) |e| { float::is_negative(*e) };
|
||||
|
||||
// Usable in funny statement-like forms:
|
||||
if !do vec::any(v) |e| { float::is_positive(e) } {
|
||||
if !do vec::any(v) |e| { float::is_positive(*e) } {
|
||||
assert false;
|
||||
}
|
||||
match do vec::all(v) |e| { float::is_negative(e) } {
|
||||
match do vec::all(v) |e| { float::is_negative(*e) } {
|
||||
true => { fail ~"incorrect answer."; }
|
||||
false => { }
|
||||
}
|
||||
match 3 {
|
||||
_ if do vec::any(v) |e| { float::is_negative(e) } => {
|
||||
_ if do vec::any(v) |e| { float::is_negative(*e) } => {
|
||||
}
|
||||
_ => {
|
||||
fail ~"wrong answer.";
|
||||
|
|
@ -38,15 +38,15 @@ fn main() {
|
|||
|
||||
|
||||
// Lower precedence than binary operations:
|
||||
let w = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let z = 10f + do vec::foldl(0f, v) |x, y| { x + y };
|
||||
let w = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
let z = 10f + do vec::foldl(0f, v) |x, y| { x + *y };
|
||||
assert w == y;
|
||||
assert y == z;
|
||||
|
||||
// In the tail of a block
|
||||
let w =
|
||||
if true { do vec::any(abs_v) |e| { float::is_nonnegative(e) } }
|
||||
if true { do vec::any(abs_v) |e| { float::is_nonnegative(*e) } }
|
||||
else { false };
|
||||
assert w;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn main() {
|
|||
let v =
|
||||
vec::map2(~[1, 2, 3, 4, 5],
|
||||
~[true, false, false, true, true],
|
||||
|i, b| if b { -i } else { i } );
|
||||
|i, b| if *b { -(*i) } else { *i } );
|
||||
log(error, v);
|
||||
assert (v == ~[-1, 2, 3, -4, -5]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn borrow(x: &int, f: fn(x: &int)) {
|
|||
fn test1(x: @~int) {
|
||||
// Right now, at least, this induces a copy of the unique pointer:
|
||||
do borrow({*x}) |p| {
|
||||
let x_a = ptr::addr_of(**x);
|
||||
let x_a = ptr::addr_of(&(**x));
|
||||
assert (x_a as uint) != to_uint(p);
|
||||
assert unsafe{*x_a} == *p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn add_int(x: &mut ints, v: int) {
|
|||
*x.sum += v;
|
||||
let mut values = ~[];
|
||||
x.values <-> values;
|
||||
vec::push(values, v);
|
||||
values.push(v);
|
||||
x.values <- values;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ fn main() {
|
|||
match *x {
|
||||
{f: b_x} => {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
|
|
@ -5,13 +5,13 @@ fn main() {
|
|||
match x {
|
||||
@@{f: b_x} => {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(x.f) == ptr::addr_of(b_x);
|
||||
assert ptr::addr_of(&(x.f)) == ptr::addr_of(&(b_x));
|
||||
|
||||
*x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = ~mut @{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
*x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @3;
|
||||
do borrow(x) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x));
|
||||
x = @22;
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ fn main() {
|
|||
let mut x = @{f: ~3};
|
||||
do borrow((*x).f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
x = @{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint);
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(*x.f) != ptr::addr_of(*b_x);
|
||||
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
fn rust_annihilate_box(ptr: *uint);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let x = @3;
|
||||
let p: *uint = cast::transmute(x);
|
||||
rustrt::rust_annihilate_box(p);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
fn rust_annihilate_box(ptr: *uint);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let x = ~[~"a", ~"b", ~"c"];
|
||||
let p: *uint = cast::transmute(x);
|
||||
rustrt::rust_annihilate_box(p);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
fn rust_annihilate_box(ptr: *uint);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let x = ~3;
|
||||
let p: *uint = cast::transmute(x);
|
||||
rustrt::rust_annihilate_box(p);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +1,29 @@
|
|||
fn main() {
|
||||
let x = ~1;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy = fn@(copy x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let lam_move = fn@(move x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy = fn@(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
let lam_move = fn@(move x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
|
||||
let x = ~2;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy: fn@() -> uint = |copy x| ptr::addr_of(*x) as uint;
|
||||
let lam_move: fn@() -> uint = |move x| ptr::addr_of(*x) as uint;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy: fn@() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: fn@() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
|
||||
let x = ~3;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let snd_copy = fn~(copy x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let snd_move = fn~(move x) -> uint { ptr::addr_of(*x) as uint };
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let snd_copy = fn~(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
let snd_move = fn~(move x) -> uint { ptr::addr_of(&(*x)) as uint };
|
||||
assert snd_copy() != y;
|
||||
assert snd_move() == y;
|
||||
|
||||
let x = ~4;
|
||||
let y = ptr::addr_of(*x) as uint;
|
||||
let lam_copy: fn~() -> uint = |copy x| ptr::addr_of(*x) as uint;
|
||||
let lam_move: fn~() -> uint = |move x| ptr::addr_of(*x) as uint;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_copy: fn~() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: fn~() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
|
||||
assert lam_copy() != y;
|
||||
assert lam_move() == y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
fn adder(+x: @int, +y: @int) -> int { return *x + *y; }
|
||||
fn failer() -> @int { fail; }
|
||||
fn main() {
|
||||
assert(result::is_err(task::try(|| {
|
||||
assert(result::is_err(&task::try(|| {
|
||||
adder(@2, failer()); ()
|
||||
})));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() }
|
|||
|
||||
fn main() {
|
||||
|
||||
for iter::eachi(Some({a: 0})) |i, a| {
|
||||
for iter::eachi(&(Some({a: 0}))) |i, a| {
|
||||
#debug["%u %d", i, a.a];
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/test/run-pass/enum-export-inheritance.rs
Normal file
12
src/test/run-pass/enum-export-inheritance.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
mod a {
|
||||
pub enum Foo {
|
||||
Bar,
|
||||
Baz,
|
||||
Boo
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = a::Bar;
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
|
||||
|
||||
// -*- rust -*-
|
||||
fn main() { debug!("hello, world."); }
|
||||
|
||||
fn main() {
|
||||
io::println("hello, world");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
use iter::BaseIter;
|
||||
|
||||
trait FlatMapToVec<A> {
|
||||
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(A) -> IB) -> ~[B];
|
||||
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(+a: A) -> IB) -> ~[B];
|
||||
}
|
||||
|
||||
impl<A:Copy> BaseIter<A>: FlatMapToVec<A> {
|
||||
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(A) -> IB) -> ~[B] {
|
||||
iter::flat_map_to_vec(self, op)
|
||||
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(+a: A) -> IB) -> ~[B] {
|
||||
iter::flat_map_to_vec(&self, op)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ mod pingpong {
|
|||
|
||||
fn liberate_ping(-p: ping) -> pipes::send_packet<pong> unsafe {
|
||||
let addr : *pipes::send_packet<pong> = match p {
|
||||
ping(x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
|
|
@ -210,7 +210,7 @@ mod pingpong {
|
|||
|
||||
fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe {
|
||||
let addr : *pipes::send_packet<ping> = match p {
|
||||
pong(x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
cast::forget(p);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extern mod std;
|
||||
use io::WriterUtil;
|
||||
use std::map::HashMap;
|
||||
use std::json;
|
||||
|
||||
enum object
|
||||
{
|
||||
|
|
@ -8,13 +9,13 @@ enum object
|
|||
int_value(i64),
|
||||
}
|
||||
|
||||
fn lookup(table: std::map::HashMap<~str, std::json::Json>, key: ~str, default: ~str) -> ~str
|
||||
fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str
|
||||
{
|
||||
match table.find(key)
|
||||
match table.find(&key)
|
||||
{
|
||||
option::Some(std::json::String(s)) =>
|
||||
{
|
||||
*s
|
||||
s
|
||||
}
|
||||
option::Some(value) =>
|
||||
{
|
||||
|
|
@ -32,7 +33,7 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str,
|
|||
{
|
||||
match data
|
||||
{
|
||||
std::json::Dict(interface) =>
|
||||
std::json::Object(interface) =>
|
||||
{
|
||||
let name = lookup(interface, ~"ifDescr", ~"");
|
||||
let label = fmt!("%s-%s", managed_ip, name);
|
||||
|
|
@ -53,7 +54,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: std::map::HashMap<~str,
|
|||
{
|
||||
std::json::List(interfaces) =>
|
||||
{
|
||||
do vec::map(*interfaces) |interface| {
|
||||
do vec::map(interfaces) |interface| {
|
||||
add_interface(store, managed_ip, *interface)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
/// Map representation
|
||||
|
||||
use io::ReaderUtil;
|
||||
|
||||
extern mod std;
|
||||
|
||||
enum square {
|
||||
|
|
@ -50,10 +52,10 @@ fn read_board_grid<rdr: Owned io::Reader>(+in: rdr) -> ~[~[square]] {
|
|||
let mut grid = ~[];
|
||||
for in.each_line |line| {
|
||||
let mut row = ~[];
|
||||
for line.each_char |c| {
|
||||
vec::push(row, square_from_char(c))
|
||||
for str::each_char(line) |c| {
|
||||
row.push(square_from_char(c))
|
||||
}
|
||||
vec::push(grid, row)
|
||||
grid.push(row)
|
||||
}
|
||||
let width = grid[0].len();
|
||||
for grid.each |row| { assert row.len() == width }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extern mod std;
|
||||
use comm::*;
|
||||
use task::*;
|
||||
use task::spawn;
|
||||
|
||||
fn a() {
|
||||
fn doit() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fn is_even(&&x: uint) -> bool { (x % 2u) == 0u }
|
||||
fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
|
||||
|
||||
fn main() {
|
||||
assert ![1u, 2u]/_.all(is_even);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
fn is_even(&&x: uint) -> bool { (x % 2u) == 0u }
|
||||
fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
|
||||
|
||||
fn main() {
|
||||
assert ![1u, 3u]/_.any(is_even);
|
||||
assert [1u, 2u]/_.any(is_even);
|
||||
assert ![]/_.any(is_even);
|
||||
|
||||
assert !Some(1u).any(is_even);
|
||||
assert Some(2u).any(is_even);
|
||||
assert !Some(1).any(is_even);
|
||||
assert Some(2).any(is_even);
|
||||
assert !None.any(is_even);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
fn main() {
|
||||
assert []/_.contains(22u) == false;
|
||||
assert [1u, 3u]/_.contains(22u) == false;
|
||||
assert [22u, 1u, 3u]/_.contains(22u) == true;
|
||||
assert [1u, 22u, 3u]/_.contains(22u) == true;
|
||||
assert [1u, 3u, 22u]/_.contains(22u) == true;
|
||||
assert None.contains(22u) == false;
|
||||
assert Some(1u).contains(22u) == false;
|
||||
assert Some(22u).contains(22u) == true;
|
||||
assert []/_.contains(&22u) == false;
|
||||
assert [1u, 3u]/_.contains(&22u) == false;
|
||||
assert [22u, 1u, 3u]/_.contains(&22u) == true;
|
||||
assert [1u, 22u, 3u]/_.contains(&22u) == true;
|
||||
assert [1u, 3u, 22u]/_.contains(&22u) == true;
|
||||
assert None.contains(&22u) == false;
|
||||
assert Some(1u).contains(&22u) == false;
|
||||
assert Some(22u).contains(&22u) == true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
fn main() {
|
||||
assert []/_.count(22u) == 0u;
|
||||
assert [1u, 3u]/_.count(22u) == 0u;
|
||||
assert [22u, 1u, 3u]/_.count(22u) == 1u;
|
||||
assert [22u, 1u, 22u]/_.count(22u) == 2u;
|
||||
assert None.count(22u) == 0u;
|
||||
assert Some(1u).count(22u) == 0u;
|
||||
assert Some(22u).count(22u) == 1u;
|
||||
assert []/_.count(&22u) == 0u;
|
||||
assert [1u, 3u]/_.count(&22u) == 0u;
|
||||
assert [22u, 1u, 3u]/_.count(&22u) == 1u;
|
||||
assert [22u, 1u, 22u]/_.count(&22u) == 2u;
|
||||
assert None.count(&22u) == 0u;
|
||||
assert Some(1u).count(&22u) == 0u;
|
||||
assert Some(22u).count(&22u) == 1u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
fn is_even(&&x: uint) -> bool { (x % 2u) == 0u }
|
||||
fn is_even(+x: uint) -> bool { (x % 2) == 0 }
|
||||
|
||||
fn main() {
|
||||
assert [1u, 3u]/_.filter_to_vec(is_even) == ~[];
|
||||
assert [1u, 2u, 3u]/_.filter_to_vec(is_even) == ~[2u];
|
||||
assert [1, 3]/_.filter_to_vec(is_even) == ~[];
|
||||
assert [1, 2, 3]/_.filter_to_vec(is_even) == ~[2];
|
||||
assert None.filter_to_vec(is_even) == ~[];
|
||||
assert Some(1u).filter_to_vec(is_even) == ~[];
|
||||
assert Some(2u).filter_to_vec(is_even) == ~[2u];
|
||||
assert Some(1).filter_to_vec(is_even) == ~[];
|
||||
assert Some(2).filter_to_vec(is_even) == ~[2];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fn add(&&x: float, &&y: uint) -> float { x + (y as float) }
|
||||
fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
|
||||
|
||||
fn main() {
|
||||
assert [1u, 3u]/_.foldl(20f, add) == 24f;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
fn inc(x: &uint) -> uint { *x + 1u }
|
||||
fn inc(+x: uint) -> uint { x + 1 }
|
||||
|
||||
fn main() {
|
||||
assert [1u, 3u]/_.map_to_vec(inc) == ~[2u, 4u];
|
||||
assert [1u, 2u, 3u]/_.map_to_vec(inc) == ~[2u, 3u, 4u];
|
||||
assert [1, 3]/_.map_to_vec(inc) == ~[2, 4];
|
||||
assert [1, 2, 3]/_.map_to_vec(inc) == ~[2, 3, 4];
|
||||
assert None.map_to_vec(inc) == ~[];
|
||||
assert Some(1u).map_to_vec(inc) == ~[2u];
|
||||
assert Some(2u).map_to_vec(inc) == ~[3u];
|
||||
assert Some(1).map_to_vec(inc) == ~[2];
|
||||
assert Some(2).map_to_vec(inc) == ~[3];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
fn main() {
|
||||
// Make sure closing over can be a last use
|
||||
let q = ~10;
|
||||
let addr = ptr::addr_of(*q);
|
||||
let f = fn@() -> *int { ptr::addr_of(*q) };
|
||||
let addr = ptr::addr_of(&(*q));
|
||||
let f = fn@() -> *int { ptr::addr_of(&(*q)) };
|
||||
assert addr == f();
|
||||
|
||||
// But only when it really is the last use
|
||||
let q = ~20;
|
||||
let f = fn@() -> *int { ptr::addr_of(*q) };
|
||||
assert ptr::addr_of(*q) != f();
|
||||
let f = fn@() -> *int { ptr::addr_of(&(*q)) };
|
||||
assert ptr::addr_of(&(*q)) != f();
|
||||
|
||||
// Ensure function arguments and box arguments interact sanely.
|
||||
fn call_me(x: fn() -> int, y: ~int) { assert x() == *y; }
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
fn main() {
|
||||
// ints
|
||||
// num
|
||||
assert 15.add(6) == 21;
|
||||
assert 15i8.add(6i8) == 21i8;
|
||||
assert 15i16.add(6i16) == 21i16;
|
||||
assert 15i32.add(6i32) == 21i32;
|
||||
assert 15i64.add(6i64) == 21i64;
|
||||
assert 15.add(&6) == 21;
|
||||
assert 15i8.add(&6i8) == 21i8;
|
||||
assert 15i16.add(&6i16) == 21i16;
|
||||
assert 15i32.add(&6i32) == 21i32;
|
||||
assert 15i64.add(&6i64) == 21i64;
|
||||
// times
|
||||
15.times(|| false);
|
||||
15i8.times(|| false);
|
||||
|
|
@ -19,11 +19,11 @@ fn main() {
|
|||
|
||||
// uints
|
||||
// num
|
||||
assert 15u.add(6u) == 21u;
|
||||
assert 15u8.add(6u8) == 21u8;
|
||||
assert 15u16.add(6u16) == 21u16;
|
||||
assert 15u32.add(6u32) == 21u32;
|
||||
assert 15u64.add(6u64) == 21u64;
|
||||
assert 15u.add(&6u) == 21u;
|
||||
assert 15u8.add(&6u8) == 21u8;
|
||||
assert 15u16.add(&6u16) == 21u16;
|
||||
assert 15u32.add(&6u32) == 21u32;
|
||||
assert 15u64.add(&6u64) == 21u64;
|
||||
// times
|
||||
15u.times(|| false);
|
||||
15u8.times(|| false);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl Point : ops::Neg<Point> {
|
|||
}
|
||||
|
||||
impl Point : ops::Index<bool,int> {
|
||||
pure fn index(&&x: bool) -> int {
|
||||
pure fn index(+x: bool) -> int {
|
||||
if x { self.x } else { self.y }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ proto! bank (
|
|||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } }
|
||||
)
|
||||
|
||||
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ mod pingpong {
|
|||
do pipes::entangle_buffer(buffer) |buffer, data| {
|
||||
data.ping.set_buffer_(buffer);
|
||||
data.pong.set_buffer_(buffer);
|
||||
ptr::addr_of(data.ping)
|
||||
ptr::addr_of(&(data.ping))
|
||||
}
|
||||
}
|
||||
enum ping = server::pong;
|
||||
|
|
@ -38,8 +38,8 @@ mod pingpong {
|
|||
fn ping(+pipe: ping) -> pong {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(b.buffer.data.pong));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(b.buffer.data.pong));
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let message = pingpong::ping(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
|
|
@ -57,8 +57,8 @@ mod pingpong {
|
|||
fn pong(+pipe: pong) -> ping {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(b.buffer.data.ping));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(b.buffer.data.ping));
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let message = pingpong::pong(s);
|
||||
pipes::send(pipe, message);
|
||||
c
|
||||
|
|
|
|||
14
src/test/run-pass/reexport-star.rs
Normal file
14
src/test/run-pass/reexport-star.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
mod a {
|
||||
pub fn f() {}
|
||||
pub fn g() {}
|
||||
}
|
||||
|
||||
mod b {
|
||||
pub use a::*;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
b::f();
|
||||
b::g();
|
||||
}
|
||||
|
||||
|
|
@ -612,7 +612,7 @@ fn get_tydesc_for<T>(&&_t: T) -> *TyDesc {
|
|||
|
||||
fn main() {
|
||||
let r = (1,2,3,true,false,{x:5,y:4,z:3});
|
||||
let p = ptr::addr_of(r) as *c_void;
|
||||
let p = ptr::addr_of(&r) as *c_void;
|
||||
let u = my_visitor(@{mut ptr1: p,
|
||||
mut ptr2: p,
|
||||
mut vals: ~[]});
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ struct r {
|
|||
v: *int,
|
||||
drop unsafe {
|
||||
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(self)),
|
||||
cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(self.v)),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)),
|
||||
cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))),
|
||||
cast::reinterpret_cast::<*int, uint>(&self.v));
|
||||
let v2: ~int = cast::reinterpret_cast(&self.v); }
|
||||
}
|
||||
|
|
@ -34,27 +34,27 @@ fn main() unsafe {
|
|||
r: {
|
||||
let rs = r(i1p);
|
||||
debug!("r = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(rs)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs }
|
||||
});
|
||||
|
||||
debug!("x1 = %x, x1.r = %x",
|
||||
cast::reinterpret_cast::<@t, uint>(&x1),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(x1.r)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x1.r))));
|
||||
|
||||
let x2 = @t({
|
||||
mut next: None,
|
||||
r: {
|
||||
let rs = r(i2p);
|
||||
debug!("r2 = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(rs)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
rs
|
||||
}
|
||||
});
|
||||
|
||||
debug!("x2 = %x, x2.r = %x",
|
||||
cast::reinterpret_cast::<@t, uint>(&x2),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(x2.r)));
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x2.r))));
|
||||
|
||||
x1.next = Some(x2);
|
||||
x2.next = Some(x1);
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ fn ret_deep() -> ~str {
|
|||
fn main() {
|
||||
let mut last = 0;
|
||||
for vec::all(~[1, 2, 3, 4, 5, 6, 7]) |e| {
|
||||
last = e;
|
||||
if e == 5 { break; }
|
||||
if e % 2 == 1 { loop; }
|
||||
assert e % 2 == 0;
|
||||
last = *e;
|
||||
if *e == 5 { break; }
|
||||
if *e % 2 == 1 { loop; }
|
||||
assert *e % 2 == 0;
|
||||
};
|
||||
assert last == 5;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fn main() unsafe {
|
|||
assert child_sched_id == new_sched_id;
|
||||
comm::send(ch, ());
|
||||
};
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(f));
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(&f));
|
||||
rustrt::start_task(new_task_id, fptr);
|
||||
cast::forget(f);
|
||||
comm::recv(po);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ macro_rules! select_if (
|
|||
match move pipes::try_recv($port) {
|
||||
$(Some($message($($(ref $x,)+)* ref next)) => {
|
||||
// FIXME (#2329) we really want move out of enum here.
|
||||
let $next = unsafe { let x <- *ptr::addr_of(*next); x };
|
||||
let $next = unsafe { let x <- *ptr::addr_of(&(*next)); x };
|
||||
$e
|
||||
})+
|
||||
_ => fail
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
fn main() {
|
||||
let foo = 1;
|
||||
assert ptr::addr_of(foo) == ptr::addr_of(foo);
|
||||
assert ptr::addr_of(&foo) == ptr::addr_of(&foo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fn test00() {
|
|||
while i < number_of_tasks {
|
||||
let ch = po.chan();
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(results, r);
|
||||
results.push(r);
|
||||
}).spawn |copy i| {
|
||||
test00_start(ch, i, number_of_messages)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn test00() {
|
|||
while i < number_of_tasks {
|
||||
i = i + 1;
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(results, r);
|
||||
results.push(r);
|
||||
}).spawn |copy i| {
|
||||
test00_start(ch, i, number_of_messages);
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ fn test06() {
|
|||
while i < number_of_tasks {
|
||||
i = i + 1;
|
||||
do task::task().future_result(|+r| {
|
||||
vec::push(results, r);
|
||||
results.push(r);
|
||||
}).spawn |copy i| {
|
||||
test06_start(i);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct notify {
|
|||
drop {
|
||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||
task::get_task(),
|
||||
ptr::addr_of(*(self.v)) as uint,
|
||||
ptr::addr_of(&(*(self.v))) as uint,
|
||||
task::failing(),
|
||||
*(self.v));
|
||||
let b = *(self.v);
|
||||
|
|
@ -30,7 +30,7 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
|
|||
let b = @mut false;
|
||||
error!("wrapper: task=%? allocated v=%x",
|
||||
task::get_task(),
|
||||
ptr::addr_of(*b) as uint);
|
||||
ptr::addr_of(&(*b)) as uint);
|
||||
let _r = notify(c, b);
|
||||
f();
|
||||
*b = true;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue