Skip to content

Commit 9c712d3

Browse files
authored
chore: address clippy lints for cargo 1.87.0-beta / clippy 0.1.87
Pull-Request: #5974.
1 parent 1206fef commit 9c712d3

File tree

38 files changed

+71
-122
lines changed

38 files changed

+71
-122
lines changed

core/src/muxing/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn into_io_error<E>(err: E) -> io::Error
8585
where
8686
E: Error + Send + Sync + 'static,
8787
{
88-
io::Error::new(io::ErrorKind::Other, err)
88+
io::Error::other(err)
8989
}
9090

9191
impl StreamMuxerBox {

core/src/transport/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,5 @@ impl<O> FusedStream for Boxed<O> {
171171
}
172172

173173
fn box_err<E: Error + Send + Sync + 'static>(e: E) -> io::Error {
174-
io::Error::new(io::ErrorKind::Other, e)
174+
io::Error::other(e)
175175
}

examples/browser-webrtc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ impl Body {
104104
}
105105

106106
fn js_error(msg: &str) -> JsError {
107-
io::Error::new(io::ErrorKind::Other, msg).into()
107+
io::Error::other(msg).into()
108108
}

examples/chat/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
7272
// signing)
7373
.message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated.
7474
.build()
75-
.map_err(|msg| io::Error::new(io::ErrorKind::Other, msg))?; // Temporary hack because `build` does not return a proper `std::error::Error`.
75+
.map_err(io::Error::other)?; // Temporary hack because `build` does not return a proper `std::error::Error`.
7676

7777
// build a gossipsub network behaviour
7878
let gossipsub = gossipsub::Behaviour::new(

examples/ipfs-private/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
138138
let gossipsub_config = gossipsub::ConfigBuilder::default()
139139
.max_transmit_size(262144)
140140
.build()
141-
.map_err(|msg| io::Error::new(io::ErrorKind::Other, msg))?; // Temporary hack because `build` does not return a proper `std::error::Error`.
141+
.map_err(io::Error::other)?; // Temporary hack because `build` does not return a proper `std::error::Error`.
142142
Ok(MyBehaviour {
143143
gossipsub: gossipsub::Behaviour::new(
144144
gossipsub::MessageAuthenticity::Signed(key.clone()),

examples/stream/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async fn send(mut stream: Stream) -> io::Result<()> {
148148
stream.read_exact(&mut buf).await?;
149149

150150
if bytes != buf {
151-
return Err(io::Error::new(io::ErrorKind::Other, "incorrect echo"));
151+
return Err(io::Error::other("incorrect echo"));
152152
}
153153

154154
stream.close().await?;

hole-punching-tests/src/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,7 @@ impl FromStr for TransportProtocol {
333333
match mode {
334334
"tcp" => Ok(TransportProtocol::Tcp),
335335
"quic" => Ok(TransportProtocol::Quic),
336-
_ => Err(io::Error::new(
337-
io::ErrorKind::Other,
338-
"Expected either 'tcp' or 'quic'",
339-
)),
336+
_ => Err(io::Error::other("Expected either 'tcp' or 'quic'")),
340337
}
341338
}
342339
}
@@ -353,10 +350,7 @@ impl FromStr for Mode {
353350
match mode {
354351
"dial" => Ok(Mode::Dial),
355352
"listen" => Ok(Mode::Listen),
356-
_ => Err(io::Error::new(
357-
io::ErrorKind::Other,
358-
"Expected either 'dial' or 'listen'",
359-
)),
353+
_ => Err(io::Error::other("Expected either 'dial' or 'listen'")),
360354
}
361355
}
362356
}

misc/connection-limits/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,7 @@ mod tests {
692692
_local_addr: &Multiaddr,
693693
_remote_addr: &Multiaddr,
694694
) -> Result<THandler<Self>, ConnectionDenied> {
695-
Err(ConnectionDenied::new(std::io::Error::new(
696-
std::io::ErrorKind::Other,
695+
Err(ConnectionDenied::new(std::io::Error::other(
697696
"ConnectionDenier",
698697
)))
699698
}
@@ -706,8 +705,7 @@ mod tests {
706705
_role_override: Endpoint,
707706
_port_use: PortUse,
708707
) -> Result<THandler<Self>, ConnectionDenied> {
709-
Err(ConnectionDenied::new(std::io::Error::new(
710-
std::io::ErrorKind::Other,
708+
Err(ConnectionDenied::new(std::io::Error::other(
711709
"ConnectionDenier",
712710
)))
713711
}

misc/multistream-select/src/negotiated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl From<NegotiationError> for io::Error {
368368
if let NegotiationError::ProtocolError(e) = err {
369369
return e.into();
370370
}
371-
io::Error::new(io::ErrorKind::Other, err)
371+
io::Error::other(err)
372372
}
373373
}
374374

misc/quick-protobuf-codec/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ fn write_length(message: &impl MessageWrite, dst: &mut BytesMut) {
5959
/// Write the message itself to `dst`.
6060
fn write_message(item: &impl MessageWrite, dst: &mut BytesMut) -> io::Result<()> {
6161
let mut writer = Writer::new(BytesMutWriterBackend::new(dst));
62-
item.write_message(&mut writer)
63-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
62+
item.write_message(&mut writer).map_err(io::Error::other)?;
6463

6564
Ok(())
6665
}

0 commit comments

Comments
 (0)