Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix `clippy::for_kv_map` lint violations (#36493)
tidely44941b5dfe5a
diff --git a/Cargo.toml b/Cargo.tomlindex dc14c8ebd92..1ed8edf836c 100644--- a/Cargo.toml+++ b/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"diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rsindex b20b126d9b9..61a3ddd9063 100644--- a/crates/agent_ui/src/agent_diff.rs+++ b/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;};diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rsindex 943e819ad6d..828248b330b 100644--- a/crates/channel/src/channel_buffer.rs+++ b/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)diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rsindex 850a4946135..daa8a91c7c8 100644--- a/crates/channel/src/channel_store.rs+++ b/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(){diff --git a/crates/extension_host/src/extension_host.rs b/crates/extension_host/src/extension_host.rsindex 4c3ab8d2427..fde0aeac940 100644--- a/crates/extension_host/src/extension_host.rs+++ b/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);}diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rsindex 4d314280940..2fe1da067bb 100644--- a/crates/gpui/src/platform/linux/wayland/client.rs+++ b/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);}}diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rsindex 346ba8718b3..68198a285f9 100644--- a/crates/gpui/src/platform/linux/x11/client.rs+++ b/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);}}diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rsindex 891ae1595d3..832b7f09d1d 100644--- a/crates/outline_panel/src/outline_panel.rs+++ b/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();}}diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex 12505a6a03d..04b14ae06e2 100644--- a/crates/project/src/lsp_store.rs+++ b/crates/project/src/lsp_store.rs@@ -10883,7 +10883,7 @@ impl LspStore {// Find all worktrees that have this server in their language server treefor (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);}diff --git a/crates/project/src/manifest_tree.rs b/crates/project/src/manifest_tree.rsindex ced9b34d93c..5a3c7bd40fb 100644--- a/crates/project/src/manifest_tree.rs+++ b/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();})diff --git a/crates/project/src/manifest_tree/server_tree.rs b/crates/project/src/manifest_tree/server_tree.rsindex f5fd4813243..5e5f4bab49c 100644--- a/crates/project/src/manifest_tree/server_tree.rs+++ b/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)));}}