Skip to content

Commit

Permalink
chore: address clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed May 8, 2024
1 parent 275c8f2 commit b4fbfcb
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 152 deletions.
1 change: 1 addition & 0 deletions crates/cli/src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use tracing_subscriber::layer::SubscriberExt as _;
use tracing_subscriber::util::SubscriberInitExt as _;

#[must_use]
pub fn env_filter() -> tracing_subscriber::EnvFilter {
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
Expand Down
6 changes: 3 additions & 3 deletions crates/runtime-wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn to_wrpc_value<T: WasiView>(
i < 64,
"flag discriminants over 64 currently cannot be represented"
);
v |= 1 << i
v |= 1 << i;
}
Ok(wrpc_transport::Value::Flags(v))
}
Expand Down Expand Up @@ -297,7 +297,7 @@ impl HostInputStream for IncomingValueInputStream {
"stream item type mismatch"
)))?
};
buffer.put_u8(v)
buffer.put_u8(v);
}
let buffer = buffer.freeze();
if buffer.len() > size {
Expand Down Expand Up @@ -423,7 +423,7 @@ pub fn from_wrpc_value<T: WasiView>(
let mut names = Vec::with_capacity(64);
for (i, name) in zip(0..64, ty.names()) {
if v & (1 << i) != 0 {
names.push(name.to_string())
names.push(name.to_string());
}
}
Ok(Val::Flags(names))
Expand Down
2 changes: 1 addition & 1 deletion crates/test-helpers/codegen-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use heck::*;
use heck::ToSnakeCase;
use proc_macro::TokenStream;
use std::env;

Expand Down
1 change: 1 addition & 0 deletions crates/test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use wit_parser::{Resolve, WorldId};
///
/// This tries to pick a location in the `target` directory that can be
/// relatively easily debugged if a test goes wrong.
#[must_use]
pub fn test_directory(suite_name: &str, gen_name: &str, wit_name: &str) -> PathBuf {
let mut me = std::env::current_exe().unwrap();
me.pop(); // chop off exe name
Expand Down
4 changes: 3 additions & 1 deletion crates/transport-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Future for Transmission {

impl Drop for Transmission {
fn drop(&mut self) {
self.handle.abort()
self.handle.abort();
}
}

Expand All @@ -152,6 +152,7 @@ impl Client {
}
}

#[must_use]
pub fn static_subject(&self, instance: &str, func: &str) -> String {
let mut s = String::with_capacity(
self.prefix.len() + PROTOCOL.len() + instance.len() + func.len() + 3,
Expand Down Expand Up @@ -297,6 +298,7 @@ pub struct Subscriber {
}

impl Subscriber {
#[must_use]
pub fn new(nats: Arc<async_nats::Client>) -> Self {
Self { nats }
}
Expand Down
34 changes: 17 additions & 17 deletions crates/transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait Transmitter: Sync {
for v in values {
trace!("encode tuple element");
let tx = v.encode(&mut buf).await.context("failed to encode value")?;
nested.push(tx)
nested.push(tx);
}
let nested: FuturesUnordered<_> = zip(0.., nested)
.filter_map(|(i, v)| {
Expand Down Expand Up @@ -1113,7 +1113,7 @@ impl<T> Stream for StreamValue<T> {

impl<T> Drop for StreamValue<T> {
fn drop(&mut self) {
self.producer.abort()
self.producer.abort();
}
}

Expand Down Expand Up @@ -1155,7 +1155,7 @@ pub async fn receive_at_least<'a>(
.context("failed to receive payload chunk")?
.context("unexpected end of stream")?;
trace!("payload chunk received");
payload = Box::new(payload.chain(chunk))
payload = Box::new(payload.chain(chunk));
}
Ok(payload)
}
Expand Down Expand Up @@ -1186,7 +1186,7 @@ pub async fn receive_leb128_unsigned<'a>(
.context("failed to receive payload chunk")?
.context("unexpected end of stream")?;
trace!("payload chunk received");
payload = Box::new(payload.chain(chunk))
payload = Box::new(payload.chain(chunk));
}
}
}
Expand Down Expand Up @@ -1217,7 +1217,7 @@ pub async fn receive_leb128_signed<'a>(
.context("failed to receive payload chunk")?
.context("unexpected end of stream")?;
trace!("payload chunk received");
payload = Box::new(payload.chain(chunk))
payload = Box::new(payload.chain(chunk));
}
}
}
Expand Down Expand Up @@ -2570,7 +2570,7 @@ impl Encode for bool {
payload: &mut (impl BufMut + Send),
) -> anyhow::Result<Option<AsyncValue>> {
trace!(v = self, "encode bool");
payload.put_u8(if self { 1 } else { 0 });
payload.put_u8(u8::from(self));
Ok(None)
}
}
Expand Down Expand Up @@ -3032,7 +3032,7 @@ where
for v in self {
trace!("encode list element");
let v = v.encode(payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs
.iter()
Expand Down Expand Up @@ -3078,7 +3078,7 @@ where
for v in self {
trace!("encode list element");
let v = v.encode(payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs
.iter()
Expand Down Expand Up @@ -3108,7 +3108,7 @@ where
for v in self {
trace!("encode list element");
let v = v.encode(payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs
.iter()
Expand Down Expand Up @@ -3254,7 +3254,7 @@ where
for v in it {
trace!("encode iterator element");
let v = v.encode(&mut payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs.iter().any(Option::is_some).then_some(txs))
}
Expand Down Expand Up @@ -3287,7 +3287,7 @@ impl Encode for Value {
for v in vs {
trace!("encode record field");
let v = v.encode(payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs
.iter()
Expand All @@ -3300,7 +3300,7 @@ impl Encode for Value {
for v in vs {
trace!("encode tuple element");
let v = v.encode(payload).await?;
txs.push(v)
txs.push(v);
}
Ok(txs
.iter()
Expand Down Expand Up @@ -3754,12 +3754,12 @@ pub trait Client: Sync {
.context("failed to invoke function")?;

select! {
_ = tx_fail => {
() = tx_fail => {
trace!("transmission task failed");
match tx.await {

Err(err) => bail!(anyhow!(err).context("transmission failed")),
Ok(_) => bail!("transmission task desynchronisation occured"),
Ok(()) => bail!("transmission task desynchronisation occured"),
}
}
results = async {
Expand Down Expand Up @@ -3832,12 +3832,12 @@ pub trait Client: Sync {
.context("failed to invoke function")?;

select! {
_ = tx_fail => {
() = tx_fail => {
trace!("transmission task failed");
match tx.await {

Err(err) => bail!(anyhow!(err).context("transmission failed")),
Ok(_) => bail!("transmission task desynchronisation occured"),
Ok(()) => bail!("transmission task desynchronisation occured"),
}
}
results = async {
Expand Down Expand Up @@ -3983,7 +3983,7 @@ mod tests {
client: &impl super::Client,
instance: &str,
) -> anyhow::Result<impl Stream<Item = ()>> {
let name = String::from("");
let name = String::new();
let invocations = client.serve_static::<()>(instance, &name).await?;
Ok(invocations.map(|invocation| ()))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmtime-nats-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub async fn run() -> anyhow::Result<()> {
"file" => {
let wasm = wasm
.to_file_path()
.map_err(|_| anyhow!("failed to convert Wasm URL to file path"))?;
.map_err(|()| anyhow!("failed to convert Wasm URL to file path"))?;
fs::read(wasm)
.await
.context("failed to read Wasm from file URL")?
Expand Down Expand Up @@ -152,5 +152,5 @@ pub async fn run() -> anyhow::Result<()> {
.call_run(&mut store)
.await
.context("failed to run component")?
.map_err(|_| anyhow!("component failed"))
.map_err(|()| anyhow!("component failed"))
}
10 changes: 5 additions & 5 deletions crates/wasmtime-nats-cli/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<C: wrpc_transport::Client + Send> wasmtime_bindings::wasi::keyvalue::store:
key: String,
) -> anyhow::Result<Result<Option<Vec<u8>>>> {
let bucket = self.table.get(&bucket).context("failed to get bucket")?;
let v = wrpc_bindings::wrpc::keyvalue::store::get(&self.wrpc, &bucket, &key)
let v = wrpc_bindings::wrpc::keyvalue::store::get(&self.wrpc, bucket, &key)
.await
.context("failed to invoke `wrpc:keyvalue/store.get`")?;
Ok(v.map_err(FromWrpc::from_wrpc))
Expand All @@ -132,7 +132,7 @@ impl<C: wrpc_transport::Client + Send> wasmtime_bindings::wasi::keyvalue::store:
value: Vec<u8>,
) -> anyhow::Result<Result<()>> {
let bucket = self.table.get(&bucket).context("failed to get bucket")?;
let v = wrpc_bindings::wrpc::keyvalue::store::set(&self.wrpc, &bucket, &key, &value)
let v = wrpc_bindings::wrpc::keyvalue::store::set(&self.wrpc, bucket, &key, &value)
.await
.context("failed to invoke `wrpc:keyvalue/store.set`")?;
Ok(v.map_err(FromWrpc::from_wrpc))
Expand All @@ -145,7 +145,7 @@ impl<C: wrpc_transport::Client + Send> wasmtime_bindings::wasi::keyvalue::store:
key: String,
) -> anyhow::Result<Result<()>> {
let bucket = self.table.get(&bucket).context("failed to get bucket")?;
let v = wrpc_bindings::wrpc::keyvalue::store::delete(&self.wrpc, &bucket, &key)
let v = wrpc_bindings::wrpc::keyvalue::store::delete(&self.wrpc, bucket, &key)
.await
.context("failed to invoke `wrpc:keyvalue/store.delete`")?;
Ok(v.map_err(FromWrpc::from_wrpc))
Expand All @@ -158,7 +158,7 @@ impl<C: wrpc_transport::Client + Send> wasmtime_bindings::wasi::keyvalue::store:
key: String,
) -> anyhow::Result<Result<bool>> {
let bucket = self.table.get(&bucket).context("failed to get bucket")?;
let v = wrpc_bindings::wrpc::keyvalue::store::exists(&self.wrpc, &bucket, &key)
let v = wrpc_bindings::wrpc::keyvalue::store::exists(&self.wrpc, bucket, &key)
.await
.context("failed to invoke `wrpc:keyvalue/store.delete`")?;
Ok(v.map_err(FromWrpc::from_wrpc))
Expand All @@ -171,7 +171,7 @@ impl<C: wrpc_transport::Client + Send> wasmtime_bindings::wasi::keyvalue::store:
cursor: Option<u64>,
) -> anyhow::Result<Result<wasmtime_bindings::wasi::keyvalue::store::KeyResponse>> {
let bucket = self.table.get(&bucket).context("failed to get bucket")?;
let keys = wrpc_bindings::wrpc::keyvalue::store::list_keys(&self.wrpc, &bucket, cursor)
let keys = wrpc_bindings::wrpc::keyvalue::store::list_keys(&self.wrpc, bucket, cursor)
.await
.context("failed to invoke `wrpc:keyvalue/store.list-keys`")?;
Ok(FromWrpc::from_wrpc(keys))
Expand Down
Loading

0 comments on commit b4fbfcb

Please sign in to comment.