diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-01 23:53:35 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-03 23:43:57 -0800 |
| commit | 7d8d06f86b48520814596bd5363d2b82bc619774 (patch) | |
| tree | eda093ca208286fd8679da8de9f3597b7a024c50 /src/libstd/io | |
| parent | 470118f3e915cdc8f936aca0640b28a7a3d8dc6c (diff) | |
| download | rust-7d8d06f86b48520814596bd5363d2b82bc619774.tar.gz rust-7d8d06f86b48520814596bd5363d2b82bc619774.zip | |
Remove deprecated functionality
This removes a large array of deprecated functionality, regardless of how recently it was deprecated. The purpose of this commit is to clean out the standard libraries and compiler for the upcoming alpha release. Some notable compiler changes were to enable warnings for all now-deprecated command line arguments (previously the deprecated versions were silently accepted) as well as removing deriving(Zero) entirely (the trait was removed). The distribution no longer contains the libtime or libregex_macros crates. Both of these have been deprecated for some time and are available externally.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/buffered.rs | 16 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 18 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 94 | ||||
| -rw-r--r-- | src/libstd/io/net/udp.rs | 157 | ||||
| -rw-r--r-- | src/libstd/io/tempfile.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/test.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 8 |
8 files changed, 13 insertions, 298 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index d97f4a7bc34..c56acd38e81 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -89,10 +89,6 @@ impl<R: Reader> BufferedReader<R> { /// /// Note that any leftover data in the internal buffer is lost. pub fn into_inner(self) -> R { self.inner } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> R { self.into_inner() } } impl<R: Reader> Buffer for BufferedReader<R> { @@ -198,10 +194,6 @@ impl<W: Writer> BufferedWriter<W> { self.flush_buf().unwrap(); self.inner.take().unwrap() } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> W { self.into_inner() } } impl<W: Writer> Writer for BufferedWriter<W> { @@ -262,10 +254,6 @@ impl<W: Writer> LineBufferedWriter<W> { /// /// The internal buffer is flushed before returning the writer. pub fn into_inner(self) -> W { self.inner.into_inner() } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> W { self.into_inner() } } impl<W: Writer> Writer for LineBufferedWriter<W> { @@ -374,10 +362,6 @@ impl<S: Stream> BufferedStream<S> { let InternalBufferedWriter(w) = self.inner.inner; w.into_inner() } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> S { self.into_inner() } } impl<S: Stream> Buffer for BufferedStream<S> { diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 8c097a65db7..af08eea210e 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -518,7 +518,7 @@ mod bench { ({ use super::u64_from_be_bytes; - let data = Vec::from_fn($stride*100+$start_index, |i| i as u8); + let data = range(0u8, $stride*100+$start_index).collect::<Vec<_>>(); let mut sum = 0u64; $b.iter(|| { let mut i = $start_index; diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 1615541e37d..5c17644a1ac 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -12,8 +12,6 @@ //! Readers and Writers for in-memory buffers -#![allow(deprecated)] - use cmp::min; use option::Option::None; use result::Result::{Err, Ok}; @@ -70,6 +68,7 @@ pub struct MemWriter { buf: Vec<u8>, } +#[allow(deprecated)] impl MemWriter { /// Create a new `MemWriter`. #[inline] @@ -96,10 +95,6 @@ impl MemWriter { /// Unwraps this `MemWriter`, returning the underlying buffer #[inline] pub fn into_inner(self) -> Vec<u8> { self.buf } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> Vec<u8> { self.into_inner() } } impl Writer for MemWriter { @@ -155,10 +150,6 @@ impl MemReader { /// Unwraps this `MemReader`, returning the underlying buffer #[inline] pub fn into_inner(self) -> Vec<u8> { self.buf } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> Vec<u8> { self.into_inner() } } impl Reader for MemReader { @@ -401,10 +392,11 @@ mod test { extern crate "test" as test_crate; use prelude::v1::*; - use super::*; use io::{SeekSet, SeekCur, SeekEnd}; use io; + use iter::repeat; use self::test_crate::Bencher; + use super::*; #[test] fn test_vec_writer() { @@ -664,7 +656,7 @@ mod test { } fn do_bench_mem_writer(b: &mut Bencher, times: uint, len: uint) { - let src: Vec<u8> = Vec::from_elem(len, 5); + let src: Vec<u8> = repeat(5).take(len).collect(); b.bytes = (times * len) as u64; b.iter(|| { @@ -673,7 +665,7 @@ mod test { wr.write(src.as_slice()).unwrap(); } - let v = wr.unwrap(); + let v = wr.into_inner(); assert_eq!(v.len(), times * len); assert!(v.iter().all(|x| *x == 5)); }); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 590231dcd82..ae401a04a96 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -263,7 +263,6 @@ pub use self::timer::Timer; pub use self::net::ip::IpAddr; pub use self::net::tcp::TcpListener; pub use self::net::tcp::TcpStream; -pub use self::net::udp::UdpStream; pub use self::pipe::PipeStream; pub use self::process::{Process, Command}; pub use self::tempfile::TempDir; @@ -863,23 +862,6 @@ pub trait Reader { } /// A reader which can be converted to a RefReader. -#[deprecated = "use ByRefReader instead"] -pub trait AsRefReader { - /// Creates a wrapper around a mutable reference to the reader. - /// - /// This is useful to allow applying adaptors while still - /// retaining ownership of the original value. - fn by_ref<'a>(&'a mut self) -> RefReader<'a, Self>; -} - -#[allow(deprecated)] -impl<T: Reader> AsRefReader for T { - fn by_ref<'a>(&'a mut self) -> RefReader<'a, T> { - RefReader { inner: self } - } -} - -/// A reader which can be converted to a RefReader. pub trait ByRefReader { /// Creates a wrapper around a mutable reference to the reader. /// @@ -1243,24 +1225,6 @@ pub trait Writer { } /// A writer which can be converted to a RefWriter. -#[deprecated = "use ByRefWriter instead"] -pub trait AsRefWriter { - /// Creates a wrapper around a mutable reference to the writer. - /// - /// This is useful to allow applying wrappers while still - /// retaining ownership of the original value. - #[inline] - fn by_ref<'a>(&'a mut self) -> RefWriter<'a, Self>; -} - -#[allow(deprecated)] -impl<T: Writer> AsRefWriter for T { - fn by_ref<'a>(&'a mut self) -> RefWriter<'a, T> { - RefWriter { inner: self } - } -} - -/// A writer which can be converted to a RefWriter. pub trait ByRefWriter { /// Creates a wrapper around a mutable reference to the writer. /// @@ -1847,64 +1811,6 @@ bitflags! { #[doc = "All possible permissions enabled."] const ALL_PERMISSIONS = USER_RWX.bits | GROUP_RWX.bits | OTHER_RWX.bits, - - // Deprecated names - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_READ instead"] - const UserRead = USER_READ.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_WRITE instead"] - const UserWrite = USER_WRITE.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_EXECUTE instead"] - const UserExecute = USER_EXECUTE.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use GROUP_READ instead"] - const GroupRead = GROUP_READ.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use GROUP_WRITE instead"] - const GroupWrite = GROUP_WRITE.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use GROUP_EXECUTE instead"] - const GroupExecute = GROUP_EXECUTE.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use OTHER_READ instead"] - const OtherRead = OTHER_READ.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use OTHER_WRITE instead"] - const OtherWrite = OTHER_WRITE.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use OTHER_EXECUTE instead"] - const OtherExecute = OTHER_EXECUTE.bits, - - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_RWX instead"] - const UserRWX = USER_RWX.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use GROUP_RWX instead"] - const GroupRWX = GROUP_RWX.bits, - #[allow(non_upper_case_globals)] - #[deprecated = "use OTHER_RWX instead"] - const OtherRWX = OTHER_RWX.bits, - - #[doc = "Deprecated: use `USER_FILE` instead."] - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_FILE instead"] - const UserFile = USER_FILE.bits, - - #[doc = "Deprecated: use `USER_DIR` instead."] - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_DIR instead"] - const UserDir = USER_DIR.bits, - #[doc = "Deprecated: use `USER_EXEC` instead."] - #[allow(non_upper_case_globals)] - #[deprecated = "use USER_EXEC instead"] - const UserExec = USER_EXEC.bits, - - #[doc = "Deprecated: use `ALL_PERMISSIONS` instead"] - #[allow(non_upper_case_globals)] - #[deprecated = "use ALL_PERMISSIONS instead"] - const AllPermissions = ALL_PERMISSIONS.bits, } } diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 6c167359966..a4db0d4f5de 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -17,10 +17,8 @@ use clone::Clone; use io::net::ip::{SocketAddr, IpAddr, ToSocketAddr}; -use io::{Reader, Writer, IoResult}; -use ops::FnOnce; +use io::IoResult; use option::Option; -use result::Result::{Ok, Err}; use sys::udp::UdpSocket as UdpSocketImp; use sys_common; @@ -88,21 +86,6 @@ impl UdpSocket { super::with_addresses(addr, |addr| self.inner.send_to(buf, addr)) } - /// Creates a `UdpStream`, which allows use of the `Reader` and `Writer` - /// traits to receive and send data from the same address. This transfers - /// ownership of the socket to the stream. - /// - /// Note that this call does not perform any actual network communication, - /// because UDP is a datagram protocol. - #[deprecated = "`UdpStream` has been deprecated"] - #[allow(deprecated)] - pub fn connect(self, other: SocketAddr) -> UdpStream { - UdpStream { - socket: self, - connected_to: other, - } - } - /// Returns the socket address that this socket was created from. pub fn socket_name(&mut self) -> IoResult<SocketAddr> { self.inner.socket_name() @@ -192,59 +175,6 @@ impl sys_common::AsInner<UdpSocketImp> for UdpSocket { } } -/// A type that allows convenient usage of a UDP stream connected to one -/// address via the `Reader` and `Writer` traits. -/// -/// # Note -/// -/// This structure has been deprecated because `Reader` is a stream-oriented API but UDP -/// is a packet-oriented protocol. Every `Reader` method will read a whole packet and -/// throw all superfluous bytes away so that they are no longer available for further -/// method calls. -#[deprecated] -pub struct UdpStream { - socket: UdpSocket, - connected_to: SocketAddr -} - -impl UdpStream { - /// Allows access to the underlying UDP socket owned by this stream. This - /// is useful to, for example, use the socket to send data to hosts other - /// than the one that this stream is connected to. - pub fn as_socket<T, F>(&mut self, f: F) -> T where - F: FnOnce(&mut UdpSocket) -> T, - { - f(&mut self.socket) - } - - /// Consumes this UDP stream and returns out the underlying socket. - pub fn disconnect(self) -> UdpSocket { - self.socket - } -} - -impl Reader for UdpStream { - /// Returns the next non-empty message from the specified address. - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { - let peer = self.connected_to; - self.as_socket(|sock| { - loop { - let (nread, src) = try!(sock.recv_from(buf)); - if nread > 0 && src == peer { - return Ok(nread); - } - } - }) - } -} - -impl Writer for UdpStream { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { - let connected_to = self.connected_to; - self.as_socket(|sock| sock.send_to(buf, connected_to)) - } -} - #[cfg(test)] #[allow(experimental)] mod test { @@ -337,91 +267,6 @@ mod test { } } - #[test] - #[allow(deprecated)] - fn stream_smoke_test_ip4() { - let server_ip = next_test_ip4(); - let client_ip = next_test_ip4(); - let dummy_ip = next_test_ip4(); - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - - let _t = Thread::spawn(move|| { - let send_as = |&:ip, val: &[u8]| { - match UdpSocket::bind(ip) { - Ok(client) => { - let client = box client; - let mut stream = client.connect(server_ip); - stream.write(val).unwrap(); - } - Err(..) => panic!() - } - }; - rx1.recv().unwrap(); - send_as(dummy_ip, &[98]); - send_as(client_ip, &[99]); - tx2.send(()).unwrap(); - }); - - match UdpSocket::bind(server_ip) { - Ok(server) => { - let server = box server; - let mut stream = server.connect(client_ip); - tx1.send(()).unwrap(); - let mut buf = [0]; - match stream.read(&mut buf) { - Ok(nread) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); - } - Err(..) => panic!(), - } - } - Err(..) => panic!() - } - rx2.recv().unwrap(); - } - - #[test] - #[allow(deprecated)] - fn stream_smoke_test_ip6() { - let server_ip = next_test_ip6(); - let client_ip = next_test_ip6(); - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - - let _t = Thread::spawn(move|| { - match UdpSocket::bind(client_ip) { - Ok(client) => { - let client = box client; - let mut stream = client.connect(server_ip); - rx1.recv().unwrap(); - stream.write(&[99]).unwrap(); - } - Err(..) => panic!() - } - tx2.send(()).unwrap(); - }); - - match UdpSocket::bind(server_ip) { - Ok(server) => { - let server = box server; - let mut stream = server.connect(client_ip); - tx1.send(()).unwrap(); - let mut buf = [0]; - match stream.read(&mut buf) { - Ok(nread) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); - } - Err(..) => panic!() - } - } - Err(..) => panic!() - } - rx2.recv().unwrap(); - } - pub fn socket_name(addr: SocketAddr) { let server = UdpSocket::bind(addr); diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index 5cf86676651..45e0dd4e8e5 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -19,7 +19,7 @@ use option::Option::{None, Some}; use os; use path::{Path, GenericPath}; use result::Result::{Ok, Err}; -use sync::atomic; +use sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering}; /// A wrapper for a path to temporary directory implementing automatic /// scope-based deletion. @@ -90,14 +90,14 @@ impl TempDir { return TempDir::new_in(&abs_tmpdir, suffix); } - static CNT: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT; + static CNT: AtomicUint = ATOMIC_UINT_INIT; let mut attempts = 0u; loop { let filename = format!("rs-{}-{}-{}", unsafe { libc::getpid() }, - CNT.fetch_add(1, atomic::SeqCst), + CNT.fetch_add(1, Ordering::SeqCst), suffix); let p = tmpdir.join(filename); match fs::mkdir(&p, io::USER_RWX) { @@ -129,10 +129,6 @@ impl TempDir { tmpdir.path.take().unwrap() } - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> Path { self.into_inner() } - /// Access the wrapped `std::path::Path` to the temporary directory. pub fn path<'a>(&'a self) -> &'a Path { self.path.as_ref().unwrap() diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 2f87abd0ee2..3ce56c907b3 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -17,12 +17,12 @@ use prelude::v1::*; use libc; use os; use std::io::net::ip::*; -use sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Relaxed}; +use sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering}; /// Get a port number, starting at 9600, for use in tests pub fn next_test_port() -> u16 { static NEXT_OFFSET: AtomicUint = ATOMIC_UINT_INIT; - base_port() + NEXT_OFFSET.fetch_add(1, Relaxed) as u16 + base_port() + NEXT_OFFSET.fetch_add(1, Ordering::Relaxed) as u16 } /// Get a temporary path which could be the location of a unix socket @@ -34,7 +34,7 @@ pub fn next_test_unix() -> Path { let string = format!("rust-test-unix-path-{}-{}-{}", base_port(), unsafe {libc::getpid()}, - COUNT.fetch_add(1, Relaxed)); + COUNT.fetch_add(1, Ordering::Relaxed)); if cfg!(unix) { os::tmpdir().join(string) } else { diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 1381ad17ea2..86fa68d63ac 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -30,10 +30,6 @@ impl<R: Reader> LimitReader<R> { /// Consumes the `LimitReader`, returning the underlying `Reader`. pub fn into_inner(self) -> R { self.inner } - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner"] - pub fn unwrap(self) -> R { self.into_inner() } - /// Returns the number of bytes that can be read before the `LimitReader` /// will return EOF. /// @@ -219,10 +215,6 @@ impl<R: Reader, W: Writer> TeeReader<R, W> { let TeeReader { reader, writer } = self; (reader, writer) } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner"] - pub fn unwrap(self) -> (R, W) { self.into_inner() } } impl<R: Reader, W: Writer> Reader for TeeReader<R, W> { |
