std: Clean out #[deprecated] APIs
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
This commit is contained in:
parent
d754722a04
commit
d4a2c94180
166 changed files with 602 additions and 4014 deletions
|
|
@ -38,11 +38,10 @@
|
|||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#![feature(rustc_private, core)]
|
||||
#![feature(rustc_private, core, step_by)]
|
||||
|
||||
extern crate arena;
|
||||
|
||||
use std::iter::range_step;
|
||||
use std::thread;
|
||||
use arena::TypedArena;
|
||||
|
||||
|
|
@ -109,7 +108,7 @@ fn main() {
|
|||
let long_lived_arena = TypedArena::new();
|
||||
let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
|
||||
|
||||
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||
let messages = (min_depth..max_depth + 1).step_by(2).map(|depth| {
|
||||
use std::num::Int;
|
||||
let iterations = 2.pow((max_depth - depth + min_depth) as u32);
|
||||
thread::scoped(move || inner(depth, iterations))
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#![feature(core)]
|
||||
#![feature(step_by)]
|
||||
|
||||
use std::{cmp, iter, mem};
|
||||
use std::{cmp, mem};
|
||||
use std::thread;
|
||||
|
||||
fn rotate(x: &mut [i32]) {
|
||||
|
|
@ -163,7 +163,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
let mut futures = vec![];
|
||||
let k = perm.max() / N;
|
||||
|
||||
for (_, j) in (0..N).zip(iter::count(0, k)) {
|
||||
for (_, j) in (0..N).zip((0..).step_by(k)) {
|
||||
let max = cmp::min(j+k, perm.max());
|
||||
|
||||
futures.push(thread::scoped(move|| {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ fn main() {
|
|||
|
||||
// start processing if this is the one
|
||||
('>', false) => {
|
||||
match line[1..].find_str("THREE") {
|
||||
match line[1..].find("THREE") {
|
||||
Some(_) => { proc_mode = true; }
|
||||
None => { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,9 @@ fn dot(v: &[f64], u: &[f64]) -> f64 {
|
|||
fn parallel<'a,T, F>(v: &mut [T], ref f: F)
|
||||
where T: Send + Sync + 'a,
|
||||
F: Fn(usize, &mut [T]) + Sync + 'a {
|
||||
let size = v.len() / os::num_cpus() + 1;
|
||||
// FIXME: pick a more appropriate parallel factor
|
||||
let parallelism = 4;
|
||||
let size = v.len() / parallelism + 1;
|
||||
v.chunks_mut(size).enumerate().map(|(i, chunk)| {
|
||||
thread::scoped(move|| {
|
||||
f(i * size, chunk)
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ use id::Id;
|
|||
|
||||
mod s {
|
||||
#![allow(unstable)]
|
||||
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
|
||||
static S_COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
||||
static S_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
pub fn next_count() -> usize {
|
||||
S_COUNT.fetch_add(1, Ordering::SeqCst) + 1
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ use id::Id;
|
|||
|
||||
mod s {
|
||||
#![allow(unstable)]
|
||||
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
|
||||
static S_COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
||||
static S_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
pub fn next_count() -> usize {
|
||||
S_COUNT.fetch_add(1, Ordering::SeqCst) + 1
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ use id::Id;
|
|||
|
||||
mod s {
|
||||
#![allow(unstable)]
|
||||
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
|
||||
static S_COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
||||
static S_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
pub fn next_count() -> usize {
|
||||
S_COUNT.fetch_add(1, Ordering::SeqCst) + 1
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ fn has_uniq(x: String) {
|
|||
|
||||
fn has_slice(x: &str) {
|
||||
wants_uniq(x); //~ ERROR mismatched types
|
||||
wants_slice(x.as_slice());
|
||||
wants_slice(x);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::iter::{Range,range};
|
||||
use std::ops::Range;
|
||||
|
||||
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
|
||||
|
||||
impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
|
||||
fn iter(&'r self) -> Range<usize> {
|
||||
let &(min, max) = self;
|
||||
range(min, max)
|
||||
min..max
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@
|
|||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
(|| Box::new(*[0].as_slice()))();
|
||||
(|| Box::new(*(&[0][..])))();
|
||||
//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[_]`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
use std::iter::{Range,range};
|
||||
use std::ops::Range;
|
||||
|
||||
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
|
||||
|
||||
impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
|
||||
fn iter(&'r self) -> Range<usize> {
|
||||
let &(min, max) = self;
|
||||
range(min, max)
|
||||
min..max
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
// 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 deprecated markers still have their old effect.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::marker;
|
||||
|
||||
#[rustc_variance]
|
||||
struct A<T>(marker::CovariantType<T>); //~ ERROR types=[[+];[];[]]
|
||||
|
||||
#[rustc_variance]
|
||||
struct B<T>(marker::ContravariantType<T>); //~ ERROR types=[[-];[];[]]
|
||||
|
||||
#[rustc_variance]
|
||||
struct C<T>(marker::InvariantType<T>); //~ ERROR types=[[o];[];[]]
|
||||
|
||||
#[rustc_variance]
|
||||
struct D<'a>(marker::CovariantLifetime<'a>); //~ ERROR regions=[[+];[];[]]
|
||||
|
||||
#[rustc_variance]
|
||||
struct E<'a>(marker::ContravariantLifetime<'a>); //~ ERROR regions=[[-];[];[]]
|
||||
|
||||
#[rustc_variance]
|
||||
struct F<'a>(marker::InvariantLifetime<'a>); //~ ERROR regions=[[o];[];[]]
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -30,9 +30,9 @@ use id::Id;
|
|||
|
||||
mod s {
|
||||
#![allow(unstable)]
|
||||
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
|
||||
static S_COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
||||
static S_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
/// generates globally unique count (global across the current
|
||||
/// process, that is)
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ fn main() {
|
|||
v.push(&x); //~ ERROR `x` does not live long enough
|
||||
v.push(&y); //~ ERROR `y` does not live long enough
|
||||
|
||||
assert_eq!(v.as_slice(), [&3, &4]);
|
||||
assert_eq!(v, [&3, &4]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
|
||||
// error-pattern:whatever
|
||||
|
||||
#![feature(os, rustc_private)]
|
||||
#![feature(exit_status, rustc_private)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
error!("whatever");
|
||||
// Setting the exit status only works when the scheduler terminates
|
||||
// normally. In this case we're going to panic, so instead of
|
||||
// returning 50 the process will return the typical rt failure code.
|
||||
os::set_exit_status(50);
|
||||
env::set_exit_status(50);
|
||||
panic!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
// error-pattern:whatever
|
||||
|
||||
#![feature(os, rustc_private)]
|
||||
#![feature(exit_status, rustc_private)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::thread;
|
||||
|
||||
struct r {
|
||||
|
|
@ -25,7 +25,7 @@ struct r {
|
|||
// runtime's exit code
|
||||
impl Drop for r {
|
||||
fn drop(&mut self) {
|
||||
os::set_exit_status(50);
|
||||
env::set_exit_status(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@
|
|||
|
||||
// error-pattern:whatever
|
||||
|
||||
#![feature(rustc_private, os)]
|
||||
#![feature(rustc_private, exit_status)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
use std::os;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
error!("whatever");
|
||||
// 101 is the code the runtime uses on task panic and the value
|
||||
// compiletest expects run-fail tests to return.
|
||||
os::set_exit_status(101);
|
||||
env::set_exit_status(101);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(libc, os)]
|
||||
#![feature(libc, exit_status)]
|
||||
|
||||
extern crate libc;
|
||||
|
||||
|
|
@ -23,6 +23,6 @@ fn main() {
|
|||
};
|
||||
|
||||
if result != 1 {
|
||||
std::os::set_exit_status(255);
|
||||
std::env::set_exit_status(255);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ fn main() {
|
|||
let expected_span = format!("\n{}^{}\n",
|
||||
repeat(" ").take(offset + 7).collect::<String>(),
|
||||
repeat("~").take(8).collect::<String>());
|
||||
assert!(err.contains(expected_span.as_slice()));
|
||||
assert!(err.contains(&expected_span));
|
||||
// Second snake is 8 ~s long, with 36 preceding spaces
|
||||
let expected_span = format!("\n{}^{}\n",
|
||||
repeat(" ").take(offset + 36).collect::<String>(),
|
||||
repeat("~").take(8).collect::<String>());
|
||||
assert!(err.contains(expected_span.as_slice()));
|
||||
assert!(err.contains(&expected_span));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,6 @@ fn main() {
|
|||
let mut tc = TestCalls { count: 1 };
|
||||
// we should never get use this filename, but lets make sure they are valid args.
|
||||
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
|
||||
rustc_driver::run_compiler(args.as_slice(), &mut tc);
|
||||
rustc_driver::run_compiler(&args, &mut tc);
|
||||
assert!(tc.count == 30);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(tempdir)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_back;
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, TempDir};
|
||||
use std::fs;
|
||||
use rustc_back::tempdir::TempDir;
|
||||
|
||||
fn main() {
|
||||
let td = TempDir::new("create-dir-all-bare").unwrap();
|
||||
|
|
@ -13,10 +13,13 @@
|
|||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(tempdir, path_ext)]
|
||||
#![feature(rustc_private, path_ext)]
|
||||
|
||||
extern crate rustc_back;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::fs::{self, TempDir, File, PathExt};
|
||||
use std::fs::{self, File, PathExt};
|
||||
use rustc_back::tempdir::TempDir;
|
||||
|
||||
fn rename_directory() {
|
||||
let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed");
|
||||
|
|
@ -80,9 +80,9 @@ fn runtest(me: &str) {
|
|||
let s = str::from_utf8(&out.error).unwrap();
|
||||
let mut i = 0;
|
||||
for _ in 0..2 {
|
||||
i += s[i + 10..].find_str("stack backtrace").unwrap() + 10;
|
||||
i += s[i + 10..].find("stack backtrace").unwrap() + 10;
|
||||
}
|
||||
assert!(s[i + 10..].find_str("stack backtrace").is_none(),
|
||||
assert!(s[i + 10..].find("stack backtrace").is_none(),
|
||||
"bad output4: {}", s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use log::{set_logger, Logger, LogRecord};
|
|||
use std::sync::mpsc::channel;
|
||||
use std::fmt;
|
||||
use std::old_io::{ChanReader, ChanWriter, Reader, Writer};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
struct MyWriter(ChanWriter);
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ impl Logger for MyWriter {
|
|||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
set_logger(box MyWriter(w) as Box<Logger+Send>);
|
||||
debug!("debug");
|
||||
info!("info");
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn child2(_s: String) { }
|
||||
|
||||
pub fn main() {
|
||||
let _x = Thread::spawn(move|| child2("hi".to_string()));
|
||||
let _x = thread::spawn(move|| child2("hi".to_string()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax, std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
struct Pair {
|
||||
a: isize,
|
||||
|
|
@ -23,7 +23,7 @@ struct Pair {
|
|||
pub fn main() {
|
||||
let z: Box<_> = box Pair { a : 10, b : 12};
|
||||
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
assert_eq!(z.a, 10);
|
||||
assert_eq!(z.b, 12);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| { child(&tx) });
|
||||
let _t = thread::scoped(move|| { child(&tx) });
|
||||
let y = rx.recv().unwrap();
|
||||
println!("received");
|
||||
println!("{}", y);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::old_io::{Process, Command, timer};
|
|||
use std::time::Duration;
|
||||
use std::str;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
macro_rules! succeed { ($e:expr) => (
|
||||
match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) }
|
||||
|
|
@ -86,7 +86,7 @@ pub fn test_destroy_actually_kills(force: bool) {
|
|||
let (tx, rx1) = channel();
|
||||
let mut t = timer::Timer::new().unwrap();
|
||||
let rx2 = t.oneshot(Duration::milliseconds(1000));
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
select! {
|
||||
_ = rx2.recv() => unsafe { libc::exit(1) },
|
||||
_ = rx1.recv() => {}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
fn main() {
|
||||
let args = vec!("foobie", "asdf::asdf");
|
||||
let arr: Vec<&str> = args[1].split_str("::").collect();
|
||||
let arr: Vec<&str> = args[1].split("::").collect();
|
||||
assert_eq!(arr[0], "asdf");
|
||||
assert_eq!(arr[0], "asdf");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#![feature(libc, std_misc)]
|
||||
|
||||
extern crate libc;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
mod rustrt {
|
||||
extern crate libc;
|
||||
|
|
@ -46,7 +46,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
|||
pub fn main() {
|
||||
// Make sure we're on a task with small Rust stacks (main currently
|
||||
// has a large stack)
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
let result = count(12);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 2048);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ mod map_reduce {
|
|||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::str;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub type putter<'a> = Box<FnMut(String, String) + 'a>;
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ mod map_reduce {
|
|||
for i in &inputs {
|
||||
let ctrl = ctrl.clone();
|
||||
let i = i.clone();
|
||||
Thread::spawn(move|| map_task(ctrl.clone(), i.clone()) );
|
||||
thread::spawn(move|| map_task(ctrl.clone(), i.clone()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#![feature(intrinsics, std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
pub fn init<T>() -> T;
|
||||
|
|
@ -26,7 +26,7 @@ const SIZE: usize = 1024 * 1024;
|
|||
|
||||
fn main() {
|
||||
// do the test in a new thread to avoid (spurious?) stack overflows
|
||||
let _ = Thread::scoped(|| {
|
||||
let _ = thread::scoped(|| {
|
||||
let _memory: [u8; SIZE] = unsafe { init() };
|
||||
}).join();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ fn main() {
|
|||
fn parent() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let mut p = Command::new(&args[0]).arg("child")
|
||||
.stdout(Stdio::capture())
|
||||
.stdin(Stdio::capture())
|
||||
.stdout(Stdio::piped())
|
||||
.stdin(Stdio::piped())
|
||||
.spawn().unwrap();
|
||||
p.stdin.as_mut().unwrap().write_all(b"test1\ntest2\ntest3").unwrap();
|
||||
let out = p.wait_with_output().unwrap();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#![feature(std_misc)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn helper(rx: Receiver<Sender<()>>) {
|
||||
for tx in rx.iter() {
|
||||
|
|
@ -26,7 +26,7 @@ fn helper(rx: Receiver<Sender<()>>) {
|
|||
|
||||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| { helper(rx) });
|
||||
let _t = thread::scoped(move|| { helper(rx) });
|
||||
let (snd, rcv) = channel::<isize>();
|
||||
for _ in 1..100000 {
|
||||
snd.send(1).unwrap();
|
||||
|
|
@ -37,4 +37,5 @@ fn main() {
|
|||
_ = rcv.recv() => ()
|
||||
}
|
||||
}
|
||||
drop(tx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ fn child() {
|
|||
fn test() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let mut p = Command::new(&args[0]).arg("child")
|
||||
.stdin(Stdio::capture())
|
||||
.stdout(Stdio::capture())
|
||||
.stderr(Stdio::capture())
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn().unwrap();
|
||||
assert!(p.wait().unwrap().success());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@
|
|||
|
||||
#![feature(core)]
|
||||
|
||||
trait Str { fn foo(&self) {} }
|
||||
impl Str for str {}
|
||||
impl<'a, S: ?Sized> Str for &'a S where S: Str {}
|
||||
|
||||
fn main() {
|
||||
let _: &Str = &"x";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@
|
|||
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
thread::Thread::spawn(move || { // no need for -> ()
|
||||
fn _foo() {
|
||||
let _t = thread::scoped(move || { // no need for -> ()
|
||||
loop {
|
||||
println!("hello");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub mod pipes {
|
|||
use std::mem::{forget, transmute};
|
||||
use std::mem::{replace, swap};
|
||||
use std::mem;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::marker::Send;
|
||||
|
||||
pub struct Stuff<T> {
|
||||
|
|
@ -115,7 +115,7 @@ pub mod pipes {
|
|||
let old_state = swap_state_acq(&mut (*p).state,
|
||||
blocked);
|
||||
match old_state {
|
||||
empty | blocked => { Thread::yield_now(); }
|
||||
empty | blocked => { thread::yield_now(); }
|
||||
full => {
|
||||
let payload = replace(&mut p.payload, None);
|
||||
return Some(payload.unwrap())
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thunk::Invoke;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ enum Msg
|
|||
}
|
||||
|
||||
fn foo(name: String, samples_chan: Sender<Msg>) {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
let mut samples_chan = samples_chan;
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
|
||||
fn periodical(n: isize) -> Receiver<bool> {
|
||||
let (chan, port) = channel();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
loop {
|
||||
for _ in 1..n {
|
||||
match chan.send(false) {
|
||||
|
|
@ -34,7 +34,7 @@ fn periodical(n: isize) -> Receiver<bool> {
|
|||
|
||||
fn integers() -> Receiver<isize> {
|
||||
let (chan, port) = channel();
|
||||
Thread::spawn(move|| {
|
||||
thread::spawn(move|| {
|
||||
let mut i = 1;
|
||||
loop {
|
||||
match chan.send(i) {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
|
||||
use std::sync::mpsc::{TryRecvError, channel};
|
||||
use std::old_io::timer::Timer;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::scoped(move||{
|
||||
let _t = thread::scoped(move||{
|
||||
let mut timer = Timer::new().unwrap();
|
||||
timer.sleep(Duration::milliseconds(10));
|
||||
tx.send(()).unwrap();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
fn producer(tx: &Sender<Vec<u8>>) {
|
||||
|
|
@ -23,7 +23,7 @@ fn producer(tx: &Sender<Vec<u8>>) {
|
|||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel::<Vec<u8>>();
|
||||
let _prod = Thread::spawn(move|| {
|
||||
let _prod = thread::scoped(move|| {
|
||||
producer(&tx)
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn user(_i: isize) {}
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ fn foo() {
|
|||
// Here, i is *copied* into the proc (heap closure).
|
||||
// Requires allocation. The proc's copy is not mutable.
|
||||
let mut i = 0;
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
user(i);
|
||||
println!("spawned {}", i)
|
||||
});
|
||||
|
|
@ -31,7 +31,7 @@ fn bar() {
|
|||
// mutable outside of the proc.
|
||||
let mut i = 0;
|
||||
while i < 10 {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
user(i);
|
||||
});
|
||||
i += 1;
|
||||
|
|
@ -42,7 +42,7 @@ fn car() {
|
|||
// Here, i must be shadowed in the proc to be mutable.
|
||||
let mut i = 0;
|
||||
while i < 10 {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
let mut i = i;
|
||||
i += 1;
|
||||
user(i);
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
macro_rules! expr { ($e: expr) => { $e } }
|
||||
|
||||
macro_rules! spawn {
|
||||
($($code: tt)*) => {
|
||||
expr!(Thread::spawn(move|| {$($code)*}))
|
||||
expr!(thread::spawn(move|| {$($code)*}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ impl<T> B for *const [T] {
|
|||
|
||||
fn main() {
|
||||
let x: [isize; 4] = [1,2,3,4];
|
||||
let xptr = x.as_slice() as *const [isize];
|
||||
let xptr = &x[..] as *const [isize];
|
||||
xptr.foo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() {
|
||||
let x = "Hello world!".to_string();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
println!("{}", x);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
pub fn main() {
|
||||
let thing = "{{ f }}";
|
||||
let f = thing.find_str("{{");
|
||||
let f = thing.find("{{");
|
||||
|
||||
if f.is_none() {
|
||||
println!("None!");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
use std::old_io::process::Command;
|
||||
use std::env;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
// lifted from the test module
|
||||
// Inlining to avoid llvm turning the recursive functions into tail calls,
|
||||
|
|
@ -37,7 +37,7 @@ fn recurse() {
|
|||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() > 1 && args[1] == "recurse" {
|
||||
let _t = Thread::scoped(recurse);
|
||||
let _t = thread::scoped(recurse);
|
||||
} else {
|
||||
let recurse = Command::new(&args[0]).arg("recurse").output().unwrap();
|
||||
assert!(!recurse.status.success());
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(start, os, std_misc, old_io)]
|
||||
|
||||
use std::ffi;
|
||||
use std::ffi::CStr;
|
||||
use std::old_io::process::{Command, ProcessOutput};
|
||||
use std::os;
|
||||
use std::rt::unwind::try;
|
||||
|
|
@ -38,7 +38,7 @@ fn start(argc: isize, argv: *const *const u8) -> isize {
|
|||
let args = unsafe {
|
||||
(0..argc as usize).map(|i| {
|
||||
let ptr = *argv.offset(i as isize) as *const _;
|
||||
ffi::c_str_to_bytes(&ptr).to_vec()
|
||||
CStr::from_ptr(ptr).to_bytes().to_vec()
|
||||
}).collect::<Vec<_>>()
|
||||
};
|
||||
let me = &*args[0];
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
extern crate log;
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub struct ChannelLogger {
|
||||
tx: Sender<String>
|
||||
|
|
@ -41,7 +41,7 @@ impl log::Logger for ChannelLogger {
|
|||
pub fn main() {
|
||||
let (logger, rx) = ChannelLogger::new();
|
||||
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
log::set_logger(logger);
|
||||
|
||||
info!("foo");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(core, std_misc)]
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::Mutex;
|
||||
|
||||
fn par_for<I, F>(iter: I, f: F)
|
||||
|
|
@ -21,7 +21,7 @@ fn par_for<I, F>(iter: I, f: F)
|
|||
{
|
||||
let f = &f;
|
||||
let _guards: Vec<_> = iter.map(|elem| {
|
||||
Thread::scoped(move || {
|
||||
thread::scoped(move || {
|
||||
f(elem)
|
||||
})
|
||||
}).collect();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
struct test {
|
||||
|
|
@ -32,7 +32,7 @@ fn test(f: isize) -> test {
|
|||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
let (tx2, rx2) = channel();
|
||||
tx.send(tx2).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright 2012-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.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(tempdir, path_ext)]
|
||||
|
||||
use std::fs::{File, TempDir};
|
||||
use std::io::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
let dir = TempDir::new_in(".", "").unwrap();
|
||||
let path = dir.path().join("file");
|
||||
|
||||
{
|
||||
match File::create(&path) {
|
||||
Err(..) => unreachable!(),
|
||||
Ok(f) => {
|
||||
let mut f = f;
|
||||
for _ in 0..1000 {
|
||||
f.write(&[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(path.exists());
|
||||
assert_eq!(path.metadata().unwrap().len(), 1000);
|
||||
}
|
||||
|
|
@ -36,7 +36,6 @@ pub fn main() {
|
|||
assert!(
|
||||
include_str!("syntax-extension-source-utils-files/includeme.\
|
||||
fragment").to_string()
|
||||
.as_slice()
|
||||
.starts_with("/* this is for "));
|
||||
assert!(
|
||||
include_bytes!("syntax-extension-source-utils-files/includeme.fragment")
|
||||
|
|
@ -44,8 +43,5 @@ pub fn main() {
|
|||
// The Windows tests are wrapped in an extra module for some reason
|
||||
assert!((m1::m2::where_am_i().ends_with("m1::m2")));
|
||||
|
||||
assert!(match (47, "( 2 * 3 ) + 5") {
|
||||
(line!(), stringify!((2*3) + 5)) => true,
|
||||
_ => false
|
||||
})
|
||||
assert_eq!((46, "( 2 * 3 ) + 5"), (line!(), stringify!((2*3) + 5)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
pub fn main() { test05(); }
|
||||
|
|
@ -26,7 +26,7 @@ fn test05_start(tx : &Sender<isize>) {
|
|||
|
||||
fn test05() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| { test05_start(&tx) });
|
||||
let _t = thread::scoped(move|| { test05_start(&tx) });
|
||||
let mut value: isize = rx.recv().unwrap();
|
||||
println!("{}", value);
|
||||
value = rx.recv().unwrap();
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() { test00(); }
|
||||
|
||||
fn start() { println!("Started / Finished task."); }
|
||||
|
||||
fn test00() {
|
||||
let _ = Thread::scoped(move|| start() ).join();
|
||||
let _ = thread::scoped(move|| start() ).join();
|
||||
println!("Completing.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
fn start(tx: &Sender<Sender<String>>) {
|
||||
|
|
@ -29,10 +29,10 @@ fn start(tx: &Sender<Sender<String>>) {
|
|||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _child = Thread::spawn(move|| { start(&tx) });
|
||||
let _child = thread::scoped(move|| { start(&tx) });
|
||||
|
||||
let mut c = rx.recv().unwrap();
|
||||
c.send("A".to_string()).unwrap();
|
||||
c.send("B".to_string()).unwrap();
|
||||
Thread::yield_now();
|
||||
thread::yield_now();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#![feature(std_misc)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn start(tx: &Sender<Sender<isize>>) {
|
||||
let (tx2, _rx) = channel();
|
||||
|
|
@ -22,7 +22,7 @@ fn start(tx: &Sender<Sender<isize>>) {
|
|||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let _child = Thread::spawn(move|| {
|
||||
let _child = thread::scoped(move|| {
|
||||
start(&tx)
|
||||
});
|
||||
let _tx = rx.recv().unwrap();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() { test00(); }
|
||||
|
||||
|
|
@ -18,14 +18,14 @@ fn start(_task_number: isize) { println!("Started / Finished task."); }
|
|||
|
||||
fn test00() {
|
||||
let i: isize = 0;
|
||||
let mut result = Thread::scoped(move|| {
|
||||
let mut result = thread::scoped(move|| {
|
||||
start(i)
|
||||
});
|
||||
|
||||
// Sleep long enough for the task to finish.
|
||||
let mut i = 0_usize;
|
||||
while i < 10000 {
|
||||
Thread::yield_now();
|
||||
thread::yield_now();
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![feature(std_misc)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn start(tx: &Sender<isize>, start: isize, number_of_messages: isize) {
|
||||
let mut i: isize = 0;
|
||||
|
|
@ -21,6 +21,6 @@ fn start(tx: &Sender<isize>, start: isize, number_of_messages: isize) {
|
|||
pub fn main() {
|
||||
println!("Check that we don't deadlock.");
|
||||
let (tx, rx) = channel();
|
||||
let _ = Thread::scoped(move|| { start(&tx, 0, 10) }).join();
|
||||
let _t = thread::scoped(move|| { start(&tx, 0, 10) }).join();
|
||||
println!("Joined task");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![feature(std_misc)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
|
|
@ -21,7 +21,7 @@ pub fn main() {
|
|||
while (i > 0) {
|
||||
println!("{}", i);
|
||||
let tx = tx.clone();
|
||||
Thread::spawn({let i = i; move|| { child(i, &tx) }});
|
||||
thread::scoped({let i = i; move|| { child(i, &tx) }});
|
||||
i = i - 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#![feature(std_misc)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn start(tx: &Sender<isize>, i0: isize) {
|
||||
let mut i = i0;
|
||||
|
|
@ -29,7 +29,7 @@ pub fn main() {
|
|||
// the child's point of view the receiver may die. We should
|
||||
// drop messages on the floor in this case, and not crash!
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
start(&tx, 10)
|
||||
});
|
||||
rx.recv();
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
// This test is specifically about spawning temporary closures.
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn f() {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let _t = Thread::scoped(move|| f() ).join();
|
||||
let _t = thread::scoped(move|| f() ).join();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// no-pretty-expanded FIXME #15189
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); }
|
||||
|
|
@ -42,7 +42,7 @@ fn test00() {
|
|||
let mut results = Vec::new();
|
||||
while i < number_of_tasks {
|
||||
let tx = tx.clone();
|
||||
results.push(Thread::scoped({
|
||||
results.push(thread::scoped({
|
||||
let i = i;
|
||||
move|| {
|
||||
test00_start(&tx, i, number_of_messages)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#![allow(dead_assignment)]
|
||||
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() { test00(); }
|
||||
|
||||
|
|
@ -31,19 +31,19 @@ fn test00() {
|
|||
let number_of_messages: isize = 10;
|
||||
|
||||
let tx2 = tx.clone();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
test00_start(&tx2, number_of_messages * 0, number_of_messages);
|
||||
});
|
||||
let tx2 = tx.clone();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
test00_start(&tx2, number_of_messages * 1, number_of_messages);
|
||||
});
|
||||
let tx2 = tx.clone();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
test00_start(&tx2, number_of_messages * 2, number_of_messages);
|
||||
});
|
||||
let tx2 = tx.clone();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
test00_start(&tx2, number_of_messages * 3, number_of_messages);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
pub fn main() { test00(); }
|
||||
|
|
@ -26,7 +26,7 @@ fn test00() {
|
|||
let (tx, rx) = channel();
|
||||
let number_of_messages: isize = 10;
|
||||
|
||||
let result = Thread::scoped(move|| {
|
||||
let result = thread::scoped(move|| {
|
||||
test00_start(&tx, number_of_messages);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() {
|
||||
let _t = Thread::spawn(move|| child("Hello".to_string()) );
|
||||
let _t = thread::scoped(move|| child("Hello".to_string()) );
|
||||
}
|
||||
|
||||
fn child(_s: String) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax, std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
pub fn main() {
|
||||
|
|
@ -22,7 +22,7 @@ pub fn main() {
|
|||
let x: Box<isize> = box 1;
|
||||
let x_in_parent = &(*x) as *const isize as usize;
|
||||
|
||||
let _t = Thread::spawn(move || {
|
||||
let _t = thread::scoped(move || {
|
||||
let x_in_child = &(*x) as *const isize as usize;
|
||||
tx.send(x_in_child).unwrap();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use std::old_io::{TcpListener, Listener, Acceptor, EndOfFile, TcpStream};
|
|||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
static N: usize = 8;
|
||||
static M: usize = 20;
|
||||
|
|
@ -40,7 +40,7 @@ fn test() {
|
|||
let a = a.clone();
|
||||
let cnt = cnt.clone();
|
||||
let srv_tx = srv_tx.clone();
|
||||
Thread::scoped(move|| {
|
||||
thread::scoped(move|| {
|
||||
let mut a = a;
|
||||
loop {
|
||||
match a.accept() {
|
||||
|
|
@ -59,7 +59,7 @@ fn test() {
|
|||
|
||||
let _t = (0..N).map(|_| {
|
||||
let cli_tx = cli_tx.clone();
|
||||
Thread::scoped(move|| {
|
||||
thread::scoped(move|| {
|
||||
for _ in 0..M {
|
||||
let _s = TcpStream::connect(addr).unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use std::old_io::test::*;
|
|||
use std::old_io;
|
||||
use std::time::Duration;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
#[cfg_attr(target_os = "freebsd", ignore)]
|
||||
fn eventual_timeout() {
|
||||
|
|
@ -34,7 +34,7 @@ fn eventual_timeout() {
|
|||
|
||||
let (tx1, rx1) = channel();
|
||||
let (_tx2, rx2) = channel::<()>();
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _t = thread::scoped(move|| {
|
||||
let _l = TcpListener::bind(addr).unwrap().listen();
|
||||
tx1.send(()).unwrap();
|
||||
let _ = rx2.recv();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::old_path::{Path, GenericPath};
|
|||
use std::old_io::fs::PathExtensions;
|
||||
use std::old_io::{fs, TempDir};
|
||||
use std::old_io;
|
||||
use std::os;
|
||||
use std::env;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread;
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ fn test_rm_tempdir_close() {
|
|||
// to depend on std
|
||||
fn recursive_mkdir_rel() {
|
||||
let path = Path::new("frob");
|
||||
let cwd = os::getcwd().unwrap();
|
||||
let cwd = Path::new(env::current_dir().unwrap().to_str().unwrap());
|
||||
println!("recursive_mkdir_rel: Making: {} in cwd {} [{}]", path.display(),
|
||||
cwd.display(), path.exists());
|
||||
fs::mkdir_recursive(&path, old_io::USER_RWX);
|
||||
|
|
@ -147,7 +147,7 @@ fn recursive_mkdir_dot() {
|
|||
|
||||
fn recursive_mkdir_rel_2() {
|
||||
let path = Path::new("./frob/baz");
|
||||
let cwd = os::getcwd().unwrap();
|
||||
let cwd = Path::new(env::current_dir().unwrap().to_str().unwrap());
|
||||
println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{}]", path.display(),
|
||||
cwd.display(), path.exists());
|
||||
fs::mkdir_recursive(&path, old_io::USER_RWX);
|
||||
|
|
@ -196,7 +196,7 @@ pub fn dont_double_panic() {
|
|||
|
||||
fn in_tmpdir<F>(f: F) where F: FnOnce() {
|
||||
let tmpdir = TempDir::new("test").ok().expect("can't make tmpdir");
|
||||
assert!(os::change_dir(tmpdir.path()).is_ok());
|
||||
assert!(env::set_current_dir(tmpdir.path().as_str().unwrap()).is_ok());
|
||||
|
||||
f();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
#![feature(std_misc)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
pub fn main() {
|
||||
let mut i = 10;
|
||||
while i > 0 {
|
||||
Thread::scoped({let i = i; move|| child(i)});
|
||||
thread::scoped({let i = i; move|| child(i)});
|
||||
i = i - 1;
|
||||
}
|
||||
println!("main thread exiting");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
trait Pet {
|
||||
fn name(&self, blk: Box<FnMut(&str)>);
|
||||
|
|
@ -83,13 +83,13 @@ pub fn main() {
|
|||
box dogge2 as Box<Pet+Sync+Send>));
|
||||
let (tx1, rx1) = channel();
|
||||
let arc1 = arc.clone();
|
||||
let _t1 = Thread::spawn(move|| { check_legs(arc1); tx1.send(()); });
|
||||
let _t1 = thread::scoped(move|| { check_legs(arc1); tx1.send(()); });
|
||||
let (tx2, rx2) = channel();
|
||||
let arc2 = arc.clone();
|
||||
let _t2 = Thread::spawn(move|| { check_names(arc2); tx2.send(()); });
|
||||
let _t2 = thread::scoped(move|| { check_names(arc2); tx2.send(()); });
|
||||
let (tx3, rx3) = channel();
|
||||
let arc3 = arc.clone();
|
||||
let _t3 = Thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); });
|
||||
let _t3 = thread::scoped(move|| { check_pedigree(arc3); tx3.send(()); });
|
||||
rx1.recv();
|
||||
rx2.recv();
|
||||
rx3.recv();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
extern crate libc;
|
||||
|
||||
use std::ffi::{self, CString};
|
||||
use std::ffi::{CStr, CString};
|
||||
use libc::{c_char, c_int};
|
||||
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ extern {
|
|||
unsafe fn check<T, F>(expected: &str, f: F) where F: FnOnce(*mut c_char) -> T {
|
||||
let mut x = [0 as c_char; 50];
|
||||
f(&mut x[0] as *mut c_char);
|
||||
assert_eq!(expected.as_bytes(), ffi::c_str_to_bytes(&x.as_ptr()));
|
||||
assert_eq!(expected.as_bytes(), CStr::from_ptr(x.as_ptr()).to_bytes());
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue