Suppress clippy

This commit is contained in:
Waffle 2019-12-07 15:26:03 +03:00
parent a9c97c5074
commit fa099b4ca8
13 changed files with 34 additions and 39 deletions

View file

@ -82,9 +82,10 @@ where
pub struct IgnoreSafe;
#[cfg(feature = "never-type")]
#[allow(unreachable_code)]
#[async_trait]
impl ErrorPolicy<!> for IgnoreSafe {
async fn handle_error(&self, never: !)
async fn handle_error(&self, _: !)
where
!: 'async_trait,
{
@ -92,14 +93,13 @@ impl ErrorPolicy<!> for IgnoreSafe {
}
}
#[allow(unreachable_code)]
#[async_trait]
impl ErrorPolicy<Infallible> for IgnoreSafe {
async fn handle_error(&self, inf: Infallible)
async fn handle_error(&self, _: Infallible)
where
Infallible: 'async_trait,
{
match inf {}
}
{}
}
/// Implementation of `ErrorPolicy` for `async fn`s

View file

@ -313,7 +313,7 @@ mod tests {
let counter = &AtomicI32::new(0);
let counter2 = &AtomicI32::new(0);
let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async { () })
let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
.message_handler(true, |_mes: Message| {
async move {
counter.fetch_add(1, Ordering::SeqCst);
@ -335,9 +335,9 @@ mod tests {
fn message() -> Message {
Message {
id: 6534,
date: 1567898953,
date: 1_567_898_953,
chat: Chat {
id: 218485655,
id: 218_485_655,
photo: None,
kind: ChatKind::Private {
type_: (),
@ -348,7 +348,7 @@ mod tests {
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 457569668,
id: 457_569_668,
is_bot: true,
first_name: "BT".to_string(),
last_name: None,

View file

@ -1,3 +1,6 @@
#![allow(clippy::needless_doctest_main)]
#![allow(clippy::unit_arg)] // TODO
#![allow(clippy::ptr_arg)] // TODO
#![cfg_attr(feature = "never-type", feature(never_type))]
#[macro_use]

View file

@ -15,7 +15,7 @@ use crate::{
/// [Update]: crate::types::Update
/// [Vec]: std::alloc::Vec
#[serde_with_macros::skip_serializing_none]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize, Default)]
pub struct GetUpdates {
/// Identifier of the first update to be returned. Must be greater by one
/// than the highest among the identifiers of previously received updates.

View file

@ -97,7 +97,7 @@ impl json::Request<'_, SendMessage> {
}
pub fn disable_notification(mut self, value: bool) -> Self {
self.payload.disable_notification = Some(value.into());
self.payload.disable_notification = Some(value);
self
}

View file

@ -37,7 +37,7 @@ mod tests {
performer: Some("Performer".to_string()),
title: Some("Title".to_string()),
mime_type: Some("MimeType".to_string()),
file_size: Some(123456),
file_size: Some(123_456),
thumb: Some(PhotoSize {
file_id: "id".to_string(),
width: 320,

View file

@ -20,7 +20,7 @@ mod tests {
#[test]
fn chat_id_id_serialization() {
let expected_json = String::from(r#"123456"#);
let actual_json = serde_json::to_string(&ChatId::Id(123456)).unwrap();
let actual_json = serde_json::to_string(&ChatId::Id(123_456)).unwrap();
assert_eq!(expected_json, actual_json)
}

View file

@ -106,7 +106,7 @@ mod tests {
language_code: None,
},
status: ChatMemberStatus::Creator,
until_date: Some(123456),
until_date: Some(123_456),
can_be_edited: Some(true),
can_change_info: Some(true),
can_post_messages: Some(true),

View file

@ -64,7 +64,7 @@ mod tests {
let markup = InlineKeyboardMarkup::new()
.append_row(vec![button1.clone(), button2.clone()]);
let expected = InlineKeyboardMarkup {
inline_keyboard: vec![vec![button1.clone(), button2.clone()]],
inline_keyboard: vec![vec![button1, button2]],
};
assert_eq!(markup, expected);
}
@ -83,7 +83,7 @@ mod tests {
.append_row(vec![button1.clone()])
.append_to_row(button2.clone(), 0);
let expected = InlineKeyboardMarkup {
inline_keyboard: vec![vec![button1.clone(), button2.clone()]],
inline_keyboard: vec![vec![button1, button2]],
};
assert_eq!(markup, expected);
}
@ -102,7 +102,7 @@ mod tests {
.append_row(vec![button1.clone()])
.append_to_row(button2.clone(), 1);
let expected = InlineKeyboardMarkup {
inline_keyboard: vec![vec![button1.clone()], vec![button2.clone()]],
inline_keyboard: vec![vec![button1], vec![button2]],
};
assert_eq!(markup, expected);
}

View file

@ -1,3 +1,5 @@
#![allow(clippy::large_enum_variant)]
use crate::types::{
InlineQueryResultArticle, InlineQueryResultAudio,
InlineQueryResultCachedAudio, InlineQueryResultCachedDocument,
@ -11,7 +13,8 @@ use crate::types::{
};
/// This object represents one result of an inline query.
#[derive(Debug, Serialize, PartialEq, Clone, From)]
//#[derive(Debug, Serialize, PartialEq, Clone, From)]
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, From)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum InlineQueryResult {
@ -54,21 +57,6 @@ mod tests {
InlineQueryResult, InlineQueryResultCachedAudio, InputMessageContent,
};
#[test]
fn into() {
let structure =
InlineQueryResult::CachedAudio(InlineQueryResultCachedAudio {
id: String::from("id"),
audio_file_id: String::from("audio_file_id"),
caption: None,
parse_mode: None,
reply_markup: None,
input_message_content: None,
});
let _: InlineQueryResult = structure.into();
}
#[test]
fn cached_audio_min_serialize() {
let structure =

View file

@ -1,3 +1,5 @@
#![allow(clippy::large_enum_variant)]
use crate::types::{
Animation, Audio, Chat, Contact, Document, Game, InlineKeyboardMarkup,
Invoice, Location, MessageEntity, PassportData, PhotoSize, Poll, Sticker,

View file

@ -11,7 +11,7 @@ mod tests {
#[test]
fn migrate_to_chat_id_deserialization() {
let expected = ResponseParameters::MigrateToChatId(123456);
let expected = ResponseParameters::MigrateToChatId(123_456);
let actual: ResponseParameters =
serde_json::from_str(r#"{"migrate_to_chat_id":123456}"#).unwrap();
@ -20,7 +20,7 @@ mod tests {
#[test]
fn retry_after_deserialization() {
let expected = ResponseParameters::RetryAfter(123456);
let expected = ResponseParameters::RetryAfter(123_456);
let actual: ResponseParameters =
serde_json::from_str(r#"{"retry_after":123456}"#).unwrap();

View file

@ -1,3 +1,5 @@
#![allow(clippy::large_enum_variant)]
use crate::types::{CallbackQuery, ChosenInlineResult, Message};
#[derive(Debug, Deserialize, PartialEq, Clone)]
@ -54,12 +56,12 @@ mod test {
}"#;
let expected: Update = Update {
id: 892252934,
id: 892_252_934,
kind: UpdateKind::Message(Message {
id: 6557,
date: 1569518342,
date: 1_569_518_342,
chat: Chat {
id: 218485655,
id: 218_485_655,
kind: ChatKind::Private {
type_: (),
username: Some(String::from("WaffleLapkin")),
@ -70,7 +72,7 @@ mod test {
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 218485655,
id: 218_485_655,
is_bot: false,
first_name: String::from("Waffle"),
last_name: None,