about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-17 19:00:20 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-17 19:42:28 -0800
commit665ea963d3c29ef7670662707f2f2307f000efa3 (patch)
tree9281d6d03436f1c92585c191a7a130d38e1ff9f0
parentba8ce4c2c27643cccfbbc481a19bcf4b7747cc89 (diff)
downloadrust-665ea963d3c29ef7670662707f2f2307f000efa3.tar.gz
rust-665ea963d3c29ef7670662707f2f2307f000efa3.zip
Test fixes and rebase conflicts
-rw-r--r--src/doc/trpl/traits.md2
-rw-r--r--src/libcollections/ring_buf.rs13
-rw-r--r--src/librustc_driver/lib.rs2
-rw-r--r--src/libstd/old_io/comm_adapters.rs5
-rw-r--r--src/libstd/old_path/posix.rs2
-rw-r--r--src/libstd/old_path/windows.rs2
-rw-r--r--src/libstd/sync/rwlock.rs12
-rw-r--r--src/libstd/thread.rs25
-rw-r--r--src/libstd/thread_local/scoped.rs12
-rw-r--r--src/test/bench/shootout-binarytrees.rs6
-rw-r--r--src/test/bench/shootout-fannkuch-redux.rs4
-rw-r--r--src/test/bench/shootout-k-nucleotide.rs8
-rw-r--r--src/test/bench/shootout-mandelbrot.rs8
-rwxr-xr-xsrc/test/compile-fail/send-is-not-static-ensures-scoping.rs7
-rw-r--r--src/test/pretty/attr-fn-inner.rs2
-rw-r--r--src/test/run-make/static-unwinding/lib.rs2
-rw-r--r--src/test/run-make/static-unwinding/main.rs7
-rw-r--r--src/test/run-pass/drop-trait-enum.rs10
18 files changed, 65 insertions, 64 deletions
diff --git a/src/doc/trpl/traits.md b/src/doc/trpl/traits.md
index 52ec012320a..abd9af1af33 100644
--- a/src/doc/trpl/traits.md
+++ b/src/doc/trpl/traits.md
@@ -343,7 +343,7 @@ trait ConvertTo<Output> {
 }
 
 impl ConvertTo<i64> for i32 {
-    fn convert(&self) -> i64 { *self as i32 }
+    fn convert(&self) -> i64 { *self as i64 }
 }
 
 // can be called with T == i32
diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs
index 5c3bd25438e..93218aed366 100644
--- a/src/libcollections/ring_buf.rs
+++ b/src/libcollections/ring_buf.rs
@@ -8,11 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! RingBuf is a double-ended queue, which is implemented with the help of a growing circular buffer.
+//! RingBuf is a double-ended queue, which is implemented with the help of a
+//! growing circular buffer.
 //!
-//! This queue has `O(1)` amortized inserts and removals from both ends of the container. It also
-//! has `O(1)` indexing like a vector. The contained elements are not required to be copyable, and
-//! the queue will be sendable if the contained type is sendable.
+//! This queue has `O(1)` amortized inserts and removals from both ends of the
+//! container. It also has `O(1)` indexing like a vector. The contained elements
+//! are not required to be copyable, and the queue will be sendable if the
+//! contained type is sendable.
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
@@ -115,7 +117,8 @@ impl<T> RingBuf<T> {
     #[inline]
     fn is_full(&self) -> bool { self.cap - self.len() == 1 }
 
-    /// Returns the index in the underlying buffer for a given logical element index.
+    /// Returns the index in the underlying buffer for a given logical element
+    /// index.
     #[inline]
     fn wrap_index(&self, idx: usize) -> usize { wrap_index(idx, self.cap) }
 
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 234809e5284..ac91a0098ea 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -764,7 +764,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) ->
 ///
 /// The diagnostic emitter yielded to the procedure should be used for reporting
 /// errors of the compiler.
