Test fixes and rebase conflicts
This commit is contained in:
parent
b283881dcc
commit
6ac3799b75
34 changed files with 155 additions and 168 deletions
|
@ -57,13 +57,13 @@ place!
|
|||
## Threads
|
||||
|
||||
Rust's standard library provides a library for 'threads', which allow you to
|
||||
run Rust code in parallel. Here's a basic example of using `Thread`:
|
||||
run Rust code in parallel. Here's a basic example of using `std::thread`:
|
||||
|
||||
```
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
Thread::scoped(|| {
|
||||
thread::scoped(|| {
|
||||
println!("Hello from a thread!");
|
||||
});
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ The `Thread::scoped()` method accepts a closure, which is executed in a new
|
|||
thread. It's called `scoped` because this thread returns a join guard:
|
||||
|
||||
```
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let guard = Thread::scoped(|| {
|
||||
let guard = thread::scoped(|| {
|
||||
println!("Hello from a thread!");
|
||||
});
|
||||
|
||||
|
@ -85,15 +85,15 @@ fn main() {
|
|||
```
|
||||
|
||||
When `guard` goes out of scope, it will block execution until the thread is
|
||||
finished. If we didn't want this behaviour, we could use `Thread::spawn()`:
|
||||
finished. If we didn't want this behaviour, we could use `thread::spawn()`:
|
||||
|
||||
```
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::old_io::timer;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
Thread::spawn(|| {
|
||||
thread::spawn(|| {
|
||||
println!("Hello from a thread!");
|
||||
});
|
||||
|
||||
|
@ -101,24 +101,6 @@ fn main() {
|
|||
}
|
||||
```
|
||||
|
||||
Or call `.detach()`:
|
||||
|
||||
```
|
||||
use std::thread::Thread;
|
||||
use std::old_io::timer;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let guard = Thread::scoped(|| {
|
||||
println!("Hello from a thread!");
|
||||
});
|
||||
|
||||
guard.detach();
|
||||
|
||||
timer::sleep(Duration::milliseconds(50));
|
||||
}
|
||||
```
|
||||
|
||||
We need to `sleep` here because when `main()` ends, it kills all of the
|
||||
running threads.
|
||||
|
||||
|
@ -164,7 +146,7 @@ As an example, here is a Rust program that would have a data race in many
|
|||
languages. It will not compile:
|
||||
|
||||
```ignore
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::old_io::timer;
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -172,7 +154,7 @@ fn main() {
|
|||
let mut data = vec![1u32, 2, 3];
|
||||
|
||||
for i in 0..2 {
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
data[i] += 1;
|
||||
});
|
||||
}
|
||||
|
@ -203,7 +185,7 @@ only one person at a time can mutate what's inside. For that, we can use the
|
|||
but for a different reason:
|
||||
|
||||
```ignore
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::old_io::timer;
|
||||
use std::time::Duration;
|
||||
use std::sync::Mutex;
|
||||
|
@ -213,7 +195,7 @@ fn main() {
|
|||
|
||||
for i in 0..2 {
|
||||
let data = data.lock().unwrap();
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
data[i] += 1;
|
||||
});
|
||||
}
|
||||
|
@ -255,7 +237,7 @@ We can use `Arc<T>` to fix this. Here's the working version:
|
|||
|
||||
```
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::old_io::timer;
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -264,7 +246,7 @@ fn main() {
|
|||
|
||||
for i in 0us..2 {
|
||||
let data = data.clone();
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
let mut data = data.lock().unwrap();
|
||||
data[i] += 1;
|
||||
});
|
||||
|
@ -280,14 +262,14 @@ thread more closely:
|
|||
|
||||
```
|
||||
# use std::sync::{Arc, Mutex};
|
||||
# use std::thread::Thread;
|
||||
# use std::thread;
|
||||
# use std::old_io::timer;
|
||||
# use std::time::Duration;
|
||||
# fn main() {
|
||||
# let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
|
||||
# for i in 0us..2 {
|
||||
# let data = data.clone();
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
let mut data = data.lock().unwrap();
|
||||
data[i] += 1;
|
||||
});
|
||||
|
@ -315,7 +297,7 @@ than waiting for a specific time:
|
|||
|
||||
```
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc;
|
||||
|
||||
fn main() {
|
||||
|
@ -326,7 +308,7 @@ fn main() {
|
|||
for _ in 0..10 {
|
||||
let (data, tx) = (data.clone(), tx.clone());
|
||||
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
let mut data = data.lock().unwrap();
|
||||
*data += 1;
|
||||
|
||||
|
@ -348,7 +330,7 @@ is `Send` over the channel!
|
|||
|
||||
```
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::mpsc;
|
||||
|
||||
fn main() {
|
||||
|
@ -357,7 +339,7 @@ fn main() {
|
|||
for _ in 0..10 {
|
||||
let tx = tx.clone();
|
||||
|
||||
Thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
let answer = 42u32;
|
||||
|
||||
tx.send(answer);
|
||||
|
@ -378,9 +360,9 @@ A `panic!` will crash the currently executing thread. You can use Rust's
|
|||
threads as a simple isolation mechanism:
|
||||
|
||||
```
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
let result = Thread::scoped(move || {
|
||||
let result = thread::spawn(move || {
|
||||
panic!("oops!");
|
||||
}).join();
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
|
|||
/// - symmetric: `a == b` implies `b == a`; and
|
||||
/// - transitive: `a == b` and `b == c` implies `a == c`.
|
||||
///
|
||||
/// This property cannot be checked by the compiler, and therefore `Eq` implies `PartialEq`, and
|
||||
/// has no extra methods.
|
||||
/// This property cannot be checked by the compiler, and therefore `Eq` implies
|
||||
/// `PartialEq`, and has no extra methods.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait Eq: PartialEq<Self> {
|
||||
// FIXME #13101: this method is used solely by #[deriving] to
|
||||
|
@ -100,6 +100,7 @@ pub trait Eq: PartialEq<Self> {
|
|||
// This should never be implemented by hand.
|
||||
#[doc(hidden)]
|
||||
#[inline(always)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn assert_receiver_is_total_eq(&self) {}
|
||||
}
|
||||
|
||||
|
@ -408,7 +409,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
|
|||
/// ```
|
||||
/// use std::cmp;
|
||||
///
|
||||
/// let result = cmp::partial_min(std::f64::NAN, &1.0);
|
||||
/// let result = cmp::partial_min(std::f64::NAN, 1.0);
|
||||
/// assert_eq!(result, None);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -439,7 +440,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
|
|||
/// ```
|
||||
/// use std::cmp;
|
||||
///
|
||||
/// let result = cmp::partial_max(std::f64::NAN, &1.0);
|
||||
/// let result = cmp::partial_max(std::f64::NAN, 1.0);
|
||||
/// assert_eq!(result, None);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
#![feature(collections)]
|
||||
#![feature(int_uint)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(str_words)]
|
||||
#![cfg_attr(test, feature(rustc_private))]
|
||||
|
||||
#[cfg(test)] #[macro_use] extern crate log;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(unsafe_destructor)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(std_misc)]
|
||||
#![feature(unicode)]
|
||||
|
||||
extern crate arena;
|
||||
|
@ -73,7 +72,7 @@ use rustc::metadata;
|
|||
use rustc::util::common::time;
|
||||
|
||||
use std::cmp::Ordering::Equal;
|
||||
use std::old_io;
|
||||
use std::old_io::{self, stdio};
|
||||
use std::iter::repeat;
|
||||
use std::env;
|
||||
use std::sync::mpsc::channel;
|
||||
|
@ -780,7 +779,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
|
|||
cfg = cfg.stack_size(STACK_SIZE);
|
||||
}
|
||||
|
||||
match cfg.scoped(move || { std::old_io::stdio::set_stderr(box w); f() }).join() {
|
||||
match cfg.spawn(move || { stdio::set_stderr(box w); f() }).unwrap().join() {
|
||||
Ok(()) => { /* fallthrough */ }
|
||||
Err(value) => {
|
||||
// Thread panicked without emitting a fatal diagnostic
|
||||
|
|
|
@ -939,7 +939,7 @@ fn run_work_multithreaded(sess: &Session,
|
|||
}
|
||||
|
||||
tx.take().unwrap().send(()).unwrap();
|
||||
});
|
||||
}).unwrap();
|
||||
}
|
||||
|
||||
let mut panicked = false;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#![feature(std_misc)]
|
||||
#![feature(test)]
|
||||
#![feature(unicode)]
|
||||
#![feature(str_words)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
|
@ -55,6 +56,7 @@ use std::env;
|
|||
use std::old_io::File;
|
||||
use std::old_io;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::channel;
|
||||
use externalfiles::ExternalHtml;
|
||||
use serialize::Decodable;
|
||||
use serialize::json::{self, Json};
|
||||
|
@ -125,8 +127,8 @@ pub fn main() {
|
|||
let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || {
|
||||
let s = env::args().collect::<Vec<_>>();
|
||||
main_args(&s)
|
||||
}).join();
|
||||
env::set_exit_status(res.ok().unwrap() as i32);
|
||||
}).unwrap().join();
|
||||
env::set_exit_status(res as i32);
|
||||
}
|
||||
|
||||
pub fn opts() -> Vec<getopts::OptGroup> {
|
||||
|
@ -365,12 +367,14 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
|||
let cr = Path::new(cratefile);
|
||||
info!("starting to run rustc");
|
||||
|
||||
let (mut krate, analysis) = std::thread::spawn(move || {
|
||||
let (tx, rx) = channel();
|
||||
std::thread::spawn(move || {
|
||||
use rustc::session::config::Input;
|
||||
|
||||
let cr = cr;
|
||||
core::run_core(paths, cfgs, externs, Input::File(cr), triple)
|
||||
tx.send(core::run_core(paths, cfgs, externs, Input::File(cr), triple)).unwrap();
|
||||
}).join().map_err(|_| "rustc failed").unwrap();
|
||||
let (mut krate, analysis) = rx.recv().unwrap();
|
||||
info!("finished with rustc");
|
||||
let mut analysis = Some(analysis);
|
||||
ANALYSISKEY.with(|s| {
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use boxed::Box;
|
||||
use prelude::v1::*;
|
||||
|
||||
use cmp;
|
||||
use io;
|
||||
use mem;
|
||||
|
|
|
@ -147,21 +147,16 @@
|
|||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use prelude::v1::*;
|
||||
|
||||
use any::Any;
|
||||
use boxed::Box;
|
||||
use cell::UnsafeCell;
|
||||
use clone::Clone;
|
||||
use fmt;
|
||||
use io;
|
||||
use marker::{Send, Sync};
|
||||
use ops::{Drop, FnOnce};
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{Err, Ok};
|
||||
use sync::{Mutex, Condvar, Arc};
|
||||
use str::Str;
|
||||
use string::String;
|
||||
use marker;
|
||||
use old_io::stdio;
|
||||
use rt::{self, unwind};
|
||||
use old_io::{Writer, stdio};
|
||||
use sync::{Mutex, Condvar, Arc};
|
||||
use thunk::Thunk;
|
||||
use time::Duration;
|
||||
|
||||
|
@ -264,7 +259,9 @@ impl Builder {
|
|||
pub fn scoped<'a, T, F>(self, f: F) -> io::Result<JoinGuard<'a, T>> where
|
||||
T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
|
||||
{
|
||||
self.spawn_inner(Thunk::new(f)).map(JoinGuard)
|
||||
self.spawn_inner(Thunk::new(f)).map(|inner| {
|
||||
JoinGuard { inner: inner, _marker: marker::PhantomData }
|
||||
})
|
||||
}
|
||||
|
||||
fn spawn_inner<T: Send>(self, f: Thunk<(), T>) -> io::Result<JoinInner<T>> {
|
||||
|
@ -643,7 +640,10 @@ impl Drop for JoinHandle {
|
|||
/// permission.
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct JoinGuard<'a, T: 'a>(JoinInner<T>);
|
||||
pub struct JoinGuard<'a, T: 'a> {
|
||||
inner: JoinInner<T>,
|
||||
_marker: marker::PhantomData<&'a T>,
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<'a, T: Send + 'a> Sync for JoinGuard<'a, T> {}
|
||||
|
@ -652,7 +652,7 @@ impl<'a, T: Send + 'a> JoinGuard<'a, T> {
|
|||
/// Extract a handle to the thread this guard will join on.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn thread(&self) -> &Thread {
|
||||
&self.0.thread
|
||||
&self.inner.thread
|
||||
}
|
||||
|
||||
/// Wait for the associated thread to finish, returning the result of the thread's
|
||||
|
@ -663,7 +663,7 @@ impl<'a, T: Send + 'a> JoinGuard<'a, T> {
|
|||
/// Panics on the child thread are propagated by panicking the parent.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn join(mut self) -> T {
|
||||
match self.0.join() {
|
||||
match self.inner.join() {
|
||||
Ok(res) => res,
|
||||
Err(_) => panic!("child thread {:?} panicked", self.thread()),
|
||||
}
|
||||
|
@ -676,8 +676,8 @@ impl<T: Send> JoinGuard<'static, T> {
|
|||
#[deprecated(since = "1.0.0", reason = "use spawn instead")]
|
||||
#[unstable(feature = "std_misc")]
|
||||
pub fn detach(mut self) {
|
||||
unsafe { imp::detach(self.0.native) };
|
||||
self.0.joined = true; // avoid joining in the destructor
|
||||
unsafe { imp::detach(self.inner.native) };
|
||||
self.inner.joined = true; // avoid joining in the destructor
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -685,8 +685,8 @@ impl<T: Send> JoinGuard<'static, T> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
if !self.0.joined {
|
||||
unsafe { imp::join(self.0.native) };
|
||||
if !self.inner.joined {
|
||||
unsafe { imp::join(self.inner.native) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(unicode)]
|
||||
#![feature(std_misc)]
|
||||
#![feature(env)]
|
||||
#![cfg_attr(windows, feature(libc))]
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ use std::iter::repeat;
|
|||
use std::num::{Float, Int};
|
||||
use std::env;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread::{self, Thread};
|
||||
use std::thread;
|
||||
use std::thunk::{Thunk, Invoke};
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -895,7 +895,7 @@ pub fn run_test(opts: &TestOpts,
|
|||
cfg = cfg.stderr(box stderr as Box<Writer + Send>);
|
||||
}
|
||||
|
||||
let result_guard = cfg.scoped(move || { testfn.invoke(()) });
|
||||
let result_guard = cfg.spawn(move || { testfn.invoke(()) }).unwrap();
|
||||
let stdout = reader.read_to_end().unwrap().into_iter().collect();
|
||||
let test_result = calc_result(&desc, result_guard.join());
|
||||
monitor_ch.send((desc.clone(), test_result, stdout)).unwrap();
|
||||
|
|
|
@ -12,44 +12,44 @@ use std::{int, i8, i16, i32, i64};
|
|||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
assert!(thread::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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::spawn(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
|
||||
}
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
#![allow(dead_code)]
|
||||
#![deny(non_snake_case)]
|
||||
|
||||
use std::old_io::File;
|
||||
use std::old_io::IoError;
|
||||
|
||||
mod foo {
|
||||
pub enum Foo { Foo }
|
||||
}
|
||||
|
@ -36,6 +33,7 @@ fn main() {
|
|||
Foo => {}
|
||||
//~^ ERROR variable `Foo` should have a snake case name such as `foo`
|
||||
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
//~^^^ WARN unused variable: `Foo`
|
||||
}
|
||||
|
||||
test(1);
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let r: Result<int,_> = thread::spawn(move|| {
|
||||
let r: Result<(),_> = thread::spawn(move|| {
|
||||
panic!("test");
|
||||
1
|
||||
}).join();
|
||||
assert!(r.is_ok());
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
use std::thread::Builder;
|
||||
|
||||
fn main() {
|
||||
let r: Result<int,_> = Builder::new().name("owned name".to_string()).scoped(move|| {
|
||||
let r: () = Builder::new().name("owned name".to_string()).scoped(move|| {
|
||||
panic!("test");
|
||||
1
|
||||
}).join();
|
||||
assert!(r.is_ok());
|
||||
()
|
||||
}).unwrap().join();
|
||||
panic!();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -18,11 +18,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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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); }
|
||||
}
|
||||
|
|
|
@ -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); }
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)); }
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue