From 729484af4c1405b417bf0ec154857160a77eca3e Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Wed, 27 Sep 2023 12:47:38 +0400 Subject: [PATCH] satisfy clippy --- crates/teloxide-core/src/local_macros.rs | 2 ++ crates/teloxide-core/src/payloads/codegen.rs | 5 ++++- crates/teloxide-core/src/requests/requester.rs | 2 ++ crates/teloxide-core/src/types.rs | 2 +- crates/teloxide-core/src/types/passport_element_error.rs | 4 ++-- crates/teloxide-core/src/types/recipient.rs | 2 +- crates/teloxide-core/src/types/thread_id.rs | 4 ++-- .../src/dispatching/dialogue/storage/sqlite_storage.rs | 8 ++++---- crates/teloxide/src/utils/markdown.rs | 5 +---- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 6b66dfe4..913c1a81 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -1333,6 +1333,8 @@ macro_rules! requester_forward { } #[test] +// waffle: efficiency is not important here, and I don't want to rewrite this +#[allow(clippy::format_collect)] fn codegen_requester_forward() { use crate::codegen::{ add_hidden_preamble, diff --git a/crates/teloxide-core/src/payloads/codegen.rs b/crates/teloxide-core/src/payloads/codegen.rs index 771caa7d..5c78f623 100644 --- a/crates/teloxide-core/src/payloads/codegen.rs +++ b/crates/teloxide-core/src/payloads/codegen.rs @@ -1,3 +1,6 @@ +// waffle: efficiency is not important here, and I don't want to rewrite this +#![allow(clippy::format_collect)] + use std::{borrow::Borrow, collections::HashSet, ops::Deref}; use itertools::Itertools; @@ -51,7 +54,7 @@ fn codegen_payloads() { let multipart = multipart_input_file_fields(&method) .map(|field| format!(" @[multipart = {}]\n", field.join(", "))) - .unwrap_or_else(String::new); + .unwrap_or_default(); let derive = if !multipart.is_empty() || matches!( diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 5336731e..887aca6d 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -1337,6 +1337,8 @@ where // } #[test] +// waffle: efficiency is not important here, and I don't want to rewrite this +#[allow(clippy::format_collect)] fn codegen_requester_methods() { use crate::codegen::{ add_hidden_preamble, diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 890dfb1a..0a94ce54 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -315,7 +315,7 @@ pub(crate) mod serde_opt_date_from_unix_timestamp { } { - let json = r#"{}"#; + let json = "{}"; let Struct { date } = serde_json::from_str(json).unwrap(); assert_eq!(date, None); diff --git a/crates/teloxide-core/src/types/passport_element_error.rs b/crates/teloxide-core/src/types/passport_element_error.rs index a3b94d0f..f6c72509 100644 --- a/crates/teloxide-core/src/types/passport_element_error.rs +++ b/crates/teloxide-core/src/types/passport_element_error.rs @@ -203,8 +203,8 @@ impl PassportElementErrorReverseSide { } } -//// Represents an issue with the selfie with a document. -// +/// Represents an issue with the selfie with a document. +/// /// The error is considered resolved when the file with the selfie changes. /// /// [The official docs](https://core.telegram.org/bots/api#passportelementerrorselfie). diff --git a/crates/teloxide-core/src/types/recipient.rs b/crates/teloxide-core/src/types/recipient.rs index 8818f559..d15f9003 100644 --- a/crates/teloxide-core/src/types/recipient.rs +++ b/crates/teloxide-core/src/types/recipient.rs @@ -31,7 +31,7 @@ mod tests { #[test] fn chat_id_id_serialization() { - let expected_json = String::from(r#"123456"#); + let expected_json = String::from("123456"); let actual_json = serde_json::to_string(&Recipient::Id(ChatId(123_456))).unwrap(); assert_eq!(expected_json, actual_json) diff --git a/crates/teloxide-core/src/types/thread_id.rs b/crates/teloxide-core/src/types/thread_id.rs index 2e3f50ac..37e55568 100644 --- a/crates/teloxide-core/src/types/thread_id.rs +++ b/crates/teloxide-core/src/types/thread_id.rs @@ -66,7 +66,7 @@ mod tests { #[test] fn smoke_deser() { - let json = r#"123"#; + let json = "123"; let mid: ThreadId = serde_json::from_str(json).unwrap(); assert_eq!(mid, ThreadId(MessageId(123))); } @@ -75,6 +75,6 @@ mod tests { fn smoke_ser() { let mid: ThreadId = ThreadId(MessageId(123)); let json = serde_json::to_string(&mid).unwrap(); - assert_eq!(json, r#"123"#); + assert_eq!(json, "123"); } } diff --git a/crates/teloxide/src/dispatching/dialogue/storage/sqlite_storage.rs b/crates/teloxide/src/dispatching/dialogue/storage/sqlite_storage.rs index 32425b24..00974be9 100644 --- a/crates/teloxide/src/dispatching/dialogue/storage/sqlite_storage.rs +++ b/crates/teloxide/src/dispatching/dialogue/storage/sqlite_storage.rs @@ -42,12 +42,12 @@ impl SqliteStorage { let pool = SqlitePool::connect(format!("sqlite:{path}?mode=rwc").as_str()).await?; let mut conn = pool.acquire().await?; sqlx::query( - r#" + " CREATE TABLE IF NOT EXISTS teloxide_dialogues ( chat_id BIGINT PRIMARY KEY, dialogue BLOB NOT NULL ); - "#, + ", ) .execute(&mut conn) .await?; @@ -98,10 +98,10 @@ where .await? .execute( sqlx::query( - r#" + " INSERT INTO teloxide_dialogues VALUES (?, ?) ON CONFLICT(chat_id) DO UPDATE SET dialogue=excluded.dialogue - "#, + ", ) .bind(chat_id) .bind(d), diff --git a/crates/teloxide/src/utils/markdown.rs b/crates/teloxide/src/utils/markdown.rs index 4e072e6b..e48b10c6 100644 --- a/crates/teloxide/src/utils/markdown.rs +++ b/crates/teloxide/src/utils/markdown.rs @@ -283,9 +283,6 @@ mod tests { is_premium: false, added_to_attachment_menu: false, }; - assert_eq!( - user_mention_or_link(&user_without_username), - r#"[Name](tg://user/?id=123456789)"# - ) + assert_eq!(user_mention_or_link(&user_without_username), "[Name](tg://user/?id=123456789)") } }