From a6879227466102159d7018830be5971f1d89cede Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Sat, 5 Jan 2019 16:55:58 +0100 Subject: [PATCH] tcp: deprecate `TcpStream::try_clone()` (#824) --- tokio-tcp/src/stream.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tokio-tcp/src/stream.rs b/tokio-tcp/src/stream.rs index 10df6741b..d3766b5a2 100644 --- a/tokio-tcp/src/stream.rs +++ b/tokio-tcp/src/stream.rs @@ -781,9 +781,14 @@ impl TcpStream { /// # Ok(()) /// # } /// ``` + #[deprecated(since = "0.1.14", note = "use `split()` instead")] + #[doc(hidden)] pub fn try_clone(&self) -> io::Result { - let io = self.io.get_ref().try_clone()?; - Ok(TcpStream::new(io)) + // Rationale for deprecation: + // - https://github.com/tokio-rs/tokio/pull/824 + // - https://github.com/tokio-rs/tokio/issues/774#issuecomment-451059317 + let msg = "`TcpStream::split()` is deprecated because it doesn't work as intended"; + Err(io::Error::new(io::ErrorKind::Other, msg)) } }