From 6b0c036aa0cc76289d8fe260779774c9667c9637 Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Sun, 2 Oct 2022 00:24:17 +0800 Subject: [PATCH] fix Rust warnings --- examples/src/basic.rs | 2 +- examples/src/bin/global_context.rs | 4 +--- examples/src/bin/middleware.rs | 2 +- pnpm-lock.yaml | 3 --- src/integrations/httpz.rs | 28 ++++++++++++++-------------- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/examples/src/basic.rs b/examples/src/basic.rs index 2bad6228..40175830 100644 --- a/examples/src/basic.rs +++ b/examples/src/basic.rs @@ -6,7 +6,7 @@ pub fn mount() -> RouterBuilder { Router::new() .query("version", |t| t(|_, _: ()| env!("CARGO_PKG_VERSION"))) .query("echo", |t| t(|_, v: String| v)) - .query("echoAsync", |t| t(|ctx, _: i32| async move { 42 })) + .query("echoAsync", |t| t(|_, _: i32| async move { 42 })) .query("error", |t| { t(|_, _: ()| { Err(rspc::Error::new( diff --git a/examples/src/bin/global_context.rs b/examples/src/bin/global_context.rs index 1b92b962..d155fdd1 100644 --- a/examples/src/bin/global_context.rs +++ b/examples/src/bin/global_context.rs @@ -6,9 +6,7 @@ use std::{ }, }; -use rspc::{Config, Router, Type}; -use serde::Serialize; -use serde_json::{json, Value}; +use rspc::{Config, Router}; #[derive(Clone)] pub struct MyCtx { diff --git a/examples/src/bin/middleware.rs b/examples/src/bin/middleware.rs index 0aa6158c..55f8c889 100644 --- a/examples/src/bin/middleware.rs +++ b/examples/src/bin/middleware.rs @@ -91,7 +91,7 @@ async fn main() { }) // Reject all middleware .middleware(|mw| { - mw.middleware(|mw| async move { + mw.middleware(|_mw| async move { Err(rspc::Error::new( ErrorCode::Unauthorized, "Unauthorized".into(), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f65b95ad..f30e2570 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,9 +71,6 @@ importers: '@astrojs/solid-js': 1.1.0_solid-js@1.5.7 '@types/react': 18.0.21 - examples/axum: - specifiers: {} - examples/nextjs: specifiers: '@rspc/client': workspace:* diff --git a/src/integrations/httpz.rs b/src/integrations/httpz.rs index 679ef6a4..5eb3d4e2 100644 --- a/src/integrations/httpz.rs +++ b/src/integrations/httpz.rs @@ -396,9 +396,9 @@ where }; let ctx = match ctx { Ok(v) => v, - Err(e) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error executing context function: {}", e); + tracing::error!("Error executing context function: {}", _err); return Ok(( Response::builder() @@ -451,9 +451,9 @@ where .status(StatusCode::OK) .header("Content-Type", "application/json") .body(v)?, - Err(e) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error serializing response: {}", e); + tracing::error!("Error serializing response: {}", _err); Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) @@ -492,17 +492,17 @@ where msg = rx.recv() => { match socket.send(Message::Text(match serde_json::to_string(&msg) { Ok(v) => v, - Err(err) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error serializing websocket message: {}", err); + tracing::error!("Error serializing websocket message: {}", _err); continue; } })).await { Ok(_) => {} - Err(err) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error sending websocket message: {}", err); + tracing::error!("Error sending websocket message: {}", _err); continue; } @@ -526,17 +526,17 @@ where match res { Ok(v) => v, - Err(err) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error parsing websocket message: {}", err); + tracing::error!("Error parsing websocket message: {}", _err); continue; } } } - Some(Err(err)) => { + Some(Err(_err)) => { #[cfg(feature = "tracing")] - tracing::error!("Error in websocket: {}", err); + tracing::error!("Error in websocket: {}", _err); continue; }, @@ -555,9 +555,9 @@ where handle_json_rpc(match ctx { Ok(v) => v, - Err(e) => { + Err(_err) => { #[cfg(feature = "tracing")] - tracing::error!("Error executing context function: {}", e); + tracing::error!("Error executing context function: {}", _err); continue; }