about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-09-18 17:30:29 +0000
committerbors <bors@rust-lang.org>2017-09-18 17:30:29 +0000
commit0701b37d97d08da7074ece7a7dcb4449498f4bfa (patch)
tree796f1ce756d1bce72a8462d6d74c28f11263895c /src/libstd
parent3a7b960731fd1cf86f1879b1a0d44196a0917c53 (diff)
parent929215db7c598722410709022e69f71702f02e0b (diff)
downloadrust-0701b37d97d08da7074ece7a7dcb4449498f4bfa.tar.gz
rust-0701b37d97d08da7074ece7a7dcb4449498f4bfa.zip
Auto merge of #44678 - alexcrichton:rollup, r=alexcrichton
Rollup of 11 pull requests

- Successful merges: #44364, #44466, #44537, #44548, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/error.rs15
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/sys_common/memchr.rs9
-rw-r--r--src/libstd/thread/mod.rs7
4 files changed, 26 insertions, 6 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 401552a6ec4..6d64ea0d503 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -53,6 +53,7 @@
 
 use alloc::allocator;
 use any::TypeId;
+use borrow::Cow;
 use cell;
 use char;
 use fmt::{self, Debug, Display};
@@ -217,6 +218,20 @@ impl<'a> From<&'a str> for Box<Error> {
     }
 }
 
+#[stable(feature = "cow_box_error", since = "1.22.0")]
+impl<'a, 'b> From<Cow<'b, str>> for Box<Error + Send + Sync + 'a> {
+    fn from(err: Cow<'b, str>) -> Box<Error + Send + Sync + 'a> {
+        From::from(String::from(err))
+    }
+}
+
+#[stable(feature = "cow_box_error", since = "1.22.0")]
+impl<'a> From<Cow<'a, str>> for Box<Error> {
+    fn from(err: Cow<'a, str>) -> Box<Error> {
+        From::from(String::from(err))
+    }
+}
+
 #[unstable(feature = "never_type_impls", issue = "35121")]
 impl Error for ! {
     fn description(&self) -> &str { *self }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 1a0f8b8d217..a3eecd46e90 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -242,6 +242,7 @@
 #![feature(allocator_internals)]
 #![feature(allow_internal_unsafe)]
 #![feature(allow_internal_unstable)]
+#![feature(align_offset)]
 #![feature(asm)]
 #![feature(box_syntax)]
 #![feature(cfg_target_has_atomic)]
diff --git a/src/libstd/sys_common/memchr.rs b/src/libstd/sys_common/memchr.rs
index 3824a5fb528..50f998eb486 100644
--- a/src/libstd/sys_common/memchr.rs
+++ b/src/libstd/sys_common/memchr.rs
@@ -65,15 +65,12 @@ pub mod fallback {
         let usize_bytes = mem::size_of::<usize>();
 
         // search up to an aligned boundary
-        let align = (ptr as usize) & (usize_bytes- 1);
-        let mut offset;
-        if align > 0 {
-            offset = cmp::min(usize_bytes - align, len);
+        let mut offset = ptr.align_offset(usize_bytes);
+        if offset > 0 {
+            offset = cmp::min(offset, len);
             if let Some(index) = text[..offset].iter().position(|elt| *elt == x) {
                 return Some(index);
             }
-        } else {
-            offset = 0;
         }
 
         // search the body of the text
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index ca01eaefcae..30887b16c60 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -287,6 +287,8 @@ impl Builder {
     /// Names the thread-to-be. Currently the name is used for identification
     /// only in panic messages.
     ///
+    /// The name must not contain null bytes (`\0`).
+    ///
     /// For more information about named threads, see
     /// [this module-level documentation][naming-threads].
     ///
@@ -355,6 +357,10 @@ impl Builder {
     /// [`io::Result`]: ../../std/io/type.Result.html
     /// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
     ///
+    /// # Panics
+    ///
+    /// Panics if a thread name was set and it contained null bytes.
+    ///
     /// # Examples
     ///
     /// ```
@@ -941,6 +947,7 @@ pub struct Thread {
 
 impl Thread {
     // Used only internally to construct a thread object without spawning
+    // Panics if the name contains nuls.
     pub(crate) fn new(name: Option<String>) -> Thread {
         let cname = name.map(|n| {
             CString::new(n).expect("thread name may not contain interior null bytes")