Manual merge of #22475 - alexcrichton:rollup, r=alexcrichton
One windows bot failed spuriously.
This commit is contained in:
commit
dfc5c0f1e8
381 changed files with 6886 additions and 3250 deletions
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{Receiver, channel};
|
||||
|
||||
pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
|
||||
pub fn foo<T:'static + Send + Clone>(x: T) -> Receiver<T> {
|
||||
let (tx, rx) = channel();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
tx.send(x.clone());
|
||||
});
|
||||
rx
|
||||
|
|
|
|||
|
|
@ -64,16 +64,6 @@ impl MethodTester {
|
|||
pub fn method_stable(&self) {}
|
||||
#[stable(feature = "rust1", since = "1.0.0", reason = "text")]
|
||||
pub fn method_stable_text(&self) {}
|
||||
|
||||
#[locked]
|
||||
pub fn method_locked(&self) {}
|
||||
#[locked="text"]
|
||||
pub fn method_locked_text(&self) {}
|
||||
|
||||
#[frozen]
|
||||
pub fn method_frozen(&self) {}
|
||||
#[frozen="text"]
|
||||
pub fn method_frozen_text(&self) {}
|
||||
}
|
||||
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
|
|
@ -101,16 +91,6 @@ pub trait Trait {
|
|||
fn trait_stable(&self) {}
|
||||
#[stable(feature = "rust1", since = "1.0.0", reason = "text")]
|
||||
fn trait_stable_text(&self) {}
|
||||
|
||||
#[locked]
|
||||
fn trait_locked(&self) {}
|
||||
#[locked="text"]
|
||||
fn trait_locked_text(&self) {}
|
||||
|
||||
#[frozen]
|
||||
fn trait_frozen(&self) {}
|
||||
#[frozen="text"]
|
||||
fn trait_frozen_text(&self) {}
|
||||
}
|
||||
|
||||
impl Trait for MethodTester {}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::rand::{Rng, IsaacRng, SeedableRng};
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
@ -20,33 +20,33 @@ fn timed<F>(label: &str, f: F) where F: FnMut() {
|
|||
}
|
||||
|
||||
trait MutableMap {
|
||||
fn insert(&mut self, k: uint, v: uint);
|
||||
fn remove(&mut self, k: &uint) -> bool;
|
||||
fn find(&self, k: &uint) -> Option<&uint>;
|
||||
fn insert(&mut self, k: usize, v: usize);
|
||||
fn remove(&mut self, k: &usize) -> bool;
|
||||
fn find(&self, k: &usize) -> Option<&usize>;
|
||||
}
|
||||
|
||||
impl MutableMap for BTreeMap<uint, uint> {
|
||||
fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
|
||||
fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
|
||||
fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
|
||||
impl MutableMap for BTreeMap<usize, usize> {
|
||||
fn insert(&mut self, k: usize, v: usize) { self.insert(k, v); }
|
||||
fn remove(&mut self, k: &usize) -> bool { self.remove(k).is_some() }
|
||||
fn find(&self, k: &usize) -> Option<&usize> { self.get(k) }
|
||||
}
|
||||
impl MutableMap for HashMap<uint, uint> {
|
||||
fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
|
||||
fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
|
||||
fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
|
||||
impl MutableMap for HashMap<usize, usize> {
|
||||
fn insert(&mut self, k: usize, v: usize) { self.insert(k, v); }
|
||||
fn remove(&mut self, k: &usize) -> bool { self.remove(k).is_some() }
|
||||
fn find(&self, k: &usize) -> Option<&usize> { self.get(k) }
|
||||
}
|
||||
|
||||
fn ascending<M: MutableMap>(map: &mut M, n_keys: uint) {
|
||||
fn ascending<M: MutableMap>(map: &mut M, n_keys: usize) {
|
||||
println!(" Ascending integers:");
|
||||
|
||||
timed("insert", || {
|
||||
for i in 0u..n_keys {
|
||||
for i in 0..n_keys {
|
||||
map.insert(i, i + 1);
|
||||
}
|
||||
});
|
||||
|
||||
timed("search", || {
|
||||
for i in 0u..n_keys {
|
||||
for i in 0..n_keys {
|
||||
assert_eq!(map.find(&i).unwrap(), &(i + 1));
|
||||
}
|
||||
});
|
||||
|
|
@ -58,7 +58,7 @@ fn ascending<M: MutableMap>(map: &mut M, n_keys: uint) {
|
|||
});
|
||||
}
|
||||
|
||||
fn descending<M: MutableMap>(map: &mut M, n_keys: uint) {
|
||||
fn descending<M: MutableMap>(map: &mut M, n_keys: usize) {
|
||||
println!(" Descending integers:");
|
||||
|
||||
timed("insert", || {
|
||||
|
|
@ -80,32 +80,31 @@ fn descending<M: MutableMap>(map: &mut M, n_keys: uint) {
|
|||
});
|
||||
}
|
||||
|
||||
fn vector<M: MutableMap>(map: &mut M, n_keys: uint, dist: &[uint]) {
|
||||
fn vector<M: MutableMap>(map: &mut M, n_keys: usize, dist: &[usize]) {
|
||||
timed("insert", || {
|
||||
for i in 0u..n_keys {
|
||||
for i in 0..n_keys {
|
||||
map.insert(dist[i], i + 1);
|
||||
}
|
||||
});
|
||||
|
||||
timed("search", || {
|
||||
for i in 0u..n_keys {
|
||||
for i in 0..n_keys {
|
||||
assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1));
|
||||
}
|
||||
});
|
||||
|
||||
timed("remove", || {
|
||||
for i in 0u..n_keys {
|
||||
for i in 0..n_keys {
|
||||
assert!(map.remove(&dist[i]));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let mut args = env::args();
|
||||
let n_keys = {
|
||||
if args.len() == 2 {
|
||||
args[1].parse::<uint>().unwrap()
|
||||
args.nth(1).unwrap().parse::<usize>().unwrap()
|
||||
} else {
|
||||
1000000
|
||||
}
|
||||
|
|
@ -131,18 +130,18 @@ fn main() {
|
|||
println!("{}", "\nBTreeMap:");
|
||||
|
||||
{
|
||||
let mut map: BTreeMap<uint,uint> = BTreeMap::new();
|
||||
let mut map: BTreeMap<usize,usize> = BTreeMap::new();
|
||||
ascending(&mut map, n_keys);
|
||||
}
|
||||
|
||||
{
|
||||
let mut map: BTreeMap<uint,uint> = BTreeMap::new();
|
||||
let mut map: BTreeMap<usize,usize> = BTreeMap::new();
|
||||
descending(&mut map, n_keys);
|
||||
}
|
||||
|
||||
{
|
||||
println!(" Random integers:");
|
||||
let mut map: BTreeMap<uint,uint> = BTreeMap::new();
|
||||
let mut map: BTreeMap<usize,usize> = BTreeMap::new();
|
||||
vector(&mut map, n_keys, &rand);
|
||||
}
|
||||
|
||||
|
|
@ -150,18 +149,18 @@ fn main() {
|
|||
println!("{}", "\nHashMap:");
|
||||
|
||||
{
|
||||
let mut map: HashMap<uint,uint> = HashMap::new();
|
||||
let mut map: HashMap<usize,usize> = HashMap::new();
|
||||
ascending(&mut map, n_keys);
|
||||
}
|
||||
|
||||
{
|
||||
let mut map: HashMap<uint,uint> = HashMap::new();
|
||||
let mut map: HashMap<usize,usize> = HashMap::new();
|
||||
descending(&mut map, n_keys);
|
||||
}
|
||||
|
||||
{
|
||||
println!(" Random integers:");
|
||||
let mut map: HashMap<uint,uint> = HashMap::new();
|
||||
let mut map: HashMap<usize,usize> = HashMap::new();
|
||||
vector(&mut map, n_keys, &rand);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use std::collections::BitvSet;
|
|||
use std::collections::HashSet;
|
||||
use std::collections::hash_map::Hasher;
|
||||
use std::hash::Hash;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::time::Duration;
|
||||
|
||||
struct Results {
|
||||
|
|
@ -53,29 +53,29 @@ impl<T: Ord> MutableSet<T> for BTreeSet<T> {
|
|||
fn remove(&mut self, k: &T) -> bool { self.remove(k) }
|
||||
fn contains(&self, k: &T) -> bool { self.contains(k) }
|
||||
}
|
||||
impl MutableSet<uint> for BitvSet {
|
||||
fn insert(&mut self, k: uint) { self.insert(k); }
|
||||
fn remove(&mut self, k: &uint) -> bool { self.remove(k) }
|
||||
fn contains(&self, k: &uint) -> bool { self.contains(k) }
|
||||
impl MutableSet<usize> for BitvSet {
|
||||
fn insert(&mut self, k: usize) { self.insert(k); }
|
||||
fn remove(&mut self, k: &usize) -> bool { self.remove(k) }
|
||||
fn contains(&self, k: &usize) -> bool { self.contains(k) }
|
||||
}
|
||||
|
||||
impl Results {
|
||||
pub fn bench_int<T:MutableSet<uint>,
|
||||
pub fn bench_int<T:MutableSet<usize>,
|
||||
R:rand::Rng,
|
||||
F:FnMut() -> T>(
|
||||
&mut self,
|
||||
rng: &mut R,
|
||||
num_keys: uint,
|
||||
rand_cap: uint,
|
||||
num_keys: usize,
|
||||
rand_cap: usize,
|
||||
mut f: F) {
|
||||
{
|
||||
let mut set = f();
|
||||
timed(&mut self.sequential_ints, || {
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
set.insert(i);
|
||||
}
|
||||
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
assert!(set.contains(&i));
|
||||
}
|
||||
})
|
||||
|
|
@ -85,19 +85,19 @@ impl Results {
|
|||
let mut set = f();
|
||||
timed(&mut self.random_ints, || {
|
||||
for _ in 0..num_keys {
|
||||
set.insert(rng.gen::<uint>() % rand_cap);
|
||||
set.insert(rng.gen::<usize>() % rand_cap);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
let mut set = f();
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
set.insert(i);
|
||||
}
|
||||
|
||||
timed(&mut self.delete_ints, || {
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
assert!(set.remove(&i));
|
||||
}
|
||||
})
|
||||
|
|
@ -109,16 +109,16 @@ impl Results {
|
|||
F:FnMut() -> T>(
|
||||
&mut self,
|
||||
rng: &mut R,
|
||||
num_keys: uint,
|
||||
num_keys: usize,
|
||||
mut f: F) {
|
||||
{
|
||||
let mut set = f();
|
||||
timed(&mut self.sequential_strings, || {
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
set.insert(i.to_string());
|
||||
}
|
||||
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
assert!(set.contains(&i.to_string()));
|
||||
}
|
||||
})
|
||||
|
|
@ -128,7 +128,7 @@ impl Results {
|
|||
let mut set = f();
|
||||
timed(&mut self.random_strings, || {
|
||||
for _ in 0..num_keys {
|
||||
let s = rng.gen::<uint>().to_string();
|
||||
let s = rng.gen::<usize>().to_string();
|
||||
set.insert(s);
|
||||
}
|
||||
})
|
||||
|
|
@ -136,11 +136,11 @@ impl Results {
|
|||
|
||||
{
|
||||
let mut set = f();
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
set.insert(i.to_string());
|
||||
}
|
||||
timed(&mut self.delete_strings, || {
|
||||
for i in 0u..num_keys {
|
||||
for i in 0..num_keys {
|
||||
assert!(set.remove(&i.to_string()));
|
||||
}
|
||||
})
|
||||
|
|
@ -179,11 +179,10 @@ fn empty_results() -> Results {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let mut args = env::args();
|
||||
let num_keys = {
|
||||
if args.len() == 2 {
|
||||
args[1].parse::<uint>().unwrap()
|
||||
args.nth(1).unwrap().parse::<usize>().unwrap()
|
||||
} else {
|
||||
100 // woefully inadequate for any real measurement
|
||||
}
|
||||
|
|
@ -196,7 +195,7 @@ fn main() {
|
|||
let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(seed);
|
||||
let mut results = empty_results();
|
||||
results.bench_int(&mut rng, num_keys, max, || {
|
||||
let s: HashSet<uint> = HashSet::new();
|
||||
let s: HashSet<usize> = HashSet::new();
|
||||
s
|
||||
});
|
||||
results.bench_str(&mut rng, num_keys, || {
|
||||
|
|
@ -210,7 +209,7 @@ fn main() {
|
|||
let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(seed);
|
||||
let mut results = empty_results();
|
||||
results.bench_int(&mut rng, num_keys, max, || {
|
||||
let s: BTreeSet<uint> = BTreeSet::new();
|
||||
let s: BTreeSet<usize> = BTreeSet::new();
|
||||
s
|
||||
});
|
||||
results.bench_str(&mut rng, num_keys, || {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
use std::old_io::File;
|
||||
use std::iter::repeat;
|
||||
use std::mem::swap;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::rand::Rng;
|
||||
use std::rand;
|
||||
|
|
@ -25,8 +24,7 @@ use std::time::Duration;
|
|||
use std::vec;
|
||||
|
||||
fn main() {
|
||||
let argv = os::args();
|
||||
let _tests = &argv[1..argv.len()];
|
||||
let argv: Vec<String> = env::args().collect();
|
||||
|
||||
macro_rules! bench {
|
||||
($id:ident) =>
|
||||
|
|
|
|||
|
|
@ -8,17 +8,16 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "10000000".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
vec!("".to_string(), "100000".to_string())
|
||||
} else {
|
||||
args.into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
|
||||
let n = args[1].parse().unwrap();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@
|
|||
// version.
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn move_out<T>(_x: T) {}
|
||||
|
|
@ -64,7 +63,7 @@ fn run(args: &[String]) {
|
|||
let mut worker_results = Vec::new();
|
||||
for _ in 0u..workers {
|
||||
let to_child = to_child.clone();
|
||||
worker_results.push(Thread::scoped(move|| {
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes)).unwrap();
|
||||
|
|
@ -72,7 +71,7 @@ fn run(args: &[String]) {
|
|||
//println!("worker {} exiting", i);
|
||||
}));
|
||||
}
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
server(&from_parent, &to_parent);
|
||||
});
|
||||
|
||||
|
|
@ -94,13 +93,13 @@ fn run(args: &[String]) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "1000000".to_string(), "10000".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "10000".to_string(), "4".to_string())
|
||||
} else {
|
||||
args.into_iter().map(|x| x.to_string()).collect()
|
||||
args.map(|x| x.to_string()).collect()
|
||||
};
|
||||
|
||||
println!("{:?}", args);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@
|
|||
// I *think* it's the same, more or less.
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
enum request {
|
||||
|
|
@ -57,7 +56,7 @@ fn run(args: &[String]) {
|
|||
let mut worker_results = Vec::new();
|
||||
let from_parent = if workers == 1 {
|
||||
let (to_child, from_parent) = channel();
|
||||
worker_results.push(Thread::scoped(move|| {
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes));
|
||||
|
|
@ -69,7 +68,7 @@ fn run(args: &[String]) {
|
|||
let (to_child, from_parent) = channel();
|
||||
for _ in 0u..workers {
|
||||
let to_child = to_child.clone();
|
||||
worker_results.push(Thread::scoped(move|| {
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes));
|
||||
|
|
@ -79,7 +78,7 @@ fn run(args: &[String]) {
|
|||
}
|
||||
from_parent
|
||||
};
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
server(&from_parent, &to_parent);
|
||||
});
|
||||
|
||||
|
|
@ -101,13 +100,13 @@ fn run(args: &[String]) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "1000000".to_string(), "8".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "10000".to_string(), "4".to_string())
|
||||
} else {
|
||||
args.clone().into_iter().map(|x| x.to_string()).collect()
|
||||
args.map(|x| x.to_string()).collect()
|
||||
};
|
||||
|
||||
println!("{:?}", args);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
// no-pretty-expanded FIXME #15189
|
||||
// ignore-lexer-test FIXME #15679
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::sync::{Arc, Future, Mutex, Condvar};
|
||||
use std::time::Duration;
|
||||
|
|
@ -64,13 +63,13 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "100".to_string(), "10000".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "10".to_string(), "100".to_string())
|
||||
} else {
|
||||
args.clone().into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
|
||||
let num_tasks = args[1].parse::<uint>().unwrap();
|
||||
|
|
|
|||
|
|
@ -18,24 +18,24 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::sync::mpsc::channel;
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::env;
|
||||
use std::thread;
|
||||
|
||||
// This is a simple bench that creates M pairs of tasks. These
|
||||
// tasks ping-pong back and forth over a pair of streams. This is a
|
||||
// canonical message-passing benchmark as it heavily strains message
|
||||
// passing and almost nothing else.
|
||||
|
||||
fn ping_pong_bench(n: uint, m: uint) {
|
||||
fn ping_pong_bench(n: usize, m: usize) {
|
||||
|
||||
// Create pairs of tasks that pingpong back and forth.
|
||||
fn run_pair(n: uint) {
|
||||
fn run_pair(n: usize) {
|
||||
// Create a channel: A->B
|
||||
let (atx, arx) = channel();
|
||||
// Create a channel: B->A
|
||||
let (btx, brx) = channel();
|
||||
|
||||
let guard_a = Thread::scoped(move|| {
|
||||
let guard_a = thread::spawn(move|| {
|
||||
let (tx, rx) = (atx, brx);
|
||||
for _ in 0..n {
|
||||
tx.send(()).unwrap();
|
||||
|
|
@ -43,7 +43,7 @@ fn ping_pong_bench(n: uint, m: uint) {
|
|||
}
|
||||
});
|
||||
|
||||
let guard_b = Thread::scoped(move|| {
|
||||
let guard_b = thread::spawn(move|| {
|
||||
let (tx, rx) = (btx, arx);
|
||||
for _ in 0..n {
|
||||
rx.recv().unwrap();
|
||||
|
|
@ -63,19 +63,13 @@ fn ping_pong_bench(n: uint, m: uint) {
|
|||
|
||||
|
||||
fn main() {
|
||||
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let n = if args.len() == 3 {
|
||||
args[1].parse::<uint>().unwrap()
|
||||
let mut args = env::args();
|
||||
let (n, m) = if args.len() == 3 {
|
||||
let n = args.nth(1).unwrap().parse::<usize>().unwrap();
|
||||
let m = args.next().unwrap().parse::<usize>().unwrap();
|
||||
(n, m)
|
||||
} else {
|
||||
10000
|
||||
};
|
||||
|
||||
let m = if args.len() == 3 {
|
||||
args[2].parse::<uint>().unwrap()
|
||||
} else {
|
||||
4
|
||||
(10000, 4)
|
||||
};
|
||||
|
||||
ping_pong_bench(n, m);
|
||||
|
|
|
|||
|
|
@ -9,20 +9,20 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::sync::mpsc::channel;
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::env;
|
||||
use std::thread;
|
||||
|
||||
// A simple implementation of parfib. One subtree is found in a new
|
||||
// task and communicated over a oneshot pipe, the other is found
|
||||
// locally. There is no sequential-mode threshold.
|
||||
|
||||
fn parfib(n: uint) -> uint {
|
||||
fn parfib(n: u64) -> u64 {
|
||||
if n == 0 || n == 1 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
let (tx, rx) = channel();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
tx.send(parfib(n-1)).unwrap();
|
||||
});
|
||||
let m2 = parfib(n-2);
|
||||
|
|
@ -30,11 +30,9 @@ fn parfib(n: uint) -> uint {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let mut args = env::args();
|
||||
let n = if args.len() == 2 {
|
||||
args[1].parse::<uint>().unwrap()
|
||||
args.nth(1).unwrap().parse::<u64>().unwrap()
|
||||
} else {
|
||||
10
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn ack(m: int, n: int) -> int {
|
||||
fn ack(m: i64, n: i64) -> i64 {
|
||||
if m == 0 {
|
||||
return n + 1
|
||||
} else {
|
||||
|
|
@ -24,13 +23,13 @@ fn ack(m: int, n: int) -> int {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let mut args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "12".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "8".to_string())
|
||||
} else {
|
||||
args.into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
let n = args[1].parse().unwrap();
|
||||
println!("Ack(3,{}): {}\n", n, ack(3, n));
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
extern crate arena;
|
||||
|
||||
use std::iter::range_step;
|
||||
use std::thread::{Thread, JoinGuard};
|
||||
use std::thread;
|
||||
use arena::TypedArena;
|
||||
|
||||
struct Tree<'a> {
|
||||
|
|
@ -84,14 +84,13 @@ fn inner(depth: i32, iterations: i32) -> String {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = std::os::args();
|
||||
let args = args;
|
||||
let mut args = std::env::args();
|
||||
let n = if std::env::var_os("RUST_BENCH").is_some() {
|
||||
17
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
8
|
||||
} else {
|
||||
args[1].parse().unwrap()
|
||||
args.nth(1).unwrap().parse().unwrap()
|
||||
};
|
||||
let min_depth = 4;
|
||||
let max_depth = if min_depth + 2 > n {min_depth + 2} else {n};
|
||||
|
|
@ -111,11 +110,11 @@ fn main() {
|
|||
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||
use std::num::Int;
|
||||
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
|
||||
Thread::scoped(move || inner(depth, iterations))
|
||||
thread::scoped(move || inner(depth, iterations))
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
for message in messages {
|
||||
println!("{}", message.join().ok().unwrap());
|
||||
println!("{}", message.join());
|
||||
}
|
||||
|
||||
println!("long lived tree of depth {}\t check: {}",
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
use self::Color::{Red, Yellow, Blue};
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::fmt;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn print_complements() {
|
||||
let all = [Blue, Red, Yellow];
|
||||
|
|
@ -187,7 +187,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
|
|||
let to_rendezvous = to_rendezvous.clone();
|
||||
let to_rendezvous_log = to_rendezvous_log.clone();
|
||||
let (to_creature, from_rendezvous) = channel();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
creature(ii,
|
||||
col,
|
||||
from_rendezvous,
|
||||
|
|
@ -230,10 +230,10 @@ fn main() {
|
|||
let nn = if std::env::var_os("RUST_BENCH").is_some() {
|
||||
200000
|
||||
} else {
|
||||
std::os::args()
|
||||
.get(1)
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.and_then(|arg| arg.parse().ok())
|
||||
.unwrap_or(600u)
|
||||
.unwrap_or(600us)
|
||||
};
|
||||
|
||||
print_complements();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use std::{cmp, iter, mem};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn rotate(x: &mut [i32]) {
|
||||
let mut prev = x[0];
|
||||
|
|
@ -164,7 +164,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
for (_, j) in (0..N).zip(iter::count(0, k)) {
|
||||
let max = cmp::min(j+k, perm.max());
|
||||
|
||||
futures.push(Thread::scoped(move|| {
|
||||
futures.push(thread::scoped(move|| {
|
||||
work(perm, j as uint, max as uint)
|
||||
}))
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
let mut checksum = 0;
|
||||
let mut maxflips = 0;
|
||||
for fut in futures {
|
||||
let (cs, mf) = fut.join().ok().unwrap();
|
||||
let (cs, mf) = fut.join();
|
||||
checksum += cs;
|
||||
maxflips = cmp::max(maxflips, mf);
|
||||
}
|
||||
|
|
@ -180,8 +180,8 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let n = std::os::args()
|
||||
.get(1)
|
||||
let n = std::env::args()
|
||||
.nth(1)
|
||||
.and_then(|arg| arg.parse().ok())
|
||||
.unwrap_or(2i32);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@
|
|||
use std::cmp::min;
|
||||
use std::old_io::{stdout, IoResult};
|
||||
use std::iter::repeat;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::slice::bytes::copy_memory;
|
||||
|
||||
const LINE_LEN: uint = 60;
|
||||
const LOOKUP_SIZE: uint = 4 * 1024;
|
||||
const LINE_LEN: usize = 60;
|
||||
const LOOKUP_SIZE: usize = 4 * 1024;
|
||||
const LOOKUP_SCALE: f32 = (LOOKUP_SIZE - 1) as f32;
|
||||
|
||||
// Random number generator constants
|
||||
|
|
@ -119,7 +119,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
|
|||
RepeatFasta { alu: alu, out: w }
|
||||
}
|
||||
|
||||
fn make(&mut self, n: uint) -> IoResult<()> {
|
||||
fn make(&mut self, n: usize) -> IoResult<()> {
|
||||
let alu_len = self.alu.len();
|
||||
let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>();
|
||||
let alu: &[u8] = self.alu.as_bytes();
|
||||
|
|
@ -188,19 +188,19 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
|
|||
0
|
||||
}
|
||||
|
||||
fn make(&mut self, n: uint) -> IoResult<()> {
|
||||
fn make(&mut self, n: usize) -> IoResult<()> {
|
||||
let lines = n / LINE_LEN;
|
||||
let chars_left = n % LINE_LEN;
|
||||
let mut buf = [0;LINE_LEN + 1];
|
||||
|
||||
for _ in 0..lines {
|
||||
for i in 0u..LINE_LEN {
|
||||
for i in 0..LINE_LEN {
|
||||
buf[i] = self.nextc();
|
||||
}
|
||||
buf[LINE_LEN] = '\n' as u8;
|
||||
try!(self.out.write(&buf));
|
||||
}
|
||||
for i in 0u..chars_left {
|
||||
for i in 0..chars_left {
|
||||
buf[i] = self.nextc();
|
||||
}
|
||||
self.out.write(&buf[..chars_left])
|
||||
|
|
@ -208,10 +208,9 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let mut args = env::args();
|
||||
let n = if args.len() > 1 {
|
||||
args[1].parse::<uint>().unwrap()
|
||||
args.nth(1).unwrap().parse::<usize>().unwrap()
|
||||
} else {
|
||||
5
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,10 +42,9 @@ use std::cmp::min;
|
|||
use std::old_io::{BufferedWriter, File};
|
||||
use std::old_io;
|
||||
use std::num::Float;
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
const LINE_LENGTH: uint = 60;
|
||||
const LINE_LENGTH: usize = 60;
|
||||
const IM: u32 = 139968;
|
||||
|
||||
struct MyRandom {
|
||||
|
|
@ -86,7 +85,7 @@ impl<'a> Iterator for AAGen<'a> {
|
|||
}
|
||||
|
||||
fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
|
||||
wr: &mut W, header: &str, mut it: I, mut n: uint)
|
||||
wr: &mut W, header: &str, mut it: I, mut n: usize)
|
||||
-> std::old_io::IoResult<()>
|
||||
{
|
||||
try!(wr.write(header.as_bytes()));
|
||||
|
|
@ -104,14 +103,13 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
|
|||
}
|
||||
|
||||
fn run<W: Writer>(writer: &mut W) -> std::old_io::IoResult<()> {
|
||||
let args = os::args();
|
||||
let args = args;
|
||||
let mut args = env::args();
|
||||
let n = if env::var_os("RUST_BENCH").is_some() {
|
||||
25000000
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
1000
|
||||
} else {
|
||||
args[1].parse().unwrap()
|
||||
args.nth(1).unwrap().parse().unwrap()
|
||||
};
|
||||
|
||||
let rng = &mut MyRandom::new();
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn fib(n: int) -> int {
|
||||
fn fib(n: i64) -> i64 {
|
||||
if n < 2 {
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -20,13 +19,13 @@ fn fib(n: int) -> int {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "40".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "30".to_string())
|
||||
} else {
|
||||
args.into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
let n = args[1].parse().unwrap();
|
||||
println!("{}\n", fib(n));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::option;
|
|||
use std::os;
|
||||
use std::env;
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn f64_cmp(x: f64, y: f64) -> Ordering {
|
||||
// arbitrarily decide that NaNs are larger than everything.
|
||||
|
|
@ -172,7 +172,7 @@ fn main() {
|
|||
|
||||
let (to_child, from_parent) = channel();
|
||||
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
make_sequence_processor(sz, &from_parent, &to_parent_);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
use std::ascii::OwnedAsciiExt;
|
||||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
static TABLE: [u8;4] = [ 'A' as u8, 'C' as u8, 'G' as u8, 'T' as u8 ];
|
||||
static TABLE_SIZE: uint = 2 << 16;
|
||||
|
|
@ -303,17 +303,17 @@ fn main() {
|
|||
|
||||
let nb_freqs: Vec<_> = (1u..3).map(|i| {
|
||||
let input = input.clone();
|
||||
(i, Thread::scoped(move|| generate_frequencies(&input, i)))
|
||||
(i, thread::scoped(move|| generate_frequencies(&input, i)))
|
||||
}).collect();
|
||||
let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
|
||||
let input = input.clone();
|
||||
Thread::scoped(move|| generate_frequencies(&input, occ.len()))
|
||||
thread::scoped(move|| generate_frequencies(&input, occ.len()))
|
||||
}).collect();
|
||||
|
||||
for (i, freq) in nb_freqs {
|
||||
print_frequencies(&freq.join().ok().unwrap(), i);
|
||||
print_frequencies(&freq.join(), i);
|
||||
}
|
||||
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {
|
||||
print_occurrences(&mut freq.join().ok().unwrap(), occ);
|
||||
print_occurrences(&mut freq.join(), occ);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@
|
|||
// ignore-pretty very bad with line comments
|
||||
|
||||
use std::old_io;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::simd::f64x2;
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
const ITER: usize = 50;
|
||||
const LIMIT: f64 = 2.0;
|
||||
|
|
@ -81,7 +81,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
|||
let mut precalc_i = Vec::with_capacity(h);
|
||||
|
||||
let precalc_futures = (0..WORKERS).map(|i| {
|
||||
Thread::scoped(move|| {
|
||||
thread::scoped(move|| {
|
||||
let mut rs = Vec::with_capacity(w / WORKERS);
|
||||
let mut is = Vec::with_capacity(w / WORKERS);
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
|||
}).collect::<Vec<_>>();
|
||||
|
||||
for res in precalc_futures {
|
||||
let (rs, is) = res.join().ok().unwrap();
|
||||
let (rs, is) = res.join();
|
||||
precalc_r.extend(rs.into_iter());
|
||||
precalc_i.extend(is.into_iter());
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
|||
let vec_init_r = arc_init_r.clone();
|
||||
let vec_init_i = arc_init_i.clone();
|
||||
|
||||
Thread::scoped(move|| {
|
||||
thread::scoped(move|| {
|
||||
let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
|
||||
let init_r_slice = vec_init_r;
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
|||
|
||||
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
|
||||
for res in data {
|
||||
try!(out.write(&res.join().ok().unwrap()));
|
||||
try!(out.write(&res.join()));
|
||||
}
|
||||
out.flush()
|
||||
}
|
||||
|
|
@ -197,13 +197,13 @@ fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec<u8>) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let mut args = env::args();
|
||||
let res = if args.len() < 2 {
|
||||
println!("Test mode: do not dump the image because it's not utf8, \
|
||||
which interferes with the test runner.");
|
||||
mandelbrot(1000, old_io::util::NullWriter)
|
||||
} else {
|
||||
mandelbrot(args[1].parse().unwrap(), old_io::stdout())
|
||||
mandelbrot(args.nth(1).unwrap().parse().unwrap(), old_io::stdout())
|
||||
};
|
||||
res.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
use std::iter::repeat;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
//
|
||||
// Utilities.
|
||||
|
|
@ -317,7 +317,7 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
|
|||
let masks = masks.clone();
|
||||
let tx = tx.clone();
|
||||
let m = *m;
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
let mut data = Data::new();
|
||||
search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data);
|
||||
tx.send(data).unwrap();
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ fn main() {
|
|||
let n = if std::env::var_os("RUST_BENCH").is_some() {
|
||||
5000000
|
||||
} else {
|
||||
std::os::args().get(1)
|
||||
std::env::args().nth(1)
|
||||
.and_then(|arg| arg.parse().ok())
|
||||
.unwrap_or(1000)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,14 +21,13 @@
|
|||
extern crate getopts;
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::result::Result::{Ok, Err};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn fib(n: int) -> int {
|
||||
fn pfib(tx: &Sender<int>, n: int) {
|
||||
fn fib(n: isize) -> isize {
|
||||
fn pfib(tx: &Sender<isize>, n: isize) {
|
||||
if n == 0 {
|
||||
tx.send(0).unwrap();
|
||||
} else if n <= 2 {
|
||||
|
|
@ -36,15 +35,15 @@ fn fib(n: int) -> int {
|
|||
} else {
|
||||
let (tx1, rx) = channel();
|
||||
let tx2 = tx1.clone();
|
||||
Thread::spawn(move|| pfib(&tx2, n - 1));
|
||||
thread::spawn(move|| pfib(&tx2, n - 1));
|
||||
let tx2 = tx1.clone();
|
||||
Thread::spawn(move|| pfib(&tx2, n - 2));
|
||||
thread::spawn(move|| pfib(&tx2, n - 2));
|
||||
tx.send(rx.recv().unwrap() + rx.recv().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
let (tx, rx) = channel();
|
||||
Thread::spawn(move|| pfib(&tx, n) );
|
||||
thread::spawn(move|| pfib(&tx, n) );
|
||||
rx.recv().unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ fn parse_opts(argv: Vec<String> ) -> Config {
|
|||
}
|
||||
}
|
||||
|
||||
fn stress_task(id: int) {
|
||||
fn stress_task(id: isize) {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
let n = 15;
|
||||
|
|
@ -79,7 +78,7 @@ fn stress_task(id: int) {
|
|||
fn stress(num_tasks: int) {
|
||||
let mut results = Vec::new();
|
||||
for i in 0..num_tasks {
|
||||
results.push(Thread::scoped(move|| {
|
||||
results.push(thread::spawn(move|| {
|
||||
stress_task(i);
|
||||
}));
|
||||
}
|
||||
|
|
@ -89,13 +88,13 @@ fn stress(num_tasks: int) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "20".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "8".to_string())
|
||||
} else {
|
||||
args.into_iter().map(|x| x.to_string()).collect()
|
||||
args.map(|x| x.to_string()).collect()
|
||||
};
|
||||
|
||||
let opts = parse_opts(args.clone());
|
||||
|
|
@ -103,12 +102,12 @@ fn main() {
|
|||
if opts.stress {
|
||||
stress(2);
|
||||
} else {
|
||||
let max = args[1].parse::<int>().unwrap();
|
||||
let max = args[1].parse::<isize>().unwrap();
|
||||
|
||||
let num_trials = 10;
|
||||
|
||||
for n in 1..max + 1 {
|
||||
for _ in 0u..num_trials {
|
||||
for _ in 0..num_trials {
|
||||
let mut fibn = None;
|
||||
let dur = Duration::span(|| fibn = Some(fib(n)));
|
||||
let fibn = fibn.unwrap();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ extern crate libc;
|
|||
use std::old_io::stdio::{stdin_raw, stdout_raw};
|
||||
use std::old_io::{IoResult, EndOfFile};
|
||||
use std::ptr::{copy_memory, Unique};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
struct Tables {
|
||||
table8: [u8;1 << 8],
|
||||
|
|
@ -229,21 +229,12 @@ unsafe impl<T: 'static> Send for Racy<T> {}
|
|||
|
||||
/// Executes a closure in parallel over the given iterator over mutable slice.
|
||||
/// The closure `f` is run in parallel with an element of `iter`.
|
||||
fn parallel<'a, I, T, F>(iter: I, f: F)
|
||||
where T: 'a+Send + Sync,
|
||||
I: Iterator<Item=&'a mut [T]>,
|
||||
F: Fn(&mut [T]) + Sync {
|
||||
use std::mem;
|
||||
use std::raw::Repr;
|
||||
|
||||
iter.map(|chunk| {
|
||||
// Need to convert `f` and `chunk` to something that can cross the task
|
||||
// boundary.
|
||||
let f = Racy(&f as *const F as *const uint);
|
||||
let raw = Racy(chunk.repr());
|
||||
Thread::scoped(move|| {
|
||||
let f = f.0 as *const F;
|
||||
unsafe { (*f)(mem::transmute(raw.0)) }
|
||||
fn parallel<'a, I: Iterator, F>(iter: I, ref f: F)
|
||||
where I::Item: Send + 'a,
|
||||
F: Fn(I::Item) + Sync + 'a {
|
||||
iter.map(|x| {
|
||||
thread::scoped(move|| {
|
||||
f(x)
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::iter::{repeat, AdditiveIterator};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::mem;
|
||||
use std::num::Float;
|
||||
use std::os;
|
||||
|
|
@ -53,13 +53,13 @@ use std::raw::Repr;
|
|||
use std::simd::f64x2;
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let mut args = env::args();
|
||||
let answer = spectralnorm(if env::var_os("RUST_BENCH").is_some() {
|
||||
5500
|
||||
} else if args.len() < 2 {
|
||||
2000
|
||||
} else {
|
||||
args[1].parse().unwrap()
|
||||
args.nth(1).unwrap().parse().unwrap()
|
||||
});
|
||||
println!("{:.9}", answer);
|
||||
}
|
||||
|
|
@ -112,26 +112,16 @@ fn dot(v: &[f64], u: &[f64]) -> f64 {
|
|||
}
|
||||
|
||||
|
||||
struct Racy<T>(T);
|
||||
|
||||
unsafe impl<T: 'static> Send for Racy<T> {}
|
||||
|
||||
// Executes a closure in parallel over the given mutable slice. The closure `f`
|
||||
// is run in parallel and yielded the starting index within `v` as well as a
|
||||
// sub-slice of `v`.
|
||||
fn parallel<T, F>(v: &mut [T], f: F)
|
||||
where T: Send + Sync,
|
||||
F: Fn(uint, &mut [T]) + Sync {
|
||||
fn parallel<'a,T, F>(v: &mut [T], ref f: F)
|
||||
where T: Send + Sync + 'a,
|
||||
F: Fn(uint, &mut [T]) + Sync + 'a {
|
||||
let size = v.len() / os::num_cpus() + 1;
|
||||
|
||||
v.chunks_mut(size).enumerate().map(|(i, chunk)| {
|
||||
// Need to convert `f` and `chunk` to something that can cross the task
|
||||
// boundary.
|
||||
let f = Racy(&f as *const _ as *const uint);
|
||||
let raw = Racy(chunk.repr());
|
||||
Thread::scoped(move|| {
|
||||
let f = f.0 as *const F;
|
||||
unsafe { (*f)(i * size, mem::transmute(raw.0)) }
|
||||
thread::scoped(move|| {
|
||||
f(i * size, chunk)
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn start(n_tasks: i32, token: i32) {
|
||||
let (tx, mut rx) = channel();
|
||||
|
|
@ -48,9 +48,9 @@ fn start(n_tasks: i32, token: i32) {
|
|||
for i in 2 .. n_tasks + 1 {
|
||||
let (tx, next_rx) = channel();
|
||||
let cur_rx = std::mem::replace(&mut rx, next_rx);
|
||||
guards.push(Thread::scoped(move|| roundtrip(i, tx, cur_rx)));
|
||||
guards.push(thread::spawn(move|| roundtrip(i, tx, cur_rx)));
|
||||
}
|
||||
let guard = Thread::scoped(move|| roundtrip(1, tx, rx));
|
||||
let guard = thread::spawn(move|| roundtrip(1, tx, rx));
|
||||
}
|
||||
|
||||
fn roundtrip(id: i32, tx: Sender<i32>, rx: Receiver<i32>) {
|
||||
|
|
@ -64,13 +64,13 @@ fn roundtrip(id: i32, tx: Sender<i32>, rx: Receiver<i32>) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = std::os::args();
|
||||
let mut args = std::env::args();
|
||||
let token = if std::env::var_os("RUST_BENCH").is_some() {
|
||||
2000000
|
||||
} else {
|
||||
args.get(1).and_then(|arg| arg.parse().ok()).unwrap_or(1000)
|
||||
args.nth(1).and_then(|arg| arg.parse().ok()).unwrap_or(1000)
|
||||
};
|
||||
let n_tasks = args.get(2)
|
||||
let n_tasks = args.next()
|
||||
.and_then(|arg| arg.parse().ok())
|
||||
.unwrap_or(503);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,41 +11,40 @@
|
|||
// Microbenchmark for the smallintmap library
|
||||
|
||||
use std::collections::VecMap;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::time::Duration;
|
||||
|
||||
fn append_sequential(min: uint, max: uint, map: &mut VecMap<uint>) {
|
||||
fn append_sequential(min: usize, max: usize, map: &mut VecMap<usize>) {
|
||||
for i in min..max {
|
||||
map.insert(i, i + 22u);
|
||||
map.insert(i, i + 22);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_sequential(min: uint, max: uint, map: &VecMap<uint>) {
|
||||
fn check_sequential(min: usize, max: usize, map: &VecMap<usize>) {
|
||||
for i in min..max {
|
||||
assert_eq!(map[i], i + 22u);
|
||||
assert_eq!(map[i], i + 22);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "100000".to_string(), "100".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "10000".to_string(), "50".to_string())
|
||||
} else {
|
||||
args.into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
let max = args[1].parse::<uint>().unwrap();
|
||||
let rep = args[2].parse::<uint>().unwrap();
|
||||
let max = args[1].parse::<usize>().unwrap();
|
||||
let rep = args[2].parse::<usize>().unwrap();
|
||||
|
||||
let mut checkf = Duration::seconds(0);
|
||||
let mut appendf = Duration::seconds(0);
|
||||
|
||||
for _ in 0u..rep {
|
||||
for _ in 0..rep {
|
||||
let mut map = VecMap::new();
|
||||
let d1 = Duration::span(|| append_sequential(0u, max, &mut map));
|
||||
let d2 = Duration::span(|| check_sequential(0u, max, &map));
|
||||
let d1 = Duration::span(|| append_sequential(0, max, &mut map));
|
||||
let d2 = Duration::span(|| check_sequential(0, max, &map));
|
||||
|
||||
checkf = checkf + d2;
|
||||
appendf = appendf + d1;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use std::old_io::stdio::StdReader;
|
|||
use std::old_io;
|
||||
use std::iter::repeat;
|
||||
use std::num::Int;
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
// Computes a single solution to a given 9x9 sudoku
|
||||
//
|
||||
|
|
@ -269,8 +269,8 @@ fn check_DEFAULT_SUDOKU_solution() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let use_default = args.len() == 1u;
|
||||
let args = env::args();
|
||||
let use_default = args.len() == 1;
|
||||
let mut sudoku = if use_default {
|
||||
Sudoku::from_vec(&DEFAULT_SUDOKU)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![feature(unsafe_destructor, box_syntax)]
|
||||
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -32,7 +32,7 @@ fn main() {
|
|||
fn run(repeat: int, depth: int) {
|
||||
for _ in 0..repeat {
|
||||
let dur = Duration::span(|| {
|
||||
let _ = Thread::scoped(move|| {
|
||||
let _ = thread::spawn(move|| {
|
||||
recurse_or_panic(depth, None)
|
||||
}).join();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,17 +18,16 @@
|
|||
// ignore-pretty very bad with line comments
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn child_generation(gens_left: uint, tx: Sender<()>) {
|
||||
// This used to be O(n^2) in the number of generations that ever existed.
|
||||
// With this code, only as many generations are alive at a time as tasks
|
||||
// alive at a time,
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
if gens_left & 1 == 1 {
|
||||
Thread::yield_now(); // shake things up a bit
|
||||
thread::yield_now(); // shake things up a bit
|
||||
}
|
||||
if gens_left > 0 {
|
||||
child_generation(gens_left - 1, tx); // recurse
|
||||
|
|
@ -39,13 +38,13 @@ fn child_generation(gens_left: uint, tx: Sender<()>) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "100000".to_string())
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "100".to_string())
|
||||
} else {
|
||||
args.clone().into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
|
||||
let (tx, rx) = channel();
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn f(n: uint) {
|
||||
fn f(n: usize) {
|
||||
let mut i = 0u;
|
||||
while i < n {
|
||||
let _ = Thread::scoped(move|| g()).join();
|
||||
let _ = thread::spawn(move|| g()).join();
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,15 +22,15 @@ fn f(n: uint) {
|
|||
fn g() { }
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "400".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "10".to_string())
|
||||
} else {
|
||||
args.into_iter().collect()
|
||||
args.collect()
|
||||
};
|
||||
let n = args[1].parse().unwrap();
|
||||
let mut i = 0u;
|
||||
while i < n { Thread::spawn(move|| f(n) ); i += 1u; }
|
||||
let mut i = 0;
|
||||
while i < n { thread::spawn(move|| f(n) ); i += 1; }
|
||||
}
|
||||
|
|
|
|||
15
src/test/compile-fail/asm-gated2.rs
Normal file
15
src/test/compile-fail/asm-gated2.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
println!("{}", asm!("")); //~ ERROR inline assembly is not stable
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
|
||||
f(v);
|
||||
|
|
@ -19,7 +19,7 @@ fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
|
|||
fn box_imm() {
|
||||
let v = box 3;
|
||||
let _w = &v;
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
println!("v={}", *v);
|
||||
//~^ ERROR cannot move `v` into closure
|
||||
});
|
||||
|
|
@ -28,7 +28,7 @@ fn box_imm() {
|
|||
fn box_imm_explicit() {
|
||||
let v = box 3;
|
||||
let _w = &v;
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
println!("v={}", *v);
|
||||
//~^ ERROR cannot move
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn borrow<T>(_: &T) { }
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ fn different_vars_after_borrows() {
|
|||
let p1 = &x1;
|
||||
let x2 = box 2;
|
||||
let p2 = &x2;
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed
|
||||
drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed
|
||||
});
|
||||
|
|
@ -32,7 +32,7 @@ fn different_vars_after_moves() {
|
|||
drop(x1);
|
||||
let x2 = box 2;
|
||||
drop(x2);
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
drop(x1); //~ ERROR capture of moved value: `x1`
|
||||
drop(x2); //~ ERROR capture of moved value: `x2`
|
||||
});
|
||||
|
|
@ -41,7 +41,7 @@ fn different_vars_after_moves() {
|
|||
fn same_var_after_borrow() {
|
||||
let x = box 1;
|
||||
let p = &x;
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
drop(x); //~ ERROR cannot move `x` into closure because it is borrowed
|
||||
drop(x); //~ ERROR use of moved value: `x`
|
||||
});
|
||||
|
|
@ -51,7 +51,7 @@ fn same_var_after_borrow() {
|
|||
fn same_var_after_move() {
|
||||
let x = box 1;
|
||||
drop(x);
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
drop(x); //~ ERROR capture of moved value: `x`
|
||||
drop(x); //~ ERROR use of moved value: `x`
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
trait Foo : Send { }
|
||||
|
||||
impl <'a> Foo for &'a mut () { }
|
||||
//~^ ERROR the type `&'a mut ()` does not fulfill the required lifetime
|
||||
impl Foo for std::rc::Rc<i8> { }
|
||||
//~^ ERROR the trait `core::marker::Send` is not implemented
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
use std::marker::Send;
|
||||
|
||||
enum TestE {
|
||||
|
|
@ -16,18 +18,21 @@ enum TestE {
|
|||
|
||||
struct MyType;
|
||||
|
||||
struct NotSync;
|
||||
impl !Sync for NotSync {}
|
||||
|
||||
unsafe impl Send for TestE {}
|
||||
unsafe impl Send for MyType {}
|
||||
unsafe impl Send for (MyType, MyType) {}
|
||||
//~^ ERROR builtin traits can only be implemented on structs or enums
|
||||
|
||||
unsafe impl Send for &'static MyType {}
|
||||
unsafe impl Send for &'static NotSync {}
|
||||
//~^ ERROR builtin traits can only be implemented on structs or enums
|
||||
|
||||
unsafe impl Send for [MyType] {}
|
||||
//~^ ERROR builtin traits can only be implemented on structs or enums
|
||||
|
||||
unsafe impl Send for &'static [MyType] {}
|
||||
unsafe impl Send for &'static [NotSync] {}
|
||||
//~^ ERROR builtin traits can only be implemented on structs or enums
|
||||
|
||||
fn is_send<T: Send>() {}
|
||||
|
|
|
|||
19
src/test/compile-fail/concat_idents-gate.rs
Normal file
19
src/test/compile-fail/concat_idents-gate.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const XY_1: i32 = 10;
|
||||
|
||||
fn main() {
|
||||
const XY_2: i32 = 20;
|
||||
let a = concat_idents!(X, Y_1); //~ ERROR `concat_idents` is not stable
|
||||
let b = concat_idents!(X, Y_2); //~ ERROR `concat_idents` is not stable
|
||||
assert_eq!(a, 10);
|
||||
assert_eq!(b, 20);
|
||||
}
|
||||
17
src/test/compile-fail/concat_idents-gate2.rs
Normal file
17
src/test/compile-fail/concat_idents-gate2.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const XY_1: i32 = 10;
|
||||
|
||||
fn main() {
|
||||
const XY_2: i32 = 20;
|
||||
assert_eq!(10, concat_idents!(X, Y_1)); //~ ERROR `concat_idents` is not stable
|
||||
assert_eq!(20, concat_idents!(X, Y_2)); //~ ERROR `concat_idents` is not stable
|
||||
}
|
||||
14
src/test/compile-fail/custom_attribute.rs
Normal file
14
src/test/compile-fail/custom_attribute.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[foo] //~ ERROR The attribute `foo`
|
||||
fn main() {
|
||||
|
||||
}
|
||||
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| -> () {
|
||||
let _t = thread::spawn(move|| -> () {
|
||||
loop {
|
||||
let tx = tx;
|
||||
//~^ ERROR: use of moved value: `tx`
|
||||
|
|
|
|||
|
|
@ -9,47 +9,47 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::{int, i8, i16, i32, i64};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
assert!(Thread::scoped(move|| int::MIN / -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { int::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempted to divide with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i8::MIN / -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempted to divide with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i16::MIN / -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempted to divide with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i32::MIN / -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempted to divide with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i64::MIN / -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempted to divide with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| 1is / 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1is / 0; }).join().is_err());
|
||||
//~^ ERROR attempted to divide by zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i8 / 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
//~^ ERROR attempted to divide by zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i16 / 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
|
||||
//~^ ERROR attempted to divide by zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i32 / 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
|
||||
//~^ ERROR attempted to divide by zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i64 / 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
//~^ ERROR attempted to divide by zero in a constant expression
|
||||
assert!(Thread::scoped(move|| int::MIN % -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { int::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i8::MIN % -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i16::MIN % -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i32::MIN % -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| i64::MIN % -1).join().is_err());
|
||||
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with overflow in a constant expression
|
||||
assert!(Thread::scoped(move|| 1is % 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1is % 0; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i8 % 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i16 % 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i32 % 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
|
||||
assert!(Thread::scoped(move|| 1i64 % 0).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct S<T>;
|
|||
|
||||
trait Gettable<T> {}
|
||||
|
||||
impl<T: Send + Copy> Gettable<T> for S<T> {}
|
||||
impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
|
||||
|
||||
fn f<T>(val: T) {
|
||||
let t: S<T> = S;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ trait Message : Send { }
|
|||
|
||||
fn object_ref_with_static_bound_not_ok() {
|
||||
assert_send::<&'static (Dummy+'static)>();
|
||||
//~^ ERROR the trait `core::marker::Send` is not implemented
|
||||
//~^ ERROR the trait `core::marker::Sync` is not implemented
|
||||
}
|
||||
|
||||
fn box_object_with_no_bound_not_ok<'a>() {
|
||||
|
|
@ -28,7 +28,7 @@ fn box_object_with_no_bound_not_ok<'a>() {
|
|||
}
|
||||
|
||||
fn object_with_send_bound_ok() {
|
||||
assert_send::<&'static (Dummy+Send)>();
|
||||
assert_send::<&'static (Dummy+Sync)>();
|
||||
assert_send::<Box<Dummy+Send>>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,22 +12,22 @@
|
|||
// is broken into two parts because some errors occur in distinct
|
||||
// phases in the compiler. See kindck-send-object2.rs as well!
|
||||
|
||||
fn assert_send<T:Send>() { }
|
||||
fn assert_send<T:Send+'static>() { }
|
||||
trait Dummy { }
|
||||
|
||||
// careful with object types, who knows what they close over...
|
||||
fn test51<'a>() {
|
||||
assert_send::<&'a Dummy>();
|
||||
//~^ ERROR the trait `core::marker::Send` is not implemented
|
||||
//~^ ERROR the trait `core::marker::Sync` is not implemented
|
||||
}
|
||||
fn test52<'a>() {
|
||||
assert_send::<&'a (Dummy+Send)>();
|
||||
assert_send::<&'a (Dummy+Sync)>();
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
// ...unless they are properly bounded
|
||||
fn test60() {
|
||||
assert_send::<&'static (Dummy+Send)>();
|
||||
assert_send::<&'static (Dummy+Sync)>();
|
||||
}
|
||||
fn test61() {
|
||||
assert_send::<Box<Dummy+Send>>();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn assert_send<T:Send>() { }
|
|||
trait Dummy { }
|
||||
|
||||
fn test50() {
|
||||
assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Send` is not implemented
|
||||
assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Sync` is not implemented
|
||||
}
|
||||
|
||||
fn test53() {
|
||||
|
|
@ -23,7 +23,7 @@ fn test53() {
|
|||
|
||||
// ...unless they are properly bounded
|
||||
fn test60() {
|
||||
assert_send::<&'static (Dummy+Send)>();
|
||||
assert_send::<&'static (Dummy+Sync)>();
|
||||
}
|
||||
fn test61() {
|
||||
assert_send::<Box<Dummy+Send>>();
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ fn test31() { assert_send::<String>(); }
|
|||
fn test32() { assert_send::<Vec<isize> >(); }
|
||||
|
||||
// but not if they own a bad thing
|
||||
fn test40<'a>(_: &'a isize) {
|
||||
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
|
||||
fn test40() {
|
||||
assert_send::<Box<*mut u8>>(); //~ ERROR `core::marker::Send` is not implemented
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that borrowed pointers are not sendable unless 'static.
|
||||
|
||||
fn assert_send<T:Send>() { }
|
||||
|
||||
// lifetime pointers with 'static lifetime are ok
|
||||
fn test01() { assert_send::<&'static isize>(); }
|
||||
fn test02() { assert_send::<&'static str>(); }
|
||||
fn test03() { assert_send::<&'static [isize]>(); }
|
||||
|
||||
// whether or not they are mutable
|
||||
fn test10() { assert_send::<&'static mut isize>(); }
|
||||
|
||||
// otherwise lifetime pointers are not ok
|
||||
fn test20<'a>(_: &'a isize) {
|
||||
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
fn test21<'a>(_: &'a isize) {
|
||||
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
fn test22<'a>(_: &'a isize) {
|
||||
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -11,4 +11,5 @@
|
|||
extern {
|
||||
#[linkage = "extern_weak"] static foo: isize;
|
||||
//~^ ERROR: the `linkage` attribute is experimental and not portable
|
||||
//~^^ ERROR: the `linkage` attribute is experimental and not portable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
#[linkage = "external"]
|
||||
static foo: isize = 0;
|
||||
//~^ ERROR: the `linkage` attribute is experimental and not portable
|
||||
//~^^ ERROR: the `linkage` attribute is experimental and not portable
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#![deny(unused_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![feature(custom_attribute)]
|
||||
|
||||
#[abi="stdcall"] extern {} //~ ERROR unused attribute
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,11 @@ mod cross_crate {
|
|||
impl UnstableTrait for S { } //~ WARNING use of unstable library feature
|
||||
|
||||
trait LocalTrait : UnstableTrait { } //~ WARNING use of unstable library feature
|
||||
|
||||
impl Trait for S {
|
||||
fn trait_stable(&self) {}
|
||||
fn trait_unstable(&self) {} //~ WARNING use of unstable library feature
|
||||
}
|
||||
}
|
||||
|
||||
mod inheritance {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
// When denying at the crate level, be sure to not get random warnings from the
|
||||
// injected intrinsics by the compiler.
|
||||
|
||||
#![feature(custom_attribute)]
|
||||
#![deny(unused_attributes)]
|
||||
|
||||
#![mutable_doc] //~ ERROR unused attribute
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@
|
|||
|
||||
#![allow(dead_code)]
|
||||
#![deny(non_snake_case)]
|
||||
#![feature(path)]
|
||||
#![feature(io)]
|
||||
|
||||
use std::old_io::File;
|
||||
use std::old_io::IoError;
|
||||
mod foo {
|
||||
pub enum Foo { Foo }
|
||||
}
|
||||
|
||||
struct Something {
|
||||
X: usize //~ ERROR structure field `X` should have a snake case name such as `x`
|
||||
|
|
@ -30,13 +29,11 @@ fn main() {
|
|||
let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
|
||||
println!("{}", Test);
|
||||
|
||||
let mut f = File::open(&Path::new("something.txt"));
|
||||
let mut buff = [0u8; 16];
|
||||
match f.read(&mut buff) {
|
||||
Ok(cnt) => println!("read this many bytes: {}", cnt),
|
||||
Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {:?}", EndOfFile),
|
||||
//~^ ERROR variable `EndOfFile` should have a snake case name such as `end_of_file`
|
||||
//~^^ WARN `EndOfFile` is named the same as one of the variants of the type `std::old_io::IoErrorKind`
|
||||
match foo::Foo::Foo {
|
||||
Foo => {}
|
||||
//~^ ERROR variable `Foo` should have a snake case name such as `foo`
|
||||
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
//~^^^ WARN unused variable: `Foo`
|
||||
}
|
||||
|
||||
test(1);
|
||||
|
|
|
|||
13
src/test/compile-fail/log-syntax-gate2.rs
Normal file
13
src/test/compile-fail/log-syntax-gate2.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(custom_attribute)]
|
||||
|
||||
macro_rules! test { ($nm:ident,
|
||||
#[$a:meta],
|
||||
$i:item) => (mod $nm { #![$a] $i }); }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(custom_attribute)]
|
||||
|
||||
macro_rules! test { ($nm:ident,
|
||||
#[$a:meta],
|
||||
$i:item) => (mod $nm { #[$a] $i }); }
|
||||
|
|
|
|||
|
|
@ -30,4 +30,4 @@ pub mod bar {
|
|||
// #[stable] is not inherited
|
||||
pub fn unmarked() {}
|
||||
//~^ ERROR This node does not have a stability attribute
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
// These are all fairly trivial cases: unused variables or direct
|
||||
// drops of substructure.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
// These are checking that enums are tracked; note that their output
|
||||
// paths include "downcasts" of the path to a particular enum.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use self::Lonely::{Zero, One, Two};
|
||||
|
||||
pub struct D { d: isize }
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
// This checks the handling of `_` within variants, especially when mixed
|
||||
// with bindings.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use self::Lonely::{Zero, One, Two};
|
||||
|
||||
pub struct D { d: isize }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
// early draft of the code did not properly traverse up through all of
|
||||
// the parents of the leaf fragment.)
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
// This is the first test that checks moving into local variables.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
// Test that moving into a field (i.e. overwriting it) fragments the
|
||||
// receiver.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::mem::drop;
|
||||
|
||||
pub struct Pair<X,Y> { x: X, y: Y }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
// both moving out of the structure (i.e. reading `*p.x`) and writing
|
||||
// into the container (i.e. writing `*p.x`).
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
// also that in this case we cannot do a move out of `&T`, so we only
|
||||
// test writing `*p.x` here.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
// Note also that the `test_move_array_then_overwrite` tests represent
|
||||
// cases that we probably should make illegal.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
pub struct D { d: isize }
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let x = "Hello world!".to_string();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
println!("{}", x);
|
||||
});
|
||||
println!("{}", x); //~ ERROR use of moved value
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
// error-pattern: use of moved value
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
let arc_v = Arc::new(v);
|
||||
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
assert_eq!((*arc_v)[3], 4);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
let arc_v = Arc::new(v);
|
||||
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
assert_eq!((*arc_v)[3], 4);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(unsafe_destructor)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -35,7 +35,7 @@ fn main() {
|
|||
|
||||
let x = foo(Port(Rc::new(())));
|
||||
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
//~^ ERROR `core::marker::Send` is not implemented
|
||||
let y = x;
|
||||
println!("{:?}", y);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_object_lifetime_default]
|
||||
struct A<T>(T); //~ ERROR None
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
// Various tests related to testing how region inference works
|
||||
// with respect to the object receivers.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(warnings)]
|
||||
|
||||
trait Foo {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
// Various tests related to testing how region inference works
|
||||
// with respect to the object receivers.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(warnings)]
|
||||
|
||||
trait Foo {
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test which of the builtin types are considered sendable. The tests
|
||||
// in this file all test region bound and lifetime violations that are
|
||||
// detected during type check.
|
||||
|
||||
extern crate core;
|
||||
use core::ptr::Unique;
|
||||
|
||||
fn assert_send<T:Send>() { }
|
||||
trait Dummy:Send { }
|
||||
|
||||
// lifetime pointers with 'static lifetime are ok
|
||||
|
||||
fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
|
||||
assert_send::<&'static isize>();
|
||||
assert_send::<&'static str>();
|
||||
assert_send::<&'static [isize]>();
|
||||
|
||||
// whether or not they are mutable
|
||||
assert_send::<&'static mut isize>();
|
||||
}
|
||||
|
||||
// otherwise lifetime pointers are not ok
|
||||
|
||||
fn param_not_ok<'a>(x: &'a isize) {
|
||||
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
fn param_not_ok1<'a>(_: &'a isize) {
|
||||
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
fn param_not_ok2<'a>(_: &'a isize) {
|
||||
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
// boxes are ok
|
||||
|
||||
fn box_ok() {
|
||||
assert_send::<Box<isize>>();
|
||||
assert_send::<String>();
|
||||
assert_send::<Vec<isize>>();
|
||||
}
|
||||
|
||||
// but not if they own a bad thing
|
||||
|
||||
fn box_with_region_not_ok<'a>() {
|
||||
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
// objects with insufficient bounds no ok
|
||||
|
||||
fn object_with_random_bound_not_ok<'a>() {
|
||||
assert_send::<&'a (Dummy+'a)>();
|
||||
//~^ ERROR reference has a longer lifetime
|
||||
}
|
||||
|
||||
fn object_with_send_bound_not_ok<'a>() {
|
||||
assert_send::<&'a (Dummy+Send)>();
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
// unsafe pointers are ok unless they point at unsendable things
|
||||
|
||||
struct UniqueUnsafePtr(Unique<*const isize>);
|
||||
|
||||
unsafe impl Send for UniqueUnsafePtr {}
|
||||
|
||||
fn unsafe_ok1<'a>(_: &'a isize) {
|
||||
assert_send::<UniqueUnsafePtr>();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn assert_send<T: Send>(_t: T) {}
|
||||
fn assert_static<T: 'static>(_t: T) {}
|
||||
|
||||
fn main() {
|
||||
let line = String::new();
|
||||
match [&*line] { //~ ERROR `line` does not live long enough
|
||||
[ word ] => { assert_send(word); }
|
||||
[ word ] => { assert_static(word); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {
|
||||
//~^ ERROR compilation successful
|
||||
|
|
|
|||
24
src/test/compile-fail/send-is-not-static-ensures-scoping.rs
Executable file
24
src/test/compile-fail/send-is-not-static-ensures-scoping.rs
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let bad = {
|
||||
let x = 1;
|
||||
let y = &x;
|
||||
|
||||
thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
|
||||
let _z = y;
|
||||
})
|
||||
};
|
||||
|
||||
bad.join();
|
||||
}
|
||||
30
src/test/compile-fail/trace_macros-gate.rs
Normal file
30
src/test/compile-fail/trace_macros-gate.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that the trace_macros feature gate is on.
|
||||
|
||||
fn main() {
|
||||
trace_macros!(); //~ ERROR `trace_macros` is not stable
|
||||
trace_macros!(1); //~ ERROR `trace_macros` is not stable
|
||||
trace_macros!(ident); //~ ERROR `trace_macros` is not stable
|
||||
trace_macros!(for); //~ ERROR `trace_macros` is not stable
|
||||
trace_macros!(true,); //~ ERROR `trace_macros` is not stable
|
||||
trace_macros!(false 1); //~ ERROR `trace_macros` is not stable
|
||||
|
||||
// Errors are signalled early for the above, before expansion.
|
||||
// See trace_macros-gate2 and trace_macros-gate3. for examples
|
||||
// of the below being caught.
|
||||
|
||||
macro_rules! expando {
|
||||
($x: ident) => { trace_macros!($x) }
|
||||
}
|
||||
|
||||
expando!(true);
|
||||
}
|
||||
20
src/test/compile-fail/trace_macros-gate2.rs
Normal file
20
src/test/compile-fail/trace_macros-gate2.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that the trace_macros feature gate is on.
|
||||
|
||||
fn main() {
|
||||
// (Infrastructure does not attempt to detect uses in macro definitions.)
|
||||
macro_rules! expando {
|
||||
($x: ident) => { trace_macros!($x) }
|
||||
}
|
||||
|
||||
expando!(true); //~ ERROR `trace_macros` is not stable
|
||||
}
|
||||
20
src/test/compile-fail/trace_macros-gate3.rs
Normal file
20
src/test/compile-fail/trace_macros-gate3.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that the trace_macros feature gate is on.
|
||||
|
||||
pub fn main() {
|
||||
println!("arg: {}", trace_macros!()); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(1)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(ident)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(for)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(true,)); //~ ERROR `trace_macros` is not stable
|
||||
println!("arg: {}", trace_macros!(false 1)); //~ ERROR `trace_macros` is not stable
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ fn c(x: Box<Foo+Sync+Send>) {
|
|||
fn d(x: Box<Foo>) {
|
||||
a(x); //~ ERROR mismatched types
|
||||
//~| expected `Box<Foo + Send>`
|
||||
//~| found `Box<Foo + 'static>`
|
||||
//~| found `Box<Foo>`
|
||||
//~| expected bounds `Send`
|
||||
//~| found no bounds
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@
|
|||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![deny(unused_attributes)]
|
||||
#![allow(dead_code, unused_imports)]
|
||||
#![feature(core)]
|
||||
#![feature(core, custom_attribute)]
|
||||
|
||||
#![foo] //~ ERROR unused attribute
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Test that the variance computation considers types/regions that
|
||||
// appear in projections to be invariant.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
trait Trait<'a> {
|
||||
type Type;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Test that Cell is considered invariant with respect to its
|
||||
// type.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
// For better or worse, associated types are invariant, and hence we
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Test that we correctly infer variance for region parameters in
|
||||
// various self-contained types.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
// Regions that just appear in normal spots are contravariant:
|
||||
|
||||
#[rustc_variance]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
// case that involve multiple intricate types.
|
||||
// Try enums too.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]]
|
||||
Test8A(extern "Rust" fn(&'a isize)),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
//
|
||||
// Issue #18262.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::mem;
|
||||
|
||||
trait T { fn foo(); }
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// preserved, and that the first outer item parsed in main is not
|
||||
// accidentally carried over to each inner function
|
||||
|
||||
#![feature(custom_attribute)]
|
||||
|
||||
fn main() {
|
||||
#![inner_attr]
|
||||
#[outer_attr]
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@
|
|||
|
||||
// error-pattern:thread '<unnamed>' panicked at 'test'
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let r: Result<int,_> = Thread::scoped(move|| {
|
||||
let r: Result<(),_> = thread::spawn(move|| {
|
||||
panic!("test");
|
||||
1
|
||||
}).join();
|
||||
assert!(r.is_ok());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
use std::thread::Builder;
|
||||
|
||||
fn main() {
|
||||
let r: Result<int,_> = Builder::new().name("owned name".to_string()).scoped(move|| {
|
||||
let r: () = Builder::new().name("owned name".to_string()).scoped(move|| {
|
||||
panic!("test");
|
||||
1
|
||||
}).join();
|
||||
assert!(r.is_ok());
|
||||
()
|
||||
}).unwrap().join();
|
||||
panic!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#[macro_use] extern crate log;
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
struct r {
|
||||
x:int,
|
||||
|
|
@ -35,7 +35,7 @@ fn r(x:int) -> r {
|
|||
|
||||
fn main() {
|
||||
error!("whatever");
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::spawn(move|| {
|
||||
let _i = r(5);
|
||||
});
|
||||
panic!();
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
// error-pattern:Ensure that the child task runs by panicking
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
// the purpose of this test is to make sure that task::spawn()
|
||||
// works when provided with a bare function:
|
||||
let r = Thread::scoped(startfn).join();
|
||||
let r = thread::spawn(startfn).join();
|
||||
if r.is_err() {
|
||||
panic!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
// error-pattern:nonzero
|
||||
// exec-env:RUST_NEWRT=1
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
os::args();
|
||||
env::args();
|
||||
panic!("please have a nonzero exit status");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::old_io::{File, Command};
|
||||
|
||||
// creates broken.rs, which has the Ident \x00name_0,ctxt_0\x00
|
||||
|
|
@ -16,7 +16,7 @@ use std::old_io::{File, Command};
|
|||
// provided `rustc`
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let rustc = &args[1];
|
||||
let tmpdir = Path::new(&args[2]);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn main() {
|
|||
fn main() {}
|
||||
"#;
|
||||
|
||||
let args = std::os::args();
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() < 4 {
|
||||
panic!("expected rustc path");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
pub static mut statik: int = 0;
|
||||
pub static mut statik: isize = 0;
|
||||
|
||||
struct A;
|
||||
impl Drop for A {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
extern crate lib;
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
static mut statik: int = 0;
|
||||
static mut statik: isize = 0;
|
||||
|
||||
struct A;
|
||||
impl Drop for A {
|
||||
|
|
@ -22,10 +22,9 @@ impl Drop for A {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
Thread::scoped(move|| {
|
||||
thread::spawn(move|| {
|
||||
let _a = A;
|
||||
lib::callback(|| panic!());
|
||||
1
|
||||
}).join().err().unwrap();
|
||||
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
|
||||
"llvm-target": "i686-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-word-size": "32",
|
||||
"target-pointer-width": "32",
|
||||
"arch": "x86",
|
||||
"os": "linux",
|
||||
"morestack": false
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
|
||||
"target-endian": "little",
|
||||
"target-word-size": "32",
|
||||
"target-pointer-width": "32",
|
||||
"arch": "x86",
|
||||
"os": "foo",
|
||||
"morestack": false
|
||||
|
|
|
|||
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