Skip to content

Commit fb2aedc

Browse files
committed
chore: address clippy warnings
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 8ae1778 commit fb2aedc

File tree

6 files changed

+27
-50
lines changed

6 files changed

+27
-50
lines changed

crates/pack/src/lib.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ impl AsyncRead for NoopStream {
2323
_: &mut Context<'_>,
2424
_: &mut tokio::io::ReadBuf<'_>,
2525
) -> Poll<std::io::Result<()>> {
26-
Poll::Ready(Err(std::io::Error::new(
27-
std::io::ErrorKind::Other,
28-
"should not be called",
29-
)))
26+
Poll::Ready(Err(std::io::Error::other("should not be called")))
3027
}
3128
}
3229

@@ -36,24 +33,15 @@ impl AsyncWrite for NoopStream {
3633
_: &mut Context<'_>,
3734
_: &[u8],
3835
) -> Poll<std::io::Result<usize>> {
39-
Poll::Ready(Err(std::io::Error::new(
40-
std::io::ErrorKind::Other,
41-
"should not be called",
42-
)))
36+
Poll::Ready(Err(std::io::Error::other("should not be called")))
4337
}
4438

4539
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<std::io::Result<()>> {
46-
Poll::Ready(Err(std::io::Error::new(
47-
std::io::ErrorKind::Other,
48-
"should not be called",
49-
)))
40+
Poll::Ready(Err(std::io::Error::other("should not be called")))
5041
}
5142

5243
fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<std::io::Result<()>> {
53-
Poll::Ready(Err(std::io::Error::new(
54-
std::io::ErrorKind::Other,
55-
"should not be called",
56-
)))
44+
Poll::Ready(Err(std::io::Error::other("should not be called")))
5745
}
5846
}
5947

