From 28d5fe1aef17e018624ad6c591d52b2af8f986d7 Mon Sep 17 00:00:00 2001 From: Andrzej Ressel Date: Sat, 9 Mar 2024 22:18:18 +0100 Subject: [PATCH 1/2] Fix clippy warnings --- pulumi_rust/src/pulumi.rs | 3 +-- pulumi_rust_wasm/src/output.rs | 2 +- pulumi_wasm/src/lib.rs | 16 ++++++++-------- pulumi_wasm/src/output.rs | 6 +++--- pulumi_wasm/tests/test.rs | 6 ++---- pulumi_wasm_main/src/lib.rs | 8 +++----- pulumi_wasm_random/src/lib.rs | 6 +++++- src/main.rs | 2 +- wasm_common/src/lib.rs | 6 ++++-- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pulumi_rust/src/pulumi.rs b/pulumi_rust/src/pulumi.rs index a54a10a05..612913ea3 100644 --- a/pulumi_rust/src/pulumi.rs +++ b/pulumi_rust/src/pulumi.rs @@ -1,5 +1,4 @@ use std::cell::RefCell; -use std::io::prelude::*; use std::ops::DerefMut; use std::rc::Rc; @@ -184,7 +183,7 @@ impl Pulumi { let component = Component::from_file(&engine, pulumi_wasm_file)?; - Ok(component.serialize()?) + component.serialize() } pub async fn start(&self) -> Result<(), Error> { diff --git a/pulumi_rust_wasm/src/output.rs b/pulumi_rust_wasm/src/output.rs index f3f566efa..11d3e8058 100644 --- a/pulumi_rust_wasm/src/output.rs +++ b/pulumi_rust_wasm/src/output.rs @@ -24,7 +24,7 @@ impl Output { pub unsafe fn new_from_handle(handle: u32) -> Output { let output = output_interface::Output::from_handle(handle); Output { - phantom: PhantomData::::default(), + phantom: PhantomData::, future: output, } } diff --git a/pulumi_wasm/src/lib.rs b/pulumi_wasm/src/lib.rs index 41677610e..1da70a251 100644 --- a/pulumi_wasm/src/lib.rs +++ b/pulumi_wasm/src/lib.rs @@ -1,29 +1,29 @@ use core::fmt::Debug; -use std::collections::{BTreeMap, HashMap}; +use std::collections::{BTreeMap}; use std::fmt::Formatter; use std::ops::Deref; -use futures::SinkExt; -use lazy_static::lazy_static; -use log::{error, info, log}; + + +use log::{error, info}; use prost::Message; use prost_types::Struct; use prost_types::value::Kind; use rmpv::{Utf8String, Value}; use bindings::component::pulumi_wasm::external_world; use crate::bindings::component::pulumi_wasm::external_world::is_in_preview; -use crate::bindings::component::pulumi_wasm::log::log; + use crate::bindings::exports::component::pulumi_wasm::function_reverse_callback::{ FunctionInvocationRequest, FunctionInvocationResult, }; use crate::bindings::exports::component::pulumi_wasm::output_interface::Output as WasmOutput; -use crate::bindings::exports::component::pulumi_wasm::output_interface::OutputBorrow as WasmOutputBorrow; + use crate::bindings::exports::component::pulumi_wasm::output_interface::{GuestOutput}; -use crate::bindings::exports::component::pulumi_wasm::register_interface::{ObjectField, RegisterResourceRequest}; +use crate::bindings::exports::component::pulumi_wasm::register_interface::{RegisterResourceRequest}; use crate::bindings::exports::component::pulumi_wasm::{ function_reverse_callback, output_interface, register_interface, }; -use crate::grpc::register_resource_request; + use crate::output::{access_map, FunctionId, FunctionSource, OutputContent}; bindings::export!(Component with_types_in bindings); diff --git a/pulumi_wasm/src/output.rs b/pulumi_wasm/src/output.rs index 9363b7bc7..cd7e3ec09 100644 --- a/pulumi_wasm/src/output.rs +++ b/pulumi_wasm/src/output.rs @@ -22,9 +22,9 @@ impl FunctionId { #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct FunctionSource(String); -impl Into for FunctionSource { - fn into(self) -> String { - self.0 +impl From for String { + fn from(val: FunctionSource) -> Self { + val.0 } } diff --git a/pulumi_wasm/tests/test.rs b/pulumi_wasm/tests/test.rs index f2d6f1a7f..7220090f1 100644 --- a/pulumi_wasm/tests/test.rs +++ b/pulumi_wasm/tests/test.rs @@ -2,7 +2,6 @@ use crate::server::component::pulumi_wasm::log; use crate::server::exports::component::pulumi_wasm::function_reverse_callback::FunctionInvocationRequest; use crate::server::PulumiWasm; use anyhow::{Error, Ok}; -use serde::{Deserialize}; use std::collections::HashMap; use std::string::String; use wasmtime::component::{Component, Linker, ResourceTable}; @@ -11,7 +10,6 @@ use wasmtime_wasi::preview2::WasiCtx; use wasmtime_wasi::preview2::WasiCtxBuilder; use wasmtime_wasi::preview2::WasiView; use std::borrow::BorrowMut; -use std::panic; mod server { wasmtime::component::bindgen!({ @@ -143,7 +141,7 @@ fn should_return_value_of_handled_mapped_value() -> Result<(), Error> { .output() .call_map(&mut store, output1, function_name)?; - let _ = run_loop(&mut store, &plugin)?; + run_loop(&mut store, &plugin)?; let output2_value = plugin .component_pulumi_wasm_output_interface() @@ -196,7 +194,7 @@ fn should_panic_when_getting_nonexisting_field_not_during_preview() -> Result<() .output() .call_constructor(&mut store, rmp_serde::to_vec(&HashMap::from([("key", "value")])).unwrap().as_slice())?; - let output2 = plugin + let _output2 = plugin .component_pulumi_wasm_output_interface() .output() .call_get_field(&mut store, output1, "nonexisting")?; diff --git a/pulumi_wasm_main/src/lib.rs b/pulumi_wasm_main/src/lib.rs index 1c0b608ec..5d8372874 100644 --- a/pulumi_wasm_main/src/lib.rs +++ b/pulumi_wasm_main/src/lib.rs @@ -1,4 +1,3 @@ -use std::fmt::format; use anyhow::{Context, Error}; use log::{error, info}; use pulumi_rust_wasm::HASHMAP; @@ -26,7 +25,7 @@ impl Guest for Component { let length: Output = Output::new(&1).map(|i: i32| i * 3); - let v = create_random_string(RandomStringArgs { + let _v = create_random_string(RandomStringArgs { name: "test1234", length, }); @@ -70,7 +69,7 @@ fn run_all_function( info!("Functions are not empty"); - let mut functions_map = HASHMAP.lock().unwrap(); + let functions_map = HASHMAP.lock().unwrap(); let mapped: Result, _> = functions .iter() @@ -90,7 +89,6 @@ fn run_all_function( }) }, ) - .into_iter() .collect(); // mapped @@ -104,7 +102,7 @@ fn run_all_function( }; info!("Setting functions"); - set_functions(&*mapped); + set_functions(&mapped); info!("run_all_function completed"); Ok(true) diff --git a/pulumi_wasm_random/src/lib.rs b/pulumi_wasm_random/src/lib.rs index a23bfaa8f..715682c35 100644 --- a/pulumi_wasm_random/src/lib.rs +++ b/pulumi_wasm_random/src/lib.rs @@ -2,6 +2,10 @@ use log::info; use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest}; use crate::bindings::exports::component::pulumi_wasm::pulumi_provider_random_interface::{Guest, RandomStringArgs, RandomStringResult}; +#[allow(clippy::all)] +#[allow(dead_code)] +#[allow(unused_variables)] +#[allow(unused_unsafe)] mod bindings; bindings::export!(Component with_types_in bindings); @@ -17,7 +21,7 @@ impl Guest for Component { let request = RegisterResourceRequest { type_: r#type, name: args.name, - object: vec![ObjectField { name: "length".to_string(), value: &args.length }], + object: vec![ObjectField { name: "length".to_string(), value: args.length }], }; let o = register(&request); diff --git a/src/main.rs b/src/main.rs index c6a508dd3..9c1e2052d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,7 @@ async fn main() -> Result<(), Error> { pulumi.start().await?; } Command::Compile { wasm, output } => { - let compiled = Pulumi::compile(&wasm)?; + let compiled = Pulumi::compile(wasm)?; std::fs::write(output, compiled)?; } Command::Plugins { .. } => todo!() diff --git a/wasm_common/src/lib.rs b/wasm_common/src/lib.rs index 32c1e8985..351909a8a 100644 --- a/wasm_common/src/lib.rs +++ b/wasm_common/src/lib.rs @@ -2,9 +2,11 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::Relaxed; use crate::logger::Logger; -use log::kv::{Source, VisitSource}; -use log::Log; +#[allow(clippy::all)] +#[allow(dead_code)] +#[allow(unused_variables)] +#[allow(unused_unsafe)] mod bindings; mod logger; From ee01bb8bf890f53cb26aedd8f2d688970d149984 Mon Sep 17 00:00:00 2001 From: Andrzej Ressel Date: Sat, 9 Mar 2024 22:22:57 +0100 Subject: [PATCH 2/2] Fix clippy warnings --- pulumi_rust_wasm/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pulumi_rust_wasm/src/lib.rs b/pulumi_rust_wasm/src/lib.rs index bcc0891ba..d918f9c8a 100644 --- a/pulumi_rust_wasm/src/lib.rs +++ b/pulumi_rust_wasm/src/lib.rs @@ -2,6 +2,10 @@ use std::collections::HashMap; use std::sync::Mutex; use lazy_static::lazy_static; +#[allow(clippy::all)] +#[allow(dead_code)] +#[allow(unused_variables)] +#[allow(unused_unsafe)] pub(crate) mod bindings; pub mod output;