about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-03-19 03:19:08 +0000
committerbors <bors@rust-lang.org>2015-03-19 03:19:08 +0000
commit0084f92302b3352372bfd14ebbf083bae695d16e (patch)
tree7aeee112b2593dfc26968c2c3692371d9dc4a5ef /src/libstd
parent12cb7c6a2847959460ecac75b2c983d071585472 (diff)
parent6f930b99b0dbd548abb7bdd9eb9472d166f66811 (diff)
downloadrust-0084f92302b3352372bfd14ebbf083bae695d16e.tar.gz
rust-0084f92302b3352372bfd14ebbf083bae695d16e.zip
Auto merge of #23502 - Manishearth:rollup, r=Manishearth
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/stdio.rs32
-rw-r--r--src/libstd/macros.rs14
-rw-r--r--src/libstd/sys/unix/os.rs5
-rw-r--r--src/libstd/sys/unix/thread.rs6
4 files changed, 47 insertions, 10 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 75d047d5c9c..9b36408aa51 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -146,7 +146,7 @@ impl Stdin {
     /// accessing the underlying data.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn lock(&self) -> StdinLock {
-        StdinLock { inner: self.inner.lock().unwrap() }
+        StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }
     }
 
     /// Locks this handle and reads a line of input into the specified buffer.
@@ -249,7 +249,7 @@ impl Stdout {
     /// returned guard also implements the `Write` trait for writing data.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn lock(&self) -> StdoutLock {
-        StdoutLock { inner: self.inner.lock().unwrap() }
+        StdoutLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }
     }
 }
 
@@ -319,7 +319,7 @@ impl Stderr {
     /// returned guard also implements the `Write` trait for writing data.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn lock(&self) -> StderrLock {
-        StderrLock { inner: self.inner.lock().unwrap() }
+        StderrLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }
     }
 }
 
@@ -402,3 +402,29 @@ pub fn _print(args: fmt::Arguments) {
         panic!("failed printing to stdout: {}", e);
     }
 }
+
+#[cfg(test)]
+mod test {
+    use thread;
+    use super::*;
+
+    #[test]
+    fn panic_doesnt_poison() {
+        thread::spawn(|| {
+            let _a = stdin();
+            let _a = _a.lock();
+            let _a = stdout();
+            let _a = _a.lock();
+            let _a = stderr();
+            let _a = _a.lock();
+            panic!();
+        }).join().unwrap_err();
+
+        let _a = stdin();
+        let _a = _a.lock();
+        let _a = stdout();
+        let _a = _a.lock();
+        let _a = stderr();
+        let _a = _a.lock();
+    }
+}
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index e1ef3062794..f4a7e8b1b98 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -404,4 +404,18 @@ pub mod builtin {
     /// ```
     #[macro_export]
     macro_rules! cfg { ($cfg:tt) => ({ /* compiler built-in */ }) }
+
+    /// Parse the current given file as an expression.
+    ///
+    /// This is generally a bad idea, because it's going to behave unhygenically.
+    ///
+    /// # Examples
+    ///
+    /// ```ignore
+    /// fn foo() {
+    ///     include!("/path/to/a/file")
+    /// }
+    /// ```
+    #[macro_export]
+    macro_rules! include { ($cfg:tt) => ({ /* compiler built-in */ }) }
 }
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 75aeafe6e3c..a5a2f71acb7 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -306,12 +306,11 @@ pub fn args() -> Args {
 // In general it looks like:
 // res = Vec::new()
 // let args = [[NSProcessInfo processInfo] arguments]
-// for i in range(0, [args count])
+// for i in (0..[args count])
 //      res.push([args objectAtIndex:i])
 // res
 #[cfg(target_os = "ios")]
 pub fn args() -> Args {
-    use iter::range;
     use mem;
 
     #[link(name = "objc")]
@@ -341,7 +340,7 @@ pub fn args() -> Args {
         let args = objc_msgSend(info, arguments_sel);
 
         let cnt: int = mem::transmute(objc_msgSend(args, count_sel));
-        for i in range(0, cnt) {
+        for i in (0..cnt) {
             let tmp = objc_msgSend(args, object_at_sel, i);
             let utf_c_str: *const libc::c_char =
                 mem::transmute(objc_msgSend(tmp, utf8_sel));
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 04508294981..c5f07c6c75a 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -130,12 +130,13 @@ pub mod guard {
     #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
     pub unsafe fn current() -> usize {
         #[repr(C)]
-        pub struct stack_t {
+        struct stack_t {
             ss_sp: *mut libc::c_void,
             ss_size: libc::size_t,
             ss_flags: libc::c_int,
         }
         extern {
+            fn pthread_main_np() -> libc::c_uint;
             fn pthread_stackseg_np(thread: pthread_t,
                                    sinfo: *mut stack_t) -> libc::c_uint;
         }
@@ -339,9 +340,6 @@ fn min_stack_size(_: *const libc::pthread_attr_t) -> libc::size_t {
 }
 
 extern {
-    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
-    fn pthread_main_np() -> libc::c_uint;
-
     fn pthread_self() -> libc::pthread_t;
     fn pthread_create(native: *mut libc::pthread_t,
                       attr: *const libc::pthread_attr_t,