Fix `clippy::for_kv_map` lint violations (#36493)

tidely created

Release Notes:

- N/A

Change summary

Cargo.toml                                       |  1 +
crates/agent_ui/src/agent_diff.rs                |  2 +-
crates/channel/src/channel_buffer.rs             |  2 +-
crates/channel/src/channel_store.rs              |  2 +-
crates/extension_host/src/extension_host.rs      | 10 +++++-----
crates/gpui/src/platform/linux/wayland/client.rs |  2 +-
crates/gpui/src/platform/linux/x11/client.rs     |  2 +-
crates/outline_panel/src/outline_panel.rs        |  2 +-
crates/project/src/lsp_store.rs                  |  2 +-
crates/project/src/manifest_tree.rs              |  2 +-
crates/project/src/manifest_tree/server_tree.rs  |  4 ++--
11 files changed, 16 insertions(+), 15 deletions(-)

Detailed changes

Cargo.toml 🔗

@@ -823,6 +823,7 @@ style = { level = "allow", priority = -1 }
 
 # Temporary list of style lints that we've fixed so far.
 comparison_to_empty = "warn"
+for_kv_map = "warn"
 into_iter_on_ref = "warn"
 iter_cloned_collect = "warn"
 iter_next_slice = "warn"

crates/agent_ui/src/agent_diff.rs 🔗

@@ -1643,7 +1643,7 @@ impl AgentDiff {
                 continue;
             };
 
-            for (weak_editor, _) in buffer_editors {
+            for weak_editor in buffer_editors.keys() {
                 let Some(editor) = weak_editor.upgrade() else {
                     continue;
                 };

crates/channel/src/channel_buffer.rs 🔗

@@ -135,7 +135,7 @@ impl ChannelBuffer {
             }
         }
 
-        for (_, old_collaborator) in &self.collaborators {
+        for old_collaborator in self.collaborators.values() {
             if !new_collaborators.contains_key(&old_collaborator.peer_id) {
                 self.buffer.update(cx, |buffer, cx| {
                     buffer.remove_peer(old_collaborator.replica_id, cx)

crates/channel/src/channel_store.rs 🔗

@@ -1073,7 +1073,7 @@ impl ChannelStore {
 
                 if let Some(this) = this.upgrade() {
                     this.update(cx, |this, cx| {
-                        for (_, buffer) in &this.opened_buffers {
+                        for buffer in this.opened_buffers.values() {
                             if let OpenEntityHandle::Open(buffer) = &buffer
                                 && let Some(buffer) = buffer.upgrade()
                             {

crates/extension_host/src/extension_host.rs 🔗

@@ -1175,16 +1175,16 @@ impl ExtensionStore {
                 }
             }
 
-            for (server_id, _) in &extension.manifest.context_servers {
+            for server_id in extension.manifest.context_servers.keys() {
                 self.proxy.unregister_context_server(server_id.clone(), cx);
             }
-            for (adapter, _) in &extension.manifest.debug_adapters {
+            for adapter in extension.manifest.debug_adapters.keys() {
                 self.proxy.unregister_debug_adapter(adapter.clone());
             }
-            for (locator, _) in &extension.manifest.debug_locators {
+            for locator in extension.manifest.debug_locators.keys() {
                 self.proxy.unregister_debug_locator(locator.clone());
             }
-            for (command_name, _) in &extension.manifest.slash_commands {
+            for command_name in extension.manifest.slash_commands.keys() {
                 self.proxy.unregister_slash_command(command_name.clone());
             }
         }
@@ -1386,7 +1386,7 @@ impl ExtensionStore {
                         );
                     }
 
-                    for (id, _context_server_entry) in &manifest.context_servers {
+                    for id in manifest.context_servers.keys() {
                         this.proxy
                             .register_context_server(extension.clone(), id.clone(), cx);
                     }

crates/gpui/src/platform/linux/wayland/client.rs 🔗

@@ -528,7 +528,7 @@ impl WaylandClient {
 
                             client.common.appearance = appearance;
 
-                            for (_, window) in &mut client.windows {
+                            for window in client.windows.values_mut() {
                                 window.set_appearance(appearance);
                             }
                         }

crates/gpui/src/platform/linux/x11/client.rs 🔗

@@ -456,7 +456,7 @@ impl X11Client {
                 move |event, _, client| match event {
                     XDPEvent::WindowAppearance(appearance) => {
                         client.with_common(|common| common.appearance = appearance);
-                        for (_, window) in &mut client.0.borrow_mut().windows {
+                        for window in client.0.borrow_mut().windows.values_mut() {
                             window.window.set_appearance(appearance);
                         }
                     }

crates/outline_panel/src/outline_panel.rs 🔗

@@ -5338,7 +5338,7 @@ fn subscribe_for_editor_events(
                 }
                 EditorEvent::Reparsed(buffer_id) => {
                     if let Some(excerpts) = outline_panel.excerpts.get_mut(buffer_id) {
-                        for (_, excerpt) in excerpts {
+                        for excerpt in excerpts.values_mut() {
                             excerpt.invalidate_outlines();
                         }
                     }

crates/project/src/lsp_store.rs 🔗

@@ -10883,7 +10883,7 @@ impl LspStore {
             // Find all worktrees that have this server in their language server tree
             for (worktree_id, servers) in &local.lsp_tree.instances {
                 if *worktree_id != key.worktree_id {
-                    for (_, server_map) in &servers.roots {
+                    for server_map in servers.roots.values() {
                         if server_map.contains_key(&key.name) {
                             worktrees_using_server.push(*worktree_id);
                         }

crates/project/src/manifest_tree.rs 🔗

@@ -77,7 +77,7 @@ impl ManifestTree {
             _subscriptions: [
                 cx.subscribe(&worktree_store, Self::on_worktree_store_event),
                 cx.observe_global::<SettingsStore>(|this, cx| {
-                    for (_, roots) in &mut this.root_points {
+                    for roots in this.root_points.values_mut() {
                         roots.update(cx, |worktree_roots, _| {
                             worktree_roots.roots = RootPathTrie::new();
                         })

crates/project/src/manifest_tree/server_tree.rs 🔗

@@ -312,8 +312,8 @@ impl LanguageServerTree {
 
     /// Remove nodes with a given ID from the tree.
     pub(crate) fn remove_nodes(&mut self, ids: &BTreeSet<LanguageServerId>) {
-        for (_, servers) in &mut self.instances {
-            for (_, nodes) in &mut servers.roots {
+        for servers in self.instances.values_mut() {
+            for nodes in &mut servers.roots.values_mut() {
                 nodes.retain(|_, (node, _)| node.id.get().is_none_or(|id| !ids.contains(id)));
             }
         }