Deny and address all warnings.

This commit is contained in:
Jimmy Cuadra 2019-07-19 15:47:14 -07:00
parent 95c3b929a5
commit de23971ee4
12 changed files with 27 additions and 34 deletions

View File

@ -1,7 +1,10 @@
//! Enums for heterogeneous collections of events, inclusive for every event type that implements
//! the trait of the same name.
use std::{convert::TryFrom, str::FromStr};
use std::str::FromStr;
use serde::{Serialize, Serializer};
use serde_json::{from_value, Value};
use crate::{
call::{
@ -48,9 +51,6 @@ use crate::{
CustomEvent, CustomRoomEvent, CustomStateEvent, EventType, InnerInvalidEvent, InvalidEvent,
};
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::{from_value, Value};
/// A basic event, room event, or state event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
@ -396,6 +396,7 @@ impl FromStr for Event {
type Err = InvalidEvent;
/// Attempt to create `Self` from parsing a string of JSON data.
#[allow(clippy::cognitive_complexity)]
fn from_str(json: &str) -> Result<Self, Self::Err> {
let value: Value = serde_json::from_str(json)?;
@ -799,6 +800,7 @@ impl FromStr for RoomEvent {
type Err = InvalidEvent;
/// Attempt to create `Self` from parsing a string of JSON data.
#[allow(clippy::cognitive_complexity)]
fn from_str(json: &str) -> Result<Self, Self::Err> {
let value: Value = serde_json::from_str(json)?;

View File

@ -1,9 +1,9 @@
//! Enums for heterogeneous collections of events, exclusive to event types that implement "at
//! most" the trait of the same name.
use std::{convert::TryFrom, str::FromStr};
use std::str::FromStr;
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Serialize, Serializer};
use serde_json::{from_value, Value};
pub use super::all::StateEvent;
@ -38,6 +38,7 @@ use crate::{
/// A basic event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum Event {
/// m.direct
Direct(DirectEvent),

View File

@ -2,8 +2,7 @@
use std::{convert::TryFrom, str::FromStr};
use js_int::UInt;
use ruma_identifiers::{DeviceId, EventId, RoomId, UserId};
use ruma_identifiers::DeviceId;
use serde::{de::Error, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::{from_value, Value};
@ -11,7 +10,7 @@ use super::{
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString,
VerificationMethod,
};
use crate::{Algorithm, Event, EventType, InnerInvalidEvent, InvalidEvent, InvalidInput};
use crate::{Event, EventType, InnerInvalidEvent, InvalidEvent, InvalidInput};
/// Begins an SAS key verification process.
///
@ -61,7 +60,7 @@ impl FromStr for StartEvent {
}
};
Ok(Self { content: content })
Ok(Self { content })
}
}
@ -388,12 +387,11 @@ impl Serialize for MSasV1Content {
#[cfg(test)]
mod tests {
use serde_json::{from_str, to_string};
use serde_json::to_string;
use super::{
HashAlgorithm, KeyAgreementProtocol, MSasV1Content, MSasV1ContentOptions,
MessageAuthenticationCode, ShortAuthenticationString, StartEvent, StartEventContent,
VerificationMethod,
};
#[test]

View File

@ -97,7 +97,7 @@
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![allow(warnings)]
#![deny(warnings)]
use std::{
error::Error,

View File

@ -331,12 +331,10 @@ impl<'de> Deserialize<'de> for PushCondition {
Ok(PushCondition::SenderNotificationPermission(condition))
}
unknown_kind => {
return Err(D::Error::custom(&format!(
unknown_kind => Err(D::Error::custom(&format!(
"unknown condition kind `{}`",
unknown_kind
)))
}
))),
}
}
}

View File

@ -8,8 +8,7 @@ use serde::{ser::SerializeStruct, Deserialize, Serialize, Serializer};
use serde_json::Value;
use crate::{
empty_string_as_none, Event, EventType, InnerInvalidEvent, InvalidEvent, InvalidInput,
RoomEvent, StateEvent,
empty_string_as_none, Event, EventType, InnerInvalidEvent, InvalidEvent, RoomEvent, StateEvent,
};
/// Informs the room as to which alias is the canonical one.
@ -231,8 +230,7 @@ mod tests {
use std::convert::TryFrom;
use js_int::UInt;
use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
use serde_json::Value;
use ruma_identifiers::{EventId, RoomAliasId, UserId};
use super::{CanonicalAliasEvent, CanonicalAliasEventContent};

View File

@ -7,7 +7,7 @@ use ruma_identifiers::{DeviceId, EventId, RoomId, UserId};
use serde::{de::Error, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::{from_value, Value};
use crate::{Algorithm, Event, EventType, InnerInvalidEvent, InvalidEvent, RoomEvent, StateEvent};
use crate::{Algorithm, Event, EventType, InnerInvalidEvent, InvalidEvent, RoomEvent};
/// This event type is used when sending encrypted events.
///
@ -83,7 +83,7 @@ impl FromStr for EncryptedEvent {
};
Ok(Self {
content: content,
content,
event_id: raw.event_id,
origin_server_ts: raw.origin_server_ts,
room_id: raw.room_id,

View File

@ -2,7 +2,6 @@
use std::collections::HashMap;
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};

View File

@ -12,7 +12,7 @@ use serde::{
use serde_json::{from_value, Value};
use super::{EncryptedFile, ImageInfo, ThumbnailInfo};
use crate::{Event, EventType, InnerInvalidEvent, InvalidEvent, InvalidInput, RoomEvent};
use crate::{Event, EventType, InnerInvalidEvent, InvalidEvent, RoomEvent};
pub mod feedback;
@ -1107,7 +1107,7 @@ impl Serialize for VideoMessageEventContent {
mod tests {
use serde_json::to_string;
use super::{AudioMessageEventContent, MessageEventContent, MessageType};
use super::{AudioMessageEventContent, MessageEventContent};
#[test]
fn serialization() {

View File

@ -1,6 +1,5 @@
//! Types for the *m.room.message.feedback* event.
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize};

View File

@ -7,9 +7,7 @@ use ruma_identifiers::{EventId, RoomId, UserId};
use serde::{ser::SerializeStruct, Deserialize, Serialize, Serializer};
use serde_json::Value;
use crate::{
Event, EventType, InnerInvalidEvent, InvalidEvent, InvalidInput, RoomEvent, StateEvent,
};
use crate::{Event, EventType, InnerInvalidEvent, InvalidEvent, RoomEvent, StateEvent};
/// Defines the power levels (privileges) of users in the room.
#[derive(Clone, Debug, PartialEq)]

View File

@ -8,7 +8,7 @@
use std::{convert::TryFrom, str::FromStr};
use ruma_identifiers::UserId;
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Serialize, Serializer};
use serde_json::{from_value, to_string, Value};
use crate::{
@ -393,7 +393,7 @@ mod tests {
use js_int::UInt;
use ruma_identifiers::UserId;
use serde_json::{from_str, to_string};
use serde_json::to_string;
use super::{StrippedRoomName, StrippedRoomTopic, StrippedState};
use crate::{