From 841fc1355ecef4636ad9f5ad6d081f72eeb868ac Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 21 May 2025 22:43:52 -0400 Subject: Remove a bunch of clippy suppressions. Notably, one of them was hiding a real (if unreachable) bug, by converting a "the token you have presented is not valid" scenario into an internal server error. --- src/channel/routes/channel/delete.rs | 5 +++-- src/channel/routes/channel/post.rs | 3 +-- src/channel/routes/post.rs | 5 +++-- src/invite/routes/invite/get.rs | 3 +-- src/message/routes/message/mod.rs | 3 +-- src/ui/assets.rs | 3 +-- src/ui/routes/login.rs | 1 - src/user/routes/logout/post.rs | 9 ++++++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/channel/routes/channel/delete.rs b/src/channel/routes/channel/delete.rs index 9c093c1..3db7772 100644 --- a/src/channel/routes/channel/delete.rs +++ b/src/channel/routes/channel/delete.rs @@ -41,7 +41,6 @@ pub struct Error(#[from] pub app::DeleteError); impl IntoResponse for Error { fn into_response(self) -> response::Response { let Self(error) = self; - #[allow(clippy::match_wildcard_for_single_variants)] match error { app::DeleteError::NotFound(_) | app::DeleteError::Deleted(_) => { NotFound(error).into_response() @@ -49,7 +48,9 @@ impl IntoResponse for Error { app::DeleteError::NotEmpty(_) => { (StatusCode::CONFLICT, error.to_string()).into_response() } - other => Internal::from(other).into_response(), + app::DeleteError::Name(_) | app::DeleteError::Database(_) => { + Internal::from(error).into_response() + } } } } diff --git a/src/channel/routes/channel/post.rs b/src/channel/routes/channel/post.rs index 0aad5e5..2547122 100644 --- a/src/channel/routes/channel/post.rs +++ b/src/channel/routes/channel/post.rs @@ -49,10 +49,9 @@ pub struct Error(#[from] pub SendError); impl IntoResponse for Error { fn into_response(self) -> response::Response { let Self(error) = self; - #[allow(clippy::match_wildcard_for_single_variants)] match error { SendError::ChannelNotFound(_) => NotFound(error).into_response(), - other => Internal::from(other).into_response(), + SendError::Name(_) | SendError::Database(_) => Internal::from(error).into_response(), } } } diff --git a/src/channel/routes/post.rs b/src/channel/routes/post.rs index 72eaad6..6ea9b61 100644 --- a/src/channel/routes/post.rs +++ b/src/channel/routes/post.rs @@ -49,7 +49,6 @@ pub struct Error(pub app::CreateError); impl IntoResponse for Error { fn into_response(self) -> response::Response { let Self(error) = self; - #[allow(clippy::match_wildcard_for_single_variants)] match error { app::CreateError::DuplicateName(_) => { (StatusCode::CONFLICT, error.to_string()).into_response() @@ -57,7 +56,9 @@ impl IntoResponse for Error { app::CreateError::InvalidName(_) => { (StatusCode::BAD_REQUEST, error.to_string()).into_response() } - other => Internal::from(other).into_response(), + app::CreateError::Name(_) | app::CreateError::Database(_) => { + Internal::from(error).into_response() + } } } } diff --git a/src/invite/routes/invite/get.rs b/src/invite/routes/invite/get.rs index c8b52f1..f862833 100644 --- a/src/invite/routes/invite/get.rs +++ b/src/invite/routes/invite/get.rs @@ -30,10 +30,9 @@ pub enum Error { impl IntoResponse for Error { fn into_response(self) -> Response { - #[allow(clippy::match_wildcard_for_single_variants)] match self { Self::NotFound(_) => NotFound(self).into_response(), - other => Internal::from(other).into_response(), + Self::Database(_) => Internal::from(self).into_response(), } } } diff --git a/src/message/routes/message/mod.rs b/src/message/routes/message/mod.rs index 4abd445..a05d344 100644 --- a/src/message/routes/message/mod.rs +++ b/src/message/routes/message/mod.rs @@ -47,7 +47,6 @@ pub mod delete { impl IntoResponse for Error { fn into_response(self) -> response::Response { let Self(error) = self; - #[allow(clippy::match_wildcard_for_single_variants)] match error { DeleteError::NotSender(_) => { (StatusCode::FORBIDDEN, error.to_string()).into_response() @@ -55,7 +54,7 @@ pub mod delete { DeleteError::NotFound(_) | DeleteError::Deleted(_) => { NotFound(error).into_response() } - other => Internal::from(other).into_response(), + DeleteError::Database(_) => Internal::from(error).into_response(), } } } diff --git a/src/ui/assets.rs b/src/ui/assets.rs index 142cdf9..642679b 100644 --- a/src/ui/assets.rs +++ b/src/ui/assets.rs @@ -54,10 +54,9 @@ pub enum Error { impl IntoResponse for Error { fn into_response(self) -> Response { - #[allow(clippy::match_wildcard_for_single_variants)] match self { Self::NotFound(_) => NotFound(self.to_string()).into_response(), - other => Internal::from(other).into_response(), + Self::Mime(_) => Internal::from(self).into_response(), } } } diff --git a/src/ui/routes/login.rs b/src/ui/routes/login.rs index 81a874c..39d45b9 100644 --- a/src/ui/routes/login.rs +++ b/src/ui/routes/login.rs @@ -4,7 +4,6 @@ pub mod get { ui::assets::{Asset, Assets}, }; - #[allow(clippy::unused_async)] pub async fn handler() -> Result { Assets::index() } diff --git a/src/user/routes/logout/post.rs b/src/user/routes/logout/post.rs index bb09b9f..0ac663e 100644 --- a/src/user/routes/logout/post.rs +++ b/src/user/routes/logout/post.rs @@ -38,10 +38,13 @@ pub struct Error(#[from] pub app::ValidateError); impl IntoResponse for Error { fn into_response(self) -> Response { let Self(error) = self; - #[allow(clippy::match_wildcard_for_single_variants)] match error { - app::ValidateError::InvalidToken => Unauthorized.into_response(), - other => Internal::from(other).into_response(), + app::ValidateError::InvalidToken | app::ValidateError::LoginDeleted => { + Unauthorized.into_response() + } + app::ValidateError::Name(_) | app::ValidateError::Database(_) => { + Internal::from(error).into_response() + } } } } -- cgit v1.2.3