diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-18 23:50:21 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-18 23:50:21 +1100 |
| commit | dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5 (patch) | |
| tree | e9c32f2e58b3462a23dd9c472d2f236640b78811 /src/test | |
| parent | 6c065fc8cb036785f61ff03e05c1563cbb2dd081 (diff) | |
| parent | 47f91a9484eceef10536d4caac6ef578cd254567 (diff) | |
| download | rust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.tar.gz rust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.zip | |
Manual merge of #22475 - alexcrichton:rollup, r=alexcrichton
One windows bot failed spuriously.
Diffstat (limited to 'src/test')
173 files changed, 786 insertions, 668 deletions
diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index 673c38697b7..b38e955231e 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -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 diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 7ac3925fb24..01b2b748ba9 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -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 {} diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 12c95e4c60c..4909d84a34f 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -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); } } diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index 33ac8a43b43..1d440c4540c 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -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, || { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 00f8feacff8..2409487c04f 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -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) => diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index 90cc222c3de..57889053e3c 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -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(); diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 4e9c2fe99bd..208f088442b 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -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); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 2530e8bd907..76b91f0295b 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -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); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index a935a6b3086..168fe929e12 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -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(); diff --git a/src/test/bench/rt-messaging-ping-pong.rs b/src/test/bench/rt-messaging-ping-pong.rs index e4e8b4a6e6e..b9512324e42 100644 --- a/src/test/bench/rt-messaging-ping-pong.rs +++ b/src/test/bench/rt-messaging-ping-pong.rs @@ -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() - } else { - 10000 - }; - - let m = if args.len() == 3 { - args[2].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 { - 4 + (10000, 4) }; ping_pong_bench(n, m); diff --git a/src/test/bench/rt-parfib.rs b/src/test/bench/rt-parfib.rs index 13b8a5ca763..d420023cf00 100644 --- a/src/test/bench/rt-parfib.rs +++ b/src/test/bench/rt-parfib.rs @@ -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 }; diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index 933c1c218c3..d07aa8850aa 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -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)); diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 0311a1ac7c4..1e23da3020f 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -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: {}", diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 628206986c5..5bd1e91ae14 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -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(); diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 92e1bc1a922..f7de935d08f 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -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); diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index d91031b8401..277c3ee73df 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -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 }; diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 5bf0862e0a1..fd559608011 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -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(); diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index 6a062ba3980..6f9c775609a 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -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)); diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 3c96878179f..4d6ef3d533e 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -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_); }); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index ca920b2fa82..b5c460737b8 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -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); } } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index e2d51fbf411..bddf6153228 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -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(); } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index d061403d590..a9c4bb99a0e 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -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(); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 7904657bece..534dfe9548c 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -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) }; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 9abc808f887..a542c81f239 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -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(); diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 94438319954..33d959dfe93 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -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<_>>(); } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 8356df8d8a1..76ba5acb16c 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -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<_>>(); } diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index 8614f94da89..2653e758a48 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -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); diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index e6948a1371c..a54a869412e 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -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; diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index c5a64db95e6..ada8efcbf38 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -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 { diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index c45efe5f54b..6b412c47cd7 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -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(); }); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 9edb4201098..e36d685d7c6 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -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(); diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 279b3fa432a..69b9e89dbc5 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -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; } } diff --git a/src/test/compile-fail/asm-gated2.rs b/src/test/compile-fail/asm-gated2.rs new file mode 100644 index 00000000000..d2ee01109f8 --- /dev/null +++ b/src/test/compile-fail/asm-gated2.rs @@ -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 + } +} diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index 980c498e39b..7f676f5166f 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -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 }); diff --git a/src/test/compile-fail/borrowck-multiple-captures.rs b/src/test/compile-fail/borrowck-multiple-captures.rs index 94e213ae1ae..9db05d76284 100644 --- a/src/test/compile-fail/borrowck-multiple-captures.rs +++ b/src/test/compile-fail/borrowck-multiple-captures.rs @@ -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` }); diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index c7b75ade555..c3fb6a1be87 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -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() { } diff --git a/src/test/compile-fail/coherence-impls-builtin.rs b/src/test/compile-fail/coherence-impls-builtin.rs index 2ca288b60a3..38730d241f6 100644 --- a/src/test/compile-fail/coherence-impls-builtin.rs +++ b/src/test/compile-fail/coherence-impls-builtin.rs @@ -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>() {} diff --git a/src/test/compile-fail/concat_idents-gate.rs b/src/test/compile-fail/concat_idents-gate.rs new file mode 100644 index 00000000000..f4d97445725 --- /dev/null +++ b/src/test/compile-fail/concat_idents-gate.rs @@ -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); +} diff --git a/src/test/compile-fail/concat_idents-gate2.rs b/src/test/compile-fail/concat_idents-gate2.rs new file mode 100644 index 00000000000..d8f8f803edc --- /dev/null +++ b/src/test/compile-fail/concat_idents-gate2.rs @@ -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 +} diff --git a/src/test/compile-fail/custom_attribute.rs b/src/test/compile-fail/custom_attribute.rs new file mode 100644 index 00000000000..193063a98cb --- /dev/null +++ b/src/test/compile-fail/custom_attribute.rs @@ -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() { + +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-12041.rs b/src/test/compile-fail/issue-12041.rs index 236142a6919..735f529277c 100644 --- a/src/test/compile-fail/issue-12041.rs +++ b/src/test/compile-fail/issue-12041.rs @@ -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` diff --git a/src/test/compile-fail/issue-8460-const.rs b/src/test/compile-fail/issue-8460-const.rs index 01bed69fb1d..b6d371e4b11 100644 --- a/src/test/compile-fail/issue-8460-const.rs +++ b/src/test/compile-fail/issue-8460-const.rs @@ -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 } diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index de7639c6213..d5276efa8be 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -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; diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 7984b3b32c2..570f7ad7fe3 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -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>>(); } diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 3d47d33d7c3..48d5215b708 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -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>>(); diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index 75bae09b37f..d3d166e2a69 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -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>>(); diff --git a/src/test/compile-fail/kindck-send-owned.rs b/src/test/compile-fail/kindck-send-owned.rs index 266b6156656..406711902a5 100644 --- a/src/test/compile-fail/kindck-send-owned.rs +++ b/src/test/compile-fail/kindck-send-owned.rs @@ -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() { } diff --git a/src/test/compile-fail/kindck-send-region-pointers.rs b/src/test/compile-fail/kindck-send-region-pointers.rs deleted file mode 100644 index e2a5b0678a6..00000000000 --- a/src/test/compile-fail/kindck-send-region-pointers.rs +++ /dev/null @@ -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() { } diff --git a/src/test/compile-fail/linkage1.rs b/src/test/compile-fail/linkage1.rs index 555cc2b9a7a..35f93c13fb5 100644 --- a/src/test/compile-fail/linkage1.rs +++ b/src/test/compile-fail/linkage1.rs @@ -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 } diff --git a/src/test/compile-fail/linkage4.rs b/src/test/compile-fail/linkage4.rs index 635d58e04c7..1cf6e90d6c8 100644 --- a/src/test/compile-fail/linkage4.rs +++ b/src/test/compile-fail/linkage4.rs @@ -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() {} diff --git a/src/test/compile-fail/lint-obsolete-attr.rs b/src/test/compile-fail/lint-obsolete-attr.rs index e4fd042d098..dd4e1212a00 100644 --- a/src/test/compile-fail/lint-obsolete-attr.rs +++ b/src/test/compile-fail/lint-obsolete-attr.rs @@ -13,6 +13,7 @@ #![deny(unused_attributes)] #![allow(dead_code)] +#![feature(custom_attribute)] #[abi="stdcall"] extern {} //~ ERROR unused attribute diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs index 5c187176fb2..f9cdfa4f7d6 100644 --- a/src/test/compile-fail/lint-stability.rs +++ b/src/test/compile-fail/lint-stability.rs @@ -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 { diff --git a/src/test/compile-fail/lint-unknown-attr.rs b/src/test/compile-fail/lint-unknown-attr.rs index e4cb92477c2..af4e81be195 100644 --- a/src/test/compile-fail/lint-unknown-attr.rs +++ b/src/test/compile-fail/lint-unknown-attr.rs @@ -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 diff --git a/src/test/compile-fail/lint-uppercase-variables.rs b/src/test/compile-fail/lint-uppercase-variables.rs index 057b8e3acc6..a4f46cbd187 100644 --- a/src/test/compile-fail/lint-uppercase-variables.rs +++ b/src/test/compile-fail/lint-uppercase-variables.rs @@ -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); diff --git a/src/test/compile-fail/log-syntax-gate2.rs b/src/test/compile-fail/log-syntax-gate2.rs new file mode 100644 index 00000000000..bb19e97ab0f --- /dev/null +++ b/src/test/compile-fail/log-syntax-gate2.rs @@ -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 +} diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs index e4fc5bb4627..e76eaea365e 100644 --- a/src/test/compile-fail/macro-inner-attributes.rs +++ b/src/test/compile-fail/macro-inner-attributes.rs @@ -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 }); } diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs index a0f23c72bc4..cff01f36f3a 100644 --- a/src/test/compile-fail/macro-outer-attributes.rs +++ b/src/test/compile-fail/macro-outer-attributes.rs @@ -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 }); } diff --git a/src/test/compile-fail/missing-stability.rs b/src/test/compile-fail/missing-stability.rs index 14dd983161b..cf7a8378b9a 100644 --- a/src/test/compile-fail/missing-stability.rs +++ b/src/test/compile-fail/missing-stability.rs @@ -30,4 +30,4 @@ pub mod bar { // #[stable] is not inherited pub fn unmarked() {} //~^ ERROR This node does not have a stability attribute -} \ No newline at end of file +} diff --git a/src/test/compile-fail/move-fragments-1.rs b/src/test/compile-fail/move-fragments-1.rs index 3f14be2da10..0219f5b6bec 100644 --- a/src/test/compile-fail/move-fragments-1.rs +++ b/src/test/compile-fail/move-fragments-1.rs @@ -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) { } } diff --git a/src/test/compile-fail/move-fragments-2.rs b/src/test/compile-fail/move-fragments-2.rs index 6c0635d6be9..175488bf2fc 100644 --- a/src/test/compile-fail/move-fragments-2.rs +++ b/src/test/compile-fail/move-fragments-2.rs @@ -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 } diff --git a/src/test/compile-fail/move-fragments-3.rs b/src/test/compile-fail/move-fragments-3.rs index 24d73ec2274..b65921177ad 100644 --- a/src/test/compile-fail/move-fragments-3.rs +++ b/src/test/compile-fail/move-fragments-3.rs @@ -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 } diff --git a/src/test/compile-fail/move-fragments-4.rs b/src/test/compile-fail/move-fragments-4.rs index 97e8e45ed06..191e23a2863 100644 --- a/src/test/compile-fail/move-fragments-4.rs +++ b/src/test/compile-fail/move-fragments-4.rs @@ -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) { } } diff --git a/src/test/compile-fail/move-fragments-5.rs b/src/test/compile-fail/move-fragments-5.rs index 9f70421fa84..38a385eacac 100644 --- a/src/test/compile-fail/move-fragments-5.rs +++ b/src/test/compile-fail/move-fragments-5.rs @@ -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) { } } diff --git a/src/test/compile-fail/move-fragments-6.rs b/src/test/compile-fail/move-fragments-6.rs index b249d0d7397..122727c3f6b 100644 --- a/src/test/compile-fail/move-fragments-6.rs +++ b/src/test/compile-fail/move-fragments-6.rs @@ -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 } diff --git a/src/test/compile-fail/move-fragments-7.rs b/src/test/compile-fail/move-fragments-7.rs index 2af2b2957f8..a2a37208cd6 100644 --- a/src/test/compile-fail/move-fragments-7.rs +++ b/src/test/compile-fail/move-fragments-7.rs @@ -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) { } } diff --git a/src/test/compile-fail/move-fragments-8.rs b/src/test/compile-fail/move-fragments-8.rs index 18bf4066076..e57268dbfa3 100644 --- a/src/test/compile-fail/move-fragments-8.rs +++ b/src/test/compile-fail/move-fragments-8.rs @@ -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) { } } diff --git a/src/test/compile-fail/move-fragments-9.rs b/src/test/compile-fail/move-fragments-9.rs index 426d5fa29a0..350f4169034 100644 --- a/src/test/compile-fail/move-fragments-9.rs +++ b/src/test/compile-fail/move-fragments-9.rs @@ -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) { } } diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs index dc90994fcc1..32fa773ec80 100644 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs @@ -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 diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index 939d7c7a534..7b7b3c414dd 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -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); }); diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 730ba9ab9ea..1720b40c83b 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -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); }); diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index ae2847aab09..5ebc386109a 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -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); diff --git a/src/test/compile-fail/object-lifetime-default.rs b/src/test/compile-fail/object-lifetime-default.rs index 73f71751ee8..ac03c085b7b 100644 --- a/src/test/compile-fail/object-lifetime-default.rs +++ b/src/test/compile-fail/object-lifetime-default.rs @@ -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 diff --git a/src/test/compile-fail/region-object-lifetime-1.rs b/src/test/compile-fail/region-object-lifetime-1.rs index bb37d55fb08..2095fb903b8 100644 --- a/src/test/compile-fail/region-object-lifetime-1.rs +++ b/src/test/compile-fail/region-object-lifetime-1.rs @@ -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 { diff --git a/src/test/compile-fail/region-object-lifetime-3.rs b/src/test/compile-fail/region-object-lifetime-3.rs index 7f00334f67e..097053276c7 100644 --- a/src/test/compile-fail/region-object-lifetime-3.rs +++ b/src/test/compile-fail/region-object-lifetime-3.rs @@ -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 { diff --git a/src/test/compile-fail/regions-bounded-by-send.rs b/src/test/compile-fail/regions-bounded-by-send.rs deleted file mode 100644 index 71254e15d32..00000000000 --- a/src/test/compile-fail/regions-bounded-by-send.rs +++ /dev/null @@ -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() { -} diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs index 57ea607cbf6..3401dd1becd 100644 --- a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs +++ b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs @@ -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); } } } diff --git a/src/test/compile-fail/rustc-error.rs b/src/test/compile-fail/rustc-error.rs index 6497439c3dc..82f32cbcd14 100644 --- a/src/test/compile-fail/rustc-error.rs +++ b/src/test/compile-fail/rustc-error.rs @@ -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 diff --git a/src/test/compile-fail/send-is-not-static-ensures-scoping.rs b/src/test/compile-fail/send-is-not-static-ensures-scoping.rs new file mode 100755 index 00000000000..abbcd7e4590 --- /dev/null +++ b/src/test/compile-fail/send-is-not-static-ensures-scoping.rs @@ -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(); +} diff --git a/src/test/compile-fail/trace_macros-gate.rs b/src/test/compile-fail/trace_macros-gate.rs new file mode 100644 index 00000000000..6473bcece91 --- /dev/null +++ b/src/test/compile-fail/trace_macros-gate.rs @@ -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); +} diff --git a/src/test/compile-fail/trace_macros-gate2.rs b/src/test/compile-fail/trace_macros-gate2.rs new file mode 100644 index 00000000000..71cc45e132d --- /dev/null +++ b/src/test/compile-fail/trace_macros-gate2.rs @@ -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 +} diff --git a/src/test/compile-fail/trace_macros-gate3.rs b/src/test/compile-fail/trace_macros-gate3.rs new file mode 100644 index 00000000000..66d03cf9d80 --- /dev/null +++ b/src/test/compile-fail/trace_macros-gate3.rs @@ -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 +} diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 89e89cf8246..79174552ae0 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -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 } diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index 50217ff9e5d..2d4bc0c857a 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -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 diff --git a/src/test/compile-fail/variance-associated-types.rs b/src/test/compile-fail/variance-associated-types.rs index ecb2287769b..0ed0861d34a 100644 --- a/src/test/compile-fail/variance-associated-types.rs +++ b/src/test/compile-fail/variance-associated-types.rs @@ -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; diff --git a/src/test/compile-fail/variance-object-types.rs b/src/test/compile-fail/variance-object-types.rs index 972ec96f5f2..2b7b05970d9 100644 --- a/src/test/compile-fail/variance-object-types.rs +++ b/src/test/compile-fail/variance-object-types.rs @@ -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 diff --git a/src/test/compile-fail/variance-regions-direct.rs b/src/test/compile-fail/variance-regions-direct.rs index 04389b67dba..d70305d1106 100644 --- a/src/test/compile-fail/variance-regions-direct.rs +++ b/src/test/compile-fail/variance-regions-direct.rs @@ -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] diff --git a/src/test/compile-fail/variance-regions-indirect.rs b/src/test/compile-fail/variance-regions-indirect.rs index e2c7958b31d..4bb329d6304 100644 --- a/src/test/compile-fail/variance-regions-indirect.rs +++ b/src/test/compile-fail/variance-regions-indirect.rs @@ -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)), diff --git a/src/test/compile-fail/variance-trait-object-bound.rs b/src/test/compile-fail/variance-trait-object-bound.rs index c61f2ff79c0..965b9430a5e 100644 --- a/src/test/compile-fail/variance-trait-object-bound.rs +++ b/src/test/compile-fail/variance-trait-object-bound.rs @@ -14,6 +14,8 @@ // // Issue #18262. +#![feature(rustc_attrs)] + use std::mem; trait T { fn foo(); } diff --git a/src/test/pretty/attr-fn-inner.rs b/src/test/pretty/attr-fn-inner.rs index 65dcf900567..79964d2a7ba 100644 --- a/src/test/pretty/attr-fn-inner.rs +++ b/src/test/pretty/attr-fn-inner.rs @@ -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] diff --git a/src/test/run-fail/panic-task-name-none.rs b/src/test/run-fail/panic-task-name-none.rs index 816ee84a841..3a5ac5a1009 100644 --- a/src/test/run-fail/panic-task-name-none.rs +++ b/src/test/run-fail/panic-task-name-none.rs @@ -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()); } diff --git a/src/test/run-fail/panic-task-name-owned.rs b/src/test/run-fail/panic-task-name-owned.rs index d48d282c9eb..8cab9e05f96 100644 --- a/src/test/run-fail/panic-task-name-owned.rs +++ b/src/test/run-fail/panic-task-name-owned.rs @@ -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!(); } diff --git a/src/test/run-fail/rt-set-exit-status-panic2.rs b/src/test/run-fail/rt-set-exit-status-panic2.rs index 446ef6f97e2..775d38c8b30 100644 --- a/src/test/run-fail/rt-set-exit-status-panic2.rs +++ b/src/test/run-fail/rt-set-exit-status-panic2.rs @@ -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!(); diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs index d58148810da..406f7dbcb67 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -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!() } diff --git a/src/test/run-fail/tls-exit-status.rs b/src/test/run-fail/tls-exit-status.rs index 5b44e375704..be619e3a82c 100644 --- a/src/test/run-fail/tls-exit-status.rs +++ b/src/test/run-fail/tls-exit-status.rs @@ -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"); } diff --git a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs index c8156b95dcf..89352a16d8b 100644 --- a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs +++ b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs @@ -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]); diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs index 808417d6521..c96210896fd 100644 --- a/src/test/run-make/issue-19371/foo.rs +++ b/src/test/run-make/issue-19371/foo.rs @@ -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"); diff --git a/src/test/run-make/static-unwinding/lib.rs b/src/test/run-make/static-unwinding/lib.rs index c3fa1a68e16..12c72d54c09 100644 --- a/src/test/run-make/static-unwinding/lib.rs +++ b/src/test/run-make/static-unwinding/lib.rs @@ -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 { diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs index 6d10a247143..d325f54d365 100644 --- a/src/test/run-make/static-unwinding/main.rs +++ b/src/test/run-make/static-unwinding/main.rs @@ -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 { diff --git a/src/test/run-make/target-specs/my-awesome-platform.json b/src/test/run-make/target-specs/my-awesome-platform.json index f5f622bbcda..d7cf7131d73 100644 --- a/src/test/run-make/target-specs/my-awesome-platform.json +++ b/src/test/run-make/target-specs/my-awesome-platform.json @@ -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 diff --git a/src/test/run-make/target-specs/my-incomplete-platform.json b/src/test/run-make/target-specs/my-incomplete-platform.json index 5005a9ff839..053f2dd6335 100644 --- a/src/test/run-make/target-specs/my-incomplete-platform.json +++ b/src/test/run-make/target-specs/my-incomplete-platform.json @@ -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 diff --git a/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json b/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json index 5e0f0f40e67..688bbe46bfa 100644 --- a/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json +++ b/src/test/run-make/target-specs/x86_64-unknown-linux-gnu.json @@ -3,7 +3,7 @@ "data-layout": "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128", "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "little", - "target-word-size": "64", + "target-pointer-width": "64", "arch": "x86_64", "os": "linux", "morestack": false diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index be67e5a066a..759a1d4aff9 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{char, os}; +use std::{char, env}; use std::old_io::{File, Command}; use std::rand::{thread_rng, Rng}; @@ -33,7 +33,7 @@ fn random_char() -> char { } fn main() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); let rustc = &args[1]; let tmpdir = Path::new(&args[2]); diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index 95ce57da4e1..5dee9104b0f 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -11,7 +11,7 @@ use std::old_io::{File, Command}; use std::iter::repeat; use std::rand::{thread_rng, Rng}; -use std::{char, os}; +use std::{char, env}; // creates a file with `fn main() { <random ident> }` and checks the // compiler emits a span of the appropriate length (for the @@ -33,7 +33,7 @@ fn random_char() -> char { } fn main() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); let rustc = &args[1]; let tmpdir = Path::new(&args[2]); let main_file = tmpdir.join("span_main.rs"); diff --git a/src/test/run-pass/attr-before-view-item.rs b/src/test/run-pass/attr-before-view-item.rs index 2a65fd9d8a6..951a716879f 100644 --- a/src/test/run-pass/attr-before-view-item.rs +++ b/src/test/run-pass/attr-before-view-item.rs @@ -10,6 +10,8 @@ // error-pattern:expected item +#![feature(custom_attribute)] + #[foo = "bar"] extern crate test; diff --git a/src/test/run-pass/attr-before-view-item2.rs b/src/test/run-pass/attr-before-view-item2.rs index 5b8e62de6bd..ad8ce608bd0 100644 --- a/src/test/run-pass/attr-before-view-item2.rs +++ b/src/test/run-pass/attr-before-view-item2.rs @@ -10,6 +10,8 @@ // error-pattern:expected item +#![feature(custom_attribute)] + mod m { #[foo = "bar"] extern crate test; diff --git a/src/test/run-pass/attr-mix-new.rs b/src/test/run-pass/attr-mix-new.rs index 55ca75b4b71..7980937ce2a 100644 --- a/src/test/run-pass/attr-mix-new.rs +++ b/src/test/run-pass/attr-mix-new.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(unused_attribute)] +#![feature(custom_attribute)] #[foo(bar)] mod foo { diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index b1cb4d6e42c..6f76322cb77 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -14,7 +14,6 @@ #![feature(unboxed_closures)] #![feature(unsafe_destructor)] -use std::os; use std::env; use std::old_io::process::Command; use std::str; @@ -86,8 +85,7 @@ fn runtest(me: &str) { } fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() >= 2 && args[1] == "fail" { foo(); } else if args.len() >= 2 && args[1] == "double-fail" { diff --git a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs index 3df9dd25d86..379ac12a954 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs @@ -22,7 +22,7 @@ trait Foo : Bar { } impl <T: Send> Foo for T { } impl <T: Send> Bar for T { } -fn foo<T: Foo>(val: T, chan: Sender<T>) { +fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index 52b826393e9..cd019c21a3d 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -25,7 +25,7 @@ struct X<T>(T); impl <T: Sync> RequiresShare for X<T> { } impl <T: Sync+Send> RequiresRequiresShareAndSend for X<T> { } -fn foo<T: RequiresRequiresShareAndSend>(val: T, chan: Sender<T>) { +fn foo<T: RequiresRequiresShareAndSend + 'static>(val: T, chan: Sender<T>) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities.rs b/src/test/run-pass/builtin-superkinds-capabilities.rs index 034e5ff2d3a..dc61508eec4 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities.rs @@ -18,7 +18,7 @@ trait Foo : Send { } impl <T: Send> Foo for T { } -fn foo<T: Foo>(val: T, chan: Sender<T>) { +fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-self-type.rs b/src/test/run-pass/builtin-superkinds-self-type.rs index 1b3070ba3b0..1d05a7baa53 100644 --- a/src/test/run-pass/builtin-superkinds-self-type.rs +++ b/src/test/run-pass/builtin-superkinds-self-type.rs @@ -13,13 +13,13 @@ use std::sync::mpsc::{Sender, channel}; -trait Foo : Send + Sized { +trait Foo : Send + Sized + 'static { fn foo(self, tx: Sender<Self>) { tx.send(self).unwrap(); } } -impl <T: Send> Foo for T { } +impl <T: Send + 'static> Foo for T { } pub fn main() { let (tx, rx) = channel(); diff --git a/src/test/run-pass/check-static-recursion-foreign.rs b/src/test/run-pass/check-static-recursion-foreign.rs index 9acc0b3a3c5..4e05c263a48 100644 --- a/src/test/run-pass/check-static-recursion-foreign.rs +++ b/src/test/run-pass/check-static-recursion-foreign.rs @@ -11,6 +11,9 @@ // Static recursion check shouldn't fail when given a foreign item (#18279) // aux-build:check_static_recursion_foreign_helper.rs + +#![feature(custom_attribute)] + extern crate check_static_recursion_foreign_helper; extern crate libc; diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs index 28081e5292a..5dc27472184 100644 --- a/src/test/run-pass/class-attributes-1.rs +++ b/src/test/run-pass/class-attributes-1.rs @@ -10,6 +10,7 @@ // pp-exact - Make sure we actually print the attributes #![allow(unused_attribute)] +#![feature(custom_attribute)] struct cat { name: String, diff --git a/src/test/run-pass/class-attributes-2.rs b/src/test/run-pass/class-attributes-2.rs index bd62f838444..cc1b15bcb81 100644 --- a/src/test/run-pass/class-attributes-2.rs +++ b/src/test/run-pass/class-attributes-2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(unused_attribute)] +#![feature(custom_attribute)] struct cat { name: String, diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index edb3d72483b..96ae7e3d336 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -27,7 +27,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -use std::thread::Thread; +use std::thread; enum Conzabble { Bickwick(Foo) @@ -48,5 +48,5 @@ pub fn fails() { } pub fn main() { - Thread::scoped(fails).join(); + thread::spawn(fails).join(); } diff --git a/src/test/run-pass/cleanup-shortcircuit.rs b/src/test/run-pass/cleanup-shortcircuit.rs index b776f098b1d..59f63a79c3d 100644 --- a/src/test/run-pass/cleanup-shortcircuit.rs +++ b/src/test/run-pass/cleanup-shortcircuit.rs @@ -20,11 +20,10 @@ // Test that cleanups for the RHS of shortcircuiting operators work. -use std::os; +use std::env; pub fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); // Here, the rvalue `"signal".to_string()` requires cleanup. Older versions // of the code had a problem that the cleanup scope for this diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index 2474bb8a4f3..d52c645730f 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -11,7 +11,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -use std::thread::Thread; +use std::thread; use std::sync::mpsc::{channel, Sender}; #[derive(PartialEq, Debug)] @@ -69,15 +69,16 @@ pub fn main() { assert_eq!(receiver.recv().ok(), None); let (sender, receiver) = channel(); - let _t = Thread::scoped(move|| { + let t = thread::spawn(move|| { let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; }); assert_eq!(receiver.recv().unwrap(), Message::Dropped); assert_eq!(receiver.recv().ok(), None); + drop(t.join()); let (sender, receiver) = channel(); - let _t = { - Thread::scoped(move|| { + let t = { + thread::spawn(move|| { let mut v = Foo::NestedVariant(box 42u, SendOnDrop { sender: sender.clone() }, sender.clone()); @@ -93,4 +94,5 @@ pub fn main() { assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); assert_eq!(receiver.recv().unwrap(), Message::Dropped); assert_eq!(receiver.recv().ok(), None); + drop(t.join()); } diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index f99d3eb1c7d..3f226a1985e 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -11,7 +11,7 @@ extern crate libc; use std::mem; -use std::thread::Thread; +use std::thread; #[link(name = "rust_test_helpers")] extern { @@ -21,9 +21,9 @@ extern { pub fn main() { unsafe { - Thread::scoped(move|| { - let i = &100; - rust_dbg_call(callback, mem::transmute(i)); + thread::spawn(move|| { + let i = 100; + rust_dbg_call(callback, mem::transmute(&i)); }).join(); } } diff --git a/src/test/run-pass/issue-10626.rs b/src/test/run-pass/issue-10626.rs index 9150920cf2c..29e4801d0a9 100644 --- a/src/test/run-pass/issue-10626.rs +++ b/src/test/run-pass/issue-10626.rs @@ -12,12 +12,11 @@ // Make sure that if a process doesn't have its stdio/stderr descriptors set up // that we don't die in a large ball of fire -use std::os; +use std::env; use std::old_io::process; pub fn main () { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { for _ in 0..1000 { println!("hello?"); diff --git a/src/test/run-pass/issue-12684.rs b/src/test/run-pass/issue-12684.rs index 38731b8c8da..e66b5d21e17 100644 --- a/src/test/run-pass/issue-12684.rs +++ b/src/test/run-pass/issue-12684.rs @@ -9,10 +9,10 @@ // except according to those terms. use std::time::Duration; -use std::thread::Thread; +use std::thread; fn main() { - Thread::scoped(move|| customtask()).join().ok().unwrap(); + thread::spawn(move|| customtask()).join().ok().unwrap(); } fn customtask() { diff --git a/src/test/run-pass/issue-13304.rs b/src/test/run-pass/issue-13304.rs index 4dc824d9068..4a7d6be55a1 100644 --- a/src/test/run-pass/issue-13304.rs +++ b/src/test/run-pass/issue-13304.rs @@ -10,13 +10,12 @@ // ignore-fast -use std::os; +use std::env; use std::old_io; use std::str; fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { child(); } else { @@ -25,8 +24,7 @@ fn main() { } fn parent() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); let mut p = old_io::process::Command::new(&args[0]) .arg("child").spawn().unwrap(); p.stdin.as_mut().unwrap().write_str("test1\ntest2\ntest3").unwrap(); diff --git a/src/test/run-pass/issue-14456.rs b/src/test/run-pass/issue-14456.rs index 1c8066bc3c9..723db9485ca 100644 --- a/src/test/run-pass/issue-14456.rs +++ b/src/test/run-pass/issue-14456.rs @@ -12,10 +12,10 @@ use std::old_io::process; use std::old_io::Command; use std::old_io; -use std::os; +use std::env; fn main() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { return child() } @@ -32,7 +32,7 @@ fn child() { } fn test() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); let mut p = Command::new(&args[0]).arg("child") .stdin(process::Ignored) .stdout(process::Ignored) diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index e5fead72beb..ed0e3bddbe5 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -8,16 +8,16 @@ // 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::{stdio, Command}; fn main() { - let args = os::args(); + let mut args = env::args(); if args.len() > 1 { let mut out = stdio::stdout(); out.write(&['a' as u8; 128 * 1024]).unwrap(); } else { - let out = Command::new(&args[0]).arg("child").output(); + let out = Command::new(&args.next().unwrap()).arg("child").output(); let out = out.unwrap(); assert!(out.status.success()); } diff --git a/src/test/run-pass/issue-15149.rs b/src/test/run-pass/issue-15149.rs index aa45a8c5d5f..aa176d5b0f0 100644 --- a/src/test/run-pass/issue-15149.rs +++ b/src/test/run-pass/issue-15149.rs @@ -11,21 +11,21 @@ // except according to those terms. use std::slice::SliceExt; -use std::old_io::{Command, fs, USER_RWX}; -use std::os; +use std::old_io::{fs, USER_RWX}; +use std::process; use std::env; use std::old_path::BytesContainer; use std::rand::random; fn main() { // If we're the child, make sure we were invoked correctly - let args = os::args(); + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { // FIXME: This should check the whole `args[0]` instead of just // checking that it ends_with the executable name. This // is needed because of Windows, which has a different behavior. // See #15149 for more info. - return assert!(args[0].ends_with(&format!("mytest{}", os::consts::EXE_SUFFIX)[])); + return assert!(args[0].ends_with(&format!("mytest{}", env::consts::EXE_SUFFIX)[])); } test(); @@ -33,7 +33,7 @@ fn main() { fn test() { // If we're the parent, copy our own binary to a new directory. - let my_path = os::self_exe_name().unwrap(); + let my_path = env::current_exe().unwrap(); let my_dir = my_path.dir_path(); let random_u32: u32 = random(); @@ -42,22 +42,24 @@ fn test() { fs::mkdir(&child_dir, USER_RWX).unwrap(); let child_path = child_dir.join(format!("mytest{}", - os::consts::EXE_SUFFIX)); + env::consts::EXE_SUFFIX)); fs::copy(&my_path, &child_path).unwrap(); // Append the new directory to our own PATH. - let mut path = os::split_paths(env::var("PATH").ok().unwrap_or(String::new())); - path.push(child_dir.clone()); - let path = os::join_paths(&path).unwrap(); + let path = { + let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect(); + paths.push(child_dir.clone()); + env::join_paths(paths.iter()).unwrap() + }; - let child_output = Command::new("mytest").env("PATH", path) - .arg("child") - .output().unwrap(); + let child_output = process::Command::new("mytest").env("PATH", &path) + .arg("child") + .output().unwrap(); assert!(child_output.status.success(), format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}", - child_output.output.container_as_str().unwrap(), - child_output.error.container_as_str().unwrap())); + child_output.stdout.container_as_str().unwrap(), + child_output.stderr.container_as_str().unwrap())); fs::rmdir_recursive(&child_dir).unwrap(); diff --git a/src/test/run-pass/issue-16272.rs b/src/test/run-pass/issue-16272.rs index d73ca1b11a5..3bab78ab0df 100644 --- a/src/test/run-pass/issue-16272.rs +++ b/src/test/run-pass/issue-16272.rs @@ -9,10 +9,10 @@ // except according to those terms. use std::old_io::{process, Command}; -use std::os; +use std::env; fn main() { - let len = os::args().len(); + let len = env::args().len(); if len == 1 { test(); @@ -22,7 +22,7 @@ fn main() { } fn test() { - let status = Command::new(os::self_exe_name().unwrap()) + let status = Command::new(env::current_exe().unwrap()) .arg("foo").arg("") .stdout(process::InheritFd(1)) .stderr(process::InheritFd(2)) diff --git a/src/test/run-pass/issue-16560.rs b/src/test/run-pass/issue-16560.rs index ca40b2fe4c7..9448e605937 100644 --- a/src/test/run-pass/issue-16560.rs +++ b/src/test/run-pass/issue-16560.rs @@ -10,7 +10,7 @@ #![feature(unboxed_closures)] -use std::thread::Thread; +use std::thread; use std::mem; fn main() { @@ -20,7 +20,7 @@ fn main() { // Check that both closures are capturing by value assert_eq!(1, mem::size_of_val(&closure)); - Thread::scoped(move|| { + thread::spawn(move|| { let ok = closure; }).join().ok().unwrap(); } diff --git a/src/test/run-pass/issue-16671.rs b/src/test/run-pass/issue-16671.rs index 707aa48259a..b06c4923c16 100644 --- a/src/test/run-pass/issue-16671.rs +++ b/src/test/run-pass/issue-16671.rs @@ -17,11 +17,11 @@ // A var moved into a proc, that has a mutable loan path should // not trigger a misleading unused_mut warning. -use std::thread::Thread; +use std::thread; pub fn main() { let mut stdin = std::old_io::stdin(); - Thread::spawn(move|| { + thread::spawn(move|| { let _ = stdin.read_to_end(); }); } diff --git a/src/test/run-pass/issue-18188.rs b/src/test/run-pass/issue-18188.rs index 7a5a86822af..a4b09eb08e0 100644 --- a/src/test/run-pass/issue-18188.rs +++ b/src/test/run-pass/issue-18188.rs @@ -14,12 +14,12 @@ use std::thunk::Thunk; pub trait Promisable: Send + Sync {} impl<T: Send + Sync> Promisable for T {} -pub fn propagate<T, E, F, G>(action: F) -> Thunk<Result<T, E>, Result<T, E>> +pub fn propagate<'a, T, E, F, G>(action: F) -> Thunk<'a,Result<T, E>, Result<T, E>> where - T: Promisable + Clone, - E: Promisable + Clone, - F: FnOnce(&T) -> Result<T, E> + Send, - G: FnOnce(Result<T, E>) -> Result<T, E> { + T: Promisable + Clone + 'a, + E: Promisable + Clone + 'a, + F: FnOnce(&T) -> Result<T, E> + Send + 'a, + G: FnOnce(Result<T, E>) -> Result<T, E> + 'a { Thunk::with_arg(move |result: Result<T, E>| { match result { Ok(ref t) => action(t), diff --git a/src/test/run-pass/issue-20091.rs b/src/test/run-pass/issue-20091.rs index 3ef63a53a6d..4d20e6360ad 100644 --- a/src/test/run-pass/issue-20091.rs +++ b/src/test/run-pass/issue-20091.rs @@ -11,11 +11,11 @@ // ignore-windows currently windows requires UTF-8 for spawning processes use std::old_io::Command; -use std::os; +use std::env; fn main() { - if os::args().len() == 1 { - assert!(Command::new(os::self_exe_name().unwrap()).arg(b"\xff") + if env::args().len() == 1 { + assert!(Command::new(env::current_exe().unwrap()).arg(b"\xff") .status().unwrap().success()) } } diff --git a/src/test/run-pass/issue-21058.rs b/src/test/run-pass/issue-21058.rs index 044d43a57fa..3cdd57aed5a 100644 --- a/src/test/run-pass/issue-21058.rs +++ b/src/test/run-pass/issue-21058.rs @@ -14,7 +14,7 @@ struct DST { a: u32, b: str } fn main() { // get_tydesc should support unsized types - assert!(unsafe {( + assert_eq!(unsafe {( // Slice (*std::intrinsics::get_tydesc::<[u8]>()).name, // str @@ -25,5 +25,5 @@ fn main() { (*std::intrinsics::get_tydesc::<NT>()).name, // DST (*std::intrinsics::get_tydesc::<DST>()).name - )} == ("[u8]", "str", "core::marker::Copy + 'static", "NT", "DST")); + )}, ("[u8]", "str", "core::marker::Copy", "NT", "DST")); } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 810bf385d7e..3025741694f 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -13,11 +13,11 @@ use std::thunk::Thunk; static generations: uint = 1024+256+128+49; -fn spawn(f: Thunk) { +fn spawn(f: Thunk<'static>) { Builder::new().stack_size(32 * 1024).spawn(move|| f.invoke(())); } -fn child_no(x: uint) -> Thunk { +fn child_no(x: uint) -> Thunk<'static> { Thunk::new(move|| { if x < generations { spawn(child_no(x+1)); diff --git a/src/test/run-pass/issue-4446.rs b/src/test/run-pass/issue-4446.rs index ec4cd02e9fd..b40a726a2c3 100644 --- a/src/test/run-pass/issue-4446.rs +++ b/src/test/run-pass/issue-4446.rs @@ -10,14 +10,14 @@ use std::old_io::println; use std::sync::mpsc::channel; -use std::thread::Thread; +use std::thread; pub fn main() { let (tx, rx) = channel(); tx.send("hello, world").unwrap(); - Thread::scoped(move|| { + thread::spawn(move|| { println(rx.recv().unwrap()); }).join().ok().unwrap(); } diff --git a/src/test/run-pass/issue-4448.rs b/src/test/run-pass/issue-4448.rs index a19bfca721a..ef30f9182ba 100644 --- a/src/test/run-pass/issue-4448.rs +++ b/src/test/run-pass/issue-4448.rs @@ -9,12 +9,12 @@ // except according to those terms. use std::sync::mpsc::channel; -use std::thread::Thread; +use std::thread; pub fn main() { let (tx, rx) = channel::<&'static str>(); - let t = Thread::scoped(move|| { + let t = thread::spawn(move|| { assert_eq!(rx.recv().unwrap(), "hello, world"); }); diff --git a/src/test/run-pass/issue-4541.rs b/src/test/run-pass/issue-4541.rs index f10303e8d84..1f090d8b622 100644 --- a/src/test/run-pass/issue-4541.rs +++ b/src/test/run-pass/issue-4541.rs @@ -9,8 +9,7 @@ // except according to those terms. fn parse_args() -> String { - let args = ::std::os::args(); - let args = args; + let args: Vec<_> = ::std::env::args().collect(); let mut n = 0; while n < args.len() { diff --git a/src/test/run-pass/issue-4542.rs b/src/test/run-pass/issue-4542.rs index ae72de50d26..521e1b40f99 100644 --- a/src/test/run-pass/issue-4542.rs +++ b/src/test/run-pass/issue-4542.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::os; +use std::env; pub fn main() { - for arg in &os::args() { - match (*arg).clone() { + for arg in env::args() { + match arg.clone() { _s => { } } } diff --git a/src/test/run-pass/issue-8460.rs b/src/test/run-pass/issue-8460.rs index 4b9ed44c7cd..72a1ec436f3 100644 --- a/src/test/run-pass/issue-8460.rs +++ b/src/test/run-pass/issue-8460.rs @@ -9,31 +9,31 @@ // except according to those terms. use std::num::Int; -use std::thread::Thread; +use std::thread; // Avoid using constants, which would trigger compile-time errors. fn min_val<T: Int>() -> T { Int::min_value() } fn zero<T: Int>() -> T { Int::zero() } fn main() { - assert!(Thread::scoped(move|| min_val::<isize>() / -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i8>() / -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i16>() / -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i32>() / -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i64>() / -1).join().is_err()); - assert!(Thread::scoped(move|| 1is / zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i8 / zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i16 / zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i32 / zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i64 / zero()).join().is_err()); - assert!(Thread::scoped(move|| min_val::<isize>() % -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i8>() % -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i16>() % -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i32>() % -1).join().is_err()); - assert!(Thread::scoped(move|| min_val::<i64>() % -1).join().is_err()); - assert!(Thread::scoped(move|| 1is % zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i8 % zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i16 % zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i32 % zero()).join().is_err()); - assert!(Thread::scoped(move|| 1i64 % zero()).join().is_err()); + assert!(thread::spawn(move|| { min_val::<isize>() / -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i8>() / -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i16>() / -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i32>() / -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i64>() / -1; }).join().is_err()); + assert!(thread::spawn(move|| { 1is / zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i8 / zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i16 / zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i32 / zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i64 / zero(); }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<isize>() % -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i8>() % -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i16>() % -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i32>() % -1; }).join().is_err()); + assert!(thread::spawn(move|| { min_val::<i64>() % -1; }).join().is_err()); + assert!(thread::spawn(move|| { 1is % zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i8 % zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i16 % zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i32 % zero(); }).join().is_err()); + assert!(thread::spawn(move|| { 1i64 % zero(); }).join().is_err()); } diff --git a/src/test/run-pass/issue22008.rs b/src/test/run-pass/issue22008.rs new file mode 100644 index 00000000000..3e145122e5a --- /dev/null +++ b/src/test/run-pass/issue22008.rs @@ -0,0 +1,18 @@ +// 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. + +pub fn main() { + let command = "a"; + + match command { + "foo" => println!("foo"), + _ => println!("{}", command), + } +} diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 6c2de471f0f..2aa5a579666 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -11,6 +11,8 @@ // These are attributes of the implicit crate. Really this just needs to parse // for completeness since .rs files linked from .rc files support this // notation to specify their module's attributes + +#![feature(custom_attribute)] #![allow(unused_attribute)] #![attr1 = "val"] #![attr2 = "val"] diff --git a/src/test/run-pass/logging-only-prints-once.rs b/src/test/run-pass/logging-only-prints-once.rs index 644efe20ded..b03c4b5ff47 100644 --- a/src/test/run-pass/logging-only-prints-once.rs +++ b/src/test/run-pass/logging-only-prints-once.rs @@ -13,7 +13,7 @@ use std::cell::Cell; use std::fmt; -use std::thread::Thread; +use std::thread; struct Foo(Cell<int>); @@ -27,7 +27,7 @@ impl fmt::Debug for Foo { } pub fn main() { - Thread::scoped(move|| { + thread::spawn(move|| { let mut f = Foo(Cell::new(0)); println!("{:?}", f); let Foo(ref mut f) = f; diff --git a/src/test/run-pass/logging-separate-lines.rs b/src/test/run-pass/logging-separate-lines.rs index e1141d4ab37..8526dfe72da 100644 --- a/src/test/run-pass/logging-separate-lines.rs +++ b/src/test/run-pass/logging-separate-lines.rs @@ -15,12 +15,11 @@ extern crate log; use std::old_io::Command; -use std::os; +use std::env; use std::str; fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { debug!("foo"); debug!("bar"); diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index c015244d520..92af96e0d8f 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -10,6 +10,7 @@ // pp-exact - Make sure we print all the attributes #![allow(unused_attribute)] +#![feature(custom_attribute)] #[frobable] trait frobable { diff --git a/src/test/run-pass/no-landing-pads.rs b/src/test/run-pass/no-landing-pads.rs index c90c6ce87f0..5ce32e4fe2c 100644 --- a/src/test/run-pass/no-landing-pads.rs +++ b/src/test/run-pass/no-landing-pads.rs @@ -10,7 +10,7 @@ // compile-flags: -Z no-landing-pads -use std::thread::Thread; +use std::thread; static mut HIT: bool = false; @@ -23,7 +23,7 @@ impl Drop for A { } fn main() { - Thread::scoped(move|| -> () { + thread::spawn(move|| -> () { let _a = A; panic!(); }).join().err().unwrap(); diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs index ca9ee469e38..f574259c375 100644 --- a/src/test/run-pass/out-of-stack-new-thread-no-split.rs +++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs @@ -16,7 +16,7 @@ #![feature(asm)] use std::old_io::process::Command; -use std::os; +use std::env; use std::thread::Thread; // lifted from the test module @@ -34,8 +34,7 @@ fn recurse() { } fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "recurse" { let _t = Thread::scoped(recurse); } else { diff --git a/src/test/run-pass/out-of-stack-no-split.rs b/src/test/run-pass/out-of-stack-no-split.rs index fba86d74816..948c4d064d7 100644 --- a/src/test/run-pass/out-of-stack-no-split.rs +++ b/src/test/run-pass/out-of-stack-no-split.rs @@ -17,7 +17,7 @@ #![feature(asm)] use std::old_io::process::Command; -use std::os; +use std::env; // lifted from the test module // Inlining to avoid llvm turning the recursive functions into tail calls, @@ -34,7 +34,7 @@ fn recurse() { } fn main() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "recurse" { recurse(); } else { diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 7dfd46fb995..cc5eb69bb87 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -13,7 +13,7 @@ #![feature(asm)] use std::old_io::process::Command; -use std::os; +use std::env; // lifted from the test module // Inlining to avoid llvm turning the recursive functions into tail calls, @@ -34,8 +34,7 @@ fn loud_recurse() { } fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "silent" { silent_recurse(); } else if args.len() > 1 && args[1] == "loud" { diff --git a/src/test/run-pass/panic-in-dtor-drops-fields.rs b/src/test/run-pass/panic-in-dtor-drops-fields.rs index 3cc01b967ce..6da15b97aca 100644 --- a/src/test/run-pass/panic-in-dtor-drops-fields.rs +++ b/src/test/run-pass/panic-in-dtor-drops-fields.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::thread::Thread; +use std::thread; static mut dropped: bool = false; @@ -33,7 +33,7 @@ impl Drop for B { } pub fn main() { - let ret = Thread::scoped(move|| { + let ret = thread::spawn(move|| { let _a = A { b: B { foo: 3 } }; }).join(); assert!(ret.is_err()); diff --git a/src/test/run-pass/process-spawn-with-unicode-params.rs b/src/test/run-pass/process-spawn-with-unicode-params.rs index 15cc128d380..017784990f4 100644 --- a/src/test/run-pass/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process-spawn-with-unicode-params.rs @@ -20,12 +20,13 @@ use std::old_io; use std::old_io::fs; use std::old_io::Command; use std::os; +use std::env; use std::old_path::Path; fn main() { - let my_args = os::args(); + let my_args = env::args().collect::<Vec<_>>(); let my_cwd = os::getcwd().unwrap(); - let my_env = os::env(); + let my_env = env::vars().collect::<Vec<_>>(); let my_path = Path::new(os::self_exe_name().unwrap()); let my_dir = my_path.dir_path(); let my_ext = my_path.extension_str().unwrap_or(""); diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs index a2706dca7d3..492736c2252 100644 --- a/src/test/run-pass/segfault-no-out-of-stack.rs +++ b/src/test/run-pass/segfault-no-out-of-stack.rs @@ -9,10 +9,10 @@ // except according to those terms. use std::old_io::process::Command; -use std::os; +use std::env; fn main() { - let args = os::args(); + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "segfault" { unsafe { *(0 as *mut int) = 1 }; // trigger a segfault } else { diff --git a/src/test/run-pass/send-is-not-static-par-for.rs b/src/test/run-pass/send-is-not-static-par-for.rs new file mode 100755 index 00000000000..c6b64d97fbd --- /dev/null +++ b/src/test/run-pass/send-is-not-static-par-for.rs @@ -0,0 +1,47 @@ +// 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. + +#![feature(core, std_misc)] +use std::thread::Thread; +use std::sync::Mutex; + +fn par_for<I, F>(iter: I, f: F) + where I: Iterator, + <I as Iterator>::Item: Send, + F: Fn(<I as Iterator>::Item) + Sync +{ + let f = &f; + let _guards: Vec<_> = iter.map(|elem| { + Thread::scoped(move || { + f(elem) + }) + }).collect(); + +} + +fn sum(x: &[i32]) { + let sum_lengths = Mutex::new(0); + par_for(x.windows(4), |x| { + *sum_lengths.lock().unwrap() += x.len() + }); + + assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4); +} + +fn main() { + let mut elements = [0; 20]; + + // iterators over references into this stack frame + par_for(elements.iter_mut().enumerate(), |(i, x)| { + *x = i as i32 + }); + + sum(&elements) +} diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index ae992a0a358..60093803f0b 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -16,7 +16,7 @@ struct Command<K, V> { val: V } -fn cache_server<K:Send,V:Send>(mut tx: Sender<Sender<Command<K, V>>>) { +fn cache_server<K:Send+'static,V:Send+'static>(mut tx: Sender<Sender<Command<K, V>>>) { let (tx1, _rx) = channel(); tx.send(tx1); } diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index 6c9707103b9..523b7528103 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -11,7 +11,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -use std::thread::Thread; +use std::thread; pub fn main() { test05(); } @@ -25,7 +25,7 @@ fn test05() { println!("{}", *three + n); // will copy x into the closure assert_eq!(*three, 3); }; - Thread::scoped(move|| { + thread::spawn(move|| { test05_start(fn_to_send); }).join().ok().unwrap(); } diff --git a/src/test/run-pass/sepcomp-unwind.rs b/src/test/run-pass/sepcomp-unwind.rs index f68dea04a08..21c5a6fc83a 100644 --- a/src/test/run-pass/sepcomp-unwind.rs +++ b/src/test/run-pass/sepcomp-unwind.rs @@ -19,7 +19,7 @@ // In any case, this test should let us know if enabling parallel codegen ever // breaks unwinding. -use std::thread::Thread; +use std::thread; fn pad() -> uint { 0 } @@ -36,5 +36,5 @@ mod b { } fn main() { - Thread::scoped(move|| { ::b::g() }).join().err().unwrap(); + thread::spawn(move|| { ::b::g() }).join().err().unwrap(); } diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index 856eb241add..776d897938d 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -10,12 +10,11 @@ // ignore-windows -use std::os; +use std::env; use std::old_io::process::{Command, ExitSignal, ExitStatus}; pub fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() >= 2 && args[1] == "signal" { // Raise a segfault. unsafe { *(0 as *mut int) = 0; } diff --git a/src/test/run-pass/sigpipe-should-be-ignored.rs b/src/test/run-pass/sigpipe-should-be-ignored.rs index de8f76518fc..d1428c6be19 100644 --- a/src/test/run-pass/sigpipe-should-be-ignored.rs +++ b/src/test/run-pass/sigpipe-should-be-ignored.rs @@ -12,6 +12,7 @@ // doesn't die in a ball of fire, but rather it's gracefully handled. use std::os; +use std::env; use std::old_io::PipeStream; use std::old_io::Command; @@ -25,8 +26,7 @@ fn test() { } fn main() { - let args = os::args(); - let args = args; + let args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "test" { return test(); } diff --git a/src/test/run-pass/slice-panic-1.rs b/src/test/run-pass/slice-panic-1.rs index b2e3d83ca9b..639ffd56002 100644 --- a/src/test/run-pass/slice-panic-1.rs +++ b/src/test/run-pass/slice-panic-1.rs @@ -10,7 +10,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -use std::thread::Thread; +use std::thread; struct Foo; @@ -26,6 +26,6 @@ fn foo() { } fn main() { - let _ = Thread::scoped(move|| foo()).join(); + let _ = thread::spawn(move|| foo()).join(); unsafe { assert!(DTOR_COUNT == 2); } } diff --git a/src/test/run-pass/slice-panic-2.rs b/src/test/run-pass/slice-panic-2.rs index dea45e63ab0..4a2038175d2 100644 --- a/src/test/run-pass/slice-panic-2.rs +++ b/src/test/run-pass/slice-panic-2.rs @@ -10,7 +10,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -use std::thread::Thread; +use std::thread; struct Foo; @@ -30,6 +30,6 @@ fn foo() { } fn main() { - let _ = Thread::scoped(move|| foo()).join(); + let _ = thread::spawn(move|| foo()).join(); unsafe { assert!(DTOR_COUNT == 2); } } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index eaad2abe8f7..bf2f03b3e6d 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -14,7 +14,7 @@ Arnold. */ -use std::thread::Thread; +use std::thread; use std::sync::mpsc::{channel, Sender}; type ctx = Sender<int>; @@ -25,6 +25,6 @@ fn iotask(_tx: &ctx, ip: String) { pub fn main() { let (tx, _rx) = channel::<int>(); - let t = Thread::scoped(move|| iotask(&tx, "localhost".to_string()) ); + let t = thread::spawn(move|| iotask(&tx, "localhost".to_string()) ); t.join().ok().unwrap(); } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 8f937afa6b9..90b47f4986b 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::thread::Thread; +use std::thread; pub fn main() { - Thread::scoped(move|| child(10)).join().ok().unwrap(); + thread::spawn(move|| child(10)).join().ok().unwrap(); } fn child(i: int) { println!("{}", i); assert!((i == 10)); } diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index 75104a4ddef..91edb5fd9c1 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::thread::Thread; +use std::thread; pub fn main() { - let t = Thread::scoped(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); + let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); t.join().ok().unwrap(); } diff --git a/src/test/run-pass/task-stderr.rs b/src/test/run-pass/task-stderr.rs index 5994b24dfdc..1c263b19dd1 100644 --- a/src/test/run-pass/task-stderr.rs +++ b/src/test/run-pass/task-stderr.rs @@ -20,9 +20,10 @@ fn main() { let mut reader = ChanReader::new(rx); let stderr = ChanWriter::new(tx); - let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>).scoped(move|| -> () { + let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>) + .spawn(move|| -> () { panic!("Hello, world!") - }).join(); + }).unwrap().join(); assert!(res.is_err()); let output = reader.read_to_string().unwrap(); diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index 4df1ff14810..053df3a57f3 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -23,7 +23,7 @@ use std::old_io::{fs, TempDir}; use std::old_io; use std::os; use std::sync::mpsc::channel; -use std::thread::Thread; +use std::thread; fn test_tempdir() { let path = { @@ -42,7 +42,7 @@ fn test_rm_tempdir() { tx.send(tmp.path().clone()).unwrap(); panic!("panic to unwind past `tmp`"); }; - let _ = Thread::scoped(f).join(); + thread::spawn(f).join(); let path = rx.recv().unwrap(); assert!(!path.exists()); @@ -52,7 +52,7 @@ fn test_rm_tempdir() { let _tmp = tmp; panic!("panic to unwind past `tmp`"); }; - let _ = Thread::scoped(f).join(); + thread::spawn(f).join(); assert!(!path.exists()); let path; @@ -61,7 +61,7 @@ fn test_rm_tempdir() { TempDir::new("test_rm_tempdir").unwrap() }; // FIXME(#16640) `: TempDir` annotation shouldn't be necessary - let tmp: TempDir = Thread::scoped(f).join().ok().expect("test_rm_tmdir"); + let tmp: TempDir = thread::scoped(f).join(); path = tmp.path().clone(); assert!(path.exists()); } @@ -85,7 +85,7 @@ fn test_rm_tempdir_close() { tmp.close(); panic!("panic when unwinding past `tmp`"); }; - let _ = Thread::scoped(f).join(); + thread::spawn(f).join(); let path = rx.recv().unwrap(); assert!(!path.exists()); @@ -96,7 +96,7 @@ fn test_rm_tempdir_close() { tmp.close(); panic!("panic when unwinding past `tmp`"); }; - let _ = Thread::scoped(f).join(); + thread::spawn(f).join(); assert!(!path.exists()); let path; @@ -105,7 +105,7 @@ fn test_rm_tempdir_close() { TempDir::new("test_rm_tempdir").unwrap() }; // FIXME(#16640) `: TempDir` annotation shouldn't be necessary - let tmp: TempDir = Thread::scoped(f).join().ok().expect("test_rm_tmdir"); + let tmp: TempDir = thread::scoped(f).join(); path = tmp.path().clone(); assert!(path.exists()); tmp.close(); @@ -179,7 +179,7 @@ pub fn test_rmdir_recursive_ok() { } pub fn dont_double_panic() { - let r: Result<(), _> = Thread::scoped(move|| { + let r: Result<(), _> = thread::spawn(move|| { let tmpdir = TempDir::new("test").unwrap(); // Remove the temporary directory so that TempDir sees // an error on drop diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 185edb02cca..bef9efa9eb6 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -12,7 +12,7 @@ // Issue #787 // Don't try to clean up uninitialized locals -use std::thread::Thread; +use std::thread; fn test_break() { loop { let _x: Box<int> = break; } } @@ -22,13 +22,13 @@ fn test_ret() { let _x: Box<int> = return; } fn test_panic() { fn f() { let _x: Box<int> = panic!(); } - Thread::scoped(move|| f() ).join().err().unwrap(); + thread::spawn(move|| f() ).join().err().unwrap(); } fn test_panic_indirect() { fn f() -> ! { panic!(); } fn g() { let _x: Box<int> = f(); } - Thread::scoped(move|| g() ).join().err().unwrap(); + thread::spawn(move|| g() ).join().err().unwrap(); } pub fn main() { diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index f0b634c0d44..08ffe403696 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] use std::sync::mpsc::{channel, Sender}; -use std::thread::Thread; +use std::thread; fn child(tx: &Sender<Box<uint>>, i: uint) { tx.send(box i).unwrap(); @@ -25,7 +25,7 @@ pub fn main() { let _t = (0u..n).map(|i| { expected += i; let tx = tx.clone(); - Thread::scoped(move|| { + thread::spawn(move|| { child(&tx, i) }) }).collect::<Vec<_>>(); diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index 0acf736e2ab..ac46187f03a 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -11,7 +11,7 @@ // Make sure the destructor is run for unit-like structs. use std::boxed::BoxAny; -use std::thread::Thread; +use std::thread; struct Foo; @@ -22,7 +22,7 @@ impl Drop for Foo { } pub fn main() { - let x = Thread::scoped(move|| { + let x = thread::spawn(move|| { let _b = Foo; }).join(); diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 159bac10183..52c09aadfbd 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::sync::mpsc::{channel, Sender}; -use std::thread::Thread; +use std::thread; struct complainer { tx: Sender<bool>, @@ -37,7 +37,7 @@ fn f(tx: Sender<bool>) { pub fn main() { let (tx, rx) = channel(); - let _t = Thread::scoped(move|| f(tx.clone())); + let _t = thread::spawn(move|| f(tx.clone())); println!("hiiiiiiiii"); assert!(rx.recv().unwrap()); } diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index ea52802d245..d38b6e79eba 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -11,7 +11,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -use std::thread::Thread; +use std::thread; fn f() { let _a = box 0; @@ -19,5 +19,5 @@ fn f() { } pub fn main() { - let _t = Thread::scoped(f); + let _t = thread::spawn(f); } diff --git a/src/test/run-pass/variant-attributes.rs b/src/test/run-pass/variant-attributes.rs index 88255ad94fd..16dca2db396 100644 --- a/src/test/run-pass/variant-attributes.rs +++ b/src/test/run-pass/variant-attributes.rs @@ -9,6 +9,7 @@ // except according to those terms. // pp-exact - Make sure we actually print the attributes +#![feature(custom_attribute)] enum crew_of_enterprise_d { diff --git a/src/test/run-pass/vec-macro-repeat.rs b/src/test/run-pass/vec-macro-repeat.rs index 9e69ecfce4f..76e7b92ea04 100644 --- a/src/test/run-pass/vec-macro-repeat.rs +++ b/src/test/run-pass/vec-macro-repeat.rs @@ -14,4 +14,9 @@ pub fn main() { assert_eq!(vec![1; 2], vec![1, 1]); assert_eq!(vec![1; 1], vec![1]); assert_eq!(vec![1; 0], vec![]); + + // from_elem syntax (see RFC 832) + let el = Box::new(1); + let n = 3; + assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]); } diff --git a/src/test/run-pass/vector-sort-panic-safe.rs b/src/test/run-pass/vector-sort-panic-safe.rs index d13369b1f52..da9cf35813b 100644 --- a/src/test/run-pass/vector-sort-panic-safe.rs +++ b/src/test/run-pass/vector-sort-panic-safe.rs @@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use std::rand::{thread_rng, Rng, Rand}; -use std::thread::Thread; +use std::thread; const REPEATS: usize = 5; const MAX_LEN: usize = 32; @@ -79,7 +79,7 @@ pub fn main() { let v = main.clone(); - let _ = Thread::scoped(move|| { + let _ = thread::spawn(move|| { let mut v = v; let mut panic_countdown = panic_countdown; v.sort_by(|a, b| { diff --git a/src/test/run-pass/weak-lang-item.rs b/src/test/run-pass/weak-lang-item.rs index b1c65d322ab..741e8be02f7 100644 --- a/src/test/run-pass/weak-lang-item.rs +++ b/src/test/run-pass/weak-lang-item.rs @@ -12,10 +12,10 @@ extern crate "weak-lang-items" as other; -use std::thread::Thread; +use std::thread; fn main() { - let _ = Thread::scoped(move|| { + let _ = thread::spawn(move|| { other::foo() }); } diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs index 9ad6dd9d2b1..45a74750958 100644 --- a/src/test/run-pass/yield.rs +++ b/src/test/run-pass/yield.rs @@ -8,18 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::thread::Thread; +use std::thread; pub fn main() { - let mut result = Thread::scoped(child); + let mut result = thread::spawn(child); println!("1"); - Thread::yield_now(); + thread::yield_now(); println!("2"); - Thread::yield_now(); + thread::yield_now(); println!("3"); result.join(); } fn child() { - println!("4"); Thread::yield_now(); println!("5"); Thread::yield_now(); println!("6"); + println!("4"); thread::yield_now(); println!("5"); thread::yield_now(); println!("6"); } diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs index 3d3a36021da..69d8431082c 100644 --- a/src/test/run-pass/yield1.rs +++ b/src/test/run-pass/yield1.rs @@ -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; pub fn main() { - let mut result = Thread::scoped(child); + let mut result = thread::spawn(child); println!("1"); - Thread::yield_now(); + thread::yield_now(); result.join(); } diff --git a/src/test/run-pass/yield2.rs b/src/test/run-pass/yield2.rs index 66ad7de0296..56dc02c6d2e 100644 --- a/src/test/run-pass/yield2.rs +++ b/src/test/run-pass/yield2.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::thread::Thread; +use std::thread; pub fn main() { let mut i: int = 0; - while i < 100 { i = i + 1; println!("{}", i); Thread::yield_now(); } + while i < 100 { i = i + 1; println!("{}", i); thread::yield_now(); } } |
