summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-01-15 10:07:52 -0800
committerAlex Crichton <alex@alexcrichton.com>2016-01-16 11:03:10 -0800
commit9a4f43b9b6558ab74b3e849a7770dc193bc1847b (patch)
tree2bd3ab2adb8e8312ad3384b108f2ae8e1b589055 /src/libstd
parentc14b615534ebcd5667f594c86d18eebff6afc7cb (diff)
downloadrust-9a4f43b9b6558ab74b3e849a7770dc193bc1847b.tar.gz
rust-9a4f43b9b6558ab74b3e849a7770dc193bc1847b.zip
std: Stabilize APIs for the 1.7 release
This commit stabilizes and deprecates the FCP (final comment period) APIs for
the upcoming 1.7 beta release. The specific APIs which changed were:

Stabilized

* `Path::strip_prefix` (renamed from `relative_from`)
* `path::StripPrefixError` (new error type returned from `strip_prefix`)
* `Ipv4Addr::is_loopback`
* `Ipv4Addr::is_private`
* `Ipv4Addr::is_link_local`
* `Ipv4Addr::is_multicast`
* `Ipv4Addr::is_broadcast`
* `Ipv4Addr::is_documentation`
* `Ipv6Addr::is_unspecified`
* `Ipv6Addr::is_loopback`
* `Ipv6Addr::is_unique_local`
* `Ipv6Addr::is_multicast`
* `Vec::as_slice`
* `Vec::as_mut_slice`
* `String::as_str`
* `String::as_mut_str`
* `<[T]>::clone_from_slice` - the `usize` return value is removed
* `<[T]>::sort_by_key`
* `i32::checked_rem` (and other signed types)
* `i32::checked_neg` (and other signed types)
* `i32::checked_shl` (and other signed types)
* `i32::checked_shr` (and other signed types)
* `i32::saturating_mul` (and other signed types)
* `i32::overflowing_add` (and other signed types)
* `i32::overflowing_sub` (and other signed types)
* `i32::overflowing_mul` (and other signed types)
* `i32::overflowing_div` (and other signed types)
* `i32::overflowing_rem` (and other signed types)
* `i32::overflowing_neg` (and other signed types)
* `i32::overflowing_shl` (and other signed types)
* `i32::overflowing_shr` (and other signed types)
* `u32::checked_rem` (and other unsigned types)
* `u32::checked_neg` (and other unsigned types)
* `u32::checked_shl` (and other unsigned types)
* `u32::saturating_mul` (and other unsigned types)
* `u32::overflowing_add` (and other unsigned types)
* `u32::overflowing_sub` (and other unsigned types)
* `u32::overflowing_mul` (and other unsigned types)
* `u32::overflowing_div` (and other unsigned types)
* `u32::overflowing_rem` (and other unsigned types)
* `u32::overflowing_neg` (and other unsigned types)
* `u32::overflowing_shl` (and other unsigned types)
* `u32::overflowing_shr` (and other unsigned types)
* `ffi::IntoStringError`
* `CString::into_string`
* `CString::into_bytes`
* `CString::into_bytes_with_nul`
* `From<CString> for Vec<u8>`
* `From<CString> for Vec<u8>`
* `IntoStringError::into_cstring`
* `IntoStringError::utf8_error`
* `Error for IntoStringError`

Deprecated

