Enable clippy::explicit_auto_deref (#8753)

This PR enables the
[`clippy::explicit_auto_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#/explicit_auto_deref)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 22:30:18 -05:00 committed by GitHub
parent 6a9e8faad2
commit 659974411d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 126 additions and 128 deletions

View file

@ -18,7 +18,7 @@ impl Database {
connection: ConnectionId, connection: ConnectionId,
) -> Result<proto::JoinChannelBufferResponse> { ) -> Result<proto::JoinChannelBufferResponse> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
@ -134,10 +134,10 @@ impl Database {
let mut results = Vec::new(); let mut results = Vec::new();
for client_buffer in buffers { for client_buffer in buffers {
let channel = self let channel = self
.get_channel_internal(ChannelId::from_proto(client_buffer.channel_id), &*tx) .get_channel_internal(ChannelId::from_proto(client_buffer.channel_id), &tx)
.await?; .await?;
if self if self
.check_user_is_channel_participant(&channel, user_id, &*tx) .check_user_is_channel_participant(&channel, user_id, &tx)
.await .await
.is_err() .is_err()
{ {
@ -145,7 +145,7 @@ impl Database {
continue; continue;
} }
let buffer = self.get_channel_buffer(channel.id, &*tx).await?; let buffer = self.get_channel_buffer(channel.id, &tx).await?;
let mut collaborators = channel_buffer_collaborator::Entity::find() let mut collaborators = channel_buffer_collaborator::Entity::find()
.filter(channel_buffer_collaborator::Column::ChannelId.eq(channel.id)) .filter(channel_buffer_collaborator::Column::ChannelId.eq(channel.id))
.all(&*tx) .all(&*tx)
@ -180,7 +180,7 @@ impl Database {
let client_version = version_from_wire(&client_buffer.version); let client_version = version_from_wire(&client_buffer.version);
let serialization_version = self let serialization_version = self
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &*tx) .get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &tx)
.await?; .await?;
let mut rows = buffer_operation::Entity::find() let mut rows = buffer_operation::Entity::find()
@ -283,7 +283,7 @@ impl Database {
connection: ConnectionId, connection: ConnectionId,
) -> Result<LeftChannelBuffer> { ) -> Result<LeftChannelBuffer> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
self.leave_channel_buffer_internal(channel_id, connection, &*tx) self.leave_channel_buffer_internal(channel_id, connection, &tx)
.await .await
}) })
.await .await
@ -337,7 +337,7 @@ impl Database {
let mut result = Vec::new(); let mut result = Vec::new();
for channel_id in channel_ids { for channel_id in channel_ids {
let left_channel_buffer = self let left_channel_buffer = self
.leave_channel_buffer_internal(channel_id, connection, &*tx) .leave_channel_buffer_internal(channel_id, connection, &tx)
.await?; .await?;
result.push(left_channel_buffer); result.push(left_channel_buffer);
} }
@ -406,7 +406,7 @@ impl Database {
channel_id: ChannelId, channel_id: ChannelId,
) -> Result<Vec<UserId>> { ) -> Result<Vec<UserId>> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
self.get_channel_buffer_collaborators_internal(channel_id, &*tx) self.get_channel_buffer_collaborators_internal(channel_id, &tx)
.await .await
}) })
.await .await
@ -447,7 +447,7 @@ impl Database {
Vec<proto::VectorClockEntry>, Vec<proto::VectorClockEntry>,
)> { )> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut requires_write_permission = false; let mut requires_write_permission = false;
for op in operations.iter() { for op in operations.iter() {
@ -457,10 +457,10 @@ impl Database {
} }
} }
if requires_write_permission { if requires_write_permission {
self.check_user_is_channel_member(&channel, user, &*tx) self.check_user_is_channel_member(&channel, user, &tx)
.await?; .await?;
} else { } else {
self.check_user_is_channel_participant(&channel, user, &*tx) self.check_user_is_channel_participant(&channel, user, &tx)
.await?; .await?;
} }
@ -471,7 +471,7 @@ impl Database {
.ok_or_else(|| anyhow!("no such buffer"))?; .ok_or_else(|| anyhow!("no such buffer"))?;
let serialization_version = self let serialization_version = self
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &*tx) .get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &tx)
.await?; .await?;
let operations = operations let operations = operations
@ -500,13 +500,13 @@ impl Database {
buffer.epoch, buffer.epoch,
*max_operation.replica_id.as_ref(), *max_operation.replica_id.as_ref(),
*max_operation.lamport_timestamp.as_ref(), *max_operation.lamport_timestamp.as_ref(),
&*tx, &tx,
) )
.await?; .await?;
channel_members = self.get_channel_participants(&channel, &*tx).await?; channel_members = self.get_channel_participants(&channel, &tx).await?;
let collaborators = self let collaborators = self
.get_channel_buffer_collaborators_internal(channel_id, &*tx) .get_channel_buffer_collaborators_internal(channel_id, &tx)
.await?; .await?;
channel_members.retain(|member| !collaborators.contains(member)); channel_members.retain(|member| !collaborators.contains(member));
@ -737,7 +737,7 @@ impl Database {
epoch, epoch,
component.replica_id as i32, component.replica_id as i32,
component.timestamp as i32, component.timestamp as i32,
&*tx, &tx,
) )
.await?; .await?;
Ok(()) Ok(())

View file

@ -53,8 +53,8 @@ impl Database {
let mut membership = None; let mut membership = None;
if let Some(parent_channel_id) = parent_channel_id { if let Some(parent_channel_id) = parent_channel_id {
let parent_channel = self.get_channel_internal(parent_channel_id, &*tx).await?; let parent_channel = self.get_channel_internal(parent_channel_id, &tx).await?;
self.check_user_is_channel_admin(&parent_channel, admin_id, &*tx) self.check_user_is_channel_admin(&parent_channel, admin_id, &tx)
.await?; .await?;
parent = Some(parent_channel); parent = Some(parent_channel);
} }
@ -105,14 +105,14 @@ impl Database {
connection: ConnectionId, connection: ConnectionId,
) -> Result<(JoinRoom, Option<MembershipUpdated>, ChannelRole)> { ) -> Result<(JoinRoom, Option<MembershipUpdated>, ChannelRole)> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut role = self.channel_role_for_user(&channel, user_id, &*tx).await?; let mut role = self.channel_role_for_user(&channel, user_id, &tx).await?;
let mut accept_invite_result = None; let mut accept_invite_result = None;
if role.is_none() { if role.is_none() {
if let Some(invitation) = self if let Some(invitation) = self
.pending_invite_for_channel(&channel, user_id, &*tx) .pending_invite_for_channel(&channel, user_id, &tx)
.await? .await?
{ {
// note, this may be a parent channel // note, this may be a parent channel
@ -125,12 +125,12 @@ impl Database {
.await?; .await?;
accept_invite_result = Some( accept_invite_result = Some(
self.calculate_membership_updated(&channel, user_id, &*tx) self.calculate_membership_updated(&channel, user_id, &tx)
.await?, .await?,
); );
debug_assert!( debug_assert!(
self.channel_role_for_user(&channel, user_id, &*tx).await? == role self.channel_role_for_user(&channel, user_id, &tx).await? == role
); );
} else if channel.visibility == ChannelVisibility::Public { } else if channel.visibility == ChannelVisibility::Public {
role = Some(ChannelRole::Guest); role = Some(ChannelRole::Guest);
@ -145,12 +145,12 @@ impl Database {
.await?; .await?;
accept_invite_result = Some( accept_invite_result = Some(
self.calculate_membership_updated(&channel, user_id, &*tx) self.calculate_membership_updated(&channel, user_id, &tx)
.await?, .await?,
); );
debug_assert!( debug_assert!(
self.channel_role_for_user(&channel, user_id, &*tx).await? == role self.channel_role_for_user(&channel, user_id, &tx).await? == role
); );
} }
} }
@ -162,10 +162,10 @@ impl Database {
let live_kit_room = format!("channel-{}", nanoid::nanoid!(30)); let live_kit_room = format!("channel-{}", nanoid::nanoid!(30));
let room_id = self let room_id = self
.get_or_create_channel_room(channel_id, &live_kit_room, &*tx) .get_or_create_channel_room(channel_id, &live_kit_room, &tx)
.await?; .await?;
self.join_channel_room_internal(room_id, user_id, connection, role, &*tx) self.join_channel_room_internal(room_id, user_id, connection, role, &tx)
.await .await
.map(|jr| (jr, accept_invite_result, role)) .map(|jr| (jr, accept_invite_result, role))
}) })
@ -180,13 +180,13 @@ impl Database {
admin_id: UserId, admin_id: UserId,
) -> Result<(Channel, Vec<channel_member::Model>)> { ) -> Result<(Channel, Vec<channel_member::Model>)> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx) self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?; .await?;
if visibility == ChannelVisibility::Public { if visibility == ChannelVisibility::Public {
if let Some(parent_id) = channel.parent_id() { if let Some(parent_id) = channel.parent_id() {
let parent = self.get_channel_internal(parent_id, &*tx).await?; let parent = self.get_channel_internal(parent_id, &tx).await?;
if parent.visibility != ChannelVisibility::Public { if parent.visibility != ChannelVisibility::Public {
Err(ErrorCode::BadPublicNesting Err(ErrorCode::BadPublicNesting
@ -196,7 +196,7 @@ impl Database {
} }
} else if visibility == ChannelVisibility::Members { } else if visibility == ChannelVisibility::Members {
if self if self
.get_channel_descendants_excluding_self([&channel], &*tx) .get_channel_descendants_excluding_self([&channel], &tx)
.await? .await?
.into_iter() .into_iter()
.any(|channel| channel.visibility == ChannelVisibility::Public) .any(|channel| channel.visibility == ChannelVisibility::Public)
@ -228,7 +228,7 @@ impl Database {
requires_zed_cla: bool, requires_zed_cla: bool,
) -> Result<()> { ) -> Result<()> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut model = channel.into_active_model(); let mut model = channel.into_active_model();
model.requires_zed_cla = ActiveValue::Set(requires_zed_cla); model.requires_zed_cla = ActiveValue::Set(requires_zed_cla);
model.update(&*tx).await?; model.update(&*tx).await?;
@ -244,8 +244,8 @@ impl Database {
user_id: UserId, user_id: UserId,
) -> Result<(Vec<ChannelId>, Vec<UserId>)> { ) -> Result<(Vec<ChannelId>, Vec<UserId>)> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, user_id, &*tx) self.check_user_is_channel_admin(&channel, user_id, &tx)
.await?; .await?;
let members_to_notify: Vec<UserId> = channel_member::Entity::find() let members_to_notify: Vec<UserId> = channel_member::Entity::find()
@ -258,7 +258,7 @@ impl Database {
.await?; .await?;
let channels_to_remove = self let channels_to_remove = self
.get_channel_descendants_excluding_self([&channel], &*tx) .get_channel_descendants_excluding_self([&channel], &tx)
.await? .await?
.into_iter() .into_iter()
.map(|channel| channel.id) .map(|channel| channel.id)
@ -284,8 +284,8 @@ impl Database {
role: ChannelRole, role: ChannelRole,
) -> Result<InviteMemberResult> { ) -> Result<InviteMemberResult> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, inviter_id, &*tx) self.check_user_is_channel_admin(&channel, inviter_id, &tx)
.await?; .await?;
if !channel.is_root() { if !channel.is_root() {
Err(ErrorCode::NotARootChannel.anyhow())? Err(ErrorCode::NotARootChannel.anyhow())?
@ -312,7 +312,7 @@ impl Database {
inviter_id: inviter_id.to_proto(), inviter_id: inviter_id.to_proto(),
}, },
true, true,
&*tx, &tx,
) )
.await? .await?
.into_iter() .into_iter()
@ -344,8 +344,8 @@ impl Database {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let new_name = Self::sanitize_channel_name(new_name)?.to_string(); let new_name = Self::sanitize_channel_name(new_name)?.to_string();
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx) self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?; .await?;
let mut model = channel.into_active_model(); let mut model = channel.into_active_model();
@ -370,7 +370,7 @@ impl Database {
accept: bool, accept: bool,
) -> Result<RespondToChannelInvite> { ) -> Result<RespondToChannelInvite> {
self.transaction(move |tx| async move { self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
let membership_update = if accept { let membership_update = if accept {
let rows_affected = channel_member::Entity::update_many() let rows_affected = channel_member::Entity::update_many()
@ -393,7 +393,7 @@ impl Database {
} }
Some( Some(
self.calculate_membership_updated(&channel, user_id, &*tx) self.calculate_membership_updated(&channel, user_id, &tx)
.await?, .await?,
) )
} else { } else {
@ -425,7 +425,7 @@ impl Database {
inviter_id: Default::default(), inviter_id: Default::default(),
}, },
accept, accept,
&*tx, &tx,
) )
.await? .await?
.into_iter() .into_iter()
@ -466,10 +466,10 @@ impl Database {
admin_id: UserId, admin_id: UserId,
) -> Result<RemoveChannelMemberResult> { ) -> Result<RemoveChannelMemberResult> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
if member_id != admin_id { if member_id != admin_id {
self.check_user_is_channel_admin(&channel, admin_id, &*tx) self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?; .await?;
} }
@ -488,7 +488,7 @@ impl Database {
Ok(RemoveChannelMemberResult { Ok(RemoveChannelMemberResult {
membership_update: self membership_update: self
.calculate_membership_updated(&channel, member_id, &*tx) .calculate_membership_updated(&channel, member_id, &tx)
.await?, .await?,
notification_id: self notification_id: self
.remove_notification( .remove_notification(
@ -498,7 +498,7 @@ impl Database {
channel_name: Default::default(), channel_name: Default::default(),
inviter_id: Default::default(), inviter_id: Default::default(),
}, },
&*tx, &tx,
) )
.await?, .await?,
}) })
@ -674,8 +674,8 @@ impl Database {
role: ChannelRole, role: ChannelRole,
) -> Result<SetMemberRoleResult> { ) -> Result<SetMemberRoleResult> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx) self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?; .await?;
let membership = channel_member::Entity::find() let membership = channel_member::Entity::find()
@ -697,7 +697,7 @@ impl Database {
if updated.accepted { if updated.accepted {
Ok(SetMemberRoleResult::MembershipUpdated( Ok(SetMemberRoleResult::MembershipUpdated(
self.calculate_membership_updated(&channel, for_user, &*tx) self.calculate_membership_updated(&channel, for_user, &tx)
.await?, .await?,
)) ))
} else { } else {
@ -717,13 +717,13 @@ impl Database {
) -> Result<Vec<proto::ChannelMember>> { ) -> Result<Vec<proto::ChannelMember>> {
let (role, members) = self let (role, members) = self
.transaction(move |tx| async move { .transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
let role = self let role = self
.check_user_is_channel_participant(&channel, user_id, &*tx) .check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
Ok(( Ok((
role, role,
self.get_channel_participant_details_internal(&channel, &*tx) self.get_channel_participant_details_internal(&channel, &tx)
.await?, .await?,
)) ))
}) })
@ -915,8 +915,8 @@ impl Database {
/// Returns the channel with the given ID. /// Returns the channel with the given ID.
pub async fn get_channel(&self, channel_id: ChannelId, user_id: UserId) -> Result<Channel> { pub async fn get_channel(&self, channel_id: ChannelId, user_id: UserId) -> Result<Channel> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
Ok(Channel::from_model(channel)) Ok(Channel::from_model(channel))
@ -971,10 +971,10 @@ impl Database {
admin_id: UserId, admin_id: UserId,
) -> Result<(Vec<Channel>, Vec<channel_member::Model>)> { ) -> Result<(Vec<Channel>, Vec<channel_member::Model>)> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx) self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?; .await?;
let new_parent = self.get_channel_internal(new_parent_id, &*tx).await?; let new_parent = self.get_channel_internal(new_parent_id, &tx).await?;
if new_parent.root_id() != channel.root_id() { if new_parent.root_id() != channel.root_id() {
Err(anyhow!(ErrorCode::WrongMoveTarget))?; Err(anyhow!(ErrorCode::WrongMoveTarget))?;

View file

@ -177,7 +177,7 @@ impl Database {
sender_id: sender_id.to_proto(), sender_id: sender_id.to_proto(),
}, },
true, true,
&*tx, &tx,
) )
.await? .await?
.into_iter() .into_iter()
@ -227,7 +227,7 @@ impl Database {
rpc::Notification::ContactRequest { rpc::Notification::ContactRequest {
sender_id: requester_id.to_proto(), sender_id: requester_id.to_proto(),
}, },
&*tx, &tx,
) )
.await?; .await?;
} }
@ -335,7 +335,7 @@ impl Database {
sender_id: requester_id.to_proto(), sender_id: requester_id.to_proto(),
}, },
accept, accept,
&*tx, &tx,
) )
.await?, .await?,
); );
@ -348,7 +348,7 @@ impl Database {
responder_id: responder_id.to_proto(), responder_id: responder_id.to_proto(),
}, },
true, true,
&*tx, &tx,
) )
.await?, .await?,
); );

View file

@ -72,7 +72,7 @@ impl Database {
github_login, github_login,
github_user_id, github_user_id,
github_email, github_email,
&*tx, &tx,
) )
.await?; .await?;

View file

@ -12,8 +12,8 @@ impl Database {
user_id: UserId, user_id: UserId,
) -> Result<()> { ) -> Result<()> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
channel_chat_participant::ActiveModel { channel_chat_participant::ActiveModel {
id: ActiveValue::NotSet, id: ActiveValue::NotSet,
@ -87,8 +87,8 @@ impl Database {
before_message_id: Option<MessageId>, before_message_id: Option<MessageId>,
) -> Result<Vec<proto::ChannelMessage>> { ) -> Result<Vec<proto::ChannelMessage>> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
let mut condition = let mut condition =
@ -105,7 +105,7 @@ impl Database {
.all(&*tx) .all(&*tx)
.await?; .await?;
self.load_channel_messages(rows, &*tx).await self.load_channel_messages(rows, &tx).await
}) })
.await .await
} }
@ -127,16 +127,16 @@ impl Database {
for row in &rows { for row in &rows {
channels.insert( channels.insert(
row.channel_id, row.channel_id,
self.get_channel_internal(row.channel_id, &*tx).await?, self.get_channel_internal(row.channel_id, &tx).await?,
); );
} }
for (_, channel) in channels { for (_, channel) in channels {
self.check_user_is_channel_participant(&channel, user_id, &*tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
} }
let messages = self.load_channel_messages(rows, &*tx).await?; let messages = self.load_channel_messages(rows, &tx).await?;
Ok(messages) Ok(messages)
}) })
.await .await
@ -212,8 +212,8 @@ impl Database {
reply_to_message_id: Option<MessageId>, reply_to_message_id: Option<MessageId>,
) -> Result<CreatedChannelMessage> { ) -> Result<CreatedChannelMessage> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx) self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?; .await?;
let mut rows = channel_chat_participant::Entity::find() let mut rows = channel_chat_participant::Entity::find()
@ -303,13 +303,13 @@ impl Database {
channel_id: channel_id.to_proto(), channel_id: channel_id.to_proto(),
}, },
false, false,
&*tx, &tx,
) )
.await?, .await?,
); );
} }
self.observe_channel_message_internal(channel_id, user_id, message_id, &*tx) self.observe_channel_message_internal(channel_id, user_id, message_id, &tx)
.await?; .await?;
} }
_ => { _ => {
@ -322,7 +322,7 @@ impl Database {
} }
} }
let mut channel_members = self.get_channel_participants(&channel, &*tx).await?; let mut channel_members = self.get_channel_participants(&channel, &tx).await?;
channel_members.retain(|member| !participant_user_ids.contains(member)); channel_members.retain(|member| !participant_user_ids.contains(member));
Ok(CreatedChannelMessage { Ok(CreatedChannelMessage {
@ -342,7 +342,7 @@ impl Database {
message_id: MessageId, message_id: MessageId,
) -> Result<NotificationBatch> { ) -> Result<NotificationBatch> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
self.observe_channel_message_internal(channel_id, user_id, message_id, &*tx) self.observe_channel_message_internal(channel_id, user_id, message_id, &tx)
.await?; .await?;
let mut batch = NotificationBatch::default(); let mut batch = NotificationBatch::default();
batch.extend( batch.extend(
@ -353,7 +353,7 @@ impl Database {
sender_id: Default::default(), sender_id: Default::default(),
channel_id: Default::default(), channel_id: Default::default(),
}, },
&*tx, &tx,
) )
.await?, .await?,
); );
@ -501,9 +501,9 @@ impl Database {
.await?; .await?;
if result.rows_affected == 0 { if result.rows_affected == 0 {
let channel = self.get_channel_internal(channel_id, &*tx).await?; let channel = self.get_channel_internal(channel_id, &tx).await?;
if self if self
.check_user_is_channel_admin(&channel, user_id, &*tx) .check_user_is_channel_admin(&channel, user_id, &tx)
.await .await
.is_ok() .is_ok()
{ {

View file

@ -1061,7 +1061,7 @@ impl Database {
.insert(&*tx) .insert(&*tx)
.await?; .await?;
let room = self.get_room(room_id, &*tx).await?; let room = self.get_room(room_id, &tx).await?;
Ok(room) Ok(room)
}) })
.await .await
@ -1095,7 +1095,7 @@ impl Database {
.exec(&*tx) .exec(&*tx)
.await?; .await?;
let room = self.get_room(room_id, &*tx).await?; let room = self.get_room(room_id, &tx).await?;
Ok(room) Ok(room)
}) })
.await .await

View file

@ -321,7 +321,7 @@ impl Database {
} }
let participant_index = self let participant_index = self
.get_next_participant_index_internal(room_id, &*tx) .get_next_participant_index_internal(room_id, &tx)
.await?; .await?;
let result = room_participant::Entity::update_many() let result = room_participant::Entity::update_many()
@ -1010,7 +1010,7 @@ impl Database {
.ok_or_else(|| anyhow!("only admins can set participant role"))?; .ok_or_else(|| anyhow!("only admins can set participant role"))?;
if role.requires_cla() { if role.requires_cla() {
self.check_user_has_signed_cla(user_id, room_id, &*tx) self.check_user_has_signed_cla(user_id, room_id, &tx)
.await?; .await?;
} }
@ -1076,10 +1076,9 @@ impl Database {
pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()> { pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()> {
self.transaction(|tx| async move { self.transaction(|tx| async move {
self.room_connection_lost(connection, &*tx).await?; self.room_connection_lost(connection, &tx).await?;
self.channel_buffer_connection_lost(connection, &*tx) self.channel_buffer_connection_lost(connection, &tx).await?;
.await?; self.channel_chat_connection_lost(connection, &tx).await?;
self.channel_chat_connection_lost(connection, &*tx).await?;
Ok(()) Ok(())
}) })
.await .await

View file

@ -80,7 +80,7 @@ impl Database {
github_login, github_login,
github_user_id, github_user_id,
github_email, github_email,
&*tx, &tx,
) )
.await .await
}) })

View file

@ -222,7 +222,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
.unwrap(); .unwrap();
buffers.push( buffers.push(
db.transaction(|tx| async move { db.get_channel_buffer(channel, &*tx).await }) db.transaction(|tx| async move { db.get_channel_buffer(channel, &tx).await })
.await .await
.unwrap(), .unwrap(),
); );
@ -238,7 +238,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
.transaction(|tx| { .transaction(|tx| {
let buffers = &buffers; let buffers = &buffers;
async move { async move {
db.get_latest_operations_for_buffers([buffers[0].id, buffers[2].id], &*tx) db.get_latest_operations_for_buffers([buffers[0].id, buffers[2].id], &tx)
.await .await
} }
}) })
@ -302,7 +302,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
.transaction(|tx| { .transaction(|tx| {
let buffers = &buffers; let buffers = &buffers;
async move { async move {
db.get_latest_operations_for_buffers([buffers[1].id, buffers[2].id], &*tx) db.get_latest_operations_for_buffers([buffers[1].id, buffers[2].id], &tx)
.await .await
} }
}) })
@ -320,7 +320,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
.transaction(|tx| { .transaction(|tx| {
let buffers = &buffers; let buffers = &buffers;
async move { async move {
db.get_latest_operations_for_buffers([buffers[0].id, buffers[1].id], &*tx) db.get_latest_operations_for_buffers([buffers[0].id, buffers[1].id], &tx)
.await .await
} }
}) })
@ -342,7 +342,7 @@ async fn test_channel_buffers_last_operations(db: &Database) {
hash.insert(buffers[1].id, buffers[1].channel_id); hash.insert(buffers[1].id, buffers[1].channel_id);
hash.insert(buffers[2].id, buffers[2].channel_id); hash.insert(buffers[2].id, buffers[2].channel_id);
async move { db.latest_channel_buffer_changes(&hash, &*tx).await } async move { db.latest_channel_buffer_changes(&hash, &tx).await }
}) })
.await .await
.unwrap(); .unwrap();

View file

@ -42,8 +42,8 @@ async fn test_channels(db: &Arc<Database>) {
let mut members = db let mut members = db
.transaction(|tx| async move { .transaction(|tx| async move {
let channel = db.get_channel_internal(replace_id, &*tx).await?; let channel = db.get_channel_internal(replace_id, &tx).await?;
Ok(db.get_channel_participants(&channel, &*tx).await?) Ok(db.get_channel_participants(&channel, &tx).await?)
}) })
.await .await
.unwrap(); .unwrap();
@ -464,9 +464,9 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
db.transaction(|tx| async move { db.transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(public_channel_id, &*tx).await?, &db.get_channel_internal(public_channel_id, &tx).await?,
admin, admin,
&*tx, &tx,
) )
.await .await
}) })
@ -474,9 +474,9 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
.unwrap(); .unwrap();
db.transaction(|tx| async move { db.transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(public_channel_id, &*tx).await?, &db.get_channel_internal(public_channel_id, &tx).await?,
member, member,
&*tx, &tx,
) )
.await .await
}) })
@ -517,9 +517,9 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
db.transaction(|tx| async move { db.transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(public_channel_id, &*tx).await?, &db.get_channel_internal(public_channel_id, &tx).await?,
guest, guest,
&*tx, &tx,
) )
.await .await
}) })
@ -547,11 +547,11 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
assert!(db assert!(db
.transaction(|tx| async move { .transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(public_channel_id, &*tx) &db.get_channel_internal(public_channel_id, &tx)
.await .await
.unwrap(), .unwrap(),
guest, guest,
&*tx, &tx,
) )
.await .await
}) })
@ -629,9 +629,9 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
db.transaction(|tx| async move { db.transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(zed_channel, &*tx).await.unwrap(), &db.get_channel_internal(zed_channel, &tx).await.unwrap(),
guest, guest,
&*tx, &tx,
) )
.await .await
}) })
@ -640,11 +640,11 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
assert!(db assert!(db
.transaction(|tx| async move { .transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(internal_channel_id, &*tx) &db.get_channel_internal(internal_channel_id, &tx)
.await .await
.unwrap(), .unwrap(),
guest, guest,
&*tx, &tx,
) )
.await .await
}) })
@ -653,11 +653,11 @@ async fn test_user_is_channel_participant(db: &Arc<Database>) {
db.transaction(|tx| async move { db.transaction(|tx| async move {
db.check_user_is_channel_participant( db.check_user_is_channel_participant(
&db.get_channel_internal(public_channel_id, &*tx) &db.get_channel_internal(public_channel_id, &tx)
.await .await
.unwrap(), .unwrap(),
guest, guest,
&*tx, &tx,
) )
.await .await
}) })

View file

@ -297,7 +297,7 @@ async fn test_unseen_channel_messages(db: &Arc<Database>) {
// Check that observer has new messages // Check that observer has new messages
let latest_messages = db let latest_messages = db
.transaction(|tx| async move { .transaction(|tx| async move {
db.latest_channel_messages(&[channel_1, channel_2], &*tx) db.latest_channel_messages(&[channel_1, channel_2], &tx)
.await .await
}) })
.await .await

View file

@ -353,7 +353,7 @@ impl Server {
&refreshed_room.room, &refreshed_room.room,
&refreshed_room.channel_members, &refreshed_room.channel_members,
&peer, &peer,
&*pool.lock(), &pool.lock(),
); );
} }
contacts_to_update contacts_to_update
@ -754,13 +754,13 @@ impl<'a> Deref for ConnectionPoolGuard<'a> {
type Target = ConnectionPool; type Target = ConnectionPool;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&*self.guard &self.guard
} }
} }
impl<'a> DerefMut for ConnectionPoolGuard<'a> { impl<'a> DerefMut for ConnectionPoolGuard<'a> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
&mut *self.guard &mut self.guard
} }
} }
@ -2226,7 +2226,7 @@ async fn request_contact(
session.peer.send(connection_id, update.clone())?; session.peer.send(connection_id, update.clone())?;
} }
send_notifications(&*connection_pool, &session.peer, notifications); send_notifications(&connection_pool, &session.peer, notifications);
response.send(proto::Ack {})?; response.send(proto::Ack {})?;
Ok(()) Ok(())
@ -2283,7 +2283,7 @@ async fn respond_to_contact_request(
session.peer.send(connection_id, update.clone())?; session.peer.send(connection_id, update.clone())?;
} }
send_notifications(&*pool, &session.peer, notifications); send_notifications(&pool, &session.peer, notifications);
} }
response.send(proto::Ack {})?; response.send(proto::Ack {})?;
@ -2451,7 +2451,7 @@ async fn invite_channel_member(
session.peer.send(connection_id, update.clone())?; session.peer.send(connection_id, update.clone())?;
} }
send_notifications(&*connection_pool, &session.peer, notifications); send_notifications(&connection_pool, &session.peer, notifications);
response.send(proto::Ack {})?; response.send(proto::Ack {})?;
Ok(()) Ok(())
@ -2713,7 +2713,7 @@ async fn respond_to_channel_invite(
} }
}; };
send_notifications(&*connection_pool, &session.peer, notifications); send_notifications(&connection_pool, &session.peer, notifications);
response.send(proto::Ack {})?; response.send(proto::Ack {})?;

View file

@ -466,7 +466,7 @@ impl TestServer {
let active_call_a = cx_a.read(ActiveCall::global); let active_call_a = cx_a.read(ActiveCall::global);
for (client_b, cx_b) in right { for (client_b, cx_b) in right {
let user_id_b = client_b.current_user_id(*cx_b).to_proto(); let user_id_b = client_b.current_user_id(cx_b).to_proto();
active_call_a active_call_a
.update(*cx_a, |call, cx| call.invite(user_id_b, None, cx)) .update(*cx_a, |call, cx| call.invite(user_id_b, None, cx))
.await .await

View file

@ -10052,7 +10052,7 @@ impl ViewInputHandler for Editor {
.disjoint_anchors() .disjoint_anchors()
.iter() .iter()
.map(|selection| { .map(|selection| {
selection.start.bias_left(&*snapshot)..selection.end.bias_right(&*snapshot) selection.start.bias_left(&snapshot)..selection.end.bias_right(&snapshot)
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
}; };

View file

@ -6774,7 +6774,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
move |_, leader, event, cx| { move |_, leader, event, cx| {
leader leader
.read(cx) .read(cx)
.add_event_to_update_proto(event, &mut *update.borrow_mut(), cx); .add_event_to_update_proto(event, &mut update.borrow_mut(), cx);
}, },
) )
.detach(); .detach();
@ -6943,7 +6943,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
cx.subscribe(&leader, move |_, leader, event, cx| { cx.subscribe(&leader, move |_, leader, event, cx| {
leader leader
.read(cx) .read(cx)
.add_event_to_update_proto(event, &mut *update.borrow_mut(), cx); .add_event_to_update_proto(event, &mut update.borrow_mut(), cx);
}) })
.detach(); .detach();
} }

View file

@ -160,7 +160,7 @@ impl TestAppContext {
/// Gives you an `&AppContext` for the duration of the closure /// Gives you an `&AppContext` for the duration of the closure
pub fn read<R>(&self, f: impl FnOnce(&AppContext) -> R) -> R { pub fn read<R>(&self, f: impl FnOnce(&AppContext) -> R) -> R {
let cx = self.app.borrow(); let cx = self.app.borrow();
f(&*cx) f(&cx)
} }
/// Adds a new window. The Window will always be backed by a `TestWindow` which /// Adds a new window. The Window will always be backed by a `TestWindow` which

View file

@ -1859,7 +1859,7 @@ impl MultiBuffer {
.cloned() .cloned()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let snapshot = self.snapshot.borrow(); let snapshot = self.snapshot.borrow();
excerpts_to_remove.sort_unstable_by(|a, b| a.cmp(b, &*snapshot)); excerpts_to_remove.sort_unstable_by(|a, b| a.cmp(b, &snapshot));
drop(snapshot); drop(snapshot);
log::info!("Removing excerpts {:?}", excerpts_to_remove); log::info!("Removing excerpts {:?}", excerpts_to_remove);
self.remove_excerpts(excerpts_to_remove, cx); self.remove_excerpts(excerpts_to_remove, cx);
@ -1920,7 +1920,7 @@ impl MultiBuffer {
for (ix, entry) in excerpt_ids.iter().enumerate() { for (ix, entry) in excerpt_ids.iter().enumerate() {
if ix == 0 { if ix == 0 {
if entry.id.cmp(&ExcerptId::min(), &*snapshot).is_le() { if entry.id.cmp(&ExcerptId::min(), &snapshot).is_le() {
panic!("invalid first excerpt id {:?}", entry.id); panic!("invalid first excerpt id {:?}", entry.id);
} }
} else { } else {

View file

@ -42,7 +42,7 @@ impl Render for KeybindingStory {
.gap_4() .gap_4()
.py_3() .py_3()
.children(chunk.map(|permutation| { .children(chunk.map(|permutation| {
KeyBinding::new(binding(&*(permutation.join("-") + "-x"))) KeyBinding::new(binding(&(permutation.join("-") + "-x")))
})) }))
}), }),
), ),

View file

@ -451,7 +451,7 @@ impl<T: Item> ItemHandle for View<T> {
if item.focus_handle(cx).contains_focused(cx) if item.focus_handle(cx).contains_focused(cx)
&& item.add_event_to_update_proto( && item.add_event_to_update_proto(
event, event,
&mut *pending_update.borrow_mut(), &mut pending_update.borrow_mut(),
cx, cx,
) )
&& !pending_update_scheduled.load(Ordering::SeqCst) && !pending_update_scheduled.load(Ordering::SeqCst)

View file

@ -91,7 +91,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
"clippy::derive_ord_xor_partial_ord", "clippy::derive_ord_xor_partial_ord",
"clippy::eq_op", "clippy::eq_op",
"clippy::expect_fun_call", "clippy::expect_fun_call",
"clippy::explicit_auto_deref",
"clippy::explicit_counter_loop", "clippy::explicit_counter_loop",
"clippy::extra_unused_lifetimes", "clippy::extra_unused_lifetimes",
"clippy::identity_op", "clippy::identity_op",