about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorJosé manuel Barroso Galindo <theypsilon@gmail.com>2016-08-10 00:35:16 +0700
committerJosé manuel Barroso Galindo <theypsilon@gmail.com>2016-08-10 00:35:16 +0700
commit71a34d728b79d0f290aa6e7eebaad8cdd789ecd0 (patch)
tree916838ad79c59630a8257d1f44154cd00b7de467 /src/libstd
parent0e8ec4333c969bfa81231e54aa6e8ef203e87987 (diff)
parentf0139140f6a2d1207cb21336b0faca69b5a337b2 (diff)
downloadrust-71a34d728b79d0f290aa6e7eebaad8cdd789ecd0.tar.gz
rust-71a34d728b79d0f290aa6e7eebaad8cdd789ecd0.zip
Merge branch 'master' of github.com:theypsilon/rust
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/error.rs15
-rw-r--r--src/libstd/ffi/c_str.rs9
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/sys/unix/os.rs14
4 files changed, 33 insertions, 6 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 1459420cdc0..914599271ac 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -49,6 +49,7 @@
 
 use any::TypeId;
 use boxed::Box;
+use cell;
 use char;
 use fmt::{self, Debug, Display};
 use marker::{Send, Sync, Reflect};
@@ -289,6 +290,20 @@ impl Error for fmt::Error {
     }
 }
 
+#[unstable(feature = "try_borrow", issue = "35070")]
+impl<'a, T: ?Sized + Reflect> Error for cell::BorrowError<'a, T> {
+    fn description(&self) -> &str {
+        "already mutably borrowed"
+    }
+}
+
+#[unstable(feature = "try_borrow", issue = "35070")]
+impl<'a, T: ?Sized + Reflect> Error for cell::BorrowMutError<'a, T> {
+    fn description(&self) -> &str {
+        "already borrowed"
+    }
+}
+
 // copied from any.rs
 impl Error + 'static {
     /// Returns true if the boxed type is the same as `T`
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index f800a6e228e..e0501f9cc61 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -373,6 +373,15 @@ impl NulError {
 
     /// Consumes this error, returning the underlying vector of bytes which
     /// generated the error in the first place.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::ffi::CString;
+    ///
+    /// let nul_error = CString::new("foo\0bar").unwrap_err();
+    /// assert_eq!(nul_error.into_vec(), b"foo\0bar");
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_vec(self) -> Vec<u8> { self.1 }
 }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 865d067cdb6..c6272012d66 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -269,6 +269,7 @@
 #![feature(str_utf16)]
 #![feature(test, rustc_private)]
 #![feature(thread_local)]
+#![feature(try_borrow)]
 #![feature(try_from)]
 #![feature(unboxed_closures)]
 #![feature(unicode)]
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 4c3558f91f5..9c57f25dfcc 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -21,6 +21,7 @@ use fmt;
 use io;
 use iter;
 use libc::{self, c_int, c_char, c_void};
+use marker::PhantomData;
 use mem;
 use memchr;
 use path::{self, PathBuf};
@@ -37,6 +38,7 @@ static ENV_LOCK: Mutex = Mutex::new();
 
 
 extern {
+    #[cfg(not(target_os = "dragonfly"))]
     #[cfg_attr(any(target_os = "linux", target_os = "emscripten"),
                link_name = "__errno_location")]
     #[cfg_attr(any(target_os = "bitrig",
@@ -304,7 +306,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
 
 pub struct Args {
     iter: vec::IntoIter<OsString>,
-    _dont_send_or_sync_me: *mut (),
+    _dont_send_or_sync_me: PhantomData<*mut ()>,
 }
 
 impl Iterator for Args {
@@ -342,7 +344,7 @@ pub fn args() -> Args {
     };
     Args {
         iter: vec.into_iter(),
-        _dont_send_or_sync_me: ptr::null_mut(),
+        _dont_send_or_sync_me: PhantomData,
     }
 }
 
@@ -399,7 +401,7 @@ pub fn args() -> Args {
         }
     }
 
-    Args { iter: res.into_iter(), _dont_send_or_sync_me: ptr::null_mut() }
+    Args { iter: res.into_iter(), _dont_send_or_sync_me: PhantomData }
 }
 
 #[cfg(any(target_os = "linux",
@@ -418,12 +420,12 @@ pub fn args() -> Args {
     let v: Vec<OsString> = bytes.into_iter().map(|v| {
         OsStringExt::from_vec(v)
     }).collect();
-    Args { iter: v.into_iter(), _dont_send_or_sync_me: ptr::null_mut() }
+    Args { iter: v.into_iter(), _dont_send_or_sync_me: PhantomData }
 }
 
 pub struct Env {
     iter: vec::IntoIter<(OsString, OsString)>,
-    _dont_send_or_sync_me: *mut (),
+    _dont_send_or_sync_me: PhantomData<*mut ()>,
 }
 
 impl Iterator for Env {
@@ -464,7 +466,7 @@ pub fn env() -> Env {
         }
         let ret = Env {
             iter: result.into_iter(),
-            _dont_send_or_sync_me: ptr::null_mut(),
+            _dont_send_or_sync_me: PhantomData,
         };
         ENV_LOCK.unlock();
         return ret