Bump MSRV to 1.40.0

This commit is contained in:
Jonas Platte 2020-05-02 22:14:05 +02:00
parent 14ba542ba1
commit 17faaaa56e
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
22 changed files with 11 additions and 193 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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! {

View File

@ -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! {

View File

@ -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.")
}
}
}
}

View File

@ -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.")
}
}
}
}

View File

@ -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)

View File

@ -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! {

View File

@ -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)

View File

@ -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)

View File

@ -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! {

View File

@ -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.");
}
}
}
}

View File

@ -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.",
)),
}
}
}

View File

@ -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! {

View File

@ -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! {

View File

@ -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! {

View File

@ -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.")
}
}
}
}

View File

@ -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.

View File

@ -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! {

View File

@ -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! {

View File

@ -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");