diff options
Diffstat (limited to 'src/libstd')
29 files changed, 146 insertions, 121 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index c8b377ba3be..77c4149f992 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -986,8 +986,6 @@ impl<K, V, S> HashMap<K, V, S> /// # Examples /// /// ``` - /// #![feature(drain)] - /// /// use std::collections::HashMap; /// /// let mut a = HashMap::new(); @@ -1002,9 +1000,7 @@ impl<K, V, S> HashMap<K, V, S> /// assert!(a.is_empty()); /// ``` #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain<K, V> { fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) } let last_two: fn((SafeHash, K, V)) -> (K, V) = last_two; // coerce to fn pointer @@ -1327,9 +1323,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> { } /// HashMap drain iterator. -#[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, K: 'a, V: 'a> { inner: iter::Map<table::Drain<'a, K, V>, fn((SafeHash, K, V)) -> (K, V)> } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index daabb0f9fa8..08f356463bc 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -413,9 +413,7 @@ impl<T, S> HashSet<T, S> /// Clears the set, returning all elements in an iterator. #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain<T> { fn first<A, B>((a, _): (A, B)) -> A { a } let first: fn((T, ())) -> T = first; // coerce to fn pointer diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 7409d9b45d2..90b108e6770 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -72,6 +72,8 @@ impl OsString { /// On Windows system, only UTF-8 byte sequences will successfully /// convert; non UTF-8 data will produce `None`. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] pub fn from_bytes<B>(bytes: B) -> Option<OsString> where B: Into<Vec<u8>> { Self::_from_bytes(bytes.into()) } @@ -256,6 +258,8 @@ impl OsStr { /// valid unicode, in which case it produces UTF-8-encoded /// data. This may entail checking validity. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] pub fn to_bytes(&self) -> Option<&[u8]> { if cfg!(windows) { self.to_str().map(|s| s.as_bytes()) @@ -272,6 +276,9 @@ impl OsStr { /// `self.to_bytes()`, and inherits the platform behavior of the /// `to_bytes` method. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] + #[allow(deprecated)] pub fn to_cstring(&self) -> Option<CString> { self.to_bytes().and_then(|b| CString::new(b).ok()) } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 7f256e6fae0..bfad2248359 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -91,6 +91,8 @@ pub struct DirEntry(fs_imp::DirEntry); may change and this may end up accounting for files such \ as symlinks differently", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] pub struct WalkDir { cur: Option<ReadDir>, stack: Vec<io::Result<ReadDir>>, @@ -156,8 +158,7 @@ pub struct FileType(fs_imp::FileType); /// A builder used to create directories in various manners. /// /// This builder also supports platform-specific options. -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] pub struct DirBuilder { inner: fs_imp::DirBuilder, recursive: bool, @@ -1132,16 +1133,23 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> { may change and this may end up accounting for files such \ as symlinks differently", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] +#[allow(deprecated)] pub fn walk_dir<P: AsRef<Path>>(path: P) -> io::Result<WalkDir> { _walk_dir(path.as_ref()) } +#[allow(deprecated)] fn _walk_dir(path: &Path) -> io::Result<WalkDir> { let start = try!(read_dir(path)); Ok(WalkDir { cur: Some(start), stack: Vec::new() }) } #[unstable(feature = "fs_walk", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] +#[allow(deprecated)] impl Iterator for WalkDir { type Item = io::Result<DirEntry>; @@ -1275,11 +1283,10 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) fs_imp::set_perm(path.as_ref(), perm.0) } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] impl DirBuilder { /// Creates a new set of options with default mode/security settings for all /// platforms and also non-recursive. + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn new() -> DirBuilder { DirBuilder { inner: fs_imp::DirBuilder::new(), @@ -1292,6 +1299,7 @@ impl DirBuilder { /// permissions settings. /// /// This option defaults to `false` + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn recursive(&mut self, recursive: bool) -> &mut Self { self.recursive = recursive; self @@ -1303,7 +1311,6 @@ impl DirBuilder { /// # Examples /// /// ```no_run - /// #![feature(dir_builder)] /// use std::fs::{self, DirBuilder}; /// /// let path = "/tmp/foo/bar/baz"; @@ -1313,6 +1320,7 @@ impl DirBuilder { /// /// assert!(fs::metadata(path).unwrap().is_dir()); /// ``` + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn create<P: AsRef<Path>>(&self, path: P) -> io::Result<()> { self._create(path.as_ref()) } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index e4f00c4874e..de09451e7c0 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -13,7 +13,6 @@ use io::prelude::*; use cmp; use io::{self, SeekFrom, Error, ErrorKind}; -use slice; /// A `Cursor` wraps another type and provides it with a /// [`Seek`](trait.Seek.html) implementation. @@ -255,8 +254,8 @@ impl Write for Cursor<Vec<u8>> { // 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())); - slice::bytes::copy_memory(left, &mut self.inner[(pos as usize)..]); - self.inner.push_all(right); + self.inner[(pos as usize)..].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/error.rs b/src/libstd/io/error.rs index 6f18aad6235..4af9596d6d0 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -79,6 +79,7 @@ struct Custom { /// exhaustively match against it. #[derive(Copy, PartialEq, Eq, Clone, Debug)] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub enum ErrorKind { /// An entity was not found, often a file. #[stable(feature = "rust1", since = "1.0.0")] @@ -155,9 +156,20 @@ pub enum ErrorKind { /// This typically means that an operation could only succeed if it read a /// particular number of bytes but only a smaller number of bytes could be /// read. - #[unstable(feature = "read_exact", reason = "recently added", issue = "27585")] + #[unstable(feature = "read_exact_old", reason = "recently added", + issue = "0")] + #[rustc_deprecated(since = "1.6.0", reason = "renamed to UnexpectedEof")] UnexpectedEOF, + /// An error returned when an operation could not be completed because an + /// "end of file" was reached prematurely. + /// + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. + #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + /// Any I/O error not part of this list. #[unstable(feature = "io_error_internals", reason = "better expressed through extensible enums that this \ diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index 5b587dd921b..95f630c9658 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -13,7 +13,6 @@ use cmp; use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; use fmt; use mem; -use slice; use string::String; use vec::Vec; @@ -157,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); - slice::bytes::copy_memory(a, buf); + buf.clone_from_slice(a); *self = b; Ok(amt) } @@ -165,10 +164,11 @@ impl<'a> Read for &'a [u8] { #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { if buf.len() > self.len() { - return Err(Error::new(ErrorKind::UnexpectedEOF, "failed to fill whole buffer")); + return Err(Error::new(ErrorKind::UnexpectedEof, + "failed to fill whole buffer")); } let (a, b) = self.split_at(buf.len()); - slice::bytes::copy_memory(a, buf); + buf.clone_from_slice(a); *self = b; Ok(()) } @@ -189,7 +189,7 @@ impl<'a> Write for &'a mut [u8] { fn write(&mut self, data: &[u8]) -> io::Result<usize> { let amt = cmp::min(data.len(), self.len()); let (a, b) = mem::replace(self, &mut []).split_at_mut(amt); - slice::bytes::copy_memory(&data[..amt], a); + a.clone_from_slice(&data[..amt]); *self = b; Ok(amt) } @@ -211,13 +211,13 @@ impl<'a> Write for &'a mut [u8] { impl Write for Vec<u8> { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result<usize> { - self.push_all(buf); + self.extend_from_slice(buf); Ok(buf.len()) } #[inline] fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.push_all(buf); + self.extend_from_slice(buf); Ok(()) } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index ebf322fab4d..e957297bf62 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -593,7 +593,6 @@ pub trait Read { /// [file]: ../std/fs/struct.File.html /// /// ``` - /// #![feature(read_exact)] /// use std::io; /// use std::io::prelude::*; /// use std::fs::File; @@ -607,7 +606,7 @@ pub trait Read { /// # Ok(()) /// # } /// ``` - #[unstable(feature = "read_exact", reason = "recently added", issue = "27585")] + #[stable(feature = "read_exact", since = "1.6.0")] fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { while !buf.is_empty() { match self.read(buf) { @@ -618,7 +617,7 @@ pub trait Read { } } if !buf.is_empty() { - Err(Error::new(ErrorKind::UnexpectedEOF, + Err(Error::new(ErrorKind::UnexpectedEof, "failed to fill whole buffer")) } else { Ok(()) @@ -838,6 +837,10 @@ pub trait Read { of where errors happen is currently \ unclear and may change", issue = "27802")] + #[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] + #[allow(deprecated)] fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized { Tee { reader: self, writer: out } } @@ -1101,6 +1104,10 @@ pub trait Write { of where errors happen is currently \ unclear and may change", issue = "27802")] + #[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] + #[allow(deprecated)] fn broadcast<W: Write>(self, other: W) -> Broadcast<Self, W> where Self: Sized { @@ -1189,11 +1196,11 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) }; match available.iter().position(|x| *x == delim) { Some(i) => { - buf.push_all(&available[..i + 1]); + buf.extend_from_slice(&available[..i + 1]); (true, i + 1) } None => { - buf.push_all(available); + buf.extend_from_slice(available); (false, available.len()) } } @@ -1484,6 +1491,9 @@ pub trait BufRead: Read { /// [broadcast]: trait.Write.html#method.broadcast #[unstable(feature = "io", reason = "awaiting stability of Write::broadcast", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] pub struct Broadcast<T, U> { first: T, second: U, @@ -1491,6 +1501,10 @@ pub struct Broadcast<T, U> { #[unstable(feature = "io", reason = "awaiting stability of Write::broadcast", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] +#[allow(deprecated)] impl<T: Write, U: Write> Write for Broadcast<T, U> { fn write(&mut self, data: &[u8]) -> Result<usize> { let n = try!(self.first.write(data)); @@ -1593,6 +1607,9 @@ impl<T: BufRead> BufRead for Take<T> { /// [tee]: trait.Read.html#method.tee #[unstable(feature = "io", reason = "awaiting stability of Read::tee", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] pub struct Tee<R, W> { reader: R, writer: W, @@ -1600,6 +1617,10 @@ pub struct Tee<R, W> { #[unstable(feature = "io", reason = "awaiting stability of Read::tee", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] +#[allow(deprecated)] impl<R: Read, W: Write> Read for Tee<R, W> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { let n = try!(self.reader.read(buf)); @@ -1907,7 +1928,7 @@ mod tests { let mut c = Cursor::new(&b""[..]); assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); let mut c = Cursor::new(&b"123"[..]).chain(Cursor::new(&b"456789"[..])); c.read_exact(&mut buf).unwrap(); @@ -1915,7 +1936,7 @@ mod tests { c.read_exact(&mut buf).unwrap(); assert_eq!(&buf, b"5678"); assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); } #[test] @@ -1924,11 +1945,11 @@ mod tests { let mut c = &b""[..]; assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); let mut c = &b"123"[..]; assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); // make sure the optimized (early returning) method is being used assert_eq!(&buf, &[0; 4]); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 37a58fdeda4..0385dff65d1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -217,6 +217,7 @@ #![cfg_attr(stage0, allow(improper_ctypes))] #![cfg_attr(stage0, feature(rustc_attrs))] +#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(stage0, allow(unused_attributes))] #![feature(alloc)] #![feature(allow_internal_unstable)] @@ -230,12 +231,10 @@ #![feature(collections)] #![feature(collections_bound)] #![feature(const_fn)] -#![feature(core)] #![feature(core_float)] #![feature(core_intrinsics)] #![feature(core_simd)] #![feature(decode_utf16)] -#![feature(drain)] #![feature(drop_in_place)] #![feature(dropck_parametricity)] #![feature(float_extras)] @@ -249,7 +248,6 @@ #![feature(link_args)] #![feature(linkage)] #![feature(macro_reexport)] -#![feature(no_std)] #![feature(oom)] #![feature(optin_builtin_traits)] #![feature(placement_in_syntax)] @@ -288,7 +286,7 @@ // imported by the compiler (via our #[no_std] attribute) In this case we just // add a new crate name so we can attach the reexports to it. #[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq, - unreachable, unimplemented, write, writeln)] + unreachable, unimplemented, write, writeln, try)] extern crate core as __core; #[macro_use] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 7a1ab790b0b..0917346213f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -120,46 +120,6 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } -/// Helper macro for unwrapping `Result` values while returning early with an -/// error if the value of the expression is `Err`. Can only be used in -/// functions that return `Result` because of the early return of `Err` that -/// it provides. -/// -/// # Examples -/// -/// ``` -/// use std::io; -/// use std::fs::File; -/// use std::io::prelude::*; -/// -/// fn write_to_file_using_try() -> Result<(), io::Error> { -/// let mut file = try!(File::create("my_best_friends.txt")); -/// try!(file.write_all(b"This is a list of my best friends.")); -/// println!("I wrote to the file"); -/// Ok(()) -/// } -/// // This is equivalent to: -/// fn write_to_file_using_match() -> Result<(), io::Error> { -/// let mut file = try!(File::create("my_best_friends.txt")); -/// match file.write_all(b"This is a list of my best friends.") { -/// Ok(_) => (), -/// Err(e) => return Err(e), -/// } -/// println!("I wrote to the file"); -/// Ok(()) -/// } -/// ``` -#[macro_export] -#[stable(feature = "rust1", since = "1.0.0")] -macro_rules! try { - ($expr:expr) => (match $expr { - $crate::result::Result::Ok(val) => val, - $crate::result::Result::Err(err) => { - return $crate::result::Result::Err($crate::convert::From::from(err)) - } - }) -} - /// A macro to select an event from a number of receivers. /// /// This macro is used to wait for the first event to occur on a number of diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index c175482bbec..9c4e2b1a54c 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -14,7 +14,9 @@ use fmt; use hash; use io; use mem; -use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr}; +use net::{lookup_host, ntoh, hton, Ipv4Addr, Ipv6Addr}; +#[allow(deprecated)] +use net::IpAddr; use option; use sys::net::netc as c; use sys_common::{FromInner, AsInner, IntoInner}; @@ -49,6 +51,9 @@ pub struct SocketAddrV6 { inner: c::sockaddr_in6 } impl SocketAddr { /// Creates a new socket address from the (ip, port) pair. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] + #[rustc_deprecated(reason = "ip type too small a type to pull its weight", + since = "1.6.0")] + #[allow(deprecated)] pub fn new(ip: IpAddr, port: u16) -> SocketAddr { match ip { IpAddr::V4(a) => SocketAddr::V4(SocketAddrV4::new(a, port)), @@ -58,6 +63,9 @@ impl SocketAddr { /// Returns the IP address associated with this socket address. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] + #[rustc_deprecated(reason = "too small a type to pull its weight", + since = "1.6.0")] + #[allow(deprecated)] pub fn ip(&self) -> IpAddr { match *self { SocketAddr::V4(ref a) => IpAddr::V4(*a.ip()), @@ -351,6 +359,7 @@ impl ToSocketAddrs for SocketAddrV6 { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl ToSocketAddrs for (IpAddr, u16) { type Iter = option::IntoIter<SocketAddr>; fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> { diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index c643c069971..00be17f7383 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -23,7 +23,10 @@ use sys_common::{AsInner, FromInner}; /// An IP address, either an IPv4 or IPv6 address. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] +#[rustc_deprecated(reason = "too small a type to pull its weight", + since = "1.6.0")] #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)] +#[allow(deprecated)] pub enum IpAddr { /// Representation of an IPv4 address. V4(Ipv4Addr), @@ -178,6 +181,7 @@ impl Ipv4Addr { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl fmt::Display for IpAddr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index 383dce737f5..6bbbabfc269 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -18,6 +18,7 @@ use io::{self, Error, ErrorKind}; use sys_common::net as net_imp; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; @@ -136,6 +137,9 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> { /// cannot be resolved, it is returned in string format. #[unstable(feature = "lookup_addr", reason = "recent addition", issue = "27705")] +#[rustc_deprecated(reason = "ipaddr type is being deprecated", + since = "1.6.0")] +#[allow(deprecated)] pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> { net_imp::lookup_addr(addr) } diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 1619dac78ca..79a269ff87c 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -17,6 +17,7 @@ use prelude::v1::*; use error::Error; use fmt; +#[allow(deprecated)] use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use str::FromStr; @@ -261,6 +262,7 @@ impl<'a> Parser<'a> { self.read_atomically(|p| p.read_ipv6_addr_impl()) } + #[allow(deprecated)] fn read_ip_addr(&mut self) -> Option<IpAddr> { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(IpAddr::V4); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(IpAddr::V6); @@ -306,6 +308,7 @@ impl<'a> Parser<'a> { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl FromStr for IpAddr { type Err = AddrParseError; fn from_str(s: &str) -> Result<IpAddr, AddrParseError> { diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index ab15867d365..c87becd741e 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -131,6 +131,7 @@ impl f32 { issue = "27736")] #[rustc_deprecated(since = "1.4.0", reason = "unclear how useful or correct this is")] + #[allow(deprecated)] pub fn from_str_radix(s: &str, radix: u32) -> Result<f32, ParseFloatError> { num::Float::from_str_radix(s, radix) } @@ -424,7 +425,7 @@ impl f32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) } /// Returns `true` if `self`'s sign is negative, including `-0.0` /// and `NEG_INFINITY`. @@ -443,7 +444,7 @@ impl f32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) } /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error. This produces a more accurate result with better performance than diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index cad42ee64f1..6b9c753443b 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -88,6 +88,7 @@ impl f64 { issue = "27736")] #[rustc_deprecated(since = "1.4.0", reason = "unclear how useful or correct this is")] + #[allow(deprecated)] pub fn from_str_radix(s: &str, radix: u32) -> Result<f64, ParseFloatError> { num::Float::from_str_radix(s, radix) } @@ -352,12 +353,12 @@ impl f64 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_positive")] #[inline] - pub fn is_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_positive(self) -> bool { num::Float::is_sign_positive(self) } /// Returns `true` if `self`'s sign is negative, including `-0.0` /// and `NEG_INFINITY`. @@ -377,12 +378,12 @@ impl f64 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_negative")] #[inline] - pub fn is_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_negative(self) -> bool { num::Float::is_sign_negative(self) } /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error. This produces a more accurate result with better performance than diff --git a/src/libstd/path.rs b/src/libstd/path.rs index f97ad5b8835..d0b9cc4c460 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -777,6 +777,8 @@ impl<'a> Components<'a> { /// Examine the next component without consuming it. #[unstable(feature = "path_components_peek", issue = "27727")] + #[rustc_deprecated(reason = "use peekable() instead", + since = "1.6.0")] pub fn peek(&self) -> Option<Component<'a>> { self.clone().next() } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 5677c5538c4..6b20e51967d 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -254,7 +254,7 @@ impl<T: ?Sized> Mutex<T> { /// /// If another user of this mutex panicked while holding the mutex, then /// this call will return an error instead. - #[unstable(feature = "mutex_into_inner", reason = "recently added", issue = "28968")] + #[stable(feature = "mutex_into_inner", since = "1.6.0")] pub fn into_inner(self) -> LockResult<T> where T: Sized { // We know statically that there are no outstanding references to // `self` so there's no need to lock the inner StaticMutex. @@ -284,7 +284,7 @@ impl<T: ?Sized> Mutex<T> { /// /// If another user of this mutex panicked while holding the mutex, then /// this call will return an error instead. - #[unstable(feature = "mutex_get_mut", reason = "recently added", issue = "28968")] + #[stable(feature = "mutex_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { // We know statically that there are no other references to `self`, so // there's no need to lock the inner StaticMutex. diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 4c236d21545..3dbef435481 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -275,7 +275,7 @@ impl<T: ?Sized> RwLock<T> { /// is poisoned whenever a writer panics while holding an exclusive lock. An /// error will only be returned if the lock would have otherwise been /// acquired. - #[unstable(feature = "rwlock_into_inner", reason = "recently added", issue = "28968")] + #[stable(feature = "rwlock_into_inner", since = "1.6.0")] pub fn into_inner(self) -> LockResult<T> where T: Sized { // We know statically that there are no outstanding references to // `self` so there's no need to lock the inner StaticRwLock. @@ -307,7 +307,7 @@ impl<T: ?Sized> RwLock<T> { /// is poisoned whenever a writer panics while holding an exclusive lock. An /// error will only be returned if the lock would have otherwise been /// acquired. - #[unstable(feature = "rwlock_get_mut", reason = "recently added", issue = "28968")] + #[stable(feature = "rwlock_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { // We know statically that there are no other references to `self`, so // there's no need to lock the inner StaticRwLock. diff --git a/src/libstd/sys/common/gnu/libbacktrace.rs b/src/libstd/sys/common/gnu/libbacktrace.rs index 3b846fd462e..f8463388384 100644 --- a/src/libstd/sys/common/gnu/libbacktrace.rs +++ b/src/libstd/sys/common/gnu/libbacktrace.rs @@ -134,9 +134,9 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, } else { None }; - let filename = match selfname.as_ref().and_then(|s| s.as_os_str().to_bytes()) { + let filename = match selfname.as_ref().and_then(|s| s.to_str()) { Some(path) => { - let bytes = path; + let bytes = path.as_bytes(); if bytes.len() < LAST_FILENAME.len() { let i = bytes.iter(); for (slot, val) in LAST_FILENAME.iter_mut().zip(i) { diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 449cd9d8c97..7e05895b2cc 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -15,6 +15,7 @@ use fmt; use io::{self, Error, ErrorKind}; use libc::{c_int, c_char, c_void}; use mem; +#[allow(deprecated)] use net::{SocketAddr, Shutdown, IpAddr}; use ptr; use str::from_utf8; @@ -129,6 +130,7 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> { // lookup_addr //////////////////////////////////////////////////////////////////////////////// +#[allow(deprecated)] pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> { init(); diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 702a34633dc..2e092d5f770 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -243,7 +243,7 @@ impl Wtf8Buf { /// Append a UTF-8 slice at the end of the string. #[inline] pub fn push_str(&mut self, other: &str) { - self.bytes.push_all(other.as_bytes()) + self.bytes.extend_from_slice(other.as_bytes()) } /// Append a WTF-8 slice at the end of the string. @@ -262,9 +262,9 @@ impl Wtf8Buf { // 4 bytes for the supplementary code point self.bytes.reserve(4 + other_without_trail_surrogate.len()); self.push_char(decode_surrogate_pair(lead, trail)); - self.bytes.push_all(other_without_trail_surrogate); + self.bytes.extend_from_slice(other_without_trail_surrogate); } - _ => self.bytes.push_all(&other.bytes) + _ => self.bytes.extend_from_slice(&other.bytes) } } @@ -331,10 +331,8 @@ impl Wtf8Buf { match self.next_surrogate(pos) { Some((surrogate_pos, _)) => { pos = surrogate_pos + 3; - slice::bytes::copy_memory( - UTF8_REPLACEMENT_CHARACTER, - &mut self.bytes[surrogate_pos .. pos], - ); + self.bytes[surrogate_pos..pos] + .clone_from_slice(UTF8_REPLACEMENT_CHARACTER); }, None => return unsafe { String::from_utf8_unchecked(self.bytes) } } @@ -493,18 +491,18 @@ impl Wtf8 { }; let wtf8_bytes = &self.bytes; let mut utf8_bytes = Vec::with_capacity(self.len()); - utf8_bytes.push_all(&wtf8_bytes[..surrogate_pos]); - utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER); + utf8_bytes.extend_from_slice(&wtf8_bytes[..surrogate_pos]); + utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER); let mut pos = surrogate_pos + 3; loop { match self.next_surrogate(pos) { Some((surrogate_pos, _)) => { - utf8_bytes.push_all(&wtf8_bytes[pos .. surrogate_pos]); - utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER); + utf8_bytes.extend_from_slice(&wtf8_bytes[pos .. surrogate_pos]); + utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER); pos = surrogate_pos + 3; }, None => { - utf8_bytes.push_all(&wtf8_bytes[pos..]); + utf8_bytes.extend_from_slice(&wtf8_bytes[pos..]); return Cow::Owned(unsafe { String::from_utf8_unchecked(utf8_bytes) }) } } diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index d2a16b5de97..16e1578296d 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -246,17 +246,16 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> sys::fs::symlink(src.as_ref(), dst.as_ref()) } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] /// An extension trait for `fs::DirBuilder` for unix-specific options. pub trait DirBuilderExt { /// Sets the mode to create new directories with. This option defaults to /// 0o777. + #[stable(feature = "dir_builder", since = "1.6.0")] fn mode(&mut self, mode: raw::mode_t) -> &mut Self; } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] impl DirBuilderExt for fs::DirBuilder { fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder { self.as_inner_mut().set_mode(mode); diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 018c9100288..8ea8f0c6c77 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -355,8 +355,7 @@ impl DirBuilder { } fn cstr(path: &Path) -> io::Result<CString> { - path.as_os_str().to_cstring().ok_or( - io::Error::new(io::ErrorKind::InvalidInput, "path contained a null")) + Ok(try!(CString::new(path.as_os_str().as_bytes()))) } impl FromInner<c_int> for File { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index dabc8090270..c2bf0651cff 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -149,7 +149,7 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError> if path.contains(&sep) { return Err(JoinPathsError) } - joined.push_all(path); + joined.extend_from_slice(path); } Ok(OsStringExt::from_vec(joined)) } diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index f0f08a72ed8..0524df218a1 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -53,7 +53,7 @@ impl Buf { } pub fn push_slice(&mut self, s: &Slice) { - self.inner.push_all(&s.inner) + self.inner.extend_from_slice(&s.inner) } } diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 8d80296ab03..407fcb0a1b8 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -43,7 +43,7 @@ pub struct Command { impl Command { pub fn new(program: &OsStr) -> Command { Command { - program: program.to_cstring().unwrap(), + program: os2c(program), args: Vec::new(), env: None, cwd: None, @@ -54,10 +54,10 @@ impl Command { } pub fn arg(&mut self, arg: &OsStr) { - self.args.push(arg.to_cstring().unwrap()) + self.args.push(os2c(arg)); } pub fn args<'a, I: Iterator<Item = &'a OsStr>>(&mut self, args: I) { - self.args.extend(args.map(|s| s.to_cstring().unwrap())) + self.args.extend(args.map(os2c)); } fn init_env_map(&mut self) { if self.env.is_none() { @@ -76,10 +76,14 @@ impl Command { self.env = Some(HashMap::new()) } pub fn cwd(&mut self, dir: &OsStr) { - self.cwd = Some(dir.to_cstring().unwrap()) + self.cwd = Some(os2c(dir)); } } +fn os2c(s: &OsStr) -> CString { + CString::new(s.as_bytes()).unwrap() +} + //////////////////////////////////////////////////////////////////////////////// // Processes //////////////////////////////////////////////////////////////////////////////// @@ -430,9 +434,9 @@ fn make_envp(env: Option<&HashMap<OsString, OsString>>) for pair in env { let mut kv = Vec::new(); - kv.push_all(pair.0.as_bytes()); + kv.extend_from_slice(pair.0.as_bytes()); kv.push('=' as u8); - kv.push_all(pair.1.as_bytes()); + kv.extend_from_slice(pair.1.as_bytes()); kv.push(0); // terminating null tmps.push(kv); } diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 4396b90a5ce..48c9b70dce4 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -196,10 +196,10 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError> return Err(JoinPathsError) } else if v.contains(&sep) { joined.push(b'"' as u16); - joined.push_all(&v[..]); + joined.extend_from_slice(&v[..]); joined.push(b'"' as u16); } else { - joined.push_all(&v[..]); + joined.extend_from_slice(&v[..]); } } diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 63d517606a0..0981a8c4a5b 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -66,6 +66,8 @@ impl Duration { wait for a more general \"moment in time\" \ abstraction", issue = "27799")] + #[rustc_deprecated(reason = "use std::time::Instant instead", + since = "1.6.0")] pub fn span<F>(f: F) -> Duration where F: FnOnce() { let start = Instant::now(); f(); |
