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.
This commit is contained in:
Benjamin Saunders
2020-12-20 01:29:58 -08:00
parent 62fa56feaa
commit cd229d342e
+2 -8
View File
@@ -628,11 +628,8 @@ impl From<ReadError> 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<WriteError> 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)
}