From 17faaaa56e08d8e26015d6009f581c7e3e970110 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 2 May 2020 22:14:05 +0200 Subject: [PATCH] Bump MSRV to 1.40.0 --- .builds/msrv.yml | 4 ++-- README.md | 2 +- src/algorithm.rs | 9 +-------- src/call.rs | 7 +------ src/call/hangup.rs | 6 ------ src/collections/raw/all.rs | 9 --------- src/collections/raw/only.rs | 6 ------ src/event_type.rs | 9 +-------- src/key/verification.rs | 30 ---------------------------- src/key/verification/cancel.rs | 8 -------- src/macros.rs | 1 - src/presence.rs | 6 ------ src/push_rules.rs | 8 -------- src/room/encrypted.rs | 17 +--------------- src/room/guest_access.rs | 7 +------ src/room/history_visibility.rs | 6 ------ src/room/join_rules.rs | 6 +----- src/room/member.rs | 14 ------------- src/room/message.rs | 36 ---------------------------------- src/room/message/feedback.rs | 6 +----- src/room_key_request.rs | 6 +----- src/to_device.rs | 1 - 22 files changed, 11 insertions(+), 193 deletions(-) diff --git a/.builds/msrv.yml b/.builds/msrv.yml index 7241edeb..3557d9a4 100644 --- a/.builds/msrv.yml +++ b/.builds/msrv.yml @@ -6,8 +6,8 @@ sources: tasks: - rustup: | # We specify --profile minimal because we'd otherwise download docs - rustup toolchain install 1.38.0 --profile minimal - rustup default 1.38.0 + rustup toolchain install 1.40.0 --profile minimal + rustup default 1.40.0 - test: | cd ruma-events diff --git a/README.md b/README.md index 0c58e246..347aedb8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Minimum Rust version -ruma-events requires Rust 1.38.0 or later. +ruma-events requires Rust 1.40.0 or later. ## Documentation diff --git a/src/algorithm.rs b/src/algorithm.rs index 803f3f61..2406be08 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; /// An encryption algorithm to be used to encrypt messages sent to a room. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] #[serde(from = "String", into = "String")] pub enum Algorithm { /// Olm version 1 using Curve25519, AES-256, and SHA-256. @@ -14,11 +15,6 @@ pub enum Algorithm { /// Any algorithm that is not part of the specification. Custom(String), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to `ruma-events`. - #[doc(hidden)] - __Nonexhaustive, } impl Display for Algorithm { @@ -27,9 +23,6 @@ impl Display for Algorithm { Algorithm::OlmV1Curve25519AesSha2 => "m.olm.v1.curve25519-aes-sha2", Algorithm::MegolmV1AesSha2 => "m.megolm.v1.aes-sha2", Algorithm::Custom(ref algorithm) => algorithm, - Algorithm::__Nonexhaustive => { - panic!("__Nonexhaustive enum variant is not intended for use.") - } }; write!(f, "{}", algorithm_str) diff --git a/src/call.rs b/src/call.rs index efb4482e..35df497c 100644 --- a/src/call.rs +++ b/src/call.rs @@ -22,6 +22,7 @@ pub struct SessionDescription { /// The type of VoIP session description. #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] +#[non_exhaustive] #[serde(rename_all = "lowercase")] pub enum SessionDescriptionType { /// An answer. @@ -29,12 +30,6 @@ pub enum SessionDescriptionType { /// An offer. Offer, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/call/hangup.rs b/src/call/hangup.rs index 6ca4d100..205fd988 100644 --- a/src/call/hangup.rs +++ b/src/call/hangup.rs @@ -37,12 +37,6 @@ pub enum Reason { /// Party did not answer in time. InviteTimeout, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/collections/raw/all.rs b/src/collections/raw/all.rs index fbe78ef5..92793f97 100644 --- a/src/collections/raw/all.rs +++ b/src/collections/raw/all.rs @@ -405,9 +405,6 @@ impl<'de> Deserialize<'de> for Event { from_value(value, Event::Custom) } } - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } @@ -474,9 +471,6 @@ impl<'de> Deserialize<'de> for RoomEvent { | RoomKeyRequest | Tag | Typing => Err(D::Error::custom("invalid event type")), - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } @@ -537,9 +531,6 @@ impl<'de> Deserialize<'de> for StateEvent { | Sticker | Tag | Typing => Err(D::Error::custom("invalid event type")), - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } diff --git a/src/collections/raw/only.rs b/src/collections/raw/only.rs index c720949f..ea96c1a8 100644 --- a/src/collections/raw/only.rs +++ b/src/collections/raw/only.rs @@ -190,9 +190,6 @@ impl<'de> Deserialize<'de> for Event { | RoomTopic | RoomRedaction | Sticker => Err(D::Error::custom("invalid event type")), - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } @@ -253,9 +250,6 @@ impl<'de> Deserialize<'de> for RoomEvent { | RoomTopic | Tag | Typing => Err(D::Error::custom("invalid event type")), - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } diff --git a/src/event_type.rs b/src/event_type.rs index 95113922..715026bd 100644 --- a/src/event_type.rs +++ b/src/event_type.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; /// The type of an event. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[non_exhaustive] #[serde(from = "String", into = "String")] pub enum EventType { /// m.call.answer @@ -137,11 +138,6 @@ pub enum EventType { /// Any event that is not part of the specification. Custom(String), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl Display for EventType { @@ -191,9 +187,6 @@ impl Display for EventType { EventType::Tag => "m.tag", EventType::Typing => "m.typing", EventType::Custom(ref event_type) => event_type, - EventType::__Nonexhaustive => { - panic!("__Nonexhaustive enum variant is not intended for use.") - } }; write!(f, "{}", event_type_str) diff --git a/src/key/verification.rs b/src/key/verification.rs index ca3572d9..fb119ee5 100644 --- a/src/key/verification.rs +++ b/src/key/verification.rs @@ -17,12 +17,6 @@ pub enum HashAlgorithm { /// The SHA256 hash algorithm. #[serde(rename = "sha256")] Sha256, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { @@ -37,12 +31,6 @@ pub enum KeyAgreementProtocol { /// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol. #[serde(rename = "curve25519")] Curve25519, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { @@ -57,12 +45,6 @@ pub enum MessageAuthenticationCode { /// The HKDF-HMAC-SHA256 MAC. #[serde(rename = "hkdf-hmac-sha256")] HkdfHmacSha256, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { @@ -81,12 +63,6 @@ pub enum ShortAuthenticationString { /// The emoji method. #[serde(rename = "emoji")] Emoji, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { @@ -102,12 +78,6 @@ pub enum VerificationMethod { /// The *m.sas.v1* verification method. #[serde(rename = "m.sas.v1")] MSasV1, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/key/verification/cancel.rs b/src/key/verification/cancel.rs index d4430ade..9c9a0283 100644 --- a/src/key/verification/cancel.rs +++ b/src/key/verification/cancel.rs @@ -70,11 +70,6 @@ pub enum CancelCode { /// Any code that is not part of the specification. Custom(String), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl Display for CancelCode { @@ -90,9 +85,6 @@ impl Display for CancelCode { CancelCode::InvalidMessage => "m.invalid_message", CancelCode::Accepted => "m.accepted", CancelCode::Custom(ref cancel_code) => cancel_code, - CancelCode::__Nonexhaustive => { - panic!("__Nonexhaustive enum variant is not intended for use.") - } }; write!(f, "{}", cancel_code_str) diff --git a/src/macros.rs b/src/macros.rs index 3d339b4e..d9b95a15 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -4,7 +4,6 @@ macro_rules! impl_enum { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { let variant = match *self { $($name::$variant => $s,)* - $name::__Nonexhaustive => panic!("__Nonexhaustive enum variant is not intended for use."), }; write!(f, "{}", variant) diff --git a/src/presence.rs b/src/presence.rs index 41b5ce23..8d721945 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -55,12 +55,6 @@ pub enum PresenceState { /// Connected to the service but not available for chat. #[serde(rename = "unavailable")] Unavailable, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/push_rules.rs b/src/push_rules.rs index 270f8f6c..9795b5f6 100644 --- a/src/push_rules.rs +++ b/src/push_rules.rs @@ -124,11 +124,6 @@ pub enum PushCondition { /// This takes into account the current power levels in the room, ensuring the sender of the /// event has high enough power to trigger the notification. SenderNotificationPermission(SenderNotificationPermissionCondition), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl Serialize for PushCondition { @@ -149,9 +144,6 @@ impl Serialize for PushCondition { PushCondition::SenderNotificationPermission(ref condition) => { condition.serialize(serializer) } - PushCondition::__Nonexhaustive => { - panic!("__Nonexhaustive enum variant is not intended for use."); - } } } } diff --git a/src/room/encrypted.rs b/src/room/encrypted.rs index 6a616182..bf517ac7 100644 --- a/src/room/encrypted.rs +++ b/src/room/encrypted.rs @@ -39,6 +39,7 @@ pub struct EncryptedEvent { /// The payload for `EncryptedEvent`. #[derive(Clone, Debug, Serialize)] +#[non_exhaustive] #[serde(untagged)] pub enum EncryptedEventContent { /// An event encrypted with *m.olm.v1.curve25519-aes-sha2*. @@ -46,11 +47,6 @@ pub enum EncryptedEventContent { /// An event encrypted with *m.megolm.v1.aes-sha2*. MegolmV1AesSha2(MegolmV1AesSha2Content), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl FromRaw for EncryptedEvent { @@ -79,9 +75,6 @@ impl FromRaw for EncryptedEventContent { EncryptedEventContent::OlmV1Curve25519AesSha2(content) } MegolmV1AesSha2(content) => EncryptedEventContent::MegolmV1AesSha2(content), - __Nonexhaustive => { - unreachable!("__Nonexhaustive variant should be impossible to obtain.") - } } } } @@ -137,11 +130,6 @@ pub(crate) mod raw { /// An event encrypted with *m.megolm.v1.aes-sha2*. MegolmV1AesSha2(MegolmV1AesSha2Content), - - /// Additional variants may be added in the future and will not be considered breaking - /// changes to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl<'de> Deserialize<'de> for EncryptedEventContent { @@ -183,9 +171,6 @@ pub(crate) mod raw { Algorithm::Custom(_) => Err(D::Error::custom( "Custom algorithms are not supported by `EncryptedEventContent`.", )), - Algorithm::__Nonexhaustive => Err(D::Error::custom( - "Attempted to deserialize __Nonexhaustive variant.", - )), } } } diff --git a/src/room/guest_access.rs b/src/room/guest_access.rs index 62ea189c..fe1c451c 100644 --- a/src/room/guest_access.rs +++ b/src/room/guest_access.rs @@ -20,6 +20,7 @@ ruma_event! { /// A policy for guest user access to a room. #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] +#[non_exhaustive] #[serde(rename_all = "snake_case")] pub enum GuestAccess { /// Guests are allowed to join the room. @@ -27,12 +28,6 @@ pub enum GuestAccess { /// Guests are not allowed to join the room. Forbidden, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/room/history_visibility.rs b/src/room/history_visibility.rs index 0cf6f63c..1627886c 100644 --- a/src/room/history_visibility.rs +++ b/src/room/history_visibility.rs @@ -37,12 +37,6 @@ pub enum HistoryVisibility { /// All events while this is the `HistoryVisibility` value may be shared by any /// participating homeserver with anyone, regardless of whether they have ever joined the room. WorldReadable, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { diff --git a/src/room/join_rules.rs b/src/room/join_rules.rs index 949556bf..29747547 100644 --- a/src/room/join_rules.rs +++ b/src/room/join_rules.rs @@ -32,11 +32,7 @@ pub enum JoinRule { /// Anyone can join the room without any prior action. Public, - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, + } impl_enum! { diff --git a/src/room/member.rs b/src/room/member.rs index a49fd42c..514b6139 100644 --- a/src/room/member.rs +++ b/src/room/member.rs @@ -80,12 +80,6 @@ pub enum MembershipState { /// The user has left. Leave, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } impl_enum! { @@ -168,11 +162,6 @@ pub enum MembershipChange { /// Not implemented. NotImplemented, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl MemberEvent { @@ -210,9 +199,6 @@ impl MemberEvent { (Leave, Invite) => MembershipChange::Invited, (Ban, Leave) => MembershipChange::Unbanned, (Knock, _) | (_, Knock) => MembershipChange::NotImplemented, - (__Nonexhaustive, _) | (_, __Nonexhaustive) => { - panic!("__Nonexhaustive enum variant is not intended for use.") - } } } } diff --git a/src/room/message.rs b/src/room/message.rs index f85b04aa..c735c41a 100644 --- a/src/room/message.rs +++ b/src/room/message.rs @@ -71,11 +71,6 @@ pub enum MessageEventContent { /// A encrypted message. Encrypted(EncryptedEventContent), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl FromRaw for MessageEvent { @@ -110,9 +105,6 @@ impl FromRaw for MessageEventContent { Text(content) => MessageEventContent::Text(content), Video(content) => MessageEventContent::Video(content), Encrypted(content) => MessageEventContent::Encrypted(content), - __Nonexhaustive => { - unreachable!("It should be impossible to obtain a __Nonexhaustive variant.") - } } } } @@ -191,11 +183,6 @@ pub(crate) mod raw { /// A video message. Encrypted(EncryptedEventContent), - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - __Nonexhaustive, } impl<'de> Deserialize<'de> for MessageEventContent { @@ -237,11 +224,6 @@ pub(crate) mod raw { MessageType::ServerNotice => deserialize_content(content, Self::ServerNotice), MessageType::Text => deserialize_content(content, Self::Text), MessageType::Video => deserialize_content(content, Self::Video), - MessageType::__Nonexhaustive => { - return Err(D::Error::custom( - "Attempted to deserialize __Nonexhaustive variant.", - )) - } } .map_err(D::Error::custom) } @@ -286,12 +268,6 @@ pub enum MessageType { /// A video message. #[serde(rename = "m.video")] Video, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } /// The payload for an audio message. @@ -505,12 +481,6 @@ pub enum ServerNoticeType { /// The server has exceeded some limit which requires the server administrator to intervene. #[serde(rename = "m.server_notice.usage_limit_reached")] UsageLimitReached, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } /// Types of usage limits. @@ -522,12 +492,6 @@ pub enum LimitType { /// New connections are being refused by the server. What defines "active" is left as an /// implementation detail, however servers are encouraged to treat syncing users as "active". MonthlyActiveUser, - - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, } /// The payload for a text message. diff --git a/src/room/message/feedback.rs b/src/room/message/feedback.rs index 9a8b4bfc..4aa21f1c 100644 --- a/src/room/message/feedback.rs +++ b/src/room/message/feedback.rs @@ -33,11 +33,7 @@ pub enum FeedbackType { /// Sent when a message has been observed by the end user. Read, - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, + } impl_enum! { diff --git a/src/room_key_request.rs b/src/room_key_request.rs index fa94a06b..c9c580f0 100644 --- a/src/room_key_request.rs +++ b/src/room_key_request.rs @@ -45,11 +45,7 @@ pub enum Action { #[serde(rename = "request_cancellation")] CancelRequest, - /// Additional variants may be added in the future and will not be considered breaking changes - /// to ruma-events. - #[doc(hidden)] - #[serde(skip)] - __Nonexhaustive, + } impl_enum! { diff --git a/src/to_device.rs b/src/to_device.rs index 966c542f..343a9b11 100644 --- a/src/to_device.rs +++ b/src/to_device.rs @@ -496,7 +496,6 @@ mod tests { let content = match &event.content { StartEventContent::MSasV1(c) => c, - _ => panic!("Key verification content deserialized into the wrong content type"), }; assert_eq!(content.from_device, "AliceDevice1");