From f70a8053191c4a28eaa86e0f42254fe40fea80bf Mon Sep 17 00:00:00 2001 From: Zeb Piasecki Date: Mon, 30 Jan 2023 12:27:52 -0500 Subject: [PATCH] chore: fix new clippy lints Recently clippy added a lint requiring the new format syntax, causing all CI runs to fail. --- worker-build/src/main.rs | 2 +- worker-sandbox/src/lib.rs | 8 ++++---- worker-sandbox/src/test/export_durable_object.rs | 2 +- worker-sandbox/tests/requests.rs | 6 +++--- worker/src/cors.rs | 2 +- worker/src/env.rs | 4 ++-- worker/src/error.rs | 12 ++++++------ worker/src/headers.rs | 2 +- worker/src/request.rs | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/worker-build/src/main.rs b/worker-build/src/main.rs index 3dccf8a5..cce7d2cf 100644 --- a/worker-build/src/main.rs +++ b/worker-build/src/main.rs @@ -152,7 +152,7 @@ fn remove_unused_js() -> Result<()> { } for to_remove in [ - format!("{}_bg.js", OUT_NAME), + format!("{OUT_NAME}_bg.js"), "shim.js".into(), "glue.js".into(), ] { diff --git a/worker-sandbox/src/lib.rs b/worker-sandbox/src/lib.rs index d81876a1..951c1db6 100644 --- a/worker-sandbox/src/lib.rs +++ b/worker-sandbox/src/lib.rs @@ -290,7 +290,7 @@ pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result Result Result Result(&self, name: &str) -> Result { let binding = js_sys::Reflect::get(self, &JsValue::from(name)) - .map_err(|_| Error::JsError(format!("Env does not contain binding `{}`", name)))?; + .map_err(|_| Error::JsError(format!("Env does not contain binding `{name}`")))?; if binding.is_undefined() { - Err(format!("Binding `{}` is undefined.", name).into()) + Err(format!("Binding `{name}` is undefined.").into()) } else { // Can't just use JsCast::dyn_into here because the type name might not be in scope // resulting in a terribly annoying javascript error which can't be caught diff --git a/worker/src/error.rs b/worker/src/error.rs index 11978ef2..d4c1e921 100644 --- a/worker/src/error.rs +++ b/worker/src/error.rs @@ -43,17 +43,17 @@ impl std::fmt::Display for Error { match self { Error::BadEncoding => write!(f, "content-type mismatch"), Error::BodyUsed => write!(f, "body has already been read"), - Error::Json((msg, status)) => write!(f, "{} (status: {})", msg, status), + Error::Json((msg, status)) => write!(f, "{msg} (status: {status})"), Error::JsError(s) | Error::RustError(s) => { - write!(f, "{}", s) + write!(f, "{s}") } Error::Internal(_) => write!(f, "unrecognized JavaScript object"), - Error::BindingError(name) => write!(f, "no binding found for `{}`", name), - Error::RouteInsertError(e) => write!(f, "failed to insert route: {}", e), + Error::BindingError(name) => write!(f, "no binding found for `{name}`"), + Error::RouteInsertError(e) => write!(f, "failed to insert route: {e}"), Error::RouteNoDataError => write!(f, "route has no corresponding shared data"), - Error::SerdeJsonError(e) => write!(f, "Serde Error: {}", e), + Error::SerdeJsonError(e) => write!(f, "Serde Error: {e}"), #[cfg(feature = "queue")] - Error::SerdeWasmBindgenError(e) => write!(f, "Serde Error: {}", e), + Error::SerdeWasmBindgenError(e) => write!(f, "Serde Error: {e}"), } } } diff --git a/worker/src/headers.rs b/worker/src/headers.rs index e0d316ae..0a59101f 100644 --- a/worker/src/headers.rs +++ b/worker/src/headers.rs @@ -19,7 +19,7 @@ impl std::fmt::Debug for Headers { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str("Headers {\n")?; for (k, v) in self.entries() { - f.write_str(&format!("{} = {}\n", k, v))?; + f.write_str(&format!("{k} = {v}\n"))?; } f.write_str("}\n") } diff --git a/worker/src/request.rs b/worker/src/request.rs index 89b3d5b3..d65cce95 100644 --- a/worker/src/request.rs +++ b/worker/src/request.rs @@ -230,7 +230,7 @@ impl Request { pub fn url(&self) -> Result { let url = self.edge_request.url(); url.parse() - .map_err(|e| Error::RustError(format!("failed to parse Url from {}: {}", e, url))) + .map_err(|e| Error::RustError(format!("failed to parse Url from {e}: {url}"))) } #[allow(clippy::should_implement_trait)]