Fix import grouping issues

This commit is contained in:
Jonas Platte 2021-02-25 20:55:19 +01:00
parent 0b83227cef
commit a20c75d536
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
27 changed files with 48 additions and 46 deletions

View File

@ -1,9 +1,10 @@
//! Functions to aid the `Api::to_tokens` method. //! Functions to aid the `Api::to_tokens` method.
use std::collections::BTreeSet;
use proc_macro2::{Span, TokenStream}; use proc_macro2::{Span, TokenStream};
use proc_macro_crate::crate_name; use proc_macro_crate::crate_name;
use quote::quote; use quote::quote;
use std::collections::BTreeSet;
use syn::{ use syn::{
AngleBracketedGenericArguments, AttrStyle, Attribute, GenericArgument, Ident, Lifetime, AngleBracketedGenericArguments, AttrStyle, Attribute, GenericArgument, Ident, Lifetime,
ParenthesizedGenericArguments, PathArguments, Type, TypeArray, TypeBareFn, TypeGroup, ParenthesizedGenericArguments, PathArguments, Type, TypeArray, TypeBareFn, TypeGroup,

View File

@ -2,9 +2,8 @@
use ruma_api::ruma_api; use ruma_api::ruma_api;
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
use super::ThirdPartyIdRemovalStatus; use super::ThirdPartyIdRemovalStatus;
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
ruma_api! { ruma_api! {
metadata: { metadata: {

View File

@ -16,10 +16,11 @@ pub mod get_backup_keys;
pub mod get_latest_backup; pub mod get_latest_backup;
pub mod update_backup; pub mod update_backup;
use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_identifiers::{DeviceKeyId, UserId}; use ruma_identifiers::{DeviceKeyId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
/// A wrapper around a mapping of session IDs to key data. /// A wrapper around a mapping of session IDs to key data.
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]

View File

@ -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) //! [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_api::ruma_api;
use ruma_identifiers::DeviceId; use ruma_identifiers::DeviceId;
use super::Device;
ruma_api! { ruma_api! {
metadata: { metadata: {
description: "Get a device for authenticated user.", description: "Get a device for authenticated user.",

View File

@ -1,8 +1,9 @@
//! [GET /_matrix/client/r0/devices](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices) //! [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 ruma_api::ruma_api;
use super::Device;
ruma_api! { ruma_api! {
metadata: { metadata: {
description: "Get registered devices for authenticated user.", description: "Get registered devices for authenticated user.",

View File

@ -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) //! [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::{collections::BTreeMap, time::Duration};
use std::time::Duration;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId};

View File

@ -133,12 +133,11 @@ pub enum Direction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Direction, Request};
use js_int::uint; use js_int::uint;
use ruma_api::OutgoingRequest; use ruma_api::OutgoingRequest;
use ruma_identifiers::room_id; use ruma_identifiers::room_id;
use super::{Direction, Request};
use crate::r0::filter::{LazyLoadOptions, RoomEventFilter}; use crate::r0::filter::{LazyLoadOptions, RoomEventFilter};
#[test] #[test]

View File

@ -532,11 +532,10 @@ impl DeviceLists {
mod tests { mod tests {
use std::time::Duration; use std::time::Duration;
use matches::assert_matches;
use ruma_api::{IncomingRequest as _, OutgoingRequest as _}; use ruma_api::{IncomingRequest as _, OutgoingRequest as _};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; 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}; use super::{Filter, IncomingFilter, IncomingRequest, PresenceState, Request, Timeline};
#[test] #[test]

View File

@ -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) //! [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 std::time::Duration;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
use serde::{de::Error, Deserialize, Deserializer, Serialize};
ruma_api! { ruma_api! {
metadata: { metadata: {

View File

@ -101,6 +101,7 @@
#![deny(missing_debug_implementations, missing_docs)] #![deny(missing_debug_implementations, missing_docs)]
use std::{ use std::{
collections::BTreeMap,
convert::TryFrom, convert::TryFrom,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
time::Duration, time::Duration,
@ -118,7 +119,6 @@ use ruma_client_api::r0::sync::sync_events::{
use ruma_common::presence::PresenceState; use ruma_common::presence::PresenceState;
use ruma_identifiers::DeviceId; use ruma_identifiers::DeviceId;
use ruma_serde::urlencoded; use ruma_serde::urlencoded;
use std::collections::BTreeMap;
mod error; mod error;
mod session; mod session;

View File

@ -167,11 +167,11 @@ mod tweak_serde {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Action, Tweak};
use matches::assert_matches; use matches::assert_matches;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{Action, Tweak};
#[test] #[test]
fn serialize_string() { fn serialize_string() {
assert_eq!(to_json_value(&Action::Notify).unwrap(), json!("notify")); assert_eq!(to_json_value(&Action::Notify).unwrap(), json!("notify"));

View File

@ -6,7 +6,6 @@ use std::collections::BTreeMap;
use ruma_identifiers::{RoomAliasId, UserId}; use ruma_identifiers::{RoomAliasId, UserId};
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Metadata about a third party protocol. /// Metadata about a third party protocol.

View File

@ -43,11 +43,11 @@ impl DerefMut for DummyEventContent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{DummyEvent, DummyEventContent, Empty};
use ruma_serde::Raw; use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{DummyEvent, DummyEventContent, Empty};
#[test] #[test]
fn serialization() { fn serialization() {
let dummy_event = DummyEvent { content: DummyEventContent(Empty) }; let dummy_event = DummyEvent { content: DummyEventContent(Empty) };

View File

@ -5,14 +5,14 @@
//! The MSC for the in-room variants of the `m.key.verification.*` events can be found //! 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). //! [here](https://github.com/matrix-org/matrix-doc/pull/2241).
#[cfg(feature = "unstable-pre-spec")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use std::convert::TryFrom; use std::convert::TryFrom;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
#[cfg(feature = "unstable-pre-spec")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use crate::room::relationships::{Reference, RelatesToJsonRepr, RelationJsonRepr}; use crate::room::relationships::{Reference, RelatesToJsonRepr, RelationJsonRepr};
@ -125,10 +125,10 @@ pub enum VerificationMethod {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{KeyAgreementProtocol, MessageAuthenticationCode};
use serde_json::{from_value as from_json_value, json}; use serde_json::{from_value as from_json_value, json};
use super::{KeyAgreementProtocol, MessageAuthenticationCode};
#[test] #[test]
fn serialize_key_agreement() { fn serialize_key_agreement() {
let serialized = let serialized =

View File

@ -2,13 +2,14 @@
use std::convert::TryFrom; use std::convert::TryFrom;
use ruma_events_macros::MessageEventContent;
use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize};
use crate::{ use crate::{
room::relationships::{Annotation, RelatesToJsonRepr, RelationJsonRepr}, room::relationships::{Annotation, RelatesToJsonRepr, RelationJsonRepr},
MessageEvent, MessageEvent,
}; };
use ruma_events_macros::MessageEventContent;
use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize};
/// A reaction to another event. /// A reaction to another event.
pub type ReactionEvent = MessageEvent<ReactionEventContent>; pub type ReactionEvent = MessageEvent<ReactionEventContent>;

View File

@ -124,10 +124,10 @@ impl From<MegolmV1AesSha2ContentInit> for MegolmV1AesSha2Content {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use matches::assert_matches; 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 serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{EncryptedEventContent, MegolmV1AesSha2Content}; use super::{EncryptedEventContent, MegolmV1AesSha2Content};
use ruma_serde::Raw;
#[test] #[test]
fn serialization() { fn serialization() {

View File

@ -10,12 +10,11 @@ use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
#[cfg(feature = "unstable-pre-spec")]
use crate::key::verification::VerificationMethod;
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
use super::relationships::{Annotation, Reference, RelationJsonRepr, Replacement}; use super::relationships::{Annotation, Reference, RelationJsonRepr, Replacement};
use super::{relationships::RelatesToJsonRepr, EncryptedFile, ImageInfo, ThumbnailInfo}; 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? // FIXME: Do we want to keep re-exporting this?
pub use super::relationships::InReplyTo; pub use super::relationships::InReplyTo;

View File

@ -67,9 +67,8 @@ mod tests {
use ruma_serde::Raw; use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use crate::{StateEvent, Unsigned};
use super::NameEventContent; use super::NameEventContent;
use crate::{StateEvent, Unsigned};
#[test] #[test]
fn serialization_with_optional_fields_as_none() { fn serialization_with_optional_fields_as_none() {

View File

@ -85,11 +85,12 @@ pub struct Replacement {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::room::message::Relation;
use matches::assert_matches; use matches::assert_matches;
use ruma_identifiers::event_id; use ruma_identifiers::event_id;
use serde_json::{from_value as from_json_value, json}; use serde_json::{from_value as from_json_value, json};
use crate::room::message::Relation;
#[test] #[test]
fn reply_deserialize() { fn reply_deserialize() {
let event_id = event_id!("$1598361704261elfgc:localhost"); let event_id = event_id!("$1598361704261elfgc:localhost");

View File

@ -40,11 +40,11 @@ pub struct ServerAclEventContent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json}; use serde_json::{from_value as from_json_value, json};
use super::ServerAclEventContent; use super::ServerAclEventContent;
use crate::StateEvent; use crate::StateEvent;
use ruma_serde::Raw;
#[test] #[test]
fn default_values() { fn default_values() {

View File

@ -2,11 +2,12 @@
use std::{collections::BTreeMap, time::SystemTime}; use std::{collections::BTreeMap, time::SystemTime};
use crate::discovery::ServerSigningKeys;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use ruma_identifiers::{ServerNameBox, ServerSigningKeyId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::discovery::ServerSigningKeys;
ruma_api! { ruma_api! {
metadata: { metadata: {
description: "Query for keys from multiple servers in a batch format.", description: "Query for keys from multiple servers in a batch format.",

View File

@ -1,10 +1,11 @@
//! Endpoint for inviting a remote user to a room //! Endpoint for inviting a remote user to a room
use std::time::SystemTime;
use ruma_events::{room::member::MemberEventContent, EventType}; use ruma_events::{room::member::MemberEventContent, EventType};
use ruma_identifiers::{ServerName, UserId}; use ruma_identifiers::{ServerName, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use std::time::SystemTime;
pub mod v1; pub mod v1;
pub mod v2; pub mod v2;

View File

@ -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) //! [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_api::ruma_api;
use ruma_events::{room::member::MemberEventContent, EventType}; use ruma_events::{room::member::MemberEventContent, EventType};
use ruma_identifiers::{EventId, RoomId, ServerName, UserId}; use ruma_identifiers::{EventId, RoomId, ServerName, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::time::SystemTime;
use super::{InviteEvent, StrippedState}; use super::{InviteEvent, StrippedState};

View File

@ -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) //! [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 ruma_api::ruma_api;
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use std::collections::BTreeMap;
ruma_api! { ruma_api! {
metadata: { 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.", description: "Performs a single query request on the receiving homeserver. The query string arguments are dependent on which type of query is being made.",

View File

@ -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) //! [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_api::ruma_api;
use ruma_common::thirdparty::Medium; use ruma_common::thirdparty::Medium;
use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
ruma_api! { ruma_api! {
metadata: { metadata: {
description: "Used by identity servers to notify the homeserver that one of its users has bound a third party identifier successfully", description: "Used by identity servers to notify the homeserver that one of its users has bound a third party identifier successfully",

View File

@ -1,5 +1,7 @@
//! [POST /_matrix/push/v1/notify](https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify) //! [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 js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_common::push::{PusherData, Tweak}; use ruma_common::push::{PusherData, Tweak};
@ -8,7 +10,6 @@ use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
use ruma_serde::{Outgoing, StringEnum}; use ruma_serde::{Outgoing, StringEnum};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;
use std::time::SystemTime;
ruma_api! { ruma_api! {
metadata: { metadata: {

View File

@ -63,14 +63,14 @@ pub fn to_canonical_value<T: Serialize>(value: T) -> Result<value::CanonicalJson
mod tests { mod tests {
use std::{collections::BTreeMap, convert::TryInto}; use std::{collections::BTreeMap, convert::TryInto};
use js_int::int;
use serde_json::{from_str as from_json_str, json, to_string as to_json_string};
use super::{ use super::{
to_canonical_value, to_string as to_canonical_json_string, try_from_json_map, to_canonical_value, to_string as to_canonical_json_string, try_from_json_map,
value::CanonicalJsonValue, value::CanonicalJsonValue,
}; };
use js_int::int;
use serde_json::{from_str as from_json_str, json, to_string as to_json_string};
#[test] #[test]
fn serialize_canon() { fn serialize_canon() {
let json: CanonicalJsonValue = json!({ let json: CanonicalJsonValue = json!({