Skip to content

Commit a46830f

Browse files
committed
Update Other errors to HostUnreachable
Rust 1.83 has dropped and with it comes new error kinds!
1 parent 49a7038 commit a46830f

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ categories = ["asynchronous", "network-programming", "simulation"]
1919
[workspace]
2020
members = ["examples/*"]
2121

22+
[workspace.package]
23+
rust-version = "1.83"
24+
2225
[dependencies]
2326
bytes = "1.4"
2427
futures = "0.3"

src/dns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl ToIpAddr for String {
6363
}
6464
}
6565

66-
impl<'a> ToIpAddr for &'a str {
66+
impl ToIpAddr for &'_ str {
6767
fn to_ip_addr(&self, dns: &mut Dns) -> IpAddr {
6868
if let Ok(ipaddr) = self.parse() {
6969
return ipaddr;
@@ -121,7 +121,7 @@ impl ToSocketAddrs for (String, u16) {
121121
}
122122
}
123123

124-
impl<'a> ToSocketAddrs for (&'a str, u16) {
124+
impl ToSocketAddrs for (&'_ str, u16) {
125125
fn to_socket_addr(&self, dns: &Dns) -> SocketAddr {
126126
// When IP address is passed directly as a str.
127127
if let Ok(ip) = self.0.parse::<IpAddr>() {

src/sim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ mod test {
674674
sim.client("client", async move {
675675
// Peers are partitioned. TCP setup should fail.
676676
let err = TcpStream::connect("server:1234").await.unwrap_err();
677-
assert_eq!(err.kind(), io::ErrorKind::Other);
677+
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
678678
assert_eq!(err.to_string(), "host unreachable");
679679

680680
Ok(())

src/top.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct LinkIter<'a> {
5959
iter: std::collections::vec_deque::IterMut<'a, Sent>,
6060
}
6161

62-
impl<'a> LinkIter<'a> {
62+
impl LinkIter<'_> {
6363
/// The [`IpAddr`] pair for the link. Always ordered to uniquely identify
6464
/// the link.
6565
pub fn pair(&self) -> (IpAddr, IpAddr) {
@@ -84,7 +84,7 @@ pub struct SentRef<'a> {
8484
sent: &'a mut Sent,
8585
}
8686

87-
impl<'a> SentRef<'a> {
87+
impl SentRef<'_> {
8888
/// The (src, dst) [`SocketAddr`] pair for the message.
8989
pub fn pair(&self) -> (SocketAddr, SocketAddr) {
9090
(self.src, self.dst)
@@ -243,11 +243,7 @@ impl Topology {
243243
link.enqueue_message(&self.config, rand, src, dst, message);
244244
Ok(())
245245
} else {
246-
// TODO: `ErrorKind::Other` is incorrect here, but
247-
// `ErrorKind::HostUnreachable` has not been stabilized.
248-
//
249-
// See: https://github.com/rust-lang/rust/issues/86442
250-
Err(Error::new(ErrorKind::Other, "host unreachable"))
246+
Err(Error::new(ErrorKind::HostUnreachable, "host unreachable"))
251247
}
252248
}
253249

tests/tcp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn network_partitions_during_connect() -> Result {
4545
turmoil::partition("client", "server");
4646

4747
let err = TcpStream::connect(("server", PORT)).await.unwrap_err();
48-
assert_eq!(err.kind(), io::ErrorKind::Other);
48+
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
4949
assert_eq!(err.to_string(), "host unreachable");
5050

5151
turmoil::repair("client", "server");
@@ -220,7 +220,7 @@ fn network_partition_once_connected() -> Result {
220220
assert!(timeout(Duration::from_secs(1), s.read_u8()).await.is_err());
221221

222222
let err = s.write_u8(1).await.unwrap_err();
223-
assert_eq!(err.kind(), io::ErrorKind::Other);
223+
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
224224
assert_eq!(err.to_string(), "host unreachable");
225225

226226
Ok(())
@@ -232,7 +232,7 @@ fn network_partition_once_connected() -> Result {
232232
turmoil::partition("server", "client");
233233

234234
let err = s.write_u8(1).await.unwrap_err();
235-
assert_eq!(err.kind(), io::ErrorKind::Other);
235+
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
236236
assert_eq!(err.to_string(), "host unreachable");
237237

238238
Ok(())
@@ -1129,7 +1129,7 @@ fn socket_to_nonexistent_node() -> Result {
11291129
);
11301130

11311131
let err = sock.unwrap_err();
1132-
assert_eq!(err.kind(), io::ErrorKind::Other);
1132+
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
11331133
assert_eq!(err.to_string(), "host unreachable");
11341134

11351135
Ok(())

tests/udp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn network_partition() -> Result {
235235

236236
let sock = bind().await?;
237237
let err = send_ping(&sock).await.unwrap_err();
238-
assert_eq!(err.kind(), ErrorKind::Other);
238+
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
239239
assert_eq!(err.to_string(), "host unreachable");
240240

241241
Ok(())
@@ -562,7 +562,7 @@ fn loopback_localhost_public_v4() -> Result {
562562
let bind_addr = SocketAddr::new(bind_addr.ip(), 0);
563563
let socket = UdpSocket::bind(bind_addr).await?;
564564
let err = socket.send_to(&expected, connect_addr).await.unwrap_err();
565-
assert_eq!(err.kind(), ErrorKind::Other);
565+
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
566566
assert_eq!(err.to_string(), "host unreachable");
567567

568568
Ok(())
@@ -614,7 +614,7 @@ fn loopback_localhost_public_v6() -> Result {
614614
let bind_addr = SocketAddr::new(bind_addr.ip(), 0);
615615
let socket = UdpSocket::bind(bind_addr).await?;
616616
let err = socket.send_to(&expected, connect_addr).await.unwrap_err();
617-
assert_eq!(err.kind(), ErrorKind::Other);
617+
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
618618
assert_eq!(err.to_string(), "host unreachable");
619619

620620
Ok(())
@@ -723,7 +723,7 @@ fn socket_to_nonexistent_node() -> Result {
723723
);
724724

725725
let err = send.unwrap_err();
726-
assert_eq!(err.kind(), ErrorKind::Other);
726+
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
727727
assert_eq!(err.to_string(), "host unreachable");
728728

729729
Ok(())

0 commit comments

Comments
 (0)