From 659974411d297adee18da22b6928dc3d8fea0a53 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sat, 2 Mar 2024 22:30:18 -0500 Subject: [PATCH] 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 --- crates/collab/src/db/queries/buffers.rs | 32 +++---- crates/collab/src/db/queries/channels.rs | 84 +++++++++---------- crates/collab/src/db/queries/contacts.rs | 8 +- crates/collab/src/db/queries/contributors.rs | 2 +- crates/collab/src/db/queries/messages.rs | 34 ++++---- crates/collab/src/db/queries/projects.rs | 4 +- crates/collab/src/db/queries/rooms.rs | 11 ++- crates/collab/src/db/queries/users.rs | 2 +- crates/collab/src/db/tests/buffer_tests.rs | 10 +-- crates/collab/src/db/tests/channel_tests.rs | 32 +++---- crates/collab/src/db/tests/message_tests.rs | 2 +- crates/collab/src/rpc.rs | 14 ++-- crates/collab/src/tests/test_server.rs | 2 +- crates/editor/src/editor.rs | 2 +- crates/editor/src/editor_tests.rs | 4 +- crates/gpui/src/app/test_context.rs | 2 +- crates/multi_buffer/src/multi_buffer.rs | 4 +- .../ui/src/components/stories/keybinding.rs | 2 +- crates/workspace/src/item.rs | 2 +- tooling/xtask/src/main.rs | 1 - 20 files changed, 126 insertions(+), 128 deletions(-) diff --git a/crates/collab/src/db/queries/buffers.rs b/crates/collab/src/db/queries/buffers.rs index e141ea8865..4ebca6cebb 100644 --- a/crates/collab/src/db/queries/buffers.rs +++ b/crates/collab/src/db/queries/buffers.rs @@ -18,7 +18,7 @@ impl Database { connection: ConnectionId, ) -> Result { 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) .await?; @@ -134,10 +134,10 @@ impl Database { let mut results = Vec::new(); for client_buffer in buffers { 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?; if self - .check_user_is_channel_participant(&channel, user_id, &*tx) + .check_user_is_channel_participant(&channel, user_id, &tx) .await .is_err() { @@ -145,7 +145,7 @@ impl Database { 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() .filter(channel_buffer_collaborator::Column::ChannelId.eq(channel.id)) .all(&*tx) @@ -180,7 +180,7 @@ impl Database { let client_version = version_from_wire(&client_buffer.version); 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?; let mut rows = buffer_operation::Entity::find() @@ -283,7 +283,7 @@ impl Database { connection: ConnectionId, ) -> Result { 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 @@ -337,7 +337,7 @@ impl Database { let mut result = Vec::new(); for channel_id in channel_ids { let left_channel_buffer = self - .leave_channel_buffer_internal(channel_id, connection, &*tx) + .leave_channel_buffer_internal(channel_id, connection, &tx) .await?; result.push(left_channel_buffer); } @@ -406,7 +406,7 @@ impl Database { channel_id: ChannelId, ) -> Result> { 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 @@ -447,7 +447,7 @@ impl Database { Vec, )> { 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; for op in operations.iter() { @@ -457,10 +457,10 @@ impl Database { } } if requires_write_permission { - self.check_user_is_channel_member(&channel, user, &*tx) + self.check_user_is_channel_member(&channel, user, &tx) .await?; } else { - self.check_user_is_channel_participant(&channel, user, &*tx) + self.check_user_is_channel_participant(&channel, user, &tx) .await?; } @@ -471,7 +471,7 @@ impl Database { .ok_or_else(|| anyhow!("no such buffer"))?; 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?; let operations = operations @@ -500,13 +500,13 @@ impl Database { buffer.epoch, *max_operation.replica_id.as_ref(), *max_operation.lamport_timestamp.as_ref(), - &*tx, + &tx, ) .await?; - channel_members = self.get_channel_participants(&channel, &*tx).await?; + channel_members = self.get_channel_participants(&channel, &tx).await?; let collaborators = self - .get_channel_buffer_collaborators_internal(channel_id, &*tx) + .get_channel_buffer_collaborators_internal(channel_id, &tx) .await?; channel_members.retain(|member| !collaborators.contains(member)); @@ -737,7 +737,7 @@ impl Database { epoch, component.replica_id as i32, component.timestamp as i32, - &*tx, + &tx, ) .await?; Ok(()) diff --git a/crates/collab/src/db/queries/channels.rs b/crates/collab/src/db/queries/channels.rs index 0896fedb13..376a44b6eb 100644 --- a/crates/collab/src/db/queries/channels.rs +++ b/crates/collab/src/db/queries/channels.rs @@ -53,8 +53,8 @@ impl Database { let mut membership = None; if let Some(parent_channel_id) = parent_channel_id { - let parent_channel = self.get_channel_internal(parent_channel_id, &*tx).await?; - self.check_user_is_channel_admin(&parent_channel, admin_id, &*tx) + let parent_channel = self.get_channel_internal(parent_channel_id, &tx).await?; + self.check_user_is_channel_admin(&parent_channel, admin_id, &tx) .await?; parent = Some(parent_channel); } @@ -105,14 +105,14 @@ impl Database { connection: ConnectionId, ) -> Result<(JoinRoom, Option, ChannelRole)> { self.transaction(move |tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - let mut role = self.channel_role_for_user(&channel, user_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 accept_invite_result = None; if role.is_none() { if let Some(invitation) = self - .pending_invite_for_channel(&channel, user_id, &*tx) + .pending_invite_for_channel(&channel, user_id, &tx) .await? { // note, this may be a parent channel @@ -125,12 +125,12 @@ impl Database { .await?; accept_invite_result = Some( - self.calculate_membership_updated(&channel, user_id, &*tx) + self.calculate_membership_updated(&channel, user_id, &tx) .await?, ); 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 { role = Some(ChannelRole::Guest); @@ -145,12 +145,12 @@ impl Database { .await?; accept_invite_result = Some( - self.calculate_membership_updated(&channel, user_id, &*tx) + self.calculate_membership_updated(&channel, user_id, &tx) .await?, ); 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 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?; - 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 .map(|jr| (jr, accept_invite_result, role)) }) @@ -180,13 +180,13 @@ impl Database { admin_id: UserId, ) -> Result<(Channel, Vec)> { self.transaction(move |tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, admin_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, admin_id, &tx) .await?; if visibility == ChannelVisibility::Public { 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 { Err(ErrorCode::BadPublicNesting @@ -196,7 +196,7 @@ impl Database { } } else if visibility == ChannelVisibility::Members { if self - .get_channel_descendants_excluding_self([&channel], &*tx) + .get_channel_descendants_excluding_self([&channel], &tx) .await? .into_iter() .any(|channel| channel.visibility == ChannelVisibility::Public) @@ -228,7 +228,7 @@ impl Database { requires_zed_cla: bool, ) -> Result<()> { 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(); model.requires_zed_cla = ActiveValue::Set(requires_zed_cla); model.update(&*tx).await?; @@ -244,8 +244,8 @@ impl Database { user_id: UserId, ) -> Result<(Vec, Vec)> { self.transaction(move |tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, user_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, user_id, &tx) .await?; let members_to_notify: Vec = channel_member::Entity::find() @@ -258,7 +258,7 @@ impl Database { .await?; let channels_to_remove = self - .get_channel_descendants_excluding_self([&channel], &*tx) + .get_channel_descendants_excluding_self([&channel], &tx) .await? .into_iter() .map(|channel| channel.id) @@ -284,8 +284,8 @@ impl Database { role: ChannelRole, ) -> Result { self.transaction(move |tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, inviter_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, inviter_id, &tx) .await?; if !channel.is_root() { Err(ErrorCode::NotARootChannel.anyhow())? @@ -312,7 +312,7 @@ impl Database { inviter_id: inviter_id.to_proto(), }, true, - &*tx, + &tx, ) .await? .into_iter() @@ -344,8 +344,8 @@ impl Database { self.transaction(move |tx| async move { let new_name = Self::sanitize_channel_name(new_name)?.to_string(); - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, admin_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, admin_id, &tx) .await?; let mut model = channel.into_active_model(); @@ -370,7 +370,7 @@ impl Database { accept: bool, ) -> Result { 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 rows_affected = channel_member::Entity::update_many() @@ -393,7 +393,7 @@ impl Database { } Some( - self.calculate_membership_updated(&channel, user_id, &*tx) + self.calculate_membership_updated(&channel, user_id, &tx) .await?, ) } else { @@ -425,7 +425,7 @@ impl Database { inviter_id: Default::default(), }, accept, - &*tx, + &tx, ) .await? .into_iter() @@ -466,10 +466,10 @@ impl Database { admin_id: UserId, ) -> Result { 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 { - self.check_user_is_channel_admin(&channel, admin_id, &*tx) + self.check_user_is_channel_admin(&channel, admin_id, &tx) .await?; } @@ -488,7 +488,7 @@ impl Database { Ok(RemoveChannelMemberResult { membership_update: self - .calculate_membership_updated(&channel, member_id, &*tx) + .calculate_membership_updated(&channel, member_id, &tx) .await?, notification_id: self .remove_notification( @@ -498,7 +498,7 @@ impl Database { channel_name: Default::default(), inviter_id: Default::default(), }, - &*tx, + &tx, ) .await?, }) @@ -674,8 +674,8 @@ impl Database { role: ChannelRole, ) -> Result { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, admin_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, admin_id, &tx) .await?; let membership = channel_member::Entity::find() @@ -697,7 +697,7 @@ impl Database { if updated.accepted { Ok(SetMemberRoleResult::MembershipUpdated( - self.calculate_membership_updated(&channel, for_user, &*tx) + self.calculate_membership_updated(&channel, for_user, &tx) .await?, )) } else { @@ -717,13 +717,13 @@ impl Database { ) -> Result> { let (role, members) = 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 role = self - .check_user_is_channel_participant(&channel, user_id, &*tx) + .check_user_is_channel_participant(&channel, user_id, &tx) .await?; Ok(( role, - self.get_channel_participant_details_internal(&channel, &*tx) + self.get_channel_participant_details_internal(&channel, &tx) .await?, )) }) @@ -915,8 +915,8 @@ impl Database { /// Returns the channel with the given ID. pub async fn get_channel(&self, channel_id: ChannelId, user_id: UserId) -> Result { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_participant(&channel, user_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_participant(&channel, user_id, &tx) .await?; Ok(Channel::from_model(channel)) @@ -971,10 +971,10 @@ impl Database { admin_id: UserId, ) -> Result<(Vec, Vec)> { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_admin(&channel, admin_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_admin(&channel, admin_id, &tx) .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() { Err(anyhow!(ErrorCode::WrongMoveTarget))?; diff --git a/crates/collab/src/db/queries/contacts.rs b/crates/collab/src/db/queries/contacts.rs index c66c33b80d..89bb07f3d9 100644 --- a/crates/collab/src/db/queries/contacts.rs +++ b/crates/collab/src/db/queries/contacts.rs @@ -177,7 +177,7 @@ impl Database { sender_id: sender_id.to_proto(), }, true, - &*tx, + &tx, ) .await? .into_iter() @@ -227,7 +227,7 @@ impl Database { rpc::Notification::ContactRequest { sender_id: requester_id.to_proto(), }, - &*tx, + &tx, ) .await?; } @@ -335,7 +335,7 @@ impl Database { sender_id: requester_id.to_proto(), }, accept, - &*tx, + &tx, ) .await?, ); @@ -348,7 +348,7 @@ impl Database { responder_id: responder_id.to_proto(), }, true, - &*tx, + &tx, ) .await?, ); diff --git a/crates/collab/src/db/queries/contributors.rs b/crates/collab/src/db/queries/contributors.rs index 0972779ce9..49194d6861 100644 --- a/crates/collab/src/db/queries/contributors.rs +++ b/crates/collab/src/db/queries/contributors.rs @@ -72,7 +72,7 @@ impl Database { github_login, github_user_id, github_email, - &*tx, + &tx, ) .await?; diff --git a/crates/collab/src/db/queries/messages.rs b/crates/collab/src/db/queries/messages.rs index 8143007e19..83796d4512 100644 --- a/crates/collab/src/db/queries/messages.rs +++ b/crates/collab/src/db/queries/messages.rs @@ -12,8 +12,8 @@ impl Database { user_id: UserId, ) -> Result<()> { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_participant(&channel, user_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_participant(&channel, user_id, &tx) .await?; channel_chat_participant::ActiveModel { id: ActiveValue::NotSet, @@ -87,8 +87,8 @@ impl Database { before_message_id: Option, ) -> Result> { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_participant(&channel, user_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_participant(&channel, user_id, &tx) .await?; let mut condition = @@ -105,7 +105,7 @@ impl Database { .all(&*tx) .await?; - self.load_channel_messages(rows, &*tx).await + self.load_channel_messages(rows, &tx).await }) .await } @@ -127,16 +127,16 @@ impl Database { for row in &rows { channels.insert( 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 { - self.check_user_is_channel_participant(&channel, user_id, &*tx) + self.check_user_is_channel_participant(&channel, user_id, &tx) .await?; } - let messages = self.load_channel_messages(rows, &*tx).await?; + let messages = self.load_channel_messages(rows, &tx).await?; Ok(messages) }) .await @@ -212,8 +212,8 @@ impl Database { reply_to_message_id: Option, ) -> Result { self.transaction(|tx| async move { - let channel = self.get_channel_internal(channel_id, &*tx).await?; - self.check_user_is_channel_participant(&channel, user_id, &*tx) + let channel = self.get_channel_internal(channel_id, &tx).await?; + self.check_user_is_channel_participant(&channel, user_id, &tx) .await?; let mut rows = channel_chat_participant::Entity::find() @@ -303,13 +303,13 @@ impl Database { channel_id: channel_id.to_proto(), }, false, - &*tx, + &tx, ) .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?; } _ => { @@ -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)); Ok(CreatedChannelMessage { @@ -342,7 +342,7 @@ impl Database { message_id: MessageId, ) -> Result { 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?; let mut batch = NotificationBatch::default(); batch.extend( @@ -353,7 +353,7 @@ impl Database { sender_id: Default::default(), channel_id: Default::default(), }, - &*tx, + &tx, ) .await?, ); @@ -501,9 +501,9 @@ impl Database { .await?; 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 - .check_user_is_channel_admin(&channel, user_id, &*tx) + .check_user_is_channel_admin(&channel, user_id, &tx) .await .is_ok() { diff --git a/crates/collab/src/db/queries/projects.rs b/crates/collab/src/db/queries/projects.rs index 33302eece1..7adf6efd72 100644 --- a/crates/collab/src/db/queries/projects.rs +++ b/crates/collab/src/db/queries/projects.rs @@ -1061,7 +1061,7 @@ impl Database { .insert(&*tx) .await?; - let room = self.get_room(room_id, &*tx).await?; + let room = self.get_room(room_id, &tx).await?; Ok(room) }) .await @@ -1095,7 +1095,7 @@ impl Database { .exec(&*tx) .await?; - let room = self.get_room(room_id, &*tx).await?; + let room = self.get_room(room_id, &tx).await?; Ok(room) }) .await diff --git a/crates/collab/src/db/queries/rooms.rs b/crates/collab/src/db/queries/rooms.rs index b5073ae7ab..f666391cde 100644 --- a/crates/collab/src/db/queries/rooms.rs +++ b/crates/collab/src/db/queries/rooms.rs @@ -321,7 +321,7 @@ impl Database { } let participant_index = self - .get_next_participant_index_internal(room_id, &*tx) + .get_next_participant_index_internal(room_id, &tx) .await?; let result = room_participant::Entity::update_many() @@ -1010,7 +1010,7 @@ impl Database { .ok_or_else(|| anyhow!("only admins can set participant role"))?; 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?; } @@ -1076,10 +1076,9 @@ impl Database { pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()> { self.transaction(|tx| async move { - self.room_connection_lost(connection, &*tx).await?; - self.channel_buffer_connection_lost(connection, &*tx) - .await?; - self.channel_chat_connection_lost(connection, &*tx).await?; + self.room_connection_lost(connection, &tx).await?; + self.channel_buffer_connection_lost(connection, &tx).await?; + self.channel_chat_connection_lost(connection, &tx).await?; Ok(()) }) .await diff --git a/crates/collab/src/db/queries/users.rs b/crates/collab/src/db/queries/users.rs index f0768a3a9c..e60ff63385 100644 --- a/crates/collab/src/db/queries/users.rs +++ b/crates/collab/src/db/queries/users.rs @@ -80,7 +80,7 @@ impl Database { github_login, github_user_id, github_email, - &*tx, + &tx, ) .await }) diff --git a/crates/collab/src/db/tests/buffer_tests.rs b/crates/collab/src/db/tests/buffer_tests.rs index c1015330bb..ebc11a7019 100644 --- a/crates/collab/src/db/tests/buffer_tests.rs +++ b/crates/collab/src/db/tests/buffer_tests.rs @@ -222,7 +222,7 @@ async fn test_channel_buffers_last_operations(db: &Database) { .unwrap(); 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 .unwrap(), ); @@ -238,7 +238,7 @@ async fn test_channel_buffers_last_operations(db: &Database) { .transaction(|tx| { let buffers = &buffers; 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 } }) @@ -302,7 +302,7 @@ async fn test_channel_buffers_last_operations(db: &Database) { .transaction(|tx| { let buffers = &buffers; 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 } }) @@ -320,7 +320,7 @@ async fn test_channel_buffers_last_operations(db: &Database) { .transaction(|tx| { let buffers = &buffers; 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 } }) @@ -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[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 .unwrap(); diff --git a/crates/collab/src/db/tests/channel_tests.rs b/crates/collab/src/db/tests/channel_tests.rs index 7f74bf15aa..99bf44744f 100644 --- a/crates/collab/src/db/tests/channel_tests.rs +++ b/crates/collab/src/db/tests/channel_tests.rs @@ -42,8 +42,8 @@ async fn test_channels(db: &Arc) { let mut members = db .transaction(|tx| async move { - let channel = db.get_channel_internal(replace_id, &*tx).await?; - Ok(db.get_channel_participants(&channel, &*tx).await?) + let channel = db.get_channel_internal(replace_id, &tx).await?; + Ok(db.get_channel_participants(&channel, &tx).await?) }) .await .unwrap(); @@ -464,9 +464,9 @@ async fn test_user_is_channel_participant(db: &Arc) { db.transaction(|tx| async move { 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, - &*tx, + &tx, ) .await }) @@ -474,9 +474,9 @@ async fn test_user_is_channel_participant(db: &Arc) { .unwrap(); db.transaction(|tx| async move { 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, - &*tx, + &tx, ) .await }) @@ -517,9 +517,9 @@ async fn test_user_is_channel_participant(db: &Arc) { db.transaction(|tx| async move { 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, - &*tx, + &tx, ) .await }) @@ -547,11 +547,11 @@ async fn test_user_is_channel_participant(db: &Arc) { assert!(db .transaction(|tx| async move { db.check_user_is_channel_participant( - &db.get_channel_internal(public_channel_id, &*tx) + &db.get_channel_internal(public_channel_id, &tx) .await .unwrap(), guest, - &*tx, + &tx, ) .await }) @@ -629,9 +629,9 @@ async fn test_user_is_channel_participant(db: &Arc) { db.transaction(|tx| async move { 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, - &*tx, + &tx, ) .await }) @@ -640,11 +640,11 @@ async fn test_user_is_channel_participant(db: &Arc) { assert!(db .transaction(|tx| async move { db.check_user_is_channel_participant( - &db.get_channel_internal(internal_channel_id, &*tx) + &db.get_channel_internal(internal_channel_id, &tx) .await .unwrap(), guest, - &*tx, + &tx, ) .await }) @@ -653,11 +653,11 @@ async fn test_user_is_channel_participant(db: &Arc) { db.transaction(|tx| async move { db.check_user_is_channel_participant( - &db.get_channel_internal(public_channel_id, &*tx) + &db.get_channel_internal(public_channel_id, &tx) .await .unwrap(), guest, - &*tx, + &tx, ) .await }) diff --git a/crates/collab/src/db/tests/message_tests.rs b/crates/collab/src/db/tests/message_tests.rs index c785e3cb73..e20473d3bd 100644 --- a/crates/collab/src/db/tests/message_tests.rs +++ b/crates/collab/src/db/tests/message_tests.rs @@ -297,7 +297,7 @@ async fn test_unseen_channel_messages(db: &Arc) { // Check that observer has new messages let latest_messages = db .transaction(|tx| async move { - db.latest_channel_messages(&[channel_1, channel_2], &*tx) + db.latest_channel_messages(&[channel_1, channel_2], &tx) .await }) .await diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 074bb44bcc..28f16e1763 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -353,7 +353,7 @@ impl Server { &refreshed_room.room, &refreshed_room.channel_members, &peer, - &*pool.lock(), + &pool.lock(), ); } contacts_to_update @@ -754,13 +754,13 @@ impl<'a> Deref for ConnectionPoolGuard<'a> { type Target = ConnectionPool; fn deref(&self) -> &Self::Target { - &*self.guard + &self.guard } } impl<'a> DerefMut for ConnectionPoolGuard<'a> { 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())?; } - send_notifications(&*connection_pool, &session.peer, notifications); + send_notifications(&connection_pool, &session.peer, notifications); response.send(proto::Ack {})?; Ok(()) @@ -2283,7 +2283,7 @@ async fn respond_to_contact_request( session.peer.send(connection_id, update.clone())?; } - send_notifications(&*pool, &session.peer, notifications); + send_notifications(&pool, &session.peer, notifications); } response.send(proto::Ack {})?; @@ -2451,7 +2451,7 @@ async fn invite_channel_member( 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 {})?; 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 {})?; diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index 08e6bf9a68..7397e51f79 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -466,7 +466,7 @@ impl TestServer { let active_call_a = cx_a.read(ActiveCall::global); 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 .update(*cx_a, |call, cx| call.invite(user_id_b, None, cx)) .await diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f9aedb5d42..86312b0134 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -10052,7 +10052,7 @@ impl ViewInputHandler for Editor { .disjoint_anchors() .iter() .map(|selection| { - selection.start.bias_left(&*snapshot)..selection.end.bias_right(&*snapshot) + selection.start.bias_left(&snapshot)..selection.end.bias_right(&snapshot) }) .collect::>() }; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 04b8c01a90..21072c908d 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -6774,7 +6774,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) { move |_, leader, event, cx| { leader .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(); @@ -6943,7 +6943,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) { cx.subscribe(&leader, move |_, leader, event, cx| { leader .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(); } diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index e2f4808ca5..20383047e7 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -160,7 +160,7 @@ impl TestAppContext { /// Gives you an `&AppContext` for the duration of the closure pub fn read(&self, f: impl FnOnce(&AppContext) -> R) -> R { let cx = self.app.borrow(); - f(&*cx) + f(&cx) } /// Adds a new window. The Window will always be backed by a `TestWindow` which diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index daf06d9f86..0c0d434825 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -1859,7 +1859,7 @@ impl MultiBuffer { .cloned() .collect::>(); 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); log::info!("Removing excerpts {:?}", excerpts_to_remove); self.remove_excerpts(excerpts_to_remove, cx); @@ -1920,7 +1920,7 @@ impl MultiBuffer { for (ix, entry) in excerpt_ids.iter().enumerate() { 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); } } else { diff --git a/crates/ui/src/components/stories/keybinding.rs b/crates/ui/src/components/stories/keybinding.rs index 980a57d7da..f7a9a86cd0 100644 --- a/crates/ui/src/components/stories/keybinding.rs +++ b/crates/ui/src/components/stories/keybinding.rs @@ -42,7 +42,7 @@ impl Render for KeybindingStory { .gap_4() .py_3() .children(chunk.map(|permutation| { - KeyBinding::new(binding(&*(permutation.join("-") + "-x"))) + KeyBinding::new(binding(&(permutation.join("-") + "-x"))) })) }), ), diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index d5d8aed39d..580703d6b0 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -451,7 +451,7 @@ impl ItemHandle for View { if item.focus_handle(cx).contains_focused(cx) && item.add_event_to_update_proto( event, - &mut *pending_update.borrow_mut(), + &mut pending_update.borrow_mut(), cx, ) && !pending_update_scheduled.load(Ordering::SeqCst) diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs index 836e8826c4..684091b460 100644 --- a/tooling/xtask/src/main.rs +++ b/tooling/xtask/src/main.rs @@ -91,7 +91,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> { "clippy::derive_ord_xor_partial_ord", "clippy::eq_op", "clippy::expect_fun_call", - "clippy::explicit_auto_deref", "clippy::explicit_counter_loop", "clippy::extra_unused_lifetimes", "clippy::identity_op",