Skip to content

Commit

Permalink
Resolve more compile errors and clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Crichton <[email protected]>
  • Loading branch information
alexcrichton committed Feb 5, 2025
1 parent af1d693 commit a96973e
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 31 deletions.
6 changes: 1 addition & 5 deletions crates/componentize/src/abi_conformance/test_config.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use super::{config, Context, TestConfig};
use anyhow::{ensure, Result};
use std::collections::HashMap;
use wasmtime::{
component::{InstancePre, __internal::async_trait},
Engine,
};
use wasmtime::{component::InstancePre, Engine};

#[derive(Default)]
pub(super) struct Config {
map: HashMap<String, String>,
}

#[async_trait]
impl config::Host for Config {
async fn get_config(&mut self, key: String) -> Result<Result<String, config::Error>> {
Ok(self
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::{
Context, TestConfig,
};
use anyhow::{ensure, Result};
use async_trait::async_trait;
use std::collections::HashMap;
use wasmtime::{component::InstancePre, Engine};

Expand All @@ -13,7 +12,6 @@ pub(crate) struct Http {
map: HashMap<String, String>,
}

#[async_trait]
impl http::Host for Http {
async fn send_request(&mut self, req: Request) -> Result<Result<Response, HttpError>> {
Ok(self
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_key_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::{
Context, TestConfig,
};
use anyhow::{anyhow, ensure, Result};
use async_trait::async_trait;
use serde::Serialize;
use std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -34,7 +33,6 @@ pub(crate) struct KeyValue {
close_set: HashSet<KvStore>,
}

#[async_trait]
impl key_value::Host for KeyValue {
async fn open(&mut self, name: String) -> Result<Result<KvStore, Error>> {
Ok(self.open_map.remove(&name).ok_or_else(|| {
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_llm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;

use anyhow::{ensure, Result};
use async_trait::async_trait;
use serde::Serialize;

use super::llm;
Expand All @@ -18,7 +17,6 @@ pub struct Llm {
embeddings: HashMap<(String, Vec<String>), Vec<Vec<f32>>>,
}

#[async_trait]
impl llm::Host for Llm {
async fn infer(
&mut self,
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::{
Context, TestConfig,
};
use anyhow::{ensure, Result};
use async_trait::async_trait;
use serde::Serialize;
use std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -40,7 +39,6 @@ pub(crate) struct Mysql {
query_map: HashMap<(String, String, String), RowSet>,
}

#[async_trait]
impl mysql::Host for Mysql {
async fn execute(
&mut self,
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::{
Context, TestConfig,
};
use anyhow::{ensure, Result};
use async_trait::async_trait;
use serde::Serialize;
use std::{collections::HashMap, iter};
use wasmtime::{component::InstancePre, Engine};
Expand Down Expand Up @@ -37,7 +36,6 @@ pub(crate) struct Postgres {
query_map: HashMap<(String, String, String), RowSet>,
}

#[async_trait]
impl postgres::Host for Postgres {
async fn execute(
&mut self,
Expand Down
2 changes: 0 additions & 2 deletions crates/componentize/src/abi_conformance/test_redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::{
Context, TestConfig,
};
use anyhow::{ensure, Result};
use async_trait::async_trait;
use serde::Serialize;
use std::collections::{HashMap, HashSet};
use wasmtime::{component::InstancePre, Engine};
Expand Down Expand Up @@ -103,7 +102,6 @@ pub(crate) struct Redis {
execute_map: HashMap<(String, String, Vec<Vec<u8>>), Vec<RedisResult>>,
}

#[async_trait]
impl redis::Host for Redis {
async fn publish(
&mut self,
Expand Down
1 change: 1 addition & 0 deletions crates/factor-key-value/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ impl wasi_keyvalue::store::HostBucket for KeyValueDispatch {

impl wasi_keyvalue::batch::Host for KeyValueDispatch {
#[instrument(name = "spin_key_value.get_many", skip(self, bucket, keys), err(level = Level::INFO), fields(otel.kind = "client"))]
#[allow(clippy::type_complexity)]
async fn get_many(
&mut self,
bucket: Resource<wasi_keyvalue::batch::Bucket>,
Expand Down
10 changes: 4 additions & 6 deletions crates/factor-outbound-mysql/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ impl<C: Client> v2::HostConnection for InstanceState<C> {
statement: String,
params: Vec<ParameterValue>,
) -> Result<(), v2::Error> {
Ok(self
.get_client(connection)
self.get_client(connection)
.await?
.execute(statement, params)
.await?)
.await
}

#[instrument(name = "spin_outbound_mysql.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", otel.name = statement))]
Expand All @@ -73,11 +72,10 @@ impl<C: Client> v2::HostConnection for InstanceState<C> {
statement: String,
params: Vec<ParameterValue>,
) -> Result<v2_types::RowSet, v2::Error> {
Ok(self
.get_client(connection)
self.get_client(connection)
.await?
.query(statement, params)
.await?)
.await
}

async fn drop(&mut self, connection: Resource<Connection>) -> Result<()> {
Expand Down
10 changes: 4 additions & 6 deletions crates/factor-outbound-pg/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ impl<C: Send + Sync + Client> spin_world::spin::postgres::postgres::HostConnecti
statement: String,
params: Vec<v3::ParameterValue>,
) -> Result<u64, v3::Error> {
Ok(self
.get_client(connection)
self.get_client(connection)
.await?
.execute(statement, params)
.await?)
.await
}

#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
Expand All @@ -111,11 +110,10 @@ impl<C: Send + Sync + Client> spin_world::spin::postgres::postgres::HostConnecti
statement: String,
params: Vec<v3::ParameterValue>,
) -> Result<v3::RowSet, v3::Error> {
Ok(self
.get_client(connection)
self.get_client(connection)
.await?
.query(statement, params)
.await?)
.await
}

async fn drop(&mut self, connection: Resource<v3::Connection>) -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ route = "/..."

/// Make sure that the plugin is uninstalled after the test
struct Uninstaller<'a>(&'a test_environment::TestEnvironment<()>);
impl<'a> Drop for Uninstaller<'a> {
impl Drop for Uninstaller<'_> {
fn drop(&mut self) {
let mut uninstall = std::process::Command::new(spin_binary());
uninstall.args(["plugins", "uninstall", "example"]);
Expand Down
2 changes: 1 addition & 1 deletion tests/testcases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn assert_spin_request<B: Into<reqwest::Body>>(

struct TruncatedSlice<'a, T>(&'a [T]);

impl<'a, T: std::fmt::Display> std::fmt::Display for TruncatedSlice<'a, T> {
impl<T: std::fmt::Display> std::fmt::Display for TruncatedSlice<'_, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("[")?;
for item in self.0.iter().take(10) {
Expand Down

0 comments on commit a96973e

Please sign in to comment.