From cd229d342e2b703cf8ecd4edb339d4aa98961710 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 20 Dec 2020 01:29:58 -0800 Subject: [PATCH] Always preserve outer type when converting to io::Error Ensures that the resulting io::Error's dynamic type is constant and its Display impl includes the "connection closed: " clarifying context. --- quinn/src/streams.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/quinn/src/streams.rs b/quinn/src/streams.rs index 0dccaf30c..30ff5a221 100644 --- a/quinn/src/streams.rs +++ b/quinn/src/streams.rs @@ -628,11 +628,8 @@ impl From for io::Error { fn from(x: ReadError) -> Self { use self::ReadError::*; let kind = match x { - ConnectionClosed(e) => { - return e.into(); - } Reset { .. } | ZeroRttRejected => io::ErrorKind::ConnectionReset, - UnknownStream => io::ErrorKind::NotConnected, + ConnectionClosed(_) | UnknownStream => io::ErrorKind::NotConnected, IllegalOrderedRead => io::ErrorKind::InvalidInput, }; io::Error::new(kind, x) @@ -686,11 +683,8 @@ impl From for io::Error { fn from(x: WriteError) -> Self { use self::WriteError::*; let kind = match x { - ConnectionClosed(e) => { - return e.into(); - } Stopped(_) | ZeroRttRejected => io::ErrorKind::ConnectionReset, - UnknownStream => io::ErrorKind::NotConnected, + ConnectionClosed(_) | UnknownStream => io::ErrorKind::NotConnected, }; io::Error::new(kind, x) }