Fixing a few clippy recommendations on 1.84 nightly. (#5222)

This commit is contained in:
Dessalines 2024-11-25 04:06:39 -05:00 committed by GitHub
parent b8dda06f5b
commit 41bd830389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 26 additions and 17 deletions

View file

@ -96,7 +96,7 @@ pub async fn get_conn<'a, 'b: 'a>(pool: &'a mut DbPool<'b>) -> Result<DbConn<'a>
}) })
} }
impl<'a> Deref for DbConn<'a> { impl Deref for DbConn<'_> {
type Target = AsyncPgConnection; type Target = AsyncPgConnection;
fn deref(&self) -> &Self::Target { 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 { fn deref_mut(&mut self) -> &mut Self::Target {
match self { match self {
DbConn::Pool(conn) => conn.deref_mut(), DbConn::Pool(conn) => conn.deref_mut(),

View file

@ -50,9 +50,12 @@ use lemmy_db_schema::{
ListingType, ListingType,
}; };
type QueriesReadTypes<'a> = (CommentId, Option<&'a LocalUser>);
type QueriesListTypes<'a> = (CommentQuery<'a>, &'a Site);
fn queries<'a>() -> Queries< fn queries<'a>() -> Queries<
impl ReadFn<'a, CommentView, (CommentId, Option<&'a LocalUser>)>, impl ReadFn<'a, CommentView, QueriesReadTypes<'a>>,
impl ListFn<'a, CommentView, (CommentQuery<'a>, &'a Site)>, impl ListFn<'a, CommentView, QueriesListTypes<'a>>,
> { > {
let creator_is_admin = exists( let creator_is_admin = exists(
local_user::table.filter( local_user::table.filter(
@ -308,10 +311,10 @@ fn queries<'a>() -> Queries<
} }
impl CommentView { impl CommentView {
pub async fn read<'a>( pub async fn read(
pool: &mut DbPool<'_>, pool: &mut DbPool<'_>,
comment_id: CommentId, comment_id: CommentId,
my_local_user: Option<&'a LocalUser>, my_local_user: Option<&'_ LocalUser>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
// If a person is given, then my_vote (res.9), if None, should be 0, not null // 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 // Necessary to differentiate between other person's votes
@ -345,7 +348,7 @@ pub struct CommentQuery<'a> {
pub max_depth: Option<i32>, pub max_depth: Option<i32>,
} }
impl<'a> CommentQuery<'a> { impl CommentQuery<'_> {
pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result<Vec<CommentView>, Error> { pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result<Vec<CommentView>, Error> {
Ok( Ok(
queries() queries()

View file

@ -62,9 +62,12 @@ use lemmy_db_schema::{
use tracing::debug; use tracing::debug;
use PostSortType::*; use PostSortType::*;
type QueriesReadTypes<'a> = (PostId, Option<&'a LocalUser>, bool);
type QueriesListTypes<'a> = (PostQuery<'a>, &'a Site);
fn queries<'a>() -> Queries< fn queries<'a>() -> Queries<
impl ReadFn<'a, PostView, (PostId, Option<&'a LocalUser>, bool)>, impl ReadFn<'a, PostView, QueriesReadTypes<'a>>,
impl ListFn<'a, PostView, (PostQuery<'a>, &'a Site)>, impl ListFn<'a, PostView, QueriesListTypes<'a>>,
> { > {
let creator_is_admin = exists( let creator_is_admin = exists(
local_user::table.filter( local_user::table.filter(
@ -431,10 +434,10 @@ fn queries<'a>() -> Queries<
} }
impl PostView { impl PostView {
pub async fn read<'a>( pub async fn read(
pool: &mut DbPool<'_>, pool: &mut DbPool<'_>,
post_id: PostId, post_id: PostId,
my_local_user: Option<&'a LocalUser>, my_local_user: Option<&'_ LocalUser>,
is_mod_or_admin: bool, is_mod_or_admin: bool,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
queries() queries()

View file

@ -34,9 +34,12 @@ use lemmy_db_schema::{
}; };
use lemmy_utils::error::{LemmyErrorType, LemmyResult}; 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< fn queries<'a>() -> Queries<
impl ReadFn<'a, CommunityView, (CommunityId, Option<&'a LocalUser>, bool)>, impl ReadFn<'a, CommunityView, QueriesReadTypes<'a>>,
impl ListFn<'a, CommunityView, (CommunityQuery<'a>, &'a Site)>, impl ListFn<'a, CommunityView, QueriesListTypes<'a>>,
> { > {
let all_joins = |query: community::BoxedQuery<'a, Pg>, my_local_user: Option<&'a LocalUser>| { let all_joins = |query: community::BoxedQuery<'a, Pg>, my_local_user: Option<&'a LocalUser>| {
query query
@ -166,10 +169,10 @@ fn queries<'a>() -> Queries<
} }
impl CommunityView { impl CommunityView {
pub async fn read<'a>( pub async fn read(
pool: &mut DbPool<'_>, pool: &mut DbPool<'_>,
community_id: CommunityId, community_id: CommunityId,
my_local_user: Option<&'a LocalUser>, my_local_user: Option<&'_ LocalUser>,
is_mod_or_admin: bool, is_mod_or_admin: bool,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
queries() queries()
@ -253,7 +256,7 @@ pub struct CommunityQuery<'a> {
pub limit: Option<i64>, pub limit: Option<i64>,
} }
impl<'a> CommunityQuery<'a> { impl CommunityQuery<'_> {
pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result<Vec<CommunityView>, Error> { pub async fn list(self, site: &Site, pool: &mut DbPool<'_>) -> Result<Vec<CommunityView>, Error> {
queries().list(pool, (self, site)).await queries().list(pool, (self, site)).await
} }

View file

@ -84,7 +84,7 @@ pub(crate) struct SendRetryTask<'a> {
pub stop: CancellationToken, pub stop: CancellationToken,
} }
impl<'a> SendRetryTask<'a> { impl SendRetryTask<'_> {
// this function will return successfully when (a) send succeeded or (b) worker cancelled // 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) // and will return an error if an internal error occurred (send errors cause an infinite loop)
pub async fn send_retry_loop(self) -> Result<()> { pub async fn send_retry_loop(self) -> Result<()> {