From 9754b06cd80cfcc523573535090519bec935fec3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Mar 2015 13:25:06 -0700 Subject: rustc: Remove support for old_impl_check This commit removes compiler support for the `old_impl_check` attribute which should in theory be entirely removed now. The last remaining use of it in the standard library has been updated by moving the type parameter on the `old_io::Acceptor` trait into an associated type. As a result, this is a breaking change for all current users of the deprecated `old_io::Acceptor` trait. Code can be migrated by using the `Connection` associated type instead. [breaking-change] --- src/libstd/lib.rs | 1 - src/libstd/old_io/mod.rs | 18 +++++++++--------- src/libstd/old_io/net/pipe.rs | 5 +++-- src/libstd/old_io/net/tcp.rs | 5 +++-- src/libstd/old_io/result.rs | 7 ++++--- 5 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index cca6bb747d4..c2d49810d59 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -114,7 +114,6 @@ #![feature(lang_items)] #![feature(libc)] #![feature(linkage, thread_local, asm)] -#![feature(old_impl_check)] #![feature(optin_builtin_traits)] #![feature(rand)] #![feature(staged_api)] diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs index ac908c529dc..3d318d97da7 100644 --- a/src/libstd/old_io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -1588,9 +1588,7 @@ pub trait Seek { /// connections. /// /// Doing so produces some sort of Acceptor. -pub trait Listener> - : PhantomFn // FIXME should be an assoc type anyhow -{ +pub trait Listener { /// Spin up the listener and start queuing incoming connections /// /// # Error @@ -1601,13 +1599,16 @@ pub trait Listener> } /// An acceptor is a value that presents incoming connections -pub trait Acceptor { +pub trait Acceptor { + /// Type of connection that is accepted by this acceptor. + type Connection; + /// Wait for and accept an incoming connection /// /// # Error /// /// Returns `Err` if an I/O error is encountered. - fn accept(&mut self) -> IoResult; + fn accept(&mut self) -> IoResult; /// Create an iterator over incoming connection attempts. /// @@ -1628,11 +1629,10 @@ pub struct IncomingConnections<'a, A: ?Sized +'a> { inc: &'a mut A, } -#[old_impl_check] -impl<'a, T, A: ?Sized + Acceptor> Iterator for IncomingConnections<'a, A> { - type Item = IoResult; +impl<'a, A: ?Sized + Acceptor> Iterator for IncomingConnections<'a, A> { + type Item = IoResult; - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { Some(self.inc.accept()) } } diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index f9e5ae71e12..d2e6aa896d3 100644 --- a/src/libstd/old_io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -202,7 +202,7 @@ impl UnixListener { } } -impl Listener for UnixListener { +impl Listener for UnixListener { fn listen(self) -> IoResult { self.inner.listen() .map(|inner| UnixAcceptor { inner: inner }) @@ -250,7 +250,8 @@ impl UnixAcceptor { } } -impl Acceptor for UnixAcceptor { +impl Acceptor for UnixAcceptor { + type Connection = UnixStream; fn accept(&mut self) -> IoResult { self.inner.accept().map(|s| { UnixStream { inner: s } diff --git a/src/libstd/old_io/net/tcp.rs b/src/libstd/old_io/net/tcp.rs index 75f786f0bb1..67a6e2c29b4 100644 --- a/src/libstd/old_io/net/tcp.rs +++ b/src/libstd/old_io/net/tcp.rs @@ -338,7 +338,7 @@ impl TcpListener { } } -impl Listener for TcpListener { +impl Listener for TcpListener { fn listen(self) -> IoResult { self.inner.listen(128).map(|a| TcpAcceptor { inner: a }) } @@ -453,7 +453,8 @@ impl TcpAcceptor { } } -impl Acceptor for TcpAcceptor { +impl Acceptor for TcpAcceptor { + type Connection = TcpStream; fn accept(&mut self) -> IoResult { self.inner.accept().map(TcpStream::new) } diff --git a/src/libstd/old_io/result.rs b/src/libstd/old_io/result.rs index 9dcb487cdb0..29ebfb229bb 100644 --- a/src/libstd/old_io/result.rs +++ b/src/libstd/old_io/result.rs @@ -58,7 +58,7 @@ impl Seek for IoResult { } } -impl, L: Listener> Listener for IoResult { +impl> Listener for IoResult { fn listen(self) -> IoResult { match self { Ok(listener) => listener.listen(), @@ -67,8 +67,9 @@ impl, L: Listener> Listener for IoResult { } } -impl> Acceptor for IoResult { - fn accept(&mut self) -> IoResult { +impl Acceptor for IoResult { + type Connection = A::Connection; + fn accept(&mut self) -> IoResult { match *self { Ok(ref mut acceptor) => acceptor.accept(), Err(ref e) => Err(e.clone()), -- cgit 1.4.1-3-g733a5