From 5f902851af2a63574d38587cccec47d25c57be89 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 27 May 2022 12:04:23 +0200 Subject: [PATCH] Upgrade to Rust 2021 --- crates/ruma-appservice-api/Cargo.toml | 2 +- crates/ruma-client-api/Cargo.toml | 2 +- crates/ruma-client-api/src/error/kind_serde.rs | 1 - crates/ruma-client-api/src/push.rs | 2 +- crates/ruma-client/Cargo.toml | 2 +- crates/ruma-client/src/http_client/reqwest.rs | 2 +- crates/ruma-client/src/lib.rs | 1 - crates/ruma-common/Cargo.toml | 2 +- crates/ruma-common/src/api/metadata.rs | 1 - crates/ruma-common/src/events/audio.rs | 2 +- .../ruma-common/src/events/audio/waveform_serde.rs | 2 -- crates/ruma-common/src/events/location.rs | 2 -- crates/ruma-common/src/events/message.rs | 2 +- .../src/events/message/content_serde.rs | 2 -- crates/ruma-common/src/events/policy/rule/room.rs | 2 -- crates/ruma-common/src/events/poll/start.rs | 2 -- .../src/events/poll/start/poll_answers_serde.rs | 2 -- crates/ruma-common/src/events/room/name.rs | 2 -- .../ruma-common/src/events/room/pinned_events.rs | 2 -- crates/ruma-common/src/events/secret/request.rs | 2 -- crates/ruma-common/src/identifiers.rs | 2 -- .../ruma-common/src/identifiers/client_secret.rs | 2 -- .../ruma-common/src/identifiers/device_key_id.rs | 2 -- crates/ruma-common/src/identifiers/event_id.rs | 3 --- crates/ruma-common/src/identifiers/matrix_uri.rs | 2 +- crates/ruma-common/src/identifiers/mxc_uri.rs | 2 -- .../ruma-common/src/identifiers/room_alias_id.rs | 3 --- crates/ruma-common/src/identifiers/room_id.rs | 3 --- .../src/identifiers/room_or_room_alias_id.rs | 5 +---- .../ruma-common/src/identifiers/room_version_id.rs | 5 +---- crates/ruma-common/src/identifiers/server_name.rs | 2 -- crates/ruma-common/src/identifiers/user_id.rs | 3 --- crates/ruma-common/src/push/condition.rs | 2 +- crates/ruma-common/src/serde/canonical_json.rs | 4 ++-- .../ruma-common/src/serde/canonical_json/value.rs | 14 +------------- crates/ruma-common/src/serde/duration/opt_ms.rs | 2 +- crates/ruma-common/src/serde/duration/secs.rs | 2 +- crates/ruma-common/src/serde/strings.rs | 2 +- crates/ruma-common/src/thirdparty.rs | 2 -- crates/ruma-common/src/time.rs | 6 +----- crates/ruma-common/src/to_device.rs | 5 +---- crates/ruma-common/tests/events/initial_state.rs | 2 -- crates/ruma-common/tests/events/message.rs | 2 -- crates/ruma-common/tests/events/pdu.rs | 2 +- crates/ruma-common/tests/events/poll.rs | 2 -- crates/ruma-common/tests/events/stripped.rs | 2 -- crates/ruma-federation-api/Cargo.toml | 2 +- crates/ruma-identifiers-validation/Cargo.toml | 2 +- crates/ruma-identity-service-api/Cargo.toml | 2 +- crates/ruma-macros/Cargo.toml | 2 +- crates/ruma-macros/src/api/request.rs | 5 +---- crates/ruma-macros/src/api/response.rs | 5 +---- crates/ruma-macros/src/api/version.rs | 2 +- crates/ruma-push-gateway-api/Cargo.toml | 2 +- crates/ruma-signatures/Cargo.toml | 2 +- crates/ruma-signatures/src/functions.rs | 6 +----- crates/ruma-signatures/src/verification.rs | 2 -- crates/ruma-state-res/Cargo.toml | 2 +- crates/ruma-state-res/benches/state_res_bench.rs | 1 - crates/ruma-state-res/src/event_auth.rs | 2 +- crates/ruma-state-res/src/test_utils.rs | 1 - crates/ruma/Cargo.toml | 2 +- examples/hello_isahc/Cargo.toml | 2 +- examples/hello_isahc/src/main.rs | 2 +- examples/hello_world/Cargo.toml | 2 +- examples/hello_world/src/main.rs | 2 +- examples/joke_bot/Cargo.toml | 2 +- examples/joke_bot/src/main.rs | 2 +- examples/message_log/Cargo.toml | 2 +- xtask/Cargo.toml | 2 +- 70 files changed, 42 insertions(+), 134 deletions(-) diff --git a/crates/ruma-appservice-api/Cargo.toml b/crates/ruma-appservice-api/Cargo.toml index f7136dac..f92772ec 100644 --- a/crates/ruma-appservice-api/Cargo.toml +++ b/crates/ruma-appservice-api/Cargo.toml @@ -8,7 +8,7 @@ name = "ruma-appservice-api" readme = "README.md" repository = "https://github.com/ruma/ruma" version = "0.6.0" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-client-api/Cargo.toml b/crates/ruma-client-api/Cargo.toml index a4c9c653..a062de06 100644 --- a/crates/ruma-client-api/Cargo.toml +++ b/crates/ruma-client-api/Cargo.toml @@ -8,7 +8,7 @@ name = "ruma-client-api" readme = "README.md" repository = "https://github.com/ruma/ruma" version = "0.14.0" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-client-api/src/error/kind_serde.rs b/crates/ruma-client-api/src/error/kind_serde.rs index adc3275f..4d93ced1 100644 --- a/crates/ruma-client-api/src/error/kind_serde.rs +++ b/crates/ruma-client-api/src/error/kind_serde.rs @@ -1,7 +1,6 @@ use std::{ borrow::Cow, collections::btree_map::{BTreeMap, Entry}, - convert::TryFrom, fmt, time::Duration, }; diff --git a/crates/ruma-client-api/src/push.rs b/crates/ruma-client-api/src/push.rs index b1d3e970..27f5b476 100644 --- a/crates/ruma-client-api/src/push.rs +++ b/crates/ruma-client-api/src/push.rs @@ -1,5 +1,5 @@ //! Endpoints for push notifications. -use std::{convert::TryFrom, error::Error, fmt}; +use std::{error::Error, fmt}; use ruma_common::{ push::{ diff --git a/crates/ruma-client/Cargo.toml b/crates/ruma-client/Cargo.toml index 08a7a903..dcb704c6 100644 --- a/crates/ruma-client/Cargo.toml +++ b/crates/ruma-client/Cargo.toml @@ -1,7 +1,7 @@ [package] categories = ["api-bindings", "web-programming"] description = "A Matrix client library." -edition = "2018" +edition = "2021" homepage = "https://www.ruma.io/" keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" diff --git a/crates/ruma-client/src/http_client/reqwest.rs b/crates/ruma-client/src/http_client/reqwest.rs index 8ae9c7d5..84293dd6 100644 --- a/crates/ruma-client/src/http_client/reqwest.rs +++ b/crates/ruma-client/src/http_client/reqwest.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, mem}; +use std::mem; use async_trait::async_trait; use bytes::{Bytes, BytesMut}; diff --git a/crates/ruma-client/src/lib.rs b/crates/ruma-client/src/lib.rs index 85ee0ced..87fad6f4 100644 --- a/crates/ruma-client/src/lib.rs +++ b/crates/ruma-client/src/lib.rs @@ -65,7 +65,6 @@ //! # .homeserver_url(homeserver_url) //! # .build::() //! # .await?; -//! use std::convert::TryFrom; //! //! use ruma_client_api::alias::get_alias; //! use ruma_common::{api::MatrixVersion, room_alias_id, room_id}; diff --git a/crates/ruma-common/Cargo.toml b/crates/ruma-common/Cargo.toml index 4b4756b0..a77b5e80 100644 --- a/crates/ruma-common/Cargo.toml +++ b/crates/ruma-common/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" readme = "README.md" repository = "https://github.com/ruma/ruma" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-common/src/api/metadata.rs b/crates/ruma-common/src/api/metadata.rs index 4e7cc121..60d10cda 100644 --- a/crates/ruma-common/src/api/metadata.rs +++ b/crates/ruma-common/src/api/metadata.rs @@ -1,5 +1,4 @@ use std::{ - convert::TryFrom, fmt::{self, Display}, str::FromStr, }; diff --git a/crates/ruma-common/src/events/audio.rs b/crates/ruma-common/src/events/audio.rs index 693f80c0..a9e21df9 100644 --- a/crates/ruma-common/src/events/audio.rs +++ b/crates/ruma-common/src/events/audio.rs @@ -2,7 +2,7 @@ //! //! [MSC3246]: https://github.com/matrix-org/matrix-spec-proposals/pull/3246 -use std::{convert::TryFrom, time::Duration}; +use std::time::Duration; use js_int::UInt; use ruma_macros::EventContent; diff --git a/crates/ruma-common/src/events/audio/waveform_serde.rs b/crates/ruma-common/src/events/audio/waveform_serde.rs index 97db719d..f1250914 100644 --- a/crates/ruma-common/src/events/audio/waveform_serde.rs +++ b/crates/ruma-common/src/events/audio/waveform_serde.rs @@ -1,7 +1,5 @@ //! `Serialize` and `Deserialize` implementations for extensible events (MSC1767). -use std::convert::TryFrom; - use serde::Deserialize; use super::{Amplitude, Waveform, WaveformError}; diff --git a/crates/ruma-common/src/events/location.rs b/crates/ruma-common/src/events/location.rs index 82edbfe1..dca94eb2 100644 --- a/crates/ruma-common/src/events/location.rs +++ b/crates/ruma-common/src/events/location.rs @@ -2,8 +2,6 @@ //! //! [MSC3488]: https://github.com/matrix-org/matrix-spec-proposals/pull/3488 -use std::convert::TryFrom; - use js_int::UInt; use ruma_macros::{EventContent, StringEnum}; use serde::{Deserialize, Serialize}; diff --git a/crates/ruma-common/src/events/message.rs b/crates/ruma-common/src/events/message.rs index 00e47efb..2193e96e 100644 --- a/crates/ruma-common/src/events/message.rs +++ b/crates/ruma-common/src/events/message.rs @@ -49,7 +49,7 @@ //! [MSC3245]: https://github.com/matrix-org/matrix-spec-proposals/pull/3245 //! [MSC3381]: https://github.com/matrix-org/matrix-spec-proposals/pull/3381 //! [`RoomMessageEventContent`]: super::room::message::RoomMessageEventContent -use std::{convert::TryFrom, ops::Deref}; +use std::ops::Deref; use ruma_macros::EventContent; use serde::{Deserialize, Serialize}; diff --git a/crates/ruma-common/src/events/message/content_serde.rs b/crates/ruma-common/src/events/message/content_serde.rs index af70868a..a5ee6d44 100644 --- a/crates/ruma-common/src/events/message/content_serde.rs +++ b/crates/ruma-common/src/events/message/content_serde.rs @@ -1,7 +1,5 @@ //! `Serialize` and `Deserialize` implementations for extensible events (MSC1767). -use std::convert::TryFrom; - use serde::{ser::SerializeStruct, Deserialize, Serialize}; use super::{MessageContent, Text, TryFromExtensibleError}; diff --git a/crates/ruma-common/src/events/policy/rule/room.rs b/crates/ruma-common/src/events/policy/rule/room.rs index 9232d2b5..0150b8d5 100644 --- a/crates/ruma-common/src/events/policy/rule/room.rs +++ b/crates/ruma-common/src/events/policy/rule/room.rs @@ -17,8 +17,6 @@ pub struct PolicyRuleRoomEventContent(pub PolicyRuleEventContent); #[cfg(test)] mod tests { - use std::convert::TryInto; - use js_int::int; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; diff --git a/crates/ruma-common/src/events/poll/start.rs b/crates/ruma-common/src/events/poll/start.rs index f5fdc781..03c154fd 100644 --- a/crates/ruma-common/src/events/poll/start.rs +++ b/crates/ruma-common/src/events/poll/start.rs @@ -1,7 +1,5 @@ //! Types for the [`m.poll.start`] event. -use std::convert::TryFrom; - use js_int::{uint, UInt}; use ruma_macros::EventContent; use serde::{Deserialize, Serialize}; diff --git a/crates/ruma-common/src/events/poll/start/poll_answers_serde.rs b/crates/ruma-common/src/events/poll/start/poll_answers_serde.rs index e1e6a765..3ee79b4f 100644 --- a/crates/ruma-common/src/events/poll/start/poll_answers_serde.rs +++ b/crates/ruma-common/src/events/poll/start/poll_answers_serde.rs @@ -1,7 +1,5 @@ //! `Serialize` and `Deserialize` implementations for extensible events (MSC1767). -use std::convert::TryFrom; - use serde::Deserialize; use super::{PollAnswer, PollAnswers, PollAnswersError}; diff --git a/crates/ruma-common/src/events/room/name.rs b/crates/ruma-common/src/events/room/name.rs index eb654d26..fcbe32c7 100644 --- a/crates/ruma-common/src/events/room/name.rs +++ b/crates/ruma-common/src/events/room/name.rs @@ -28,8 +28,6 @@ impl RoomNameEventContent { #[cfg(test)] mod tests { - use std::convert::TryInto; - use assert_matches::assert_matches; use js_int::{int, uint}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; diff --git a/crates/ruma-common/src/events/room/pinned_events.rs b/crates/ruma-common/src/events/room/pinned_events.rs index e18b0cbc..278bda24 100644 --- a/crates/ruma-common/src/events/room/pinned_events.rs +++ b/crates/ruma-common/src/events/room/pinned_events.rs @@ -27,8 +27,6 @@ impl RoomPinnedEventsEventContent { #[cfg(all(test, feature = "rand"))] mod tests { - use std::convert::TryInto; - use super::RoomPinnedEventsEventContent; use crate::{ events::{EmptyStateKey, OriginalStateEvent, StateUnsigned}, diff --git a/crates/ruma-common/src/events/secret/request.rs b/crates/ruma-common/src/events/secret/request.rs index c674a755..92634af8 100644 --- a/crates/ruma-common/src/events/secret/request.rs +++ b/crates/ruma-common/src/events/secret/request.rs @@ -2,8 +2,6 @@ //! //! [`m.secret.request`]: https://spec.matrix.org/v1.2/client-server-api/#msecretrequest -use std::convert::TryFrom; - use ruma_macros::EventContent; use serde::{ser::SerializeStruct, Deserialize, Serialize}; diff --git a/crates/ruma-common/src/identifiers.rs b/crates/ruma-common/src/identifiers.rs index 2d379bf7..6631749c 100644 --- a/crates/ruma-common/src/identifiers.rs +++ b/crates/ruma-common/src/identifiers.rs @@ -4,8 +4,6 @@ // FIXME: Remove once lint doesn't trigger on std::convert::TryFrom in identifiers/macros.rs anymore #![allow(unused_qualifications)] -use std::convert::TryFrom; - use serde::de::{self, Deserializer, Unexpected}; #[doc(inline)] diff --git a/crates/ruma-common/src/identifiers/client_secret.rs b/crates/ruma-common/src/identifiers/client_secret.rs index 5920b610..a714a3aa 100644 --- a/crates/ruma-common/src/identifiers/client_secret.rs +++ b/crates/ruma-common/src/identifiers/client_secret.rs @@ -30,8 +30,6 @@ impl ClientSecret { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::ClientSecret; #[test] diff --git a/crates/ruma-common/src/identifiers/device_key_id.rs b/crates/ruma-common/src/identifiers/device_key_id.rs index a9521944..c73add43 100644 --- a/crates/ruma-common/src/identifiers/device_key_id.rs +++ b/crates/ruma-common/src/identifiers/device_key_id.rs @@ -41,8 +41,6 @@ impl DeviceKeyId { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{DeviceKeyId, OwnedDeviceKeyId}; use crate::identifiers::{crypto_algorithms::DeviceKeyAlgorithm, IdParseError}; diff --git a/crates/ruma-common/src/identifiers/event_id.rs b/crates/ruma-common/src/identifiers/event_id.rs index 917133e1..67f9c31e 100644 --- a/crates/ruma-common/src/identifiers/event_id.rs +++ b/crates/ruma-common/src/identifiers/event_id.rs @@ -19,7 +19,6 @@ use super::ServerName; /// format. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::EventId; /// // Original format /// assert_eq!(<&EventId>::try_from("$h29iv0s8:example.com").unwrap(), "$h29iv0s8:example.com"); @@ -78,8 +77,6 @@ impl EventId { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{EventId, OwnedEventId}; use crate::IdParseError; diff --git a/crates/ruma-common/src/identifiers/matrix_uri.rs b/crates/ruma-common/src/identifiers/matrix_uri.rs index 5757298b..7a7302c9 100644 --- a/crates/ruma-common/src/identifiers/matrix_uri.rs +++ b/crates/ruma-common/src/identifiers/matrix_uri.rs @@ -1,6 +1,6 @@ //! Matrix URIs. -use std::{convert::TryFrom, fmt, str::FromStr}; +use std::{fmt, str::FromStr}; use percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS}; use ruma_identifiers_validation::{ diff --git a/crates/ruma-common/src/identifiers/mxc_uri.rs b/crates/ruma-common/src/identifiers/mxc_uri.rs index c6726d29..a074a0e5 100644 --- a/crates/ruma-common/src/identifiers/mxc_uri.rs +++ b/crates/ruma-common/src/identifiers/mxc_uri.rs @@ -61,8 +61,6 @@ impl MxcUri { #[cfg(test)] mod tests { - use std::convert::TryInto; - use ruma_identifiers_validation::error::MxcUriError; use super::{MxcUri, OwnedMxcUri}; diff --git a/crates/ruma-common/src/identifiers/room_alias_id.rs b/crates/ruma-common/src/identifiers/room_alias_id.rs index 6ab97702..bfd33199 100644 --- a/crates/ruma-common/src/identifiers/room_alias_id.rs +++ b/crates/ruma-common/src/identifiers/room_alias_id.rs @@ -10,7 +10,6 @@ use super::{matrix_uri::UriAction, server_name::ServerName, EventId, MatrixToUri /// needed. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::RoomAliasId; /// assert_eq!(<&RoomAliasId>::try_from("#ruma:example.com").unwrap(), "#ruma:example.com"); /// ``` @@ -61,8 +60,6 @@ impl RoomAliasId { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{OwnedRoomAliasId, RoomAliasId}; use crate::IdParseError; diff --git a/crates/ruma-common/src/identifiers/room_id.rs b/crates/ruma-common/src/identifiers/room_id.rs index 123626f9..aec7243d 100644 --- a/crates/ruma-common/src/identifiers/room_id.rs +++ b/crates/ruma-common/src/identifiers/room_id.rs @@ -10,7 +10,6 @@ use super::{matrix_uri::UriAction, EventId, MatrixToUri, MatrixUri, ServerName}; /// into a string as needed. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::RoomId; /// assert_eq!(<&RoomId>::try_from("!n8f893n9:example.com").unwrap(), "!n8f893n9:example.com"); /// ``` @@ -110,8 +109,6 @@ impl RoomId { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{OwnedRoomId, RoomId}; use crate::IdParseError; diff --git a/crates/ruma-common/src/identifiers/room_or_room_alias_id.rs b/crates/ruma-common/src/identifiers/room_or_room_alias_id.rs index ed22b606..1c1f83d5 100644 --- a/crates/ruma-common/src/identifiers/room_or_room_alias_id.rs +++ b/crates/ruma-common/src/identifiers/room_or_room_alias_id.rs @@ -1,6 +1,6 @@ //! Matrix identifiers for places where a room ID or room alias ID are used interchangeably. -use std::{convert::TryFrom, hint::unreachable_unchecked}; +use std::hint::unreachable_unchecked; use ruma_macros::IdZst; @@ -13,7 +13,6 @@ use super::{server_name::ServerName, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, /// string slice, the variant is determined by the leading sigil character. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::RoomOrAliasId; /// assert_eq!(<&RoomOrAliasId>::try_from("#ruma:example.com").unwrap(), "#ruma:example.com"); /// @@ -144,8 +143,6 @@ impl TryFrom for OwnedRoomAliasId { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{OwnedRoomOrAliasId, RoomOrAliasId}; use crate::IdParseError; diff --git a/crates/ruma-common/src/identifiers/room_version_id.rs b/crates/ruma-common/src/identifiers/room_version_id.rs index 88298a25..336d5b82 100644 --- a/crates/ruma-common/src/identifiers/room_version_id.rs +++ b/crates/ruma-common/src/identifiers/room_version_id.rs @@ -1,6 +1,6 @@ //! Matrix room version identifiers. -use std::{cmp::Ordering, convert::TryFrom, str::FromStr}; +use std::{cmp::Ordering, str::FromStr}; use ruma_macros::DisplayAsRefStr; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -13,7 +13,6 @@ use super::IdParseError; /// or serialized back into a string as needed. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::RoomVersionId; /// assert_eq!(RoomVersionId::try_from("1").unwrap().as_ref(), "1"); /// ``` @@ -246,8 +245,6 @@ impl AsRef for CustomRoomVersion { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::RoomVersionId; use crate::IdParseError; diff --git a/crates/ruma-common/src/identifiers/server_name.rs b/crates/ruma-common/src/identifiers/server_name.rs index 3beb562e..8ab8cda2 100644 --- a/crates/ruma-common/src/identifiers/server_name.rs +++ b/crates/ruma-common/src/identifiers/server_name.rs @@ -53,8 +53,6 @@ impl ServerName { #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::ServerName; #[test] diff --git a/crates/ruma-common/src/identifiers/user_id.rs b/crates/ruma-common/src/identifiers/user_id.rs index a0fda448..165a17db 100644 --- a/crates/ruma-common/src/identifiers/user_id.rs +++ b/crates/ruma-common/src/identifiers/user_id.rs @@ -10,7 +10,6 @@ use super::{matrix_uri::UriAction, IdParseError, MatrixToUri, MatrixUri, ServerN /// into a string as needed. /// /// ``` -/// # use std::convert::TryFrom; /// # use ruma_common::UserId; /// assert_eq!(<&UserId>::try_from("@carl:example.com").unwrap(), "@carl:example.com"); /// ``` @@ -155,8 +154,6 @@ use ruma_macros::IdZst; #[cfg(test)] mod tests { - use std::convert::TryFrom; - use super::{OwnedUserId, UserId}; use crate::{server_name, IdParseError}; diff --git a/crates/ruma-common/src/push/condition.rs b/crates/ruma-common/src/push/condition.rs index bcc32d4f..6d64c08e 100644 --- a/crates/ruma-common/src/push/condition.rs +++ b/crates/ruma-common/src/push/condition.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeMap, convert::TryFrom, ops::RangeBounds, str::FromStr}; +use std::{collections::BTreeMap, ops::RangeBounds, str::FromStr}; use js_int::{Int, UInt}; use serde::{Deserialize, Serialize}; diff --git a/crates/ruma-common/src/serde/canonical_json.rs b/crates/ruma-common/src/serde/canonical_json.rs index 513ccd0c..97263da1 100644 --- a/crates/ruma-common/src/serde/canonical_json.rs +++ b/crates/ruma-common/src/serde/canonical_json.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, fmt}; +use std::fmt; use serde::Serialize; use serde_json::{Error as JsonError, Value as JsonValue}; @@ -43,7 +43,7 @@ pub fn to_canonical_value(value: T) -> Result Deserialize<'de> for CanonicalJsonValue { #[cfg(test)] mod tests { - use std::convert::TryInto; - use serde_json::json; use super::CanonicalJsonValue; diff --git a/crates/ruma-common/src/serde/duration/opt_ms.rs b/crates/ruma-common/src/serde/duration/opt_ms.rs index 567d0b6b..3539aeba 100644 --- a/crates/ruma-common/src/serde/duration/opt_ms.rs +++ b/crates/ruma-common/src/serde/duration/opt_ms.rs @@ -3,7 +3,7 @@ //! //! Delegates to `js_int::UInt` to ensure integer size is within bounds. -use std::{convert::TryFrom, time::Duration}; +use std::time::Duration; use js_int::UInt; use serde::{ diff --git a/crates/ruma-common/src/serde/duration/secs.rs b/crates/ruma-common/src/serde/duration/secs.rs index 9ac56622..8ded36d5 100644 --- a/crates/ruma-common/src/serde/duration/secs.rs +++ b/crates/ruma-common/src/serde/duration/secs.rs @@ -3,7 +3,7 @@ //! //! Delegates to `js_int::UInt` to ensure integer size is within bounds. -use std::{convert::TryFrom, time::Duration}; +use std::time::Duration; use js_int::UInt; use serde::{ diff --git a/crates/ruma-common/src/serde/strings.rs b/crates/ruma-common/src/serde/strings.rs index 8bf24fe1..4e79bb11 100644 --- a/crates/ruma-common/src/serde/strings.rs +++ b/crates/ruma-common/src/serde/strings.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeMap, convert::TryInto, fmt, marker::PhantomData}; +use std::{collections::BTreeMap, fmt, marker::PhantomData}; use js_int::{Int, UInt}; use serde::{ diff --git a/crates/ruma-common/src/thirdparty.rs b/crates/ruma-common/src/thirdparty.rs index c0e9c770..b93dfed0 100644 --- a/crates/ruma-common/src/thirdparty.rs +++ b/crates/ruma-common/src/thirdparty.rs @@ -291,8 +291,6 @@ impl From for ThirdPartyIdentifier { #[cfg(test)] mod tests { - use std::convert::TryInto; - use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; use super::{Medium, ThirdPartyIdentifier}; diff --git a/crates/ruma-common/src/time.rs b/crates/ruma-common/src/time.rs index ae15df87..cd12e727 100644 --- a/crates/ruma-common/src/time.rs +++ b/crates/ruma-common/src/time.rs @@ -1,7 +1,4 @@ -use std::{ - convert::TryInto, - time::{Duration, SystemTime, UNIX_EPOCH}, -}; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; use js_int::{uint, UInt}; use serde::{Deserialize, Serialize}; @@ -83,7 +80,6 @@ impl SecondsSinceUnixEpoch { #[cfg(all(target_arch = "wasm32", target_os = "unknown", feature = "js"))] fn f64_to_uint(val: f64) -> UInt { - use std::convert::TryFrom; // UInt::MAX milliseconds is ~285 616 years, we do not account for that // (or for dates before the unix epoch which would have to be negative) UInt::try_from(val as u64).expect("date out of range") diff --git a/crates/ruma-common/src/to_device.rs b/crates/ruma-common/src/to_device.rs index 384d5284..2305e7ac 100644 --- a/crates/ruma-common/src/to_device.rs +++ b/crates/ruma-common/src/to_device.rs @@ -2,10 +2,7 @@ //! //! [send-to-device]: https://spec.matrix.org/v1.2/client-server-api/#send-to-device-messaging -use std::{ - convert::TryFrom, - fmt::{Display, Formatter, Result as FmtResult}, -}; +use std::fmt::{Display, Formatter, Result as FmtResult}; use serde::{ de::{self, Unexpected}, diff --git a/crates/ruma-common/tests/events/initial_state.rs b/crates/ruma-common/tests/events/initial_state.rs index 6f90e712..240756dd 100644 --- a/crates/ruma-common/tests/events/initial_state.rs +++ b/crates/ruma-common/tests/events/initial_state.rs @@ -1,5 +1,3 @@ -use std::convert::TryFrom; - use assert_matches::assert_matches; use ruma_common::{ events::{AnyInitialStateEvent, InitialStateEvent}, diff --git a/crates/ruma-common/tests/events/message.rs b/crates/ruma-common/tests/events/message.rs index 56cca5f1..e18b4c80 100644 --- a/crates/ruma-common/tests/events/message.rs +++ b/crates/ruma-common/tests/events/message.rs @@ -1,7 +1,5 @@ #![cfg(feature = "unstable-msc1767")] -use std::convert::TryFrom; - use assert_matches::assert_matches; use assign::assign; use js_int::uint; diff --git a/crates/ruma-common/tests/events/pdu.rs b/crates/ruma-common/tests/events/pdu.rs index 73e4cbe2..a1f03e97 100644 --- a/crates/ruma-common/tests/events/pdu.rs +++ b/crates/ruma-common/tests/events/pdu.rs @@ -1,6 +1,6 @@ #![cfg(all(feature = "unstable-pdu"))] -use std::{collections::BTreeMap, convert::TryInto}; +use std::collections::BTreeMap; use js_int::uint; use ruma_common::{ diff --git a/crates/ruma-common/tests/events/poll.rs b/crates/ruma-common/tests/events/poll.rs index b4687624..0b66c15d 100644 --- a/crates/ruma-common/tests/events/poll.rs +++ b/crates/ruma-common/tests/events/poll.rs @@ -1,7 +1,5 @@ #![cfg(feature = "unstable-msc3381")] -use std::convert::TryInto; - use assert_matches::assert_matches; use assign::assign; use js_int::uint; diff --git a/crates/ruma-common/tests/events/stripped.rs b/crates/ruma-common/tests/events/stripped.rs index 5f27a89b..3abf2947 100644 --- a/crates/ruma-common/tests/events/stripped.rs +++ b/crates/ruma-common/tests/events/stripped.rs @@ -1,5 +1,3 @@ -use std::convert::TryFrom; - use js_int::uint; use ruma_common::{ events::{ diff --git a/crates/ruma-federation-api/Cargo.toml b/crates/ruma-federation-api/Cargo.toml index 427d985c..a381f164 100644 --- a/crates/ruma-federation-api/Cargo.toml +++ b/crates/ruma-federation-api/Cargo.toml @@ -1,7 +1,7 @@ [package] categories = ["api-bindings", "web-programming"] description = "Types for the endpoints in the Matrix server-server API." -edition = "2018" +edition = "2021" homepage = "https://www.ruma.io/" keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" diff --git a/crates/ruma-identifiers-validation/Cargo.toml b/crates/ruma-identifiers-validation/Cargo.toml index 858d65f7..08397765 100644 --- a/crates/ruma-identifiers-validation/Cargo.toml +++ b/crates/ruma-identifiers-validation/Cargo.toml @@ -5,7 +5,7 @@ homepage = "https://www.ruma.io/" repository = "https://github.com/ruma/ruma" license = "MIT" version = "0.8.1" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-identity-service-api/Cargo.toml b/crates/ruma-identity-service-api/Cargo.toml index 8418f9b1..14c6600c 100644 --- a/crates/ruma-identity-service-api/Cargo.toml +++ b/crates/ruma-identity-service-api/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" readme = "README.md" repository = "https://github.com/ruma/ruma" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-macros/Cargo.toml b/crates/ruma-macros/Cargo.toml index 01bd7556..8e9e3d3e 100644 --- a/crates/ruma-macros/Cargo.toml +++ b/crates/ruma-macros/Cargo.toml @@ -1,7 +1,7 @@ [package] categories = ["api-bindings", "web-programming"] description = "Procedural macros used by the Ruma crates." -edition = "2018" +edition = "2021" homepage = "https://www.ruma.io/" keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" diff --git a/crates/ruma-macros/src/api/request.rs b/crates/ruma-macros/src/api/request.rs index 77a0c96b..92466dd7 100644 --- a/crates/ruma-macros/src/api/request.rs +++ b/crates/ruma-macros/src/api/request.rs @@ -1,7 +1,4 @@ -use std::{ - collections::{BTreeMap, BTreeSet}, - convert::{TryFrom, TryInto}, -}; +use std::collections::{BTreeMap, BTreeSet}; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; diff --git a/crates/ruma-macros/src/api/response.rs b/crates/ruma-macros/src/api/response.rs index 0017524b..131be0bd 100644 --- a/crates/ruma-macros/src/api/response.rs +++ b/crates/ruma-macros/src/api/response.rs @@ -1,7 +1,4 @@ -use std::{ - convert::{TryFrom, TryInto}, - ops::Not, -}; +use std::ops::Not; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; diff --git a/crates/ruma-macros/src/api/version.rs b/crates/ruma-macros/src/api/version.rs index c7687bf7..af3eb811 100644 --- a/crates/ruma-macros/src/api/version.rs +++ b/crates/ruma-macros/src/api/version.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, num::NonZeroU8}; +use std::num::NonZeroU8; use proc_macro2::TokenStream; use quote::{format_ident, quote, ToTokens}; diff --git a/crates/ruma-push-gateway-api/Cargo.toml b/crates/ruma-push-gateway-api/Cargo.toml index 6770b569..0a04c133 100644 --- a/crates/ruma-push-gateway-api/Cargo.toml +++ b/crates/ruma-push-gateway-api/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["matrix", "chat", "messaging", "ruma"] license = "MIT" readme = "README.md" repository = "https://github.com/ruma/ruma" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-signatures/Cargo.toml b/crates/ruma-signatures/Cargo.toml index 06dd2047..f5571837 100644 --- a/crates/ruma-signatures/Cargo.toml +++ b/crates/ruma-signatures/Cargo.toml @@ -1,7 +1,7 @@ [package] categories = ["api-bindings", "cryptography"] description = "Digital signatures according to the Matrix specification." -edition = "2018" +edition = "2021" homepage = "https://www.ruma.io/" keywords = ["matrix", "chat", "messaging", "ruma", "cryptography"] license = "MIT" diff --git a/crates/ruma-signatures/src/functions.rs b/crates/ruma-signatures/src/functions.rs index 30288dda..6386a931 100644 --- a/crates/ruma-signatures/src/functions.rs +++ b/crates/ruma-signatures/src/functions.rs @@ -3,7 +3,6 @@ use std::{ borrow::Cow, collections::{BTreeMap, BTreeSet}, - convert::TryFrom, mem, }; @@ -876,10 +875,7 @@ fn is_third_party_invite(object: &CanonicalJsonObject) -> Result { #[cfg(test)] mod tests { - use std::{ - collections::BTreeMap, - convert::{TryFrom, TryInto}, - }; + use std::collections::BTreeMap; use ruma_common::{ serde::{Base64, CanonicalJsonValue}, diff --git a/crates/ruma-signatures/src/verification.rs b/crates/ruma-signatures/src/verification.rs index 8c47ac4a..8b8efae9 100644 --- a/crates/ruma-signatures/src/verification.rs +++ b/crates/ruma-signatures/src/verification.rs @@ -1,7 +1,5 @@ //! Verification of digital signatures. -use std::convert::TryInto; - use ed25519_dalek::{PublicKey, Verifier as _}; use crate::{Error, ParseError, VerificationError}; diff --git a/crates/ruma-state-res/Cargo.toml b/crates/ruma-state-res/Cargo.toml index 210c4a53..afac81c2 100644 --- a/crates/ruma-state-res/Cargo.toml +++ b/crates/ruma-state-res/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/ruma/ruma" readme = "README.md" license = "MIT" version = "0.7.0" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/crates/ruma-state-res/benches/state_res_bench.rs b/crates/ruma-state-res/benches/state_res_bench.rs index 7faa2ec2..ff70b3a3 100644 --- a/crates/ruma-state-res/benches/state_res_bench.rs +++ b/crates/ruma-state-res/benches/state_res_bench.rs @@ -10,7 +10,6 @@ use std::{ borrow::Borrow, collections::{HashMap, HashSet}, - convert::TryInto, sync::{ atomic::{AtomicU64, Ordering::SeqCst}, Arc, diff --git a/crates/ruma-state-res/src/event_auth.rs b/crates/ruma-state-res/src/event_auth.rs index 019611fa..63518efb 100644 --- a/crates/ruma-state-res/src/event_auth.rs +++ b/crates/ruma-state-res/src/event_auth.rs @@ -1,4 +1,4 @@ -use std::{borrow::Borrow, collections::BTreeSet, convert::TryFrom}; +use std::{borrow::Borrow, collections::BTreeSet}; use js_int::{int, Int}; use ruma_common::{ diff --git a/crates/ruma-state-res/src/test_utils.rs b/crates/ruma-state-res/src/test_utils.rs index 196d9a1d..d8e387cf 100644 --- a/crates/ruma-state-res/src/test_utils.rs +++ b/crates/ruma-state-res/src/test_utils.rs @@ -1,7 +1,6 @@ use std::{ borrow::Borrow, collections::{BTreeMap, HashMap, HashSet}, - convert::TryInto, sync::{ atomic::{AtomicU64, Ordering::SeqCst}, Arc, diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 5df8ef49..0cd28d77 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/ruma/ruma" readme = "README.md" license = "MIT" version = "0.6.2" -edition = "2018" +edition = "2021" [package.metadata.docs.rs] all-features = true diff --git a/examples/hello_isahc/Cargo.toml b/examples/hello_isahc/Cargo.toml index 54c91ff6..a4ea2293 100644 --- a/examples/hello_isahc/Cargo.toml +++ b/examples/hello_isahc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_isahc" version = "0.1.0" -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/hello_isahc/src/main.rs b/examples/hello_isahc/src/main.rs index 4aa20c4d..b8d23814 100644 --- a/examples/hello_isahc/src/main.rs +++ b/examples/hello_isahc/src/main.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, env, process::exit}; +use std::{env, process::exit}; use ruma::{ api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event}, diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 463d7da4..7aac8811 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_world" version = "0.1.0" -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs index b6add0cc..dc7c3257 100644 --- a/examples/hello_world/src/main.rs +++ b/examples/hello_world/src/main.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, env, process::exit}; +use std::{env, process::exit}; use ruma::{ api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event}, diff --git a/examples/joke_bot/Cargo.toml b/examples/joke_bot/Cargo.toml index 1eeab2db..d5ec7e62 100644 --- a/examples/joke_bot/Cargo.toml +++ b/examples/joke_bot/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "joke_bot" version = "0.1.0" -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/joke_bot/src/main.rs b/examples/joke_bot/src/main.rs index 8a079dd0..d5b0198c 100644 --- a/examples/joke_bot/src/main.rs +++ b/examples/joke_bot/src/main.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, error::Error, io, process::exit, time::Duration}; +use std::{error::Error, io, process::exit, time::Duration}; use futures_util::future::{join, join_all}; use ruma::{ diff --git a/examples/message_log/Cargo.toml b/examples/message_log/Cargo.toml index 3326e544..f2ab0049 100644 --- a/examples/message_log/Cargo.toml +++ b/examples/message_log/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "message_log" version = "0.1.0" -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 50918ad8..48f59248 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "xtask" version = "0.1.0" -edition = "2018" +edition = "2021" publish = false [features]