diff --git a/crates/ruma-api-macros/src/api/request.rs b/crates/ruma-api-macros/src/api/request.rs index d9320e33..1a8ecef7 100644 --- a/crates/ruma-api-macros/src/api/request.rs +++ b/crates/ruma-api-macros/src/api/request.rs @@ -142,13 +142,6 @@ impl Request { ); let struct_attributes = &self.attributes; - let request_def = if self.fields.is_empty() { - quote!(;) - } else { - let fields = self.fields.iter().map(|request_field| request_field.field()); - quote! { { #(#fields),* } } - }; - let request_body_struct = if let Some(body_field) = self.fields.iter().find(|f| f.is_newtype_body()) { let field = Field { ident: None, colon_token: None, ..body_field.field().clone() }; @@ -232,6 +225,8 @@ impl Request { }; let lifetimes = self.combine_lifetimes(); + let fields = self.fields.iter().map(|request_field| request_field.field()); + let outgoing_request_impl = self.expand_outgoing(metadata, error_ty, &lifetimes, ruma_api); let incoming_request_impl = self.expand_incoming(metadata, error_ty, ruma_api); @@ -241,7 +236,9 @@ impl Request { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[incoming_derive(!Deserialize)] #( #struct_attributes )* - pub struct Request #lifetimes #request_def + pub struct Request #lifetimes { + #(#fields),* + } #request_body_struct #request_query_struct diff --git a/crates/ruma-api-macros/src/api/response.rs b/crates/ruma-api-macros/src/api/response.rs index a464c0c2..5aa412f1 100644 --- a/crates/ruma-api-macros/src/api/response.rs +++ b/crates/ruma-api-macros/src/api/response.rs @@ -52,22 +52,11 @@ impl Response { format!("Data in the response from the `{}` API endpoint.", metadata.name.value()); let struct_attributes = &self.attributes; - let response_def = if self.fields.is_empty() { - quote!(;) - } else { - let fields = self.fields.iter().map(|response_field| response_field.field()); - quote! { { #(#fields),* } } - }; - let def = if let Some(body_field) = self.fields.iter().find(|f| f.is_newtype_body()) { let field = Field { ident: None, colon_token: None, ..body_field.field().clone() }; - quote! { (#field); } } else if self.has_body_fields() { - let fields = self.fields.iter().filter(|f| f.is_body()); - - let fields = fields.map(ResponseField::field); - + let fields = self.fields.iter().filter(|f| f.is_body()).map(ResponseField::field); quote! { { #(#fields),* } } } else { quote! { {} } @@ -91,6 +80,8 @@ impl Response { quote! { #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] } }; + let fields = self.fields.iter().map(|response_field| response_field.field()); + let outgoing_response_impl = self.expand_outgoing(ruma_api); let incoming_response_impl = self.expand_incoming(error_ty, ruma_api); @@ -100,7 +91,9 @@ impl Response { #non_exhaustive_attr #[incoming_derive(!Deserialize)] #( #struct_attributes )* - pub struct Response #response_def + pub struct Response { + #(#fields),* + } #response_body_struct diff --git a/crates/ruma-appservice-api/src/event/push_events/v1.rs b/crates/ruma-appservice-api/src/event/push_events/v1.rs index e14c6dd8..2eab1939 100644 --- a/crates/ruma-appservice-api/src/event/push_events/v1.rs +++ b/crates/ruma-appservice-api/src/event/push_events/v1.rs @@ -92,7 +92,7 @@ impl IncomingRequest { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-appservice-api/src/query/query_room_alias/v1.rs b/crates/ruma-appservice-api/src/query/query_room_alias/v1.rs index 9bbb9417..1cc2e9e9 100644 --- a/crates/ruma-appservice-api/src/query/query_room_alias/v1.rs +++ b/crates/ruma-appservice-api/src/query/query_room_alias/v1.rs @@ -33,6 +33,6 @@ impl<'a> Request<'a> { impl Response { /// Create an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-appservice-api/src/query/query_user_id/v1.rs b/crates/ruma-appservice-api/src/query/query_user_id/v1.rs index 262595bf..ffa057c9 100644 --- a/crates/ruma-appservice-api/src/query/query_user_id/v1.rs +++ b/crates/ruma-appservice-api/src/query/query_user_id/v1.rs @@ -33,6 +33,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/account/add_3pid.rs b/crates/ruma-client-api/src/r0/account/add_3pid.rs index 7d964ecd..1759ee70 100644 --- a/crates/ruma-client-api/src/r0/account/add_3pid.rs +++ b/crates/ruma-client-api/src/r0/account/add_3pid.rs @@ -42,6 +42,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/account/bind_3pid.rs b/crates/ruma-client-api/src/r0/account/bind_3pid.rs index 04cbe373..13ee6476 100644 --- a/crates/ruma-client-api/src/r0/account/bind_3pid.rs +++ b/crates/ruma-client-api/src/r0/account/bind_3pid.rs @@ -48,6 +48,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/account/change_password.rs b/crates/ruma-client-api/src/r0/account/change_password.rs index e50f763b..58bc3a10 100644 --- a/crates/ruma-client-api/src/r0/account/change_password.rs +++ b/crates/ruma-client-api/src/r0/account/change_password.rs @@ -49,6 +49,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/account/whoami.rs b/crates/ruma-client-api/src/r0/account/whoami.rs index b304227e..b276c1b0 100644 --- a/crates/ruma-client-api/src/r0/account/whoami.rs +++ b/crates/ruma-client-api/src/r0/account/whoami.rs @@ -27,7 +27,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/alias/create_alias.rs b/crates/ruma-client-api/src/r0/alias/create_alias.rs index 5516af42..4e4d340b 100644 --- a/crates/ruma-client-api/src/r0/alias/create_alias.rs +++ b/crates/ruma-client-api/src/r0/alias/create_alias.rs @@ -38,6 +38,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/alias/delete_alias.rs b/crates/ruma-client-api/src/r0/alias/delete_alias.rs index fdc8f484..e3e30be7 100644 --- a/crates/ruma-client-api/src/r0/alias/delete_alias.rs +++ b/crates/ruma-client-api/src/r0/alias/delete_alias.rs @@ -35,6 +35,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/appservice/set_room_visibility.rs b/crates/ruma-client-api/src/r0/appservice/set_room_visibility.rs index d8d4a874..548e2edd 100644 --- a/crates/ruma-client-api/src/r0/appservice/set_room_visibility.rs +++ b/crates/ruma-client-api/src/r0/appservice/set_room_visibility.rs @@ -44,6 +44,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/backup/delete_backup.rs b/crates/ruma-client-api/src/r0/backup/delete_backup.rs index 969e2ba5..1e7aa638 100644 --- a/crates/ruma-client-api/src/r0/backup/delete_backup.rs +++ b/crates/ruma-client-api/src/r0/backup/delete_backup.rs @@ -34,6 +34,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/backup/get_latest_backup.rs b/crates/ruma-client-api/src/r0/backup/get_latest_backup.rs index 64151323..51b92fb1 100644 --- a/crates/ruma-client-api/src/r0/backup/get_latest_backup.rs +++ b/crates/ruma-client-api/src/r0/backup/get_latest_backup.rs @@ -40,7 +40,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/backup/update_backup.rs b/crates/ruma-client-api/src/r0/backup/update_backup.rs index 66ab7552..789ccc2b 100644 --- a/crates/ruma-client-api/src/r0/backup/update_backup.rs +++ b/crates/ruma-client-api/src/r0/backup/update_backup.rs @@ -40,6 +40,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/capabilities/get_capabilities.rs b/crates/ruma-client-api/src/r0/capabilities/get_capabilities.rs index 81edec5d..d58eaf61 100644 --- a/crates/ruma-client-api/src/r0/capabilities/get_capabilities.rs +++ b/crates/ruma-client-api/src/r0/capabilities/get_capabilities.rs @@ -28,7 +28,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/config/set_global_account_data.rs b/crates/ruma-client-api/src/r0/config/set_global_account_data.rs index 2336f797..dbc5cf1e 100644 --- a/crates/ruma-client-api/src/r0/config/set_global_account_data.rs +++ b/crates/ruma-client-api/src/r0/config/set_global_account_data.rs @@ -50,6 +50,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/config/set_room_account_data.rs b/crates/ruma-client-api/src/r0/config/set_room_account_data.rs index 7faba5f8..a8979116 100644 --- a/crates/ruma-client-api/src/r0/config/set_room_account_data.rs +++ b/crates/ruma-client-api/src/r0/config/set_room_account_data.rs @@ -59,6 +59,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/contact/get_contacts.rs b/crates/ruma-client-api/src/r0/contact/get_contacts.rs index 113dcdf5..a9566835 100644 --- a/crates/ruma-client-api/src/r0/contact/get_contacts.rs +++ b/crates/ruma-client-api/src/r0/contact/get_contacts.rs @@ -29,7 +29,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/contact/request_contact_verification_token.rs b/crates/ruma-client-api/src/r0/contact/request_contact_verification_token.rs index 726ebcd4..b9ee0a69 100644 --- a/crates/ruma-client-api/src/r0/contact/request_contact_verification_token.rs +++ b/crates/ruma-client-api/src/r0/contact/request_contact_verification_token.rs @@ -64,6 +64,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/device/delete_device.rs b/crates/ruma-client-api/src/r0/device/delete_device.rs index 2d3bce12..74929fa2 100644 --- a/crates/ruma-client-api/src/r0/device/delete_device.rs +++ b/crates/ruma-client-api/src/r0/device/delete_device.rs @@ -41,6 +41,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/device/delete_devices.rs b/crates/ruma-client-api/src/r0/device/delete_devices.rs index 1d0e15c3..94c6c427 100644 --- a/crates/ruma-client-api/src/r0/device/delete_devices.rs +++ b/crates/ruma-client-api/src/r0/device/delete_devices.rs @@ -40,6 +40,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/device/get_devices.rs b/crates/ruma-client-api/src/r0/device/get_devices.rs index c6e40936..99648665 100644 --- a/crates/ruma-client-api/src/r0/device/get_devices.rs +++ b/crates/ruma-client-api/src/r0/device/get_devices.rs @@ -28,7 +28,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/device/update_device.rs b/crates/ruma-client-api/src/r0/device/update_device.rs index 1f5fb96d..038dcf2b 100644 --- a/crates/ruma-client-api/src/r0/device/update_device.rs +++ b/crates/ruma-client-api/src/r0/device/update_device.rs @@ -40,6 +40,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/directory/set_room_visibility.rs b/crates/ruma-client-api/src/r0/directory/set_room_visibility.rs index 1e2d83cf..1f9b96fe 100644 --- a/crates/ruma-client-api/src/r0/directory/set_room_visibility.rs +++ b/crates/ruma-client-api/src/r0/directory/set_room_visibility.rs @@ -40,6 +40,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/keys/upload_signatures.rs b/crates/ruma-client-api/src/r0/keys/upload_signatures.rs index be2e73fe..d1a400c6 100644 --- a/crates/ruma-client-api/src/r0/keys/upload_signatures.rs +++ b/crates/ruma-client-api/src/r0/keys/upload_signatures.rs @@ -40,6 +40,6 @@ impl Request { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/keys/upload_signing_keys.rs b/crates/ruma-client-api/src/r0/keys/upload_signing_keys.rs index 69e42544..ef0eb814 100644 --- a/crates/ruma-client-api/src/r0/keys/upload_signing_keys.rs +++ b/crates/ruma-client-api/src/r0/keys/upload_signing_keys.rs @@ -54,6 +54,6 @@ impl Request<'_> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/media/get_media_config.rs b/crates/ruma-client-api/src/r0/media/get_media_config.rs index 4dd67554..61a99700 100644 --- a/crates/ruma-client-api/src/r0/media/get_media_config.rs +++ b/crates/ruma-client-api/src/r0/media/get_media_config.rs @@ -28,7 +28,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/ban_user.rs b/crates/ruma-client-api/src/r0/membership/ban_user.rs index 0fe33953..b70afb1f 100644 --- a/crates/ruma-client-api/src/r0/membership/ban_user.rs +++ b/crates/ruma-client-api/src/r0/membership/ban_user.rs @@ -42,6 +42,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/forget_room.rs b/crates/ruma-client-api/src/r0/membership/forget_room.rs index 4d6caf48..764620d3 100644 --- a/crates/ruma-client-api/src/r0/membership/forget_room.rs +++ b/crates/ruma-client-api/src/r0/membership/forget_room.rs @@ -35,6 +35,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/invite_user.rs b/crates/ruma-client-api/src/r0/membership/invite_user.rs index 71d84ce3..b4558adf 100644 --- a/crates/ruma-client-api/src/r0/membership/invite_user.rs +++ b/crates/ruma-client-api/src/r0/membership/invite_user.rs @@ -50,7 +50,7 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/joined_rooms.rs b/crates/ruma-client-api/src/r0/membership/joined_rooms.rs index 36af2a8d..e814b2dd 100644 --- a/crates/ruma-client-api/src/r0/membership/joined_rooms.rs +++ b/crates/ruma-client-api/src/r0/membership/joined_rooms.rs @@ -28,7 +28,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/kick_user.rs b/crates/ruma-client-api/src/r0/membership/kick_user.rs index 81b277d5..103d0842 100644 --- a/crates/ruma-client-api/src/r0/membership/kick_user.rs +++ b/crates/ruma-client-api/src/r0/membership/kick_user.rs @@ -42,6 +42,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/leave_room.rs b/crates/ruma-client-api/src/r0/membership/leave_room.rs index 3d452c19..d900df20 100644 --- a/crates/ruma-client-api/src/r0/membership/leave_room.rs +++ b/crates/ruma-client-api/src/r0/membership/leave_room.rs @@ -35,6 +35,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/membership/unban_user.rs b/crates/ruma-client-api/src/r0/membership/unban_user.rs index 1e7f04b2..2952ae6d 100644 --- a/crates/ruma-client-api/src/r0/membership/unban_user.rs +++ b/crates/ruma-client-api/src/r0/membership/unban_user.rs @@ -38,6 +38,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/presence/set_presence.rs b/crates/ruma-client-api/src/r0/presence/set_presence.rs index d4b93dc5..2f4af219 100644 --- a/crates/ruma-client-api/src/r0/presence/set_presence.rs +++ b/crates/ruma-client-api/src/r0/presence/set_presence.rs @@ -43,6 +43,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/profile/set_avatar_url.rs b/crates/ruma-client-api/src/r0/profile/set_avatar_url.rs index 6206c409..2b776465 100644 --- a/crates/ruma-client-api/src/r0/profile/set_avatar_url.rs +++ b/crates/ruma-client-api/src/r0/profile/set_avatar_url.rs @@ -70,7 +70,7 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/profile/set_display_name.rs b/crates/ruma-client-api/src/r0/profile/set_display_name.rs index 201a2711..b139c31f 100644 --- a/crates/ruma-client-api/src/r0/profile/set_display_name.rs +++ b/crates/ruma-client-api/src/r0/profile/set_display_name.rs @@ -39,6 +39,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/delete_pushrule.rs b/crates/ruma-client-api/src/r0/push/delete_pushrule.rs index 5319126a..b77d5856 100644 --- a/crates/ruma-client-api/src/r0/push/delete_pushrule.rs +++ b/crates/ruma-client-api/src/r0/push/delete_pushrule.rs @@ -44,6 +44,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/get_pushers.rs b/crates/ruma-client-api/src/r0/push/get_pushers.rs index a8bc2572..6451693e 100644 --- a/crates/ruma-client-api/src/r0/push/get_pushers.rs +++ b/crates/ruma-client-api/src/r0/push/get_pushers.rs @@ -29,7 +29,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/get_pushrules_all.rs b/crates/ruma-client-api/src/r0/push/get_pushrules_all.rs index 46c5f23c..abf57782 100644 --- a/crates/ruma-client-api/src/r0/push/get_pushrules_all.rs +++ b/crates/ruma-client-api/src/r0/push/get_pushrules_all.rs @@ -27,7 +27,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/get_pushrules_global_scope.rs b/crates/ruma-client-api/src/r0/push/get_pushrules_global_scope.rs index e330c374..d9d1a376 100644 --- a/crates/ruma-client-api/src/r0/push/get_pushrules_global_scope.rs +++ b/crates/ruma-client-api/src/r0/push/get_pushrules_global_scope.rs @@ -28,7 +28,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/set_pusher.rs b/crates/ruma-client-api/src/r0/push/set_pusher.rs index db51ee80..7faf3102 100644 --- a/crates/ruma-client-api/src/r0/push/set_pusher.rs +++ b/crates/ruma-client-api/src/r0/push/set_pusher.rs @@ -43,7 +43,7 @@ impl Request { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/set_pushrule.rs b/crates/ruma-client-api/src/r0/push/set_pushrule.rs index 3bd25f0f..265d5401 100644 --- a/crates/ruma-client-api/src/r0/push/set_pushrule.rs +++ b/crates/ruma-client-api/src/r0/push/set_pushrule.rs @@ -77,6 +77,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/set_pushrule_actions.rs b/crates/ruma-client-api/src/r0/push/set_pushrule_actions.rs index 88b3432e..8fda7df6 100644 --- a/crates/ruma-client-api/src/r0/push/set_pushrule_actions.rs +++ b/crates/ruma-client-api/src/r0/push/set_pushrule_actions.rs @@ -48,6 +48,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/push/set_pushrule_enabled.rs b/crates/ruma-client-api/src/r0/push/set_pushrule_enabled.rs index e8d7172a..8e625b14 100644 --- a/crates/ruma-client-api/src/r0/push/set_pushrule_enabled.rs +++ b/crates/ruma-client-api/src/r0/push/set_pushrule_enabled.rs @@ -57,6 +57,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/read_marker/set_read_marker.rs b/crates/ruma-client-api/src/r0/read_marker/set_read_marker.rs index a22a9fd9..320a3411 100644 --- a/crates/ruma-client-api/src/r0/read_marker/set_read_marker.rs +++ b/crates/ruma-client-api/src/r0/read_marker/set_read_marker.rs @@ -47,6 +47,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/receipt/create_receipt.rs b/crates/ruma-client-api/src/r0/receipt/create_receipt.rs index f9bdbfab..371f1b2a 100644 --- a/crates/ruma-client-api/src/r0/receipt/create_receipt.rs +++ b/crates/ruma-client-api/src/r0/receipt/create_receipt.rs @@ -44,6 +44,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/room/report_content.rs b/crates/ruma-client-api/src/r0/room/report_content.rs index 903ac37d..52ffeaa9 100644 --- a/crates/ruma-client-api/src/r0/room/report_content.rs +++ b/crates/ruma-client-api/src/r0/room/report_content.rs @@ -46,6 +46,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/session/get_login_types.rs b/crates/ruma-client-api/src/r0/session/get_login_types.rs index 988d9de4..6c411f23 100644 --- a/crates/ruma-client-api/src/r0/session/get_login_types.rs +++ b/crates/ruma-client-api/src/r0/session/get_login_types.rs @@ -36,7 +36,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/session/logout.rs b/crates/ruma-client-api/src/r0/session/logout.rs index f7233a4d..1f1ebbe5 100644 --- a/crates/ruma-client-api/src/r0/session/logout.rs +++ b/crates/ruma-client-api/src/r0/session/logout.rs @@ -24,13 +24,13 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/session/logout_all.rs b/crates/ruma-client-api/src/r0/session/logout_all.rs index 558caf2f..dbda4d2e 100644 --- a/crates/ruma-client-api/src/r0/session/logout_all.rs +++ b/crates/ruma-client-api/src/r0/session/logout_all.rs @@ -24,13 +24,13 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/tag/create_tag.rs b/crates/ruma-client-api/src/r0/tag/create_tag.rs index 414ad710..3ed1424a 100644 --- a/crates/ruma-client-api/src/r0/tag/create_tag.rs +++ b/crates/ruma-client-api/src/r0/tag/create_tag.rs @@ -48,6 +48,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/tag/delete_tag.rs b/crates/ruma-client-api/src/r0/tag/delete_tag.rs index 688edb2c..5bb6649b 100644 --- a/crates/ruma-client-api/src/r0/tag/delete_tag.rs +++ b/crates/ruma-client-api/src/r0/tag/delete_tag.rs @@ -43,6 +43,6 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/thirdparty/get_protocols.rs b/crates/ruma-client-api/src/r0/thirdparty/get_protocols.rs index 38e920d3..3b858813 100644 --- a/crates/ruma-client-api/src/r0/thirdparty/get_protocols.rs +++ b/crates/ruma-client-api/src/r0/thirdparty/get_protocols.rs @@ -30,7 +30,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/to_device/send_event_to_device.rs b/crates/ruma-client-api/src/r0/to_device/send_event_to_device.rs index 42eabbc3..cb450ead 100644 --- a/crates/ruma-client-api/src/r0/to_device/send_event_to_device.rs +++ b/crates/ruma-client-api/src/r0/to_device/send_event_to_device.rs @@ -50,7 +50,7 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/typing/create_typing_event.rs b/crates/ruma-client-api/src/r0/typing/create_typing_event.rs index 02d7562a..9efae616 100644 --- a/crates/ruma-client-api/src/r0/typing/create_typing_event.rs +++ b/crates/ruma-client-api/src/r0/typing/create_typing_event.rs @@ -46,7 +46,7 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/r0/voip/get_turn_server_info.rs b/crates/ruma-client-api/src/r0/voip/get_turn_server_info.rs index 08e6f730..2b0c77c3 100644 --- a/crates/ruma-client-api/src/r0/voip/get_turn_server_info.rs +++ b/crates/ruma-client-api/src/r0/voip/get_turn_server_info.rs @@ -38,7 +38,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/unversioned/discover_homeserver.rs b/crates/ruma-client-api/src/unversioned/discover_homeserver.rs index 181fb744..c6ea3453 100644 --- a/crates/ruma-client-api/src/unversioned/discover_homeserver.rs +++ b/crates/ruma-client-api/src/unversioned/discover_homeserver.rs @@ -32,7 +32,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-client-api/src/unversioned/get_supported_versions.rs b/crates/ruma-client-api/src/unversioned/get_supported_versions.rs index c8cbab68..1e77c72a 100644 --- a/crates/ruma-client-api/src/unversioned/get_supported_versions.rs +++ b/crates/ruma-client-api/src/unversioned/get_supported_versions.rs @@ -32,7 +32,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-events-macros/src/event_content.rs b/crates/ruma-events-macros/src/event_content.rs index 7df3258b..196cfc14 100644 --- a/crates/ruma-events-macros/src/event_content.rs +++ b/crates/ruma-events-macros/src/event_content.rs @@ -173,23 +173,15 @@ pub fn expand_event_content( }; let redaction_struct_fields = kept_redacted_fields.iter().flat_map(|f| &f.ident); - // redacted_fields allows one to declare an empty redacted event without braces, - // otherwise `RedactedWhateverEventContent {}` is needed. - // The redacted_return is used in `EventContent::redacted` which only returns - // zero sized types (unit structs). - let (redacted_fields, redacted_return) = if kept_redacted_fields.is_empty() { - (quote! { ; }, quote! { Ok(#redacted_ident {}) }) + // Used in `EventContent::redacted` which only returns zero sized types (unit structs). + let redacted_return = if kept_redacted_fields.is_empty() { + quote! { Ok(#redacted_ident {}) } } else { - ( - quote! { - { #( #kept_redacted_fields, )* } - }, - quote! { - Err(#serde::de::Error::custom( - format!("this redacted event has fields that cannot be constructed") - )) - }, - ) + quote! { + Err(#serde::de::Error::custom( + format!("this redacted event has fields that cannot be constructed") + )) + } }; let has_deserialize_fields = if kept_redacted_fields.is_empty() { @@ -210,7 +202,7 @@ pub fn expand_event_content( impl #redacted_ident { #[doc = #doc] pub fn new() -> Self { - Self + Self {} } } } @@ -252,7 +244,9 @@ pub fn expand_event_content( #[doc = #doc] #[derive(Clone, Debug, #serde::Deserialize, #serde::Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] - pub struct #redacted_ident #redacted_fields + pub struct #redacted_ident { + #( #kept_redacted_fields, )* + } #initializer diff --git a/crates/ruma-events/src/dummy.rs b/crates/ruma-events/src/dummy.rs index 74dc0f6f..f0e47587 100644 --- a/crates/ruma-events/src/dummy.rs +++ b/crates/ruma-events/src/dummy.rs @@ -27,7 +27,7 @@ pub struct DummyToDeviceEventContent; impl DummyToDeviceEventContent { /// Create a new `DummyToDeviceEventContent`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-federation-api/src/discovery/discover_homeserver.rs b/crates/ruma-federation-api/src/discovery/discover_homeserver.rs index aad2aaea..42ef1d55 100644 --- a/crates/ruma-federation-api/src/discovery/discover_homeserver.rs +++ b/crates/ruma-federation-api/src/discovery/discover_homeserver.rs @@ -26,7 +26,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-federation-api/src/discovery/get_server_keys/v2.rs b/crates/ruma-federation-api/src/discovery/get_server_keys/v2.rs index a87160c1..27430b71 100644 --- a/crates/ruma-federation-api/src/discovery/get_server_keys/v2.rs +++ b/crates/ruma-federation-api/src/discovery/get_server_keys/v2.rs @@ -27,7 +27,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-federation-api/src/discovery/get_server_version/v1.rs b/crates/ruma-federation-api/src/discovery/get_server_version/v1.rs index 5f3a6bf4..b8fcad52 100644 --- a/crates/ruma-federation-api/src/discovery/get_server_version/v1.rs +++ b/crates/ruma-federation-api/src/discovery/get_server_version/v1.rs @@ -27,7 +27,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-federation-api/src/membership/create_leave_event/v2.rs b/crates/ruma-federation-api/src/membership/create_leave_event/v2.rs index 13dd5dda..2a593387 100644 --- a/crates/ruma-federation-api/src/membership/create_leave_event/v2.rs +++ b/crates/ruma-federation-api/src/membership/create_leave_event/v2.rs @@ -45,7 +45,7 @@ impl<'a> Request<'a> { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs b/crates/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs index 525e1080..3ae94d79 100644 --- a/crates/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs +++ b/crates/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs @@ -52,6 +52,6 @@ impl<'a> Request<'a> { impl Response { /// Creates a new `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-identity-service-api/src/authentication/get_account_information/v2.rs b/crates/ruma-identity-service-api/src/authentication/get_account_information/v2.rs index 2c4739c2..bccf7dac 100644 --- a/crates/ruma-identity-service-api/src/authentication/get_account_information/v2.rs +++ b/crates/ruma-identity-service-api/src/authentication/get_account_information/v2.rs @@ -25,7 +25,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-identity-service-api/src/authentication/logout/v2.rs b/crates/ruma-identity-service-api/src/authentication/logout/v2.rs index c833faa4..3ae3fde5 100644 --- a/crates/ruma-identity-service-api/src/authentication/logout/v2.rs +++ b/crates/ruma-identity-service-api/src/authentication/logout/v2.rs @@ -22,13 +22,13 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } } impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-identity-service-api/src/tos/accept_terms_of_service/v2.rs b/crates/ruma-identity-service-api/src/tos/accept_terms_of_service/v2.rs index 71b67af2..e73c51e5 100644 --- a/crates/ruma-identity-service-api/src/tos/accept_terms_of_service/v2.rs +++ b/crates/ruma-identity-service-api/src/tos/accept_terms_of_service/v2.rs @@ -33,6 +33,6 @@ impl Request { impl Response { /// Creates an empty `Response`. pub fn new() -> Self { - Self + Self {} } } diff --git a/crates/ruma-identity-service-api/src/tos/get_terms_of_service/v2.rs b/crates/ruma-identity-service-api/src/tos/get_terms_of_service/v2.rs index 28eff315..8b34e16d 100644 --- a/crates/ruma-identity-service-api/src/tos/get_terms_of_service/v2.rs +++ b/crates/ruma-identity-service-api/src/tos/get_terms_of_service/v2.rs @@ -29,7 +29,7 @@ ruma_api! { impl Request { /// Creates an empty `Request`. pub fn new() -> Self { - Self + Self {} } }