-pub fn monitor<F:FnOnce()+Send>(f: F) {
+pub fn monitor<F:FnOnce()+Send+'static>(f: F) {
     static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
 
     let (tx, rx) = channel();
diff --git a/src/libstd/old_io/comm_adapters.rs b/src/libstd/old_io/comm_adapters.rs
index a75686369ad..207d3d39167 100644
--- a/src/libstd/old_io/comm_adapters.rs
+++ b/src/libstd/old_io/comm_adapters.rs
@@ -234,10 +234,7 @@ mod test {
         writer.write_be_u32(42).unwrap();
 
         let wanted = vec![0u8, 0u8, 0u8, 42u8];
-        let got = match thread::spawn(move|| { rx.recv().unwrap() }).join() {
-            Ok(got) => got,
-            Err(_) => panic!(),
-        };
+        let got = thread::scoped(move|| { rx.recv().unwrap() }).join();
         assert_eq!(wanted, got);
 
         match writer.write_u8(1) {
diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs
index 9bbce1934b0..440d17cfd50 100644
--- a/src/libstd/old_path/posix.rs
+++ b/src/libstd/old_path/posix.rs
@@ -520,7 +520,7 @@ mod tests {
     fn test_null_byte() {
         use thread;
         let result = thread::spawn(move|| {
-            Path::new(b"foo/bar\0")
+            Path::new(b"foo/bar\0");
         }).join();
         assert!(result.is_err());
 
diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs
index 8362e9a9530..07c5e10992b 100644
--- a/src/libstd/old_path/windows.rs
+++ b/src/libstd/old_path/windows.rs
@@ -1307,7 +1307,7 @@ mod tests {
     fn test_null_byte() {
         use thread;
         let result = thread::spawn(move|| {
-            Path::new(b"foo/bar\0")
+            Path::new(b"foo/bar\0");
         }).join();
         assert!(result.is_err());
 
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index 402542b8bdc..b8d157d341e 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -425,8 +425,8 @@ mod tests {
     #[test]
     fn frob() {
         static R: StaticRwLock = RW_LOCK_INIT;
-        static N: uint = 10;
-        static M: uint = 1000;
+        static N: usize = 10;
+        static M: usize = 1000;
 
         let (tx, rx) = channel::<()>();
         for _ in 0..N {
@@ -452,7 +452,7 @@ mod tests {
     fn test_rw_arc_poison_wr() {
         let arc = Arc::new(RwLock::new(1));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = thread::spawn(move|| {
+        let _: Result<(), _> = thread::spawn(move|| {
             let _lock = arc2.write().unwrap();
             panic!();
         }).join();
@@ -464,7 +464,7 @@ mod tests {
         let arc = Arc::new(RwLock::new(1));
         assert!(!arc.is_poisoned());
         let arc2 = arc.clone();
-        let _: Result<uint, _> = thread::spawn(move|| {
+        let _: Result<(), _> = thread::spawn(move|| {
             let _lock = arc2.write().unwrap();
             panic!();
         }).join();
@@ -476,7 +476,7 @@ mod tests {
     fn test_rw_arc_no_poison_rr() {
         let arc = Arc::new(RwLock::new(1));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = thread::spawn(move|| {
+        let _: Result<(), _> = thread::spawn(move|| {
             let _lock = arc2.read().unwrap();
             panic!();
         }).join();
@@ -487,7 +487,7 @@ mod tests {
     fn test_rw_arc_no_poison_rw() {
         let arc = Arc::new(RwLock::new(1));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = thread::spawn(move|| {
+        let _: Result<(), _> = thread::spawn(move|| {
             let _lock = arc2.read().unwrap();
             panic!()
         }).join();
diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs
index ea25ddc0fca..3137d779c40 100644
--- a/src/libstd/thread.rs
+++ b/src/libstd/thread.rs
@@ -260,7 +260,7 @@ impl Builder {
         T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
     {
         self.spawn_inner(Thunk::new(f)).map(|inner| {
-            JoinGuard { inner: inner, _marker: marker::PhantomData }
+            JoinGuard { inner: inner, _marker: marker::CovariantType }
         })
     }
 
@@ -642,7 +642,7 @@ impl Drop for JoinHandle {
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct JoinGuard<'a, T: 'a> {
     inner: JoinInner<T>,
-    _marker: marker::PhantomData<&'a T>,
+    _marker: marker::CovariantType<&'a T>,
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -686,7 +686,9 @@ impl<T: Send> JoinGuard<'static, T> {
 impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
     fn drop(&mut self) {
         if !self.inner.joined {
-            unsafe { imp::join(self.inner.native) };
+            if self.inner.join().is_err() {
+                panic!("child thread {:?} panicked", self.thread());
+            }
         }
     }
 }
@@ -700,7 +702,8 @@ mod test {
     use boxed::BoxAny;
     use result;
     use std::old_io::{ChanReader, ChanWriter};
-    use super::{self, Thread, Builder};
+    use super::{Thread, Builder};
+    use thread;
     use thunk::Thunk;
     use time::Duration;
 
@@ -718,7 +721,7 @@ mod test {
     fn test_named_thread() {
         Builder::new().name("ada lovelace".to_string()).scoped(move|| {
             assert!(thread::current().name().unwrap() == "ada lovelace".to_string());
-        }).join().ok().unwrap();
+        }).unwrap().join();
     }
 
     #[test]
@@ -732,12 +735,9 @@ mod test {
 
     #[test]
     fn test_join_success() {
-        match thread::spawn(move|| -> String {
+        assert!(thread::scoped(move|| -> String {
             "Success!".to_string()
-        }).join().as_ref().map(|s| &**s) {
-            result::Result::Ok("Success!") => (),
-            _ => panic!()
-        }
+        }).join() == "Success!");
     }
 
     #[test]
@@ -928,10 +928,9 @@ mod test {
         let mut reader = ChanReader::new(rx);
         let stdout = ChanWriter::new(tx);
 
-        let r = Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
+        Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
             print!("Hello, world!");
-        }).join();
-        assert!(r.is_ok());
+        }).unwrap().join();
 
         let output = reader.read_to_string().unwrap();
         assert_eq!(output, "Hello, world!".to_string());
diff --git a/src/libstd/thread_local/scoped.rs b/src/libstd/thread_local/scoped.rs
index e4633ea0f76..01220e7bc1f 100644
--- a/src/libstd/thread_local/scoped.rs
+++ b/src/libstd/thread_local/scoped.rs
@@ -84,7 +84,7 @@ macro_rules! __scoped_thread_local_inner {
                            target_os = "openbsd",
                            target_arch = "aarch64")),
                    thread_local)]
-        static $name: ::std::thread_local::spawn::Key<$t> =
+        static $name: ::std::thread_local::scoped::Key<$t> =
             __scoped_thread_local_inner!($t);
     );
     (pub static $name:ident: $t:ty) => (
@@ -94,11 +94,11 @@ macro_rules! __scoped_thread_local_inner {
                            target_os = "openbsd",
                            target_arch = "aarch64")),
                    thread_local)]
-        pub static $name: ::std::thread_local::spawn::Key<$t> =
+        pub static $name: ::std::thread_local::scoped::Key<$t> =
             __scoped_thread_local_inner!($t);
     );
     ($t:ty) => ({
-        use std::thread_local::spawn::Key as __Key;
+        use std::thread_local::scoped::Key as __Key;
 
         #[cfg(not(any(windows,
                       target_os = "android",
@@ -106,7 +106,7 @@ macro_rules! __scoped_thread_local_inner {
                       target_os = "openbsd",
                       target_arch = "aarch64")))]
         const _INIT: __Key<$t> = __Key {
-            inner: ::std::thread_local::spawn::__impl::KeyInner {
+            inner: ::std::thread_local::scoped::__impl::KeyInner {
                 inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
             }
         };
@@ -117,8 +117,8 @@ macro_rules! __scoped_thread_local_inner {
                   target_os = "openbsd",
                   target_arch = "aarch64"))]
         const _INIT: __Key<$t> = __Key {
-            inner: ::std::thread_local::spawn::__impl::KeyInner {
-                inner: ::std::thread_local::spawn::__impl::OS_INIT,
+            inner: ::std::thread_local::scoped::__impl::KeyInner {
+                inner: ::std::thread_local::scoped::__impl::OS_INIT,
                 marker: ::std::marker::InvariantType,
             }
         };
diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs
index dc0a2a6459f..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> {
@@ -110,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::spawn(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-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs
index 8b840b16352..f7de935d08f 100644
--- a/src/test/bench/shootout-fannkuch-redux.rs
+++ b/src/test/bench/shootout-fannkuch-redux.rs
@@ -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::spawn(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);
     }
diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs
index e6beb952603..b5c460737b8 100644
--- a/src/test/bench/shootout-k-nucleotide.rs
+++ b/src/test/bench/shootout-k-nucleotide.rs
@@ -303,17 +303,17 @@ fn main() {
 
     let nb_freqs: Vec<_> = (1u..3).map(|i| {
         let input = input.clone();
-        (i, thread::spawn(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::spawn(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 8ab3b14a1f5..bddf6153228 100644
--- a/src/test/bench/shootout-mandelbrot.rs
+++ b/src/test/bench/shootout-mandelbrot.rs
@@ -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::spawn(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::spawn(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()
 }
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
index 0b74892d66c..abbcd7e4590 100755
--- a/src/test/compile-fail/send-is-not-static-ensures-scoping.rs
+++ b/src/test/compile-fail/send-is-not-static-ensures-scoping.rs
@@ -8,18 +8,17 @@
 // 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::thread;
 
 fn main() {
     let bad = {
         let x = 1;
         let y = &x;
 
-        Thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
+        thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
             let _z = y;
         })
     };
 
-    bad.join().ok().unwrap();
+    bad.join();
 }
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-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-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());
 }