diff --git a/ruma-api-macros/src/util.rs b/ruma-api-macros/src/util.rs index 93dca2cb..fa5312c8 100644 --- a/ruma-api-macros/src/util.rs +++ b/ruma-api-macros/src/util.rs @@ -1,9 +1,10 @@ //! Functions to aid the `Api::to_tokens` method. +use std::collections::BTreeSet; + use proc_macro2::{Span, TokenStream}; use proc_macro_crate::crate_name; use quote::quote; -use std::collections::BTreeSet; use syn::{ AngleBracketedGenericArguments, AttrStyle, Attribute, GenericArgument, Ident, Lifetime, ParenthesizedGenericArguments, PathArguments, Type, TypeArray, TypeBareFn, TypeGroup, diff --git a/ruma-client-api/src/r0/account/deactivate.rs b/ruma-client-api/src/r0/account/deactivate.rs index cdcec56a..106b60d5 100644 --- a/ruma-client-api/src/r0/account/deactivate.rs +++ b/ruma-client-api/src/r0/account/deactivate.rs @@ -2,9 +2,8 @@ use ruma_api::ruma_api; -use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; - use super::ThirdPartyIdRemovalStatus; +use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; ruma_api! { metadata: { diff --git a/ruma-client-api/src/r0/backup.rs b/ruma-client-api/src/r0/backup.rs index ba253fb2..ea527a84 100644 --- a/ruma-client-api/src/r0/backup.rs +++ b/ruma-client-api/src/r0/backup.rs @@ -16,10 +16,11 @@ pub mod get_backup_keys; pub mod get_latest_backup; pub mod update_backup; +use std::collections::BTreeMap; + use js_int::UInt; use ruma_identifiers::{DeviceKeyId, UserId}; use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; /// A wrapper around a mapping of session IDs to key data. #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/ruma-client-api/src/r0/device/get_device.rs b/ruma-client-api/src/r0/device/get_device.rs index 715fa6a6..edf2f0b0 100644 --- a/ruma-client-api/src/r0/device/get_device.rs +++ b/ruma-client-api/src/r0/device/get_device.rs @@ -1,9 +1,10 @@ //! [GET /_matrix/client/r0/devices/{deviceId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices-deviceid) -use super::Device; use ruma_api::ruma_api; use ruma_identifiers::DeviceId; +use super::Device; + ruma_api! { metadata: { description: "Get a device for authenticated user.", diff --git a/ruma-client-api/src/r0/device/get_devices.rs b/ruma-client-api/src/r0/device/get_devices.rs index 90f9de59..c6e40936 100644 --- a/ruma-client-api/src/r0/device/get_devices.rs +++ b/ruma-client-api/src/r0/device/get_devices.rs @@ -1,8 +1,9 @@ //! [GET /_matrix/client/r0/devices](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices) -use super::Device; use ruma_api::ruma_api; +use super::Device; + ruma_api! { metadata: { description: "Get registered devices for authenticated user.", diff --git a/ruma-client-api/src/r0/keys/claim_keys.rs b/ruma-client-api/src/r0/keys/claim_keys.rs index 975a099d..7f14fc1c 100644 --- a/ruma-client-api/src/r0/keys/claim_keys.rs +++ b/ruma-client-api/src/r0/keys/claim_keys.rs @@ -1,8 +1,6 @@ //! [POST /_matrix/client/r0/keys/claim](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-claim) -use std::collections::BTreeMap; - -use std::time::Duration; +use std::{collections::BTreeMap, time::Duration}; use ruma_api::ruma_api; use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; diff --git a/ruma-client-api/src/r0/message/get_message_events.rs b/ruma-client-api/src/r0/message/get_message_events.rs index 884f974d..69311972 100644 --- a/ruma-client-api/src/r0/message/get_message_events.rs +++ b/ruma-client-api/src/r0/message/get_message_events.rs @@ -133,12 +133,11 @@ pub enum Direction { #[cfg(test)] mod tests { - use super::{Direction, Request}; - use js_int::uint; use ruma_api::OutgoingRequest; use ruma_identifiers::room_id; + use super::{Direction, Request}; use crate::r0::filter::{LazyLoadOptions, RoomEventFilter}; #[test] diff --git a/ruma-client-api/src/r0/sync/sync_events.rs b/ruma-client-api/src/r0/sync/sync_events.rs index 46084624..dc3223fe 100644 --- a/ruma-client-api/src/r0/sync/sync_events.rs +++ b/ruma-client-api/src/r0/sync/sync_events.rs @@ -532,11 +532,10 @@ impl DeviceLists { mod tests { use std::time::Duration; + use matches::assert_matches; use ruma_api::{IncomingRequest as _, OutgoingRequest as _}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; - use matches::assert_matches; - use super::{Filter, IncomingFilter, IncomingRequest, PresenceState, Request, Timeline}; #[test] diff --git a/ruma-client-api/src/r0/typing/create_typing_event.rs b/ruma-client-api/src/r0/typing/create_typing_event.rs index 8c3d7248..02d7562a 100644 --- a/ruma-client-api/src/r0/typing/create_typing_event.rs +++ b/ruma-client-api/src/r0/typing/create_typing_event.rs @@ -1,10 +1,10 @@ //! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-typing-userid) -use serde::{de::Error, Deserialize, Deserializer, Serialize}; use std::time::Duration; use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; +use serde::{de::Error, Deserialize, Deserializer, Serialize}; ruma_api! { metadata: { diff --git a/ruma-client/src/lib.rs b/ruma-client/src/lib.rs index 93c52598..a6860343 100644 --- a/ruma-client/src/lib.rs +++ b/ruma-client/src/lib.rs @@ -101,6 +101,7 @@ #![deny(missing_debug_implementations, missing_docs)] use std::{ + collections::BTreeMap, convert::TryFrom, sync::{Arc, Mutex}, time::Duration, @@ -118,7 +119,6 @@ use ruma_client_api::r0::sync::sync_events::{ use ruma_common::presence::PresenceState; use ruma_identifiers::DeviceId; use ruma_serde::urlencoded; -use std::collections::BTreeMap; mod error; mod session; diff --git a/ruma-common/src/push/action.rs b/ruma-common/src/push/action.rs index 67902073..62c8b10e 100644 --- a/ruma-common/src/push/action.rs +++ b/ruma-common/src/push/action.rs @@ -167,11 +167,11 @@ mod tweak_serde { #[cfg(test)] mod tests { - use super::{Action, Tweak}; - use matches::assert_matches; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; + use super::{Action, Tweak}; + #[test] fn serialize_string() { assert_eq!(to_json_value(&Action::Notify).unwrap(), json!("notify")); diff --git a/ruma-common/src/thirdparty.rs b/ruma-common/src/thirdparty.rs index a4fc4e91..2db8199e 100644 --- a/ruma-common/src/thirdparty.rs +++ b/ruma-common/src/thirdparty.rs @@ -6,7 +6,6 @@ use std::collections::BTreeMap; use ruma_identifiers::{RoomAliasId, UserId}; use ruma_serde::StringEnum; - use serde::{Deserialize, Serialize}; /// Metadata about a third party protocol. diff --git a/ruma-events/src/dummy.rs b/ruma-events/src/dummy.rs index 11382b6d..e882b6e6 100644 --- a/ruma-events/src/dummy.rs +++ b/ruma-events/src/dummy.rs @@ -43,11 +43,11 @@ impl DerefMut for DummyEventContent { #[cfg(test)] mod tests { - use super::{DummyEvent, DummyEventContent, Empty}; use ruma_serde::Raw; - use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; + use super::{DummyEvent, DummyEventContent, Empty}; + #[test] fn serialization() { let dummy_event = DummyEvent { content: DummyEventContent(Empty) }; diff --git a/ruma-events/src/key/verification.rs b/ruma-events/src/key/verification.rs index 28679da0..6a83b43a 100644 --- a/ruma-events/src/key/verification.rs +++ b/ruma-events/src/key/verification.rs @@ -5,14 +5,14 @@ //! The MSC for the in-room variants of the `m.key.verification.*` events can be found //! [here](https://github.com/matrix-org/matrix-doc/pull/2241). -#[cfg(feature = "unstable-pre-spec")] -use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use std::convert::TryFrom; #[cfg(feature = "unstable-pre-spec")] use ruma_identifiers::EventId; use ruma_serde::StringEnum; +#[cfg(feature = "unstable-pre-spec")] +use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use crate::room::relationships::{Reference, RelatesToJsonRepr, RelationJsonRepr}; @@ -125,10 +125,10 @@ pub enum VerificationMethod { #[cfg(test)] mod tests { - use super::{KeyAgreementProtocol, MessageAuthenticationCode}; - use serde_json::{from_value as from_json_value, json}; + use super::{KeyAgreementProtocol, MessageAuthenticationCode}; + #[test] fn serialize_key_agreement() { let serialized = diff --git a/ruma-events/src/reaction.rs b/ruma-events/src/reaction.rs index 56759c2b..6857f6b3 100644 --- a/ruma-events/src/reaction.rs +++ b/ruma-events/src/reaction.rs @@ -2,13 +2,14 @@ use std::convert::TryFrom; +use ruma_events_macros::MessageEventContent; +use ruma_identifiers::EventId; +use serde::{Deserialize, Serialize}; + use crate::{ room::relationships::{Annotation, RelatesToJsonRepr, RelationJsonRepr}, MessageEvent, }; -use ruma_events_macros::MessageEventContent; -use ruma_identifiers::EventId; -use serde::{Deserialize, Serialize}; /// A reaction to another event. pub type ReactionEvent = MessageEvent; diff --git a/ruma-events/src/room/encrypted.rs b/ruma-events/src/room/encrypted.rs index 9fdd02c1..2a418634 100644 --- a/ruma-events/src/room/encrypted.rs +++ b/ruma-events/src/room/encrypted.rs @@ -124,10 +124,10 @@ impl From for MegolmV1AesSha2Content { #[cfg(test)] mod tests { use matches::assert_matches; + use ruma_serde::Raw; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use super::{EncryptedEventContent, MegolmV1AesSha2Content}; - use ruma_serde::Raw; #[test] fn serialization() { diff --git a/ruma-events/src/room/message.rs b/ruma-events/src/room/message.rs index a188c618..62bb2260 100644 --- a/ruma-events/src/room/message.rs +++ b/ruma-events/src/room/message.rs @@ -10,12 +10,11 @@ use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; -#[cfg(feature = "unstable-pre-spec")] -use crate::key::verification::VerificationMethod; - #[cfg(feature = "unstable-pre-spec")] use super::relationships::{Annotation, Reference, RelationJsonRepr, Replacement}; use super::{relationships::RelatesToJsonRepr, EncryptedFile, ImageInfo, ThumbnailInfo}; +#[cfg(feature = "unstable-pre-spec")] +use crate::key::verification::VerificationMethod; // FIXME: Do we want to keep re-exporting this? pub use super::relationships::InReplyTo; diff --git a/ruma-events/src/room/name.rs b/ruma-events/src/room/name.rs index b7a63d6e..e6ba33ed 100644 --- a/ruma-events/src/room/name.rs +++ b/ruma-events/src/room/name.rs @@ -67,9 +67,8 @@ mod tests { use ruma_serde::Raw; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; - use crate::{StateEvent, Unsigned}; - use super::NameEventContent; + use crate::{StateEvent, Unsigned}; #[test] fn serialization_with_optional_fields_as_none() { diff --git a/ruma-events/src/room/relationships.rs b/ruma-events/src/room/relationships.rs index 6d228327..050e774b 100644 --- a/ruma-events/src/room/relationships.rs +++ b/ruma-events/src/room/relationships.rs @@ -85,11 +85,12 @@ pub struct Replacement { #[cfg(test)] mod tests { - use crate::room::message::Relation; use matches::assert_matches; use ruma_identifiers::event_id; use serde_json::{from_value as from_json_value, json}; + use crate::room::message::Relation; + #[test] fn reply_deserialize() { let event_id = event_id!("$1598361704261elfgc:localhost"); diff --git a/ruma-events/src/room/server_acl.rs b/ruma-events/src/room/server_acl.rs index e2846e2f..73d90346 100644 --- a/ruma-events/src/room/server_acl.rs +++ b/ruma-events/src/room/server_acl.rs @@ -40,11 +40,11 @@ pub struct ServerAclEventContent { #[cfg(test)] mod tests { + use ruma_serde::Raw; use serde_json::{from_value as from_json_value, json}; use super::ServerAclEventContent; use crate::StateEvent; - use ruma_serde::Raw; #[test] fn default_values() { diff --git a/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs b/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs index 8d9e797e..67b2ede8 100644 --- a/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs +++ b/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs @@ -2,11 +2,12 @@ use std::{collections::BTreeMap, time::SystemTime}; -use crate::discovery::ServerSigningKeys; use ruma_api::ruma_api; use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use serde::{Deserialize, Serialize}; +use crate::discovery::ServerSigningKeys; + ruma_api! { metadata: { description: "Query for keys from multiple servers in a batch format.", diff --git a/ruma-federation-api/src/membership/create_invite.rs b/ruma-federation-api/src/membership/create_invite.rs index 46a5067b..0fef2ede 100644 --- a/ruma-federation-api/src/membership/create_invite.rs +++ b/ruma-federation-api/src/membership/create_invite.rs @@ -1,10 +1,11 @@ //! Endpoint for inviting a remote user to a room +use std::time::SystemTime; + use ruma_events::{room::member::MemberEventContent, EventType}; use ruma_identifiers::{ServerName, UserId}; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; -use std::time::SystemTime; pub mod v1; pub mod v2; diff --git a/ruma-federation-api/src/membership/create_invite/v1.rs b/ruma-federation-api/src/membership/create_invite/v1.rs index f73f74a9..6d775778 100644 --- a/ruma-federation-api/src/membership/create_invite/v1.rs +++ b/ruma-federation-api/src/membership/create_invite/v1.rs @@ -1,10 +1,11 @@ //! [PUT /_matrix/federation/v1/invite/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v1-invite-roomid-eventid) +use std::time::SystemTime; + use ruma_api::ruma_api; use ruma_events::{room::member::MemberEventContent, EventType}; use ruma_identifiers::{EventId, RoomId, ServerName, UserId}; use serde::{Deserialize, Serialize}; -use std::time::SystemTime; use super::{InviteEvent, StrippedState}; diff --git a/ruma-federation-api/src/query/get_custom_information/v1.rs b/ruma-federation-api/src/query/get_custom_information/v1.rs index 87a53944..568a0aa4 100644 --- a/ruma-federation-api/src/query/get_custom_information/v1.rs +++ b/ruma-federation-api/src/query/get_custom_information/v1.rs @@ -1,10 +1,10 @@ //! [GET /_matrix/federation/v1/query/{queryType}](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-querytype) +use std::collections::BTreeMap; + use ruma_api::ruma_api; use serde_json::Value as JsonValue; -use std::collections::BTreeMap; - ruma_api! { metadata: { description: "Performs a single query request on the receiving homeserver. The query string arguments are dependent on which type of query is being made.", diff --git a/ruma-federation-api/src/thirdparty/bind_callback/v1.rs b/ruma-federation-api/src/thirdparty/bind_callback/v1.rs index ecb86592..043d18b1 100644 --- a/ruma-federation-api/src/thirdparty/bind_callback/v1.rs +++ b/ruma-federation-api/src/thirdparty/bind_callback/v1.rs @@ -1,12 +1,12 @@ //! [PUT /_matrix/federation/v1/3pid/onbind](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v1-3pid-onbind) +use std::collections::BTreeMap; + use ruma_api::ruma_api; use ruma_common::thirdparty::Medium; use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; - ruma_api! { metadata: { description: "Used by identity servers to notify the homeserver that one of its users has bound a third party identifier successfully", diff --git a/ruma-push-gateway-api/src/send_event_notification/v1.rs b/ruma-push-gateway-api/src/send_event_notification/v1.rs index 8bb775f5..36b5b87c 100644 --- a/ruma-push-gateway-api/src/send_event_notification/v1.rs +++ b/ruma-push-gateway-api/src/send_event_notification/v1.rs @@ -1,5 +1,7 @@ //! [POST /_matrix/push/v1/notify](https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify) +use std::time::SystemTime; + use js_int::UInt; use ruma_api::ruma_api; use ruma_common::push::{PusherData, Tweak}; @@ -8,7 +10,6 @@ use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId}; use ruma_serde::{Outgoing, StringEnum}; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; -use std::time::SystemTime; ruma_api! { metadata: { diff --git a/ruma-serde/src/canonical_json.rs b/ruma-serde/src/canonical_json.rs index af0679b4..b46f8d4a 100644 --- a/ruma-serde/src/canonical_json.rs +++ b/ruma-serde/src/canonical_json.rs @@ -63,14 +63,14 @@ pub fn to_canonical_value(value: T) -> Result