Remove immediately-deref'ed double references

master
Jonas Platte 2020-07-11 21:20:02 +02:00
parent 85522ac35a
commit eea00301ff
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 34 additions and 36 deletions

View File

@ -890,9 +890,9 @@ impl BaseClient {
///
/// * `event` - The presence event for a specified room member.
pub async fn receive_account_data_event(&self, _: &RoomId, event: &AnyBasicEvent) -> bool {
match &event {
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(&event).await,
AnyBasicEvent::PushRules(event) => self.handle_push_rules(&event).await,
match event {
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(event).await,
AnyBasicEvent::PushRules(event) => self.handle_push_rules(event).await,
_ => false,
}
}
@ -907,7 +907,7 @@ impl BaseClient {
///
/// * `event` - The presence event for a specified room member.
pub async fn receive_ephemeral_event(&self, event: &AnyEphemeralRoomEventStub) -> bool {
match &event {
match event {
AnyEphemeralRoomEventStub::FullyRead(_) => {}
AnyEphemeralRoomEventStub::Receipt(_) => {}
AnyEphemeralRoomEventStub::Typing(_) => {}
@ -1471,44 +1471,42 @@ impl BaseClient {
}
};
match &event {
AnyRoomEventStub::State(event) => match &event {
AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, &e).await,
AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, &e).await,
match event {
AnyRoomEventStub::State(event) => match event {
AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, e).await,
AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, e).await,
AnyStateEventStub::RoomCanonicalAlias(e) => {
event_emitter.on_room_canonical_alias(room, &e).await
event_emitter.on_room_canonical_alias(room, e).await
}
AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, &e).await,
AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, &e).await,
AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, e).await,
AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, e).await,
AnyStateEventStub::RoomPowerLevels(e) => {
event_emitter.on_room_power_levels(room, &e).await
event_emitter.on_room_power_levels(room, e).await
}
AnyStateEventStub::RoomTombstone(e) => {
event_emitter.on_room_tombstone(room, &e).await
event_emitter.on_room_tombstone(room, e).await
}
AnyStateEventStub::RoomJoinRules(e) => {
event_emitter.on_room_join_rules(room, &e).await
event_emitter.on_room_join_rules(room, e).await
}
AnyStateEventStub::Custom(e) => {
event_emitter
.on_unrecognized_event(room, &CustomOrRawEvent::State(&e))
.on_unrecognized_event(room, &CustomOrRawEvent::State(e))
.await
}
_ => {}
},
AnyRoomEventStub::Message(event) => match &event {
AnyMessageEventStub::RoomMessage(e) => {
event_emitter.on_room_message(room, &e).await
}
AnyRoomEventStub::Message(event) => match event {
AnyMessageEventStub::RoomMessage(e) => event_emitter.on_room_message(room, e).await,
AnyMessageEventStub::RoomMessageFeedback(e) => {
event_emitter.on_room_message_feedback(room, &e).await
event_emitter.on_room_message_feedback(room, e).await
}
AnyMessageEventStub::RoomRedaction(e) => {
event_emitter.on_room_redaction(room, e).await
}
AnyMessageEventStub::Custom(e) => {
event_emitter
.on_unrecognized_event(room, &CustomOrRawEvent::Message(&e))
.on_unrecognized_event(room, &CustomOrRawEvent::Message(e))
.await
}
_ => {}

View File

@ -746,27 +746,27 @@ impl Room {
///
/// * `event` - The event of the room.
pub fn receive_timeline_event(&mut self, event: &AnyRoomEventStub) -> bool {
match &event {
AnyRoomEventStub::State(event) => match &event {
match event {
AnyRoomEventStub::State(event) => match event {
// update to the current members of the room
AnyStateEventStub::RoomMember(event) => self.handle_membership(&event),
AnyStateEventStub::RoomMember(event) => self.handle_membership(event),
// finds all events related to the name of the room for later use
AnyStateEventStub::RoomName(event) => self.handle_room_name(&event),
AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(&event),
AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(&event),
AnyStateEventStub::RoomName(event) => self.handle_room_name(event),
AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(event),
AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(event),
// power levels of the room members
AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(&event),
AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(&event),
AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(&event),
AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(event),
AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(event),
AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(event),
_ => false,
},
AnyRoomEventStub::Message(event) => match &event {
AnyRoomEventStub::Message(event) => match event {
#[cfg(feature = "messages")]
// We ignore this variants event because `handle_message` takes the enum
// to store AnyMessageEventStub events in the `MessageQueue`.
AnyMessageEventStub::RoomMessage(_) => self.handle_message(&event),
AnyMessageEventStub::RoomMessage(_) => self.handle_message(event),
#[cfg(feature = "messages")]
AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(&event),
AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(event),
_ => false,
},
}
@ -804,7 +804,7 @@ impl Room {
/// * `event` - The `AnyStrippedStateEvent` sent by the server for invited but not
/// joined rooms.
pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool {
match &event {
match event {
AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event),
_ => false,
}

View File

@ -1333,7 +1333,7 @@ impl OlmMachine {
match &event {
AnyToDeviceEvent::RoomEncrypted(e) => {
let decrypted_event = match self.decrypt_to_device_event(&e).await {
let decrypted_event = match self.decrypt_to_device_event(e).await {
Ok(e) => e,
Err(err) => {
warn!(
@ -1350,7 +1350,7 @@ impl OlmMachine {
// before we replace the result.
*event_result = decrypted_event;
}
AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(&e),
AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(e),
AnyToDeviceEvent::KeyVerificationAccept(..)
| AnyToDeviceEvent::KeyVerificationCancel(..)
| AnyToDeviceEvent::KeyVerificationKey(..)