crates/runtime-wasmtime/src/codec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,7 @@ where
791791
Type::Own(ty) | Type::Borrow(ty) => {
792792
if *ty == ResourceType::host::<DynInputStream>() {
793793
let mut store = store.as_context_mut();
794-
let r = r
795-
.index(path)
796-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
794+
let r = r.index(path).map_err(std::io::Error::other)?;
797795
// TODO: Implement a custom reader, this approach ignores the stream end (`\0`),
798796
// which will could potentially break/hang with some transports
799797
let res = store
@@ -807,7 +805,7 @@ where
807805
.map_err(|err| std::io::Error::new(std::io::ErrorKind::OutOfMemory, err))?;
808806
let v = res
809807
.try_into_resource_any(store)
810-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
808+
.map_err(std::io::Error::other)?;
811809
*val = Val::Resource(v);
812810
Ok(())
813811
} else if resources.contains(ty) {
@@ -858,7 +856,7 @@ where
858856
.map_err(|err| std::io::Error::new(std::io::ErrorKind::OutOfMemory, err))?;
859857
let resource = resource
860858
.try_into_resource_any(store)
861-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
859+
.map_err(std::io::Error::other)?;
862860
*val = Val::Resource(resource);
863861
Ok(())
864862
}

crates/transport-nats/src/lib.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub fn invocation_subject(prefix: &str, instance: &str, func: &str) -> String {
147147
}
148148

149149
fn corrupted_memory_error() -> std::io::Error {
150-
std::io::Error::new(std::io::ErrorKind::Other, "corrupted memory state")
150+
std::io::Error::other("corrupted memory state")
151151
}
152152

153153
/// Transport subscriber
@@ -735,8 +735,7 @@ impl RootParamWriter {
735735
status: Some(code),
736736
description,
737737
..
738-
})) if !code.is_success() => Poll::Ready(Err(std::io::Error::new(
739-
std::io::ErrorKind::Other,
738+
})) if !code.is_success() => Poll::Ready(Err(std::io::Error::other(
740739
if let Some(description) = description {
741740
format!("received a response with code `{code}` ({description})")
742741
} else {
@@ -757,13 +756,11 @@ impl RootParamWriter {
757756
return Poll::Ready(Err(corrupted_memory_error()));
758757
};
759758
let tx = SubjectWriter::new(nats, Subject::from(param_subject(&tx)), tasks);
760-
let indexed = indexed.into_inner().map_err(|err| {
761-
std::io::Error::new(std::io::ErrorKind::Other, err.to_string())
762-
})?;
759+
let indexed = indexed
760+
.into_inner()
761+
.map_err(|err| std::io::Error::other(err.to_string()))?;
763762
for (path, tx_tx) in indexed {
764-
let tx = tx.index(&path).map_err(|err| {
765-
std::io::Error::new(std::io::ErrorKind::Other, err)
766-
})?;
763+
let tx = tx.index(&path).map_err(std::io::Error::other)?;
767764
tx_tx.send(tx).map_err(|_| {
768765
std::io::Error::from(std::io::ErrorKind::BrokenPipe)
769766
})?;
@@ -820,9 +817,9 @@ impl wrpc_transport::Index<IndexedParamWriter> for RootParamWriter {
820817
Self::Corrupted => Err(anyhow!(corrupted_memory_error())),
821818
Self::Handshaking { indexed, .. } => {
822819
let (tx_tx, tx_rx) = oneshot::channel();
823-
let mut indexed = indexed.lock().map_err(|err| {
824-
std::io::Error::new(std::io::ErrorKind::Other, err.to_string())
825-
})?;
820+
let mut indexed = indexed
821+
.lock()
822+
.map_err(|err| std::io::Error::other(err.to_string()))?;
826823
indexed.push((path.to_vec(), tx_tx));
827824
Ok(IndexedParamWriter::Handshaking {
828825
tx_rx,
@@ -907,13 +904,11 @@ impl IndexedParamWriter {
907904
let Self::Handshaking { indexed, .. } = mem::take(&mut *self) else {
908905
return Poll::Ready(Err(corrupted_memory_error()));
909906
};
910-
let indexed = indexed.into_inner().map_err(|err| {
911-
std::io::Error::new(std::io::ErrorKind::Other, err.to_string())
912-
})?;
907+
let indexed = indexed
908+
.into_inner()
909+
.map_err(|err| std::io::Error::other(err.to_string()))?;
913910
for (path, tx_tx) in indexed {
914-
let tx = tx.index(&path).map_err(|err| {
915-
std::io::Error::new(std::io::ErrorKind::Other, err)
916-
})?;
911+
let tx = tx.index(&path).map_err(std::io::Error::other)?;
917912
tx_tx.send(tx).map_err(|_| {
918913
std::io::Error::from(std::io::ErrorKind::BrokenPipe)
919914
})?;
@@ -938,9 +933,9 @@ impl wrpc_transport::Index<Self> for IndexedParamWriter {
938933
Self::Corrupted => Err(anyhow!(corrupted_memory_error())),
939934
Self::Handshaking { indexed, .. } => {
940935
let (tx_tx, tx_rx) = oneshot::channel();
941-
let mut indexed = indexed.lock().map_err(|err| {
942-
std::io::Error::new(std::io::ErrorKind::Other, err.to_string())
943-
})?;
936+
let mut indexed = indexed
937+
.lock()
938+
.map_err(|err| std::io::Error::other(err.to_string()))?;
944939
indexed.push((path.to_vec(), tx_tx));
945940
Ok(Self::Handshaking {
946941
tx_rx,

crates/transport-web/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ impl Accept for &Client {
130130
type Incoming = RecvStream;
131131

132132
async fn accept(&self) -> std::io::Result<(Self::Context, Self::Outgoing, Self::Incoming)> {
133-
let (tx, rx) = self
134-
.0
135-
.accept_bi()
136-
.await
137-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
133+
let (tx, rx) = self.0.accept_bi().await.map_err(std::io::Error::other)?;
138134
Ok(((), tx, rx))
139135
}
140136
}

crates/transport/src/frame/conn/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl Index<Self> for Incoming {
320320
let mut index = self
321321
.index
322322
.lock()
323-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))?;
323+
.map_err(|err| std::io::Error::other(err.to_string()))?;
324324
trace!(?path, "taking index subscription");
325325
let rx = index
326326
.take_rx(&path)
@@ -462,7 +462,7 @@ async fn ingress(
462462
trace!("locking index trie");
463463
let mut index = index
464464
.lock()
465-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))?;
465+
.map_err(|err| std::io::Error::other(err.to_string()))?;
466466
&index.get_tx(&path).ok_or_else(|| {
467467
std::io::Error::new(
468468
std::io::ErrorKind::NotFound,

crates/wit-bindgen-go/src/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ func ServeInterface(s {wrpc}.Server, h Handler) (stop func() error, err error) {
25692569
uwrite!(self.src, "r{i}, ");
25702570
}
25712571
self.push_str("err ");
2572-
if results.len() > 0 {
2572+
if !results.is_empty() {
25732573
self.push_str(":");
25742574
}
25752575
self.push_str("= h.");

0 commit comments

Comments
 (0)