Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use collections::{HashMap, HashSet} instead of its std:: counterpart (#7502)
Kirill Bulatov83cffdde1fad
diff --git a/Cargo.lock b/Cargo.lockindex 78a47cc6046..8e72a590dec 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -7530,6 +7530,7 @@ name = "sqlez"version = "0.1.0"dependencies = ["anyhow",+ "collections","futures 0.3.28","indoc","lazy_static",@@ -8105,6 +8106,7 @@ version = "0.1.0"dependencies = ["alacritty_terminal","anyhow",+ "collections","db","dirs 4.0.0","futures 0.3.28",@@ -8200,6 +8202,7 @@ name = "theme"version = "0.1.0"dependencies = ["anyhow",+ "collections","color","derive_more","fs",@@ -9343,6 +9346,7 @@ version = "0.1.0"dependencies = ["anyhow","backtrace",+ "collections","dirs 3.0.2","futures 0.3.28","git2",diff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rsindex ad843470be3..e6ed013adee 100644--- a/crates/channel/src/channel_chat.rs+++ b/crates/channel/src/channel_chat.rs@@ -5,13 +5,13 @@ use client::{user::{User, UserStore},Client, Subscription, TypedEnvelope, UserId,};+use collections::HashSet;use futures::lock::Mutex;use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel,};use rand::prelude::*;use std::{- collections::HashSet,ops::{ControlFlow, Range},sync::Arc,};diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex ff8adc96607..e454d3ddaf3 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -10,6 +10,7 @@ use async_tungstenite::tungstenite::{error::Error as WebsocketError,http::{Request, StatusCode},};+use collections::HashMap;use futures::{channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt,TryFutureExt as _, TryStreamExt,@@ -29,7 +30,6 @@ use serde_json;use settings::{Settings, SettingsStore};use std::{any::TypeId,- collections::HashMap,convert::TryFrom,fmt::Write as _,future::Future,diff --git a/crates/gpui/src/keymap.rs b/crates/gpui/src/keymap.rsindex 45e0ebbe951..e2a6bdfc4b5 100644--- a/crates/gpui/src/keymap.rs+++ b/crates/gpui/src/keymap.rs@@ -7,12 +7,9 @@ pub use context::*;pub(crate) use matcher::*;use crate::{Action, Keystroke, NoAction};-use collections::HashSet;+use collections::{HashMap, HashSet};use smallvec::SmallVec;-use std::{- any::{Any, TypeId},- collections::HashMap,-};+use std::any::{Any, TypeId};/// An opaque identifier of which version of the keymap is currently active./// The keymap's version is changed whenever bindings are added or removed.diff --git a/crates/gpui/src/window/element_cx.rs b/crates/gpui/src/window/element_cx.rsindex 2f05e716731..e3d95de58d6 100644--- a/crates/gpui/src/window/element_cx.rs+++ b/crates/gpui/src/window/element_cx.rs@@ -71,7 +71,7 @@ pub(crate) struct Frame {pub(crate) reused_views: FxHashSet<EntityId>,#[cfg(any(test, feature = "test-support"))]- pub(crate) debug_bounds: collections::FxHashMap<String, Bounds<Pixels>>,+ pub(crate) debug_bounds: FxHashMap<String, Bounds<Pixels>>,}impl Frame {diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex b43b5d84131..3744a36c00f 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -8,6 +8,7 @@ use editor::{actions::Cancel, scroll::Autoscroll, Editor};use file_associations::FileAssociations;use anyhow::{anyhow, Result};+use collections::{hash_map, HashMap};use gpui::{actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement,@@ -22,14 +23,7 @@ use project::{};use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};use serde::{Deserialize, Serialize};-use std::{- cmp::Ordering,- collections::{hash_map, HashMap},- ffi::OsStr,- ops::Range,- path::Path,- sync::Arc,-};+use std::{cmp::Ordering, ffi::OsStr, ops::Range, path::Path, sync::Arc};use theme::ThemeSettings;use ui::{prelude::*, v_flex, ContextMenu, Icon, KeyBinding, Label, ListItem};use unicase::UniCase;@@ -1699,15 +1693,13 @@ impl ClipboardEntry {#[cfg(test)]mod tests {use super::*;+ use collections::HashSet;use gpui::{TestAppContext, View, VisualTestContext, WindowHandle};use pretty_assertions::assert_eq;use project::{project_settings::ProjectSettings, FakeFs};use serde_json::json;use settings::SettingsStore;- use std::{- collections::HashSet,- path::{Path, PathBuf},- };+ use std::path::{Path, PathBuf};use workspace::AppState;#[gpui::test]@@ -3509,7 +3501,7 @@ mod tests {cx: &mut VisualTestContext,) -> Vec<String> {let mut result = Vec::new();- let mut project_entries = HashSet::new();+ let mut project_entries = HashSet::default();let mut has_editor = false;panel.update(cx, |panel, cx| {diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex f79e2556a38..ad2e8945273 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -25,11 +25,11 @@ use project::{};use semantic_index::{SemanticIndex, SemanticIndexStatus};+use collections::HashSet;use settings::Settings;use smol::stream::StreamExt;use std::{any::{Any, TypeId},- collections::HashSet,mem,ops::{Not, Range},path::PathBuf,@@ -955,7 +955,7 @@ impl ProjectSearchView {semantic_state: None,semantic_permissioned: None,search_options: options,- panels_with_errors: HashSet::new(),+ panels_with_errors: HashSet::default(),active_match_index: None,query_editor_was_focused: false,included_files_editor,diff --git a/crates/semantic_index/src/parsing.rs b/crates/semantic_index/src/parsing.rsindex 9f2db711ae0..e6f4a37d10d 100644--- a/crates/semantic_index/src/parsing.rs+++ b/crates/semantic_index/src/parsing.rs@@ -3,6 +3,7 @@ use ai::{models::TruncationDirection,};use anyhow::{anyhow, Result};+use collections::HashSet;use language::{Grammar, Language};use rusqlite::{types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef},@@ -12,7 +13,6 @@ use sha1::{Digest, Sha1};use std::{borrow::Cow,cmp::{self, Reverse},- collections::HashSet,ops::Range,path::Path,sync::Arc,@@ -267,7 +267,7 @@ impl CodeContextRetriever {let mut spans = Vec::new();let mut collapsed_ranges_within = Vec::new();- let mut parsed_name_ranges = HashSet::new();+ let mut parsed_name_ranges = HashSet::default();for (i, context_match) in matches.iter().enumerate() {// Items which are collapsible but not embeddable have no item rangelet item_range = if let Some(item_range) = context_match.item_range.clone() {diff --git a/crates/sqlez/Cargo.toml b/crates/sqlez/Cargo.tomlindex 2ee5e6cbf39..71c67af0950 100644--- a/crates/sqlez/Cargo.toml+++ b/crates/sqlez/Cargo.toml@@ -7,6 +7,7 @@ license = "GPL-3.0-or-later"[dependencies]anyhow.workspace = true+collections.workspace = truefutures.workspace = trueindoc.workspace = truelazy_static.workspace = truediff --git a/crates/sqlez/src/thread_safe_connection.rs b/crates/sqlez/src/thread_safe_connection.rsindex 98402df108e..cd4664c9aec 100644--- a/crates/sqlez/src/thread_safe_connection.rs+++ b/crates/sqlez/src/thread_safe_connection.rs@@ -1,8 +1,9 @@use anyhow::Context;+use collections::HashMap;use futures::{channel::oneshot, Future, FutureExt};use lazy_static::lazy_static;use parking_lot::{Mutex, RwLock};-use std::{collections::HashMap, marker::PhantomData, ops::Deref, sync::Arc, thread};+use std::{marker::PhantomData, ops::Deref, sync::Arc, thread};use thread_local::ThreadLocal;use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender};diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.tomlindex 7f12fc6eb75..a52a7c6f939 100644--- a/crates/terminal/Cargo.toml+++ b/crates/terminal/Cargo.toml@@ -13,6 +13,7 @@ doctest = false[dependencies]alacritty_terminal = "0.22.0"anyhow.workspace = true+collections.workspace = truedb.workspace = truedirs = "4.0.0"futures.workspace = truediff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rsindex ad9587a3267..46c7cb0c191 100644--- a/crates/terminal/src/terminal.rs+++ b/crates/terminal/src/terminal.rs@@ -30,6 +30,7 @@ use mappings::mouse::{scroll_report,};+use collections::{HashMap, VecDeque};use procinfo::LocalProcessInfo;use serde::{Deserialize, Serialize};use settings::Settings;@@ -39,7 +40,6 @@ use util::truncate_and_trailoff;use std::{cmp::{self, min},- collections::{HashMap, VecDeque},fmt::Display,ops::{Deref, Index, RangeInclusive},os::unix::prelude::AsRawFd,diff --git a/crates/terminal/src/terminal_settings.rs b/crates/terminal/src/terminal_settings.rsindex 7b3d97145c0..1a072ca8bce 100644--- a/crates/terminal/src/terminal_settings.rs+++ b/crates/terminal/src/terminal_settings.rs@@ -1,3 +1,4 @@+use collections::HashMap;use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels};use schemars::{gen::SchemaGenerator,@@ -7,7 +8,7 @@ use schemars::{use serde_derive::{Deserialize, Serialize};use serde_json::Value;use settings::SettingsJsonSchemaParams;-use std::{collections::HashMap, path::PathBuf};+use std::path::PathBuf;#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]#[serde(rename_all = "snake_case")]diff --git a/crates/theme/Cargo.toml b/crates/theme/Cargo.tomlindex 8970cfbacf7..c060627ad61 100644--- a/crates/theme/Cargo.toml+++ b/crates/theme/Cargo.toml@@ -8,11 +8,7 @@ license = "GPL-3.0-or-later"[features]default = []stories = ["dep:itertools", "dep:story"]-test-support = [- "gpui/test-support",- "fs/test-support",- "settings/test-support"-]+test-support = ["gpui/test-support", "fs/test-support", "settings/test-support"][lib]path = "src/theme.rs"@@ -20,6 +16,7 @@ doctest = false[dependencies]anyhow.workspace = true+collections.workspace = truecolor.workspace = truederive_more.workspace = truefs.workspace = truediff --git a/crates/theme/src/registry.rs b/crates/theme/src/registry.rsindex fac119ff1d0..2cc4d902a2d 100644--- a/crates/theme/src/registry.rs+++ b/crates/theme/src/registry.rs@@ -1,8 +1,8 @@-use std::collections::HashMap;use std::path::Path;use std::sync::Arc;use anyhow::{anyhow, Context, Result};+use collections::HashMap;use derive_more::{Deref, DerefMut};use fs::Fs;use futures::StreamExt;@@ -64,7 +64,7 @@ impl ThemeRegistry {pub fn new(assets: Box<dyn AssetSource>) -> Self {let registry = Self {state: RwLock::new(ThemeRegistryState {- themes: HashMap::new(),+ themes: HashMap::default(),}),assets,};diff --git a/crates/util/Cargo.toml b/crates/util/Cargo.tomlindex c510d6f5577..fc06ebeb4ae 100644--- a/crates/util/Cargo.toml+++ b/crates/util/Cargo.toml@@ -15,6 +15,7 @@ test-support = ["tempfile", "git2"][dependencies]anyhow.workspace = truebacktrace = "0.3"+collections.workspace = truedirs = "3.0"futures.workspace = truegit2 = { workspace = true, optional = true }diff --git a/crates/util/src/test/marked_text.rs b/crates/util/src/test/marked_text.rsindex dadf78622de..cf85a806e4d 100644--- a/crates/util/src/test/marked_text.rs+++ b/crates/util/src/test/marked_text.rs@@ -1,4 +1,5 @@-use std::{cmp::Ordering, collections::HashMap, ops::Range};+use collections::HashMap;+use std::{cmp::Ordering, ops::Range};/// Construct a string and a list of offsets within that string using a single/// string containing embedded position markers.diff --git a/crates/zed/src/open_listener.rs b/crates/zed/src/open_listener.rsindex 012b5a2413e..d3ccf753d1a 100644--- a/crates/zed/src/open_listener.rs+++ b/crates/zed/src/open_listener.rs@@ -1,6 +1,7 @@use anyhow::{anyhow, Context, Result};use cli::{ipc, IpcHandshake};use cli::{ipc::IpcSender, CliRequest, CliResponse};+use collections::HashMap;use editor::scroll::Autoscroll;use editor::Editor;use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};@@ -10,7 +11,6 @@ use gpui::{AppContext, AsyncAppContext, Global};use itertools::Itertools;use language::{Bias, Point};use release_channel::parse_zed_link;-use std::collections::HashMap;use std::ffi::OsStr;use std::os::unix::prelude::OsStrExt;use std::path::Path;@@ -176,7 +176,7 @@ pub async fn handle_cli_connection(if let Some(request) = requests.next().await {match request {CliRequest::Open { paths, wait } => {- let mut caret_positions = HashMap::new();+ let mut caret_positions = HashMap::default();let paths = if paths.is_empty() {workspace::last_opened_workspace_paths()diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 443adac50d2..b4ec4711136 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -733,6 +733,7 @@ fn open_settings_file(mod tests {use super::*;use assets::Assets;+ use collections::HashSet;use editor::{scroll::Autoscroll, DisplayPoint, Editor};use gpui::{actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext,@@ -742,10 +743,7 @@ mod tests {use project::{project_settings::ProjectSettings, Project, ProjectPath};use serde_json::json;use settings::{handle_settings_file_changes, watch_config_file, SettingsStore};- use std::{- collections::HashSet,- path::{Path, PathBuf},- };+ use std::path::{Path, PathBuf};use theme::{ThemeRegistry, ThemeSettings};use workspace::{item::{Item, ItemHandle},