From 7bebf1cb0c226abc801f473f1ef4434a54912422 Mon Sep 17 00:00:00 2001 From: zach Date: Tue, 8 Jul 2025 08:57:53 -0700 Subject: [PATCH] chore: clippy --- runtime/examples/fs.rs | 4 ++-- runtime/examples/linking.rs | 2 +- runtime/examples/log_callback.rs | 2 +- runtime/examples/readme.rs | 2 +- runtime/src/lib.rs | 2 +- runtime/src/manifest.rs | 2 +- runtime/src/plugin.rs | 3 +-- runtime/src/sdk.rs | 4 ++-- runtime/src/tests/issues.rs | 4 ++-- runtime/src/tests/pool.rs | 2 +- runtime/src/tests/runtime.rs | 17 ++++++++--------- 11 files changed, 21 insertions(+), 23 deletions(-) diff --git a/runtime/examples/fs.rs b/runtime/examples/fs.rs index a52128b..bf3239a 100644 --- a/runtime/examples/fs.rs +++ b/runtime/examples/fs.rs @@ -16,7 +16,7 @@ fn main() { let res = plugin.call::<&str, &str>("try_read", "").unwrap(); - println!("{:?}", res); + println!("{res:?}"); println!("-----------------------------------------------------"); @@ -30,7 +30,7 @@ fn main() { ); let res2 = plugin.call::<&str, &str>("try_write", &line).unwrap(); - println!("{:?}", res2); + println!("{res2:?}"); println!("done!"); } diff --git a/runtime/examples/linking.rs b/runtime/examples/linking.rs index 7abe3ab..4a2140e 100644 --- a/runtime/examples/linking.rs +++ b/runtime/examples/linking.rs @@ -30,6 +30,6 @@ fn main() { let res = plugin .call::<&str, &str>("reflect", "Hello, world!") .unwrap(); - println!("{}", res); + println!("{res}"); } } diff --git a/runtime/examples/log_callback.rs b/runtime/examples/log_callback.rs index 3cefbd2..9b1d668 100644 --- a/runtime/examples/log_callback.rs +++ b/runtime/examples/log_callback.rs @@ -25,6 +25,6 @@ fn main() { println!("Dumping logs"); for line in LOGS.lock().unwrap().iter() { - print!("{}", line); + print!("{line}"); } } diff --git a/runtime/examples/readme.rs b/runtime/examples/readme.rs index 61ce217..1bcefed 100644 --- a/runtime/examples/readme.rs +++ b/runtime/examples/readme.rs @@ -52,6 +52,6 @@ fn main() { let res = plugin .call::<&str, &str>("count_vowels", "Hello, world!") .unwrap(); - println!("{}", res); + println!("{res}"); } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9eb74d9..1fb64e7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -98,7 +98,7 @@ pub fn set_log_callback( let x = tracing_subscriber::EnvFilter::builder() .with_default_directive(tracing::Level::ERROR.into()); if is_level { - x.parse_lossy(format!("extism={}", filter)) + x.parse_lossy(format!("extism={filter}")) } else { x.parse_lossy(filter) } diff --git a/runtime/src/manifest.rs b/runtime/src/manifest.rs index 3b00349..8838633 100644 --- a/runtime/src/manifest.rs +++ b/runtime/src/manifest.rs @@ -10,7 +10,7 @@ use crate::*; fn hex(data: &[u8]) -> String { let mut s = String::new(); for &byte in data { - write!(&mut s, "{:02x}", byte).unwrap(); + write!(&mut s, "{byte:02x}").unwrap(); } s } diff --git a/runtime/src/plugin.rs b/runtime/src/plugin.rs index 06db867..119a6a4 100644 --- a/runtime/src/plugin.rs +++ b/runtime/src/plugin.rs @@ -963,8 +963,7 @@ impl Plugin { } Err(msg) => { res = Err(Error::msg(format!( - "unable to load error message from memory: {}", - msg, + "unable to load error message from memory: {msg}", ))); } } diff --git a/runtime/src/sdk.rs b/runtime/src/sdk.rs index 0307cf9..9abd110 100644 --- a/runtime/src/sdk.rs +++ b/runtime/src/sdk.rs @@ -871,7 +871,7 @@ fn set_log_file(log_file: impl Into, filter: &str) -> Result let x = tracing_subscriber::EnvFilter::builder() .with_default_directive(tracing::Level::ERROR.into()); if is_level { - x.parse_lossy(format!("extism={}", filter)) + x.parse_lossy(format!("extism={filter}")) } else { x.parse_lossy(filter) } @@ -926,7 +926,7 @@ unsafe fn set_log_buffer(filter: &str) -> Result<(), Error> { let x = tracing_subscriber::EnvFilter::builder() .with_default_directive(tracing::Level::ERROR.into()); if is_level { - x.parse_lossy(format!("extism={}", filter)) + x.parse_lossy(format!("extism={filter}")) } else { x.parse_lossy(filter) } diff --git a/runtime/src/tests/issues.rs b/runtime/src/tests/issues.rs index df61683..512f3d9 100644 --- a/runtime/src/tests/issues.rs +++ b/runtime/src/tests/issues.rs @@ -16,7 +16,7 @@ fn test_issue_620() { // Call test method, this does not work let p = plugin.call::<(), String>("test", ()).unwrap(); - println!("{}", p); + println!("{p}"); } // https://github.com/extism/extism/issues/619 @@ -53,5 +53,5 @@ fn test_issue_775() { Ok(code) => Err(code), } .unwrap(); - println!("{}", p); + println!("{p}"); } diff --git a/runtime/src/tests/pool.rs b/runtime/src/tests/pool.rs index 4af353d..daed318 100644 --- a/runtime/src/tests/pool.rs +++ b/runtime/src/tests/pool.rs @@ -9,7 +9,7 @@ fn run_thread(p: Pool, i: u64) -> std::thread::JoinHandle<()> { .unwrap() .call("count_vowels", "abc") .unwrap(); - println!("{}", s); + println!("{s}"); }) } diff --git a/runtime/src/tests/runtime.rs b/runtime/src/tests/runtime.rs index 5f810d7..7616608 100644 --- a/runtime/src/tests/runtime.rs +++ b/runtime/src/tests/runtime.rs @@ -134,8 +134,7 @@ fn it_works() { let native_avg: std::time::Duration = native_sum / native_num_tests as u32; println!( - "native function call (avg, N = {}): {:?}", - native_num_tests, native_avg + "native function call (avg, N = {native_num_tests}): {native_avg:?}" ); let num_tests = test_times.len(); @@ -145,7 +144,7 @@ fn it_works() { .unwrap(); let avg: std::time::Duration = sum / num_tests as u32; - println!("wasm function call (avg, N = {}): {:?}", num_tests, avg); + println!("wasm function call (avg, N = {num_tests}): {avg:?}"); // Check that log file was written to if log { @@ -212,7 +211,7 @@ fn test_cancel() { let _output: Result<&[u8], Error> = plugin.call("loop_forever", "abc123"); let end = std::time::Instant::now(); let time = end - start; - println!("Cancelled plugin ran for {:?}", time); + println!("Cancelled plugin ran for {time:?}"); } } @@ -271,7 +270,7 @@ fn test_fuel_consumption() { assert!(output.is_err()); let fuel_consumed = plugin.fuel_consumed().unwrap(); - println!("Fuel consumed: {}", fuel_consumed); + println!("Fuel consumed: {fuel_consumed}"); assert!(fuel_consumed > 0); } @@ -440,7 +439,7 @@ fn test_memory_max() { assert!(output.is_err()); let err = output.unwrap_err().root_cause().to_string(); - println!("{:?}", err); + println!("{err:?}"); assert_eq!(err, "oom"); // Should pass with memory.max set to a large enough number @@ -503,7 +502,7 @@ fn test_extism_error() { let mut plugin = Plugin::new(&manifest, [f], true).unwrap(); let output: Result = plugin.call("count_vowels", "a".repeat(1024)); assert!(output.is_err()); - println!("{:?}", output); + println!("{output:?}"); assert_eq!(output.unwrap_err().root_cause().to_string(), "TEST"); } @@ -823,7 +822,7 @@ fn test_http_response_headers() { .unwrap(); let req = HttpRequest::new("https://extism.org"); let Json(res): Json> = plugin.call("http_get", Json(req)).unwrap(); - println!("{:?}", res); + println!("{res:?}"); assert_eq!(res["content-type"], "text/html; charset=utf-8"); } @@ -838,6 +837,6 @@ fn test_http_response_headers_disabled() { .unwrap(); let req = HttpRequest::new("https://extism.org"); let Json(res): Json> = plugin.call("http_get", Json(req)).unwrap(); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_empty()); }