about summary refs log tree commit diff
path: root/src/libstd
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 /src/libstd
parentba8ce4c2c27643cccfbbc481a19bcf4b7747cc89 (diff)
downloadrust-665ea963d3c29ef7670662707f2f2307f000efa3.tar.gz
rust-665ea963d3c29ef7670662707f2f2307f000efa3.zip
Test fixes and rebase conflicts
Diffstat (limited to 'src/libstd')
-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
6 files changed, 27 insertions, 31 deletions
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,
             }
         };