* `Path::relative_from` - renamed to `strip_prefix`
* `Path::prefix` - use `components().next()` instead
* `os::unix::fs` constants - moved to the `libc` crate
* `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize
* `IntoCow` - conflicts with `Into` and may come back later
* `i32::{BITS, BYTES}` (and other integers) - not pulling their weight
* `DebugTuple::formatter` - will be removed
* `sync::Semaphore` - not used enough and confused with system semaphores

Closes #23284
cc #27709 (still lots more methods though)
Closes #27712
Closes #27722
Closes #27728
Closes #27735
Closes #27729
Closes #27755
Closes #27782
Closes #27798
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/table.rs1
-rw-r--r--src/libstd/ffi/c_str.rs32
-rw-r--r--src/libstd/io/cursor.rs11
-rw-r--r--src/libstd/io/impls.rs2
-rw-r--r--src/libstd/lib.rs3
-rw-r--r--src/libstd/memchr.rs28
-rw-r--r--src/libstd/net/ip.rs23
-rw-r--r--src/libstd/net/parser.rs2
-rw-r--r--src/libstd/path.rs49
-rw-r--r--src/libstd/sync/mod.rs1
-rw-r--r--src/libstd/sync/semaphore.rs4
-rw-r--r--src/libstd/sys/unix/ext/fs.rs19
12 files changed, 137 insertions, 38 deletions
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs
index 097968cd5a3..f8550fd8842 100644
--- a/src/libstd/collections/hash/table.rs
+++ b/src/libstd/collections/hash/table.rs
@@ -15,7 +15,6 @@ use hash::{Hash, Hasher};
 use marker;
 use mem::{align_of, size_of};
 use mem;
-use num::wrapping::OverflowingOps;
 use ops::{Deref, DerefMut};
 use ptr::{self, Unique};
 use collections::hash_state::HashState;
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 9a41272299e..d6aa746f4cb 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -150,7 +150,7 @@ pub struct NulError(usize, Vec<u8>);
 /// An error returned from `CString::into_string` to indicate that a UTF-8 error
 /// was encountered during the conversion.
 #[derive(Clone, PartialEq, Debug)]
-#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+#[stable(feature = "cstring_into", since = "1.7.0")]
 pub struct IntoStringError {
     inner: CString,
     error: Utf8Error,
@@ -235,7 +235,7 @@ impl CString {
     /// Converts the `CString` into a `String` if it contains valid Unicode data.
     ///
     /// On failure, ownership of the original `CString` is returned.
-    #[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+    #[stable(feature = "cstring_into", since = "1.7.0")]
     pub fn into_string(self) -> Result<String, IntoStringError> {
         String::from_utf8(self.into_bytes())
             .map_err(|e| IntoStringError {
@@ -248,9 +248,8 @@ impl CString {
     ///
     /// The returned buffer does **not** contain the trailing nul separator and
     /// it is guaranteed to not have any interior nul bytes.
-    #[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+    #[stable(feature = "cstring_into", since = "1.7.0")]
     pub fn into_bytes(self) -> Vec<u8> {
-        // FIXME: Once this method becomes stable, add an `impl Into<Vec<u8>> for CString`
         let mut vec = self.inner.into_vec();
         let _nul = vec.pop();
         debug_assert_eq!(_nul, Some(0u8));
@@ -259,7 +258,7 @@ impl CString {
 
     /// Equivalent to the `into_bytes` function except that the returned vector
     /// includes the trailing nul byte.
-    #[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+    #[stable(feature = "cstring_into", since = "1.7.0")]
     pub fn into_bytes_with_nul(self) -> Vec<u8> {
         self.inner.into_vec()
     }
@@ -297,6 +296,13 @@ impl fmt::Debug for CString {
     }
 }
 
+#[stable(feature = "cstring_into", since = "1.7.0")]
+impl From<CString> for Vec<u8> {
+    fn from(s: CString) -> Vec<u8> {
+        s.into_bytes()
+    }
+}
+
 #[stable(feature = "cstr_debug", since = "1.3.0")]
 impl fmt::Debug for CStr {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -348,29 +354,33 @@ impl From<NulError> for io::Error {
 impl IntoStringError {
     /// Consumes this error, returning original `CString` which generated the
     /// error.
-    #[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+    #[stable(feature = "cstring_into", since = "1.7.0")]
     pub fn into_cstring(self) -> CString {
         self.inner
     }
 
     /// Access the underlying UTF-8 error that was the cause of this error.
-    #[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+    #[stable(feature = "cstring_into", since = "1.7.0")]
     pub fn utf8_error(&self) -> Utf8Error {
         self.error
     }
 }
 
-#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+#[stable(feature = "cstring_into", since = "1.7.0")]
 impl Error for IntoStringError {
     fn description(&self) -> &str {
-        Error::description(&self.error)
+        "C string contained non-utf8 bytes"
+    }
+
+    fn cause(&self) -> Option<&Error> {
+        Some(&self.error)
     }
 }
 
-#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
+#[stable(feature = "cstring_into", since = "1.7.0")]
 impl fmt::Display for IntoStringError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::Display::fmt(&self.error, f)
+        self.description().fmt(f)
     }
 }
 
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs
index de09451e7c0..4573f465819 100644
--- a/src/libstd/io/cursor.rs
+++ b/src/libstd/io/cursor.rs
@@ -252,10 +252,13 @@ impl Write for Cursor<Vec<u8>> {
 
         // Figure out what bytes will be used to overwrite what's currently
         // there (left), and what will be appended on the end (right)
-        let space = self.inner.len() - pos as usize;
-        let (left, right) = buf.split_at(cmp::min(space, buf.len()));
-        self.inner[(pos as usize)..].clone_from_slice(left);
-        self.inner.extend_from_slice(right);
+        {
+            let pos = pos as usize;
+            let space = self.inner.len() - pos;
+            let (left, right) = buf.split_at(cmp::min(space, buf.len()));
+            self.inner[pos..pos + left.len()].clone_from_slice(left);
+            self.inner.extend_from_slice(right);
+        }
 
         // Bump us forward
         self.set_position(pos + buf.len() as u64);
diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs
index 95f630c9658..592e16b0a3c 100644
--- a/src/libstd/io/impls.rs
+++ b/src/libstd/io/impls.rs
@@ -156,7 +156,7 @@ impl<'a> Read for &'a [u8] {
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
         let amt = cmp::min(buf.len(), self.len());
         let (a, b) = self.split_at(amt);
-        buf.clone_from_slice(a);
+        buf[..amt].clone_from_slice(a);
         *self = b;
         Ok(amt)
     }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 824acda522f..9adea351e3d 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -219,7 +219,6 @@
 #![feature(cfg_target_vendor)]
 #![feature(cfg_target_thread_local)]
 #![feature(char_internals)]
-#![feature(clone_from_slice)]
 #![feature(collections)]
 #![feature(collections_bound)]
 #![feature(const_fn)]
@@ -240,6 +239,7 @@
 #![feature(linkage)]
 #![feature(macro_reexport)]
 #![feature(num_bits_bytes)]
+#![feature(old_wrapping)]
 #![feature(on_unimplemented)]
 #![feature(oom)]
 #![feature(optin_builtin_traits)]
@@ -266,7 +266,6 @@
 #![feature(unsafe_no_drop_flag, filling_drop)]
 #![feature(unwind_attributes)]
 #![feature(vec_push_all)]
-#![feature(wrapping)]
 #![feature(zero_one)]
 
 // Don't link to std. We are std.
diff --git a/src/libstd/memchr.rs b/src/libstd/memchr.rs
index c654efd499b..c043b41ed21 100644
--- a/src/libstd/memchr.rs
+++ b/src/libstd/memchr.rs
@@ -107,7 +107,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
 #[allow(dead_code)]
 mod fallback {
     use cmp;
-    use usize;
+    use mem;
 
     const LO_U64: u64 = 0x0101010101010101;
     const HI_U64: u64 = 0x8080808080808080;
@@ -155,12 +155,13 @@ mod fallback {
         // - the last remaining part, < 2 word size
         let len = text.len();
         let ptr = text.as_ptr();
+        let usize_bytes = mem::size_of::<usize>();
 
         // search up to an aligned boundary
-        let align = (ptr as usize) & (usize::BYTES- 1);
+        let align = (ptr as usize) & (usize_bytes- 1);
         let mut offset;
         if align > 0 {
-            offset = cmp::min(usize::BYTES - align, len);
+            offset = cmp::min(usize_bytes - align, len);
             if let Some(index) = text[..offset].iter().position(|elt| *elt == x) {
                 return Some(index);
             }
@@ -171,11 +172,11 @@ mod fallback {
         // search the body of the text
         let repeated_x = repeat_byte(x);
 
-        if len >= 2 * usize::BYTES {
-            while offset <= len - 2 * usize::BYTES {
+        if len >= 2 * usize_bytes {
+            while offset <= len - 2 * usize_bytes {
                 unsafe {
                     let u = *(ptr.offset(offset as isize) as *const usize);
-                    let v = *(ptr.offset((offset + usize::BYTES) as isize) as *const usize);
+                    let v = *(ptr.offset((offset + usize_bytes) as isize) as *const usize);
 
                     // break if there is a matching byte
                     let zu = contains_zero_byte(u ^ repeated_x);
@@ -184,7 +185,7 @@ mod fallback {
                         break;
                     }
                 }
-                offset += usize::BYTES * 2;
+                offset += usize_bytes * 2;
             }
         }
 
@@ -202,12 +203,13 @@ mod fallback {
         // - the first remaining bytes, < 2 word size
         let len = text.len();
         let ptr = text.as_ptr();
+        let usize_bytes = mem::size_of::<usize>();
 
         // search to an aligned boundary
-        let end_align = (ptr as usize + len) & (usize::BYTES - 1);
+        let end_align = (ptr as usize + len) & (usize_bytes - 1);
         let mut offset;
         if end_align > 0 {
-            offset = len - cmp::min(usize::BYTES - end_align, len);
+            offset = len - cmp::min(usize_bytes - end_align, len);
             if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) {
                 return Some(offset + index);
             }
@@ -218,10 +220,10 @@ mod fallback {
         // search the body of the text
         let repeated_x = repeat_byte(x);
 
-        while offset >= 2 * usize::BYTES {
+        while offset >= 2 * usize_bytes {
             unsafe {
-                let u = *(ptr.offset(offset as isize - 2 * usize::BYTES as isize) as *const usize);
-                let v = *(ptr.offset(offset as isize - usize::BYTES as isize) as *const usize);
+                let u = *(ptr.offset(offset as isize - 2 * usize_bytes as isize) as *const usize);
+                let v = *(ptr.offset(offset as isize - usize_bytes as isize) as *const usize);
 
                 // break if there is a matching byte
                 let zu = contains_zero_byte(u ^ repeated_x);
@@ -230,7 +232,7 @@ mod fallback {
                     break;
                 }
             }
-            offset -= 2 * usize::BYTES;
+            offset -= 2 * usize_bytes;
         }
 
         // find the byte before the point the body loop stopped
diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs
index 808cf5cc031..341ba98191a 100644
--- a/src/libstd/net/ip.rs
+++ b/src/libstd/net/ip.rs
@@ -89,6 +89,9 @@ impl Ipv4Addr {
     }
 
     /// Returns true if this is a loopback address (127.0.0.0/8).
+    ///
+    /// This property is defined by RFC 6890
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_loopback(&self) -> bool {
         self.octets()[0] == 127
     }
@@ -100,6 +103,7 @@ impl Ipv4Addr {
     ///  - 10.0.0.0/8
     ///  - 172.16.0.0/12
     ///  - 192.168.0.0/16
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_private(&self) -> bool {
         match (self.octets()[0], self.octets()[1]) {
             (10, _) => true,
@@ -110,6 +114,9 @@ impl Ipv4Addr {
     }
 
     /// Returns true if the address is link-local (169.254.0.0/16).
+    ///
+    /// This property is defined by RFC 6890
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_link_local(&self) -> bool {
         self.octets()[0] == 169 && self.octets()[1] == 254
     }
@@ -130,7 +137,9 @@ impl Ipv4Addr {
 
     /// Returns true if this is a multicast address.
     ///
-    /// Multicast addresses have a most significant octet between 224 and 239.
+    /// Multicast addresses have a most significant octet between 224 and 239,
+    /// and is defined by RFC 5771
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_multicast(&self) -> bool {
         self.octets()[0] >= 224 && self.octets()[0] <= 239
     }
@@ -138,6 +147,7 @@ impl Ipv4Addr {
     /// Returns true if this is a broadcast address.
     ///
     /// A broadcast address has all octets set to 255 as defined in RFC 919.
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_broadcast(&self) -> bool {
         self.octets()[0] == 255 && self.octets()[1] == 255 &&
         self.octets()[2] == 255 && self.octets()[3] == 255
@@ -150,6 +160,7 @@ impl Ipv4Addr {
     /// - 192.0.2.0/24 (TEST-NET-1)
     /// - 198.51.100.0/24 (TEST-NET-2)
     /// - 203.0.113.0/24 (TEST-NET-3)
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_documentation(&self) -> bool {
         match(self.octets()[0], self.octets()[1], self.octets()[2], self.octets()[3]) {
             (192, 0, 2, _) => true,
@@ -302,11 +313,17 @@ impl Ipv6Addr {
     }
 
     /// Returns true for the special 'unspecified' address ::.
+    ///
+    /// This property is defined in RFC 6890.
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_unspecified(&self) -> bool {
         self.segments() == [0, 0, 0, 0, 0, 0, 0, 0]
     }
 
     /// Returns true if this is a loopback address (::1).
+    ///
+    /// This property is defined in RFC 6890.
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_loopback(&self) -> bool {
         self.segments() == [0, 0, 0, 0, 0, 0, 0, 1]
     }
@@ -378,7 +395,9 @@ impl Ipv6Addr {
 
     /// Returns true if this is a multicast address.
     ///
-    /// Multicast addresses have the form ff00::/8.
+    /// Multicast addresses have the form ff00::/8, and this property is defined
+    /// by RFC 3956.
+    #[stable(since = "1.7.0", feature = "ip_17")]
     pub fn is_multicast(&self) -> bool {
         (self.segments()[0] & 0xff00) == 0xff00
     }
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs
index 79a269ff87c..91401c8e4fd 100644
--- a/src/libstd/net/parser.rs
+++ b/src/libstd/net/parser.rs
@@ -193,7 +193,7 @@ impl<'a> Parser<'a> {
         fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> Ipv6Addr {
             assert!(head.len() + tail.len() <= 8);
             let mut gs = [0; 8];
-            gs.clone_from_slice(head);
+            gs[..head.len()].clone_from_slice(head);
             gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
             Ipv6Addr::new(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
         }
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 3956f948eb9..e398a5a28c9 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -100,8 +100,10 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use ascii::*;
+#[allow(deprecated)]
 use borrow::{Borrow, IntoCow, ToOwned, Cow};
 use cmp;
+use error::Error;
 use fmt;
 use fs;
 use hash::{Hash, Hasher};
@@ -1043,6 +1045,7 @@ impl PathBuf {
         self._push(path.as_ref())
     }
 
+    #[allow(deprecated)]
     fn _push(&mut self, path: &Path) {
         // in general, a separator is needed if the rightmost byte is not a separator
         let mut need_sep = self.as_mut_vec().last().map(|c| !is_sep_byte(*c)).unwrap_or(false);
@@ -1219,6 +1222,7 @@ impl Borrow<Path> for PathBuf {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl IntoCow<'static, Path> for PathBuf {
     fn into_cow(self) -> Cow<'static, Path> {
         Cow::Owned(self)
@@ -1226,6 +1230,7 @@ impl IntoCow<'static, Path> for PathBuf {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl<'a> IntoCow<'a, Path> for &'a Path {
     fn into_cow(self) -> Cow<'a, Path> {
         Cow::Borrowed(self)
@@ -1328,6 +1333,12 @@ pub struct Path {
     inner: OsStr,
 }
 
+/// An error returned from the `Path::strip_prefix` method indicating that the
+/// prefix was not found in `self`.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[stable(since = "1.7.0", feature = "strip_prefix")]
+pub struct StripPrefixError(());
+
 impl Path {
     // The following (private!) function allows construction of a path from a u8
     // slice, which is only safe when it is known to follow the OsStr encoding.
@@ -1447,6 +1458,7 @@ impl Path {
     /// assert!(!Path::new("foo.txt").is_absolute());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[allow(deprecated)]
     pub fn is_absolute(&self) -> bool {
         self.has_root() && (cfg!(unix) || self.prefix().is_some())
     }
@@ -1473,6 +1485,8 @@ impl Path {
     #[unstable(feature = "path_prefix",
                reason = "uncertain whether to expose this convenience",
                issue = "27722")]
+    #[rustc_deprecated(since = "1.7.0",
+                       reason = "inspect components().next() instead")]
     pub fn prefix(&self) -> Option<Prefix> {
         self.components().prefix
     }
@@ -1561,12 +1575,28 @@ impl Path {
     /// returns false), then `relative_from` returns `None`.
     #[unstable(feature = "path_relative_from", reason = "see #23284",
                issue = "23284")]
+    #[rustc_deprecated(since = "1.7.0", reason = "renamed to strip_prefix")]
     pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Option<&Path> {
-        self._relative_from(base.as_ref())
+        self._strip_prefix(base.as_ref()).ok()
+    }
+
+    /// Returns a path that, when joined onto `base`, yields `self`.
+    ///
+    /// If `base` is not a prefix of `self` (i.e. `starts_with`
+    /// returns false), then `relative_from` returns `None`.
+    #[stable(since = "1.7.0", feature = "path_strip_prefix")]
+    pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P)
+                                       -> Result<&'a Path, StripPrefixError>
+        where P: AsRef<Path>
+    {
+        self._strip_prefix(base.as_ref())
     }
 
-    fn _relative_from<'a>(&'a self, base: &'a Path) -> Option<&'a Path> {
-        iter_after(self.components(), base.components()).map(|c| c.as_path())
+    fn _strip_prefix<'a>(&'a self, base: &'a Path)
+                         -> Result<&'a Path, StripPrefixError> {
+        iter_after(self.components(), base.components())
+            .map(|c| c.as_path())
+            .ok_or(StripPrefixError(()))
     }
 
     /// Determines whether `base` is a prefix of `self`.
@@ -2015,6 +2045,18 @@ impl_eq!(Cow<'a, Path>, Path);
 impl_eq!(Cow<'a, Path>, &'b Path);
 impl_eq!(Cow<'a, Path>, PathBuf);
 
+#[stable(since = "1.7.0", feature = "strip_prefix")]
+impl fmt::Display for StripPrefixError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.description().fmt(f)
+    }
+}
+
+#[stable(since = "1.7.0", feature = "strip_prefix")]
+impl Error for StripPrefixError {
+    fn description(&self) -> &str { "prefix not found" }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -2105,6 +2147,7 @@ mod tests {
     );
 
     #[test]
+    #[allow(deprecated)]
     fn into_cow() {
         use borrow::{Cow, IntoCow};
 
diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs
index e1b7930b6d8..9c9aa20eff5 100644
--- a/src/libstd/sync/mod.rs
+++ b/src/libstd/sync/mod.rs
@@ -39,6 +39,7 @@ pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub use self::semaphore::{Semaphore, SemaphoreGuard};
 
 pub mod mpsc;
diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs
index 891f8775ff2..8f08c840c21 100644
--- a/src/libstd/sync/semaphore.rs
+++ b/src/libstd/sync/semaphore.rs
@@ -12,6 +12,10 @@
             reason = "the interaction between semaphores and the acquisition/release \
                       of resources is currently unclear",
             issue = "27798")]
+#![rustc_deprecated(since = "1.7.0",
+                    reason = "easily confused with system sempahores and not \
+                              used enough to pull its weight")]
+#![allow(deprecated)]
 
 use ops::Drop;
 use sync::{Mutex, Condvar};
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs
index 16e1578296d..8d21ba8f661 100644
--- a/src/libstd/sys/unix/ext/fs.rs
+++ b/src/libstd/sys/unix/ext/fs.rs
@@ -23,42 +23,61 @@ use sys;
 use sys_common::{FromInner, AsInner, AsInnerMut};
 
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const USER_READ: raw::mode_t = 0o400;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const USER_WRITE: raw::mode_t = 0o200;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const USER_EXECUTE: raw::mode_t = 0o100;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const USER_RWX: raw::mode_t = 0o700;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const GROUP_READ: raw::mode_t = 0o040;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const GROUP_WRITE: raw::mode_t = 0o020;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const GROUP_EXECUTE: raw::mode_t = 0o010;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const GROUP_RWX: raw::mode_t = 0o070;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const OTHER_READ: raw::mode_t = 0o004;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const OTHER_WRITE: raw::mode_t = 0o002;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const OTHER_EXECUTE: raw::mode_t = 0o001;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const OTHER_RWX: raw::mode_t = 0o007;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const ALL_READ: raw::mode_t = 0o444;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const ALL_WRITE: raw::mode_t = 0o222;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const ALL_EXECUTE: raw::mode_t = 0o111;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const ALL_RWX: raw::mode_t = 0o777;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const SETUID: raw::mode_t = 0o4000;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const SETGID: raw::mode_t = 0o2000;
 #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
+#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
 pub const STICKY_BIT: raw::mode_t = 0o1000;
 
 /// Unix-specific extensions to `Permissions`