From 09621d36bbc81428f73378a2cfd361d371308b87 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 22 Nov 2024 22:34:10 -0500 Subject: [PATCH] Fixing a few clippy recommendations on 1.84 nightly. --- crates/db_schema/src/utils.rs | 4 ++-- crates/db_views/src/comment_view.rs | 13 ++++++++----- crates/db_views/src/post_view.rs | 11 +++++++---- crates/db_views_actor/src/community_view.rs | 13 ++++++++----- crates/federate/src/send.rs | 2 +- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index ed9ca0ab4..aa213887e 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -96,7 +96,7 @@ pub async fn get_conn<'a, 'b: 'a>(pool: &'a mut DbPool<'b>) -> Result }) } -impl<'a> Deref for DbConn<'a> { +impl Deref for DbConn<'_> { type Target = AsyncPgConnection; fn deref(&self) -> &Self::Target { @@ -107,7 +107,7 @@ impl<'a> Deref for DbConn<'a> { } } -impl<'a> DerefMut for DbConn<'a> { +impl DerefMut for DbConn<'_> { fn deref_mut(&mut self) -> &mut Self::Target { match self { DbConn::Pool(conn) => conn.deref_mut(), diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 22b7b3de4..1740a36be 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -50,9 +50,12 @@ use lemmy_db_schema::{ ListingType, }; +type QueriesReadTypes<'a> = (CommentId, Option<&'a LocalUser>); +type QueriesListTypes<'a> = (CommentQuery<'a>, &'a Site); + fn queries<'a>() -> Queries< - impl ReadFn<'a, CommentView, (CommentId, Option<&'a LocalUser>)>, - impl ListFn<'a, CommentView, (CommentQuery<'a>, &'a Site)>, + impl ReadFn<'a, CommentView, QueriesReadTypes<'a>>, + impl ListFn<'a, CommentView, QueriesListTypes<'a>>, > { let creator_is_admin = exists( local_user::table.filter( @@ -308,10 +311,10 @@ fn queries<'a>() -> Queries< } impl CommentView { - pub async fn read<'a>( + pub async fn read( pool: &mut DbPool<'_>, comment_id: CommentId, - my_local_user: Option<&'a LocalUser>, + my_local_user: Option<&'_ LocalUser>, ) -> Result { // If a person is given, then my_vote (res.9), if None, should be 0, not null // Necessary to differentiate between other person's votes @@ -345,7 +348,7 @@ pub struct CommentQuery<'a> { pub max_depth: Option, } -impl<'a> CommentQuery<'a> { +impl CommentQuery<'_> { pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result, Error> { Ok( queries() diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 4363d2a3e..e2eac77a5 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -62,9 +62,12 @@ use lemmy_db_schema::{ use tracing::debug; use PostSortType::*; +type QueriesReadTypes<'a> = (PostId, Option<&'a LocalUser>, bool); +type QueriesListTypes<'a> = (PostQuery<'a>, &'a Site); + fn queries<'a>() -> Queries< - impl ReadFn<'a, PostView, (PostId, Option<&'a LocalUser>, bool)>, - impl ListFn<'a, PostView, (PostQuery<'a>, &'a Site)>, + impl ReadFn<'a, PostView, QueriesReadTypes<'a>>, + impl ListFn<'a, PostView, QueriesListTypes<'a>>, > { let creator_is_admin = exists( local_user::table.filter( @@ -431,10 +434,10 @@ fn queries<'a>() -> Queries< } impl PostView { - pub async fn read<'a>( + pub async fn read( pool: &mut DbPool<'_>, post_id: PostId, - my_local_user: Option<&'a LocalUser>, + my_local_user: Option<&'_ LocalUser>, is_mod_or_admin: bool, ) -> Result { queries() diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index da349c93e..f6ce82d37 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -34,9 +34,12 @@ use lemmy_db_schema::{ }; use lemmy_utils::error::{LemmyErrorType, LemmyResult}; +type QueriesReadTypes<'a> = (CommunityId, Option<&'a LocalUser>, bool); +type QueriesListTypes<'a> = (CommunityQuery<'a>, &'a Site); + fn queries<'a>() -> Queries< - impl ReadFn<'a, CommunityView, (CommunityId, Option<&'a LocalUser>, bool)>, - impl ListFn<'a, CommunityView, (CommunityQuery<'a>, &'a Site)>, + impl ReadFn<'a, CommunityView, QueriesReadTypes<'a>>, + impl ListFn<'a, CommunityView, QueriesListTypes<'a>>, > { let all_joins = |query: community::BoxedQuery<'a, Pg>, my_local_user: Option<&'a LocalUser>| { query @@ -166,10 +169,10 @@ fn queries<'a>() -> Queries< } impl CommunityView { - pub async fn read<'a>( + pub async fn read( pool: &mut DbPool<'_>, community_id: CommunityId, - my_local_user: Option<&'a LocalUser>, + my_local_user: Option<&'_ LocalUser>, is_mod_or_admin: bool, ) -> Result { queries() @@ -253,7 +256,7 @@ pub struct CommunityQuery<'a> { pub limit: Option, } -impl<'a> CommunityQuery<'a> { +impl CommunityQuery<'_> { pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result, Error> { queries().list(pool, (self, site)).await } diff --git a/crates/federate/src/send.rs b/crates/federate/src/send.rs index 01d620eb0..d77ebe9f7 100644 --- a/crates/federate/src/send.rs +++ b/crates/federate/src/send.rs @@ -84,7 +84,7 @@ pub(crate) struct SendRetryTask<'a> { pub stop: CancellationToken, } -impl<'a> SendRetryTask<'a> { +impl SendRetryTask<'_> { // this function will return successfully when (a) send succeeded or (b) worker cancelled // and will return an error if an internal error occurred (send errors cause an infinite loop) pub async fn send_retry_loop(self) -> Result<()> {