Fix clippy warnings added in nightly (#1833)

This commit is contained in:
Nutomic 2021-10-12 16:46:26 +00:00 committed by Dessalines
parent 2eb43889a4
commit 805beb7368
12 changed files with 23 additions and 23 deletions

View file

@ -188,7 +188,7 @@ impl Perform for CreateCommentLike {
// Only add the like if the score isnt 0 // Only add the like if the score isnt 0
let comment = orig_comment.comment; let comment = orig_comment.comment;
let object = PostOrComment::Comment(Box::new(comment)); let object = PostOrComment::Comment(comment);
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
if do_add { if do_add {
let like_form2 = like_form.clone(); let like_form2 = like_form.clone();

View file

@ -409,7 +409,7 @@ impl Perform for TransferCommunity {
}) })
.await??; .await??;
let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??; let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
// Making sure the site creator, if an admin, is at the top // Making sure the site creator, if an admin, is at the top
let creator_index = admins let creator_index = admins

View file

@ -375,7 +375,7 @@ impl Perform for AddAdmin {
}) })
.await??; .await??;
let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??; let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
let creator_index = admins let creator_index = admins
.iter() .iter()
.position(|r| r.person.id == site_creator_id) .position(|r| r.person.id == site_creator_id)

View file

@ -472,9 +472,9 @@ impl Perform for TransferSite {
blocking(context.pool(), move |conn| ModAdd::create(conn, &form)).await??; blocking(context.pool(), move |conn| ModAdd::create(conn, &form)).await??;
let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??; let site_view = blocking(context.pool(), SiteView::read).await??;
let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??; let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
let creator_index = admins let creator_index = admins
.iter() .iter()
.position(|r| r.person.id == site_view.creator.id) .position(|r| r.person.id == site_view.creator.id)
@ -482,7 +482,7 @@ impl Perform for TransferSite {
let creator_person = admins.remove(creator_index); let creator_person = admins.remove(creator_index);
admins.insert(0, creator_person); admins.insert(0, creator_person);
let banned = blocking(context.pool(), move |conn| PersonViewSafe::banned(conn)).await??; let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
let federated_instances = build_federated_instances( let federated_instances = build_federated_instances(
context.pool(), context.pool(),
&context.settings().federation, &context.settings().federation,

View file

@ -142,7 +142,7 @@ impl PerformCrud for CreateComment {
return Err(ApiError::err("couldnt_like_comment").into()); return Err(ApiError::err("couldnt_like_comment").into());
} }
let object = PostOrComment::Comment(Box::new(updated_comment)); let object = PostOrComment::Comment(updated_comment);
Vote::send( Vote::send(
&object, &object,
&local_user_view.person, &local_user_view.person,

View file

@ -76,7 +76,7 @@ impl PerformCrud for CreateSite {
return Err(ApiError::err("site_already_exists").into()); return Err(ApiError::err("site_already_exists").into());
} }
let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??; let site_view = blocking(context.pool(), SiteView::read).await??;
Ok(SiteResponse { site_view }) Ok(SiteResponse { site_view })
} }

View file

@ -30,7 +30,7 @@ impl PerformCrud for GetSite {
) -> Result<GetSiteResponse, LemmyError> { ) -> Result<GetSiteResponse, LemmyError> {
let data: &GetSite = self; let data: &GetSite = self;
let site_view = match blocking(context.pool(), move |conn| SiteView::read(conn)).await? { let site_view = match blocking(context.pool(), SiteView::read).await? {
Ok(site_view) => Some(site_view), Ok(site_view) => Some(site_view),
// If the site isn't created yet, check the setup // If the site isn't created yet, check the setup
Err(_) => { Err(_) => {
@ -61,14 +61,14 @@ impl PerformCrud for GetSite {
}; };
create_site.perform(context, websocket_id).await?; create_site.perform(context, websocket_id).await?;
info!("Site {} created", setup.site_name); info!("Site {} created", setup.site_name);
Some(blocking(context.pool(), move |conn| SiteView::read(conn)).await??) Some(blocking(context.pool(), SiteView::read).await??)
} else { } else {
None None
} }
} }
}; };
let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??; let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
// Make sure the site creator is the top admin // Make sure the site creator is the top admin
if let Some(site_view) = site_view.to_owned() { if let Some(site_view) = site_view.to_owned() {
@ -81,7 +81,7 @@ impl PerformCrud for GetSite {
} }
} }
let banned = blocking(context.pool(), move |conn| PersonViewSafe::banned(conn)).await??; let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
let online = context let online = context
.chat_server() .chat_server()

View file

@ -69,7 +69,7 @@ impl PerformCrud for EditSite {
return Err(ApiError::err("couldnt_update_site").into()); return Err(ApiError::err("couldnt_update_site").into());
} }
let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??; let site_view = blocking(context.pool(), SiteView::read).await??;
let res = SiteResponse { site_view }; let res = SiteResponse { site_view };

View file

@ -111,7 +111,7 @@ impl ActivityHandler for UndoVote {
.await?; .await?;
match object { match object {
PostOrComment::Post(p) => undo_vote_post(actor, p.deref(), context).await, PostOrComment::Post(p) => undo_vote_post(actor, p.deref(), context).await,
PostOrComment::Comment(c) => undo_vote_comment(actor, c.deref(), context).await, PostOrComment::Comment(c) => undo_vote_comment(actor, &c, context).await,
} }
} }
} }

View file

@ -131,7 +131,7 @@ impl ActivityHandler for Vote {
let object = self.object.dereference(context, request_counter).await?; let object = self.object.dereference(context, request_counter).await?;
match object { match object {
PostOrComment::Post(p) => vote_post(&self.kind, actor, p.deref(), context).await, PostOrComment::Post(p) => vote_post(&self.kind, actor, p.deref(), context).await,
PostOrComment::Comment(c) => vote_comment(&self.kind, actor, c.deref(), context).await, PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await,
} }
} }
} }

View file

@ -16,20 +16,20 @@ use url::Url;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum PostOrComment { pub enum PostOrComment {
Comment(Box<Comment>),
Post(Box<Post>), Post(Box<Post>),
Comment(Comment),
} }
pub enum PostOrCommentForm { pub enum PostOrCommentForm {
PostForm(PostForm), PostForm(Box<PostForm>),
CommentForm(CommentForm), CommentForm(CommentForm),
} }
#[derive(Deserialize)] #[derive(Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum PageOrNote { pub enum PageOrNote {
Page(Page), Page(Box<Page>),
Note(Note), Note(Box<Note>),
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
@ -46,7 +46,7 @@ impl ApubObject for PostOrComment {
let post = Post::read_from_apub_id(conn, object_id); let post = Post::read_from_apub_id(conn, object_id);
Ok(match post { Ok(match post {
Ok(o) => PostOrComment::Post(Box::new(o)), Ok(o) => PostOrComment::Post(Box::new(o)),
Err(_) => PostOrComment::Comment(Box::new(Comment::read_from_apub_id(conn, object_id)?)), Err(_) => PostOrComment::Comment(Comment::read_from_apub_id(conn, object_id)?),
}) })
} }
} }
@ -68,9 +68,9 @@ impl FromApub for PostOrComment {
PageOrNote::Page(p) => PostOrComment::Post(Box::new( PageOrNote::Page(p) => PostOrComment::Post(Box::new(
Post::from_apub(p, context, expected_domain, request_counter).await?, Post::from_apub(p, context, expected_domain, request_counter).await?,
)), )),
PageOrNote::Note(n) => PostOrComment::Comment(Box::new( PageOrNote::Note(n) => PostOrComment::Comment(
Comment::from_apub(n, context, expected_domain, request_counter).await?, Comment::from_apub(n, context, expected_domain, request_counter).await?,
)), ),
}) })
} }
} }

View file

@ -83,7 +83,7 @@ async fn get_feed_data(
listing_type: ListingType, listing_type: ListingType,
sort_type: SortType, sort_type: SortType,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??; let site_view = blocking(context.pool(), SiteView::read).await??;
let posts = blocking(context.pool(), move |conn| { let posts = blocking(context.pool(), move |conn| {
PostQueryBuilder::create(conn) PostQueryBuilder::create(conn)