diff --git a/crates/ruma-common/tests/events/enums.rs b/crates/ruma-common/tests/events/enums.rs index 6ed882c0..68eaee84 100644 --- a/crates/ruma-common/tests/events/enums.rs +++ b/crates/ruma-common/tests/events/enums.rs @@ -12,9 +12,9 @@ use ruma_common::{ }, AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncMessageLikeEvent, AnySyncRoomEvent, AnySyncStateEvent, - EphemeralRoomEventType, EventType, GlobalAccountDataEventType, MessageLikeEvent, - MessageLikeEventType, RoomAccountDataEventType, StateEvent, StateEventType, - SyncMessageLikeEvent, SyncStateEvent, ToDeviceEventType, Unsigned, + EphemeralRoomEventType, GlobalAccountDataEventType, MessageLikeEvent, MessageLikeEventType, + RoomAccountDataEventType, StateEvent, StateEventType, SyncMessageLikeEvent, SyncStateEvent, + ToDeviceEventType, Unsigned, }, MilliSecondsSinceUnixEpoch, }; @@ -323,7 +323,10 @@ fn ephemeral_event_deserialization() { } #[test] +#[allow(deprecated)] fn serialize_and_deserialize_from_display_form() { + use ruma_common::events::EventType; + serde_json_eq(EventType::CallAnswer, json!("m.call.answer")); serde_json_eq(MessageLikeEventType::CallAnswer, json!("m.call.answer")); serde_json_eq(EventType::CallCandidates, json!("m.call.candidates")); diff --git a/crates/ruma-macros/src/events/event_type.rs b/crates/ruma-macros/src/events/event_type.rs index 5e8025a3..5d8789e0 100644 --- a/crates/ruma-macros/src/events/event_type.rs +++ b/crates/ruma-macros/src/events/event_type.rs @@ -65,6 +65,12 @@ fn generate_enum( let byte_doc = format!("Creates a byte slice from this `{}`.", ident); let enum_doc = format!("The type of `{}` this is.", ident.strip_suffix("Type").unwrap()); + let deprecated_attr = (ident == "EventType").then(|| { + quote! { + #[deprecated = "use a fine-grained event type enum like RoomEventType instead"] + } + }); + let ident = Ident::new(ident, Span::call_site()); let mut deduped: Vec<&EventEnumEntry> = vec![]; @@ -88,6 +94,7 @@ fn generate_enum( /// /// This type can hold an arbitrary string. To check for events that are not available as a /// documented variant here, use its string representation, obtained through `.as_str()`. + #deprecated_attr #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, #ruma_common::serde::StringEnum)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub enum #ident { @@ -100,6 +107,7 @@ fn generate_enum( _Custom(crate::PrivOwnedStr), } + #[allow(deprecated)] impl #ident { #[doc = #str_doc] pub fn as_str(&self) -> &str {