Clean up import grouping / ordering

This commit is contained in:
Jonas Platte 2022-02-18 11:20:39 +01:00
parent 65e9259a80
commit 215cb35806
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
27 changed files with 50 additions and 56 deletions

View File

@ -2,9 +2,8 @@ use proc_macro2::TokenStream;
use quote::quote;
use syn::{Field, LitStr};
use crate::{auth_scheme::AuthScheme, util};
use super::{Request, RequestField};
use crate::{auth_scheme::AuthScheme, util};
impl Request {
pub fn expand_outgoing(&self, ruma_api: &TokenStream) -> TokenStream {

View File

@ -109,11 +109,12 @@ pub mod v1 {
#[cfg(feature = "helper")]
#[cfg(test)]
mod helper_tests {
use super::{AnyRoomEvent, IncomingRequest, Raw};
use ruma_client_api::sync::sync_events;
use ruma_identifiers::room_id;
use serde_json::json;
use super::{AnyRoomEvent, IncomingRequest, Raw};
#[test]
fn convert_incoming_request_to_sync_response() {
let txn_id = "any_txn_id".to_owned();

View File

@ -1,8 +1,8 @@
use super::HttpClient;
use async_trait::async_trait;
use futures_lite::AsyncReadExt;
use super::HttpClient;
/// The `isahc` crate's `HttpClient`.
pub type Isahc = isahc::HttpClient;

View File

@ -16,14 +16,14 @@
use std::hash::{Hash, Hasher};
use crate::PrivOwnedStr;
use indexmap::{Equivalent, IndexSet};
use ruma_serde::{Raw, StringEnum};
use serde::{Deserialize, Serialize};
#[cfg(feature = "unstable-pre-spec")]
use serde_json::Value as JsonValue;
use crate::PrivOwnedStr;
mod action;
mod condition;
mod iter;
@ -470,13 +470,12 @@ mod tests {
value::RawValue as RawJsonValue, Value as JsonValue,
};
use crate::power_levels::NotificationPowerLevels;
use super::{
action::{Action, Tweak},
condition::{PushCondition, PushConditionRoomCtx, RoomMemberCountIs},
AnyPushRule, ConditionalPushRule, PatternedPushRule, Ruleset, SimplePushRule,
};
use crate::power_levels::NotificationPowerLevels;
fn example_ruleset() -> Ruleset {
let mut set = Ruleset::new();

View File

@ -314,9 +314,8 @@ mod tests {
from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue,
};
use crate::power_levels::NotificationPowerLevels;
use super::{FlattenedJson, PushCondition, PushConditionRoomCtx, RoomMemberCountIs, StrExt};
use crate::power_levels::NotificationPowerLevels;
#[test]
fn serialize_event_match_condition() {

View File

@ -1,10 +1,11 @@
use js_int::{uint, UInt};
use serde::{Deserialize, Serialize};
use std::{
convert::TryInto,
time::{Duration, SystemTime, UNIX_EPOCH},
};
use js_int::{uint, UInt};
use serde::{Deserialize, Serialize};
/// A timestamp represented as the number of milliseconds since the unix epoch.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[allow(clippy::exhaustive_structs)]

View File

@ -15,10 +15,10 @@ use proc_macro_crate::{crate_name, FoundCrate};
use quote::{format_ident, quote};
use syn::{parse_macro_input, DeriveInput};
use crate::event_enum::expand_from_impls_derived;
use self::{
event::expand_event, event_content::expand_event_content, event_enum::expand_event_enums,
event::expand_event,
event_content::expand_event_content,
event_enum::{expand_event_enums, expand_from_impls_derived},
event_type::expand_event_type_enum,
};

View File

@ -181,16 +181,15 @@ pub mod typing;
#[cfg(feature = "unstable-msc2675")]
pub use self::relation::Relations;
#[doc(hidden)]
#[cfg(feature = "compat")]
pub use self::unsigned::{RedactedUnsignedWithPrevContent, UnsignedWithPrevContent};
pub use self::{
enums::*,
event_kinds::*,
unsigned::{RedactedUnsigned, Unsigned},
};
#[doc(hidden)]
#[cfg(feature = "compat")]
pub use unsigned::{RedactedUnsignedWithPrevContent, UnsignedWithPrevContent};
/// The base trait that all event content types implement.
///
/// Implementing this trait allows content types to be serialized as well as deserialized.

View File

@ -245,6 +245,7 @@ impl From<MegolmV1AesSha2ContentInit> for MegolmV1AesSha2Content {
#[cfg(test)]
mod tests {
use matches::assert_matches;
use ruma_identifiers::event_id;
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -252,7 +253,6 @@ mod tests {
EncryptedEventScheme, MegolmV1AesSha2Content, Relation, RoomEncryptedEventContent,
};
use crate::room::message::InReplyTo;
use ruma_identifiers::event_id;
#[test]
fn serialization() {

View File

@ -2,6 +2,8 @@
//!
//! [`m.room.join_rules`]: https://spec.matrix.org/v1.1/client-server-api/#mroomjoin_rules
use std::{borrow::Cow, collections::BTreeMap};
use ruma_events_macros::EventContent;
use ruma_identifiers::RoomId;
use ruma_serde::from_raw_json_value;
@ -10,7 +12,6 @@ use serde::{
Deserialize, Serialize,
};
use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue};
use std::{borrow::Cow, collections::BTreeMap};
use crate::PrivOwnedStr;

View File

@ -5,15 +5,13 @@
use std::collections::BTreeMap;
use js_int::{int, Int};
use ruma_common::power_levels::default_power_level;
use ruma_common::power_levels::{default_power_level, NotificationPowerLevels};
use ruma_events_macros::EventContent;
use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
use crate::EventType;
use ruma_common::power_levels::NotificationPowerLevels;
/// The content of an `m.room.power_levels` event.
///
/// Defines the power levels (privileges) of users in the room.

View File

@ -52,10 +52,11 @@ impl SpaceChildEventContent {
#[cfg(test)]
mod tests {
use super::SpaceChildEventContent;
use ruma_identifiers::server_name;
use serde_json::{json, to_value as to_json_value};
use super::SpaceChildEventContent;
#[test]
fn space_child_serialization() {
let content = SpaceChildEventContent {

View File

@ -40,10 +40,11 @@ impl SpaceParentEventContent {
#[cfg(test)]
mod tests {
use super::SpaceParentEventContent;
use ruma_identifiers::server_name;
use serde_json::{json, to_value as to_json_value};
use super::SpaceParentEventContent;
#[test]
fn space_parent_serialization() {
let content = SpaceParentEventContent {

View File

@ -11,7 +11,6 @@ pub mod v1 {
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, RoomId, ServerName};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -10,7 +10,6 @@ pub mod v1 {
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{EventId, ServerName};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -10,7 +10,6 @@ pub mod v1 {
use js_int::{uint, UInt};
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -9,7 +9,6 @@ pub mod v1 {
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -4,7 +4,6 @@
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
use super::RoomState;

View File

@ -4,7 +4,6 @@
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
use super::RoomState;

View File

@ -9,7 +9,6 @@ pub mod v1 {
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomVersionId, UserId};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -4,7 +4,6 @@
use ruma_api::ruma_api;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -8,7 +8,6 @@ pub mod v1 {
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomVersionId, UserId};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {

View File

@ -2,7 +2,6 @@
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
use proc_macro::TokenStream;
use quote::quote;
use ruma_identifiers_validation::{
device_key_id, event_id, key_id, mxc_uri, room_alias_id, room_id, room_version_id, server_name,

View File

@ -5,14 +5,16 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput, ItemEnum};
use deserialize_from_cow_str::expand_deserialize_from_cow_str;
use display_as_ref_str::expand_display_as_ref_str;
use enum_as_ref_str::expand_enum_as_ref_str;
use enum_from_string::expand_enum_from_string;
use eq_as_ref_str::expand_partial_eq_as_ref_str;
use ord_as_ref_str::{expand_ord_as_ref_str, expand_partial_ord_as_ref_str};
use outgoing::expand_derive_outgoing;
use serialize_as_ref_str::expand_serialize_as_ref_str;
use self::{
deserialize_from_cow_str::expand_deserialize_from_cow_str,
display_as_ref_str::expand_display_as_ref_str,
enum_as_ref_str::expand_enum_as_ref_str,
enum_from_string::expand_enum_from_string,
eq_as_ref_str::expand_partial_eq_as_ref_str,
ord_as_ref_str::{expand_ord_as_ref_str, expand_partial_ord_as_ref_str},
outgoing::expand_derive_outgoing,
serialize_as_ref_str::expand_serialize_as_ref_str,
};
mod attr;
mod case;

View File

@ -6,7 +6,6 @@ use std::{
};
use ed25519_dalek::{ExpandedSecretKey, PublicKey, SecretKey};
use pkcs8::{
der::{Decodable, Encodable},
AlgorithmIdentifier, ObjectIdentifier, PrivateKeyInfo,

View File

@ -929,6 +929,17 @@ fn verify_third_party_invite(
mod tests {
use std::sync::Arc;
use ruma_events::{
room::{
join_rules::{
AllowRule, JoinRule, Restricted, RoomJoinRulesEventContent, RoomMembership,
},
member::{MembershipState, RoomMemberEventContent},
},
EventType,
};
use serde_json::value::to_raw_value as to_raw_json_value;
use crate::{
event_auth::valid_membership_change,
test_utils::{
@ -937,13 +948,6 @@ mod tests {
},
Event, RoomVersion, StateMap,
};
use ruma_events::room::{
join_rules::{AllowRule, JoinRule, Restricted, RoomJoinRulesEventContent, RoomMembership},
member::{MembershipState, RoomMemberEventContent},
};
use serde_json::value::to_raw_value as to_raw_json_value;
use ruma_events::EventType;
#[test]
fn test_ban_pass() {

View File

@ -1,11 +1,11 @@
#![allow(dead_code)] // silence never-used warning for from_vec in generated code
#[cfg(feature = "default")]
use semver::Version;
#[cfg(not(feature = "default"))]
use std::string::String as Version;
#[cfg(feature = "default")]
use semver::Version;
xflags::xflags! {
src "./src/flags.rs"