Use collections::{HashMap, HashSet} instead of its std:: counterpart (#7502)

This commit is contained in:
Kirill Bulatov 2024-02-07 19:06:03 +02:00 committed by GitHub
parent c322179bb9
commit 83cffdde1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 36 additions and 42 deletions

4
Cargo.lock generated
View File

@ -7530,6 +7530,7 @@ name = "sqlez"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collections",
"futures 0.3.28", "futures 0.3.28",
"indoc", "indoc",
"lazy_static", "lazy_static",
@ -8105,6 +8106,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"alacritty_terminal", "alacritty_terminal",
"anyhow", "anyhow",
"collections",
"db", "db",
"dirs 4.0.0", "dirs 4.0.0",
"futures 0.3.28", "futures 0.3.28",
@ -8200,6 +8202,7 @@ name = "theme"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collections",
"color", "color",
"derive_more", "derive_more",
"fs", "fs",
@ -9343,6 +9346,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"backtrace", "backtrace",
"collections",
"dirs 3.0.2", "dirs 3.0.2",
"futures 0.3.28", "futures 0.3.28",
"git2", "git2",

View File

@ -5,13 +5,13 @@ use client::{
user::{User, UserStore}, user::{User, UserStore},
Client, Subscription, TypedEnvelope, UserId, Client, Subscription, TypedEnvelope, UserId,
}; };
use collections::HashSet;
use futures::lock::Mutex; use futures::lock::Mutex;
use gpui::{ use gpui::{
AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel, AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel,
}; };
use rand::prelude::*; use rand::prelude::*;
use std::{ use std::{
collections::HashSet,
ops::{ControlFlow, Range}, ops::{ControlFlow, Range},
sync::Arc, sync::Arc,
}; };

View File

@ -10,6 +10,7 @@ use async_tungstenite::tungstenite::{
error::Error as WebsocketError, error::Error as WebsocketError,
http::{Request, StatusCode}, http::{Request, StatusCode},
}; };
use collections::HashMap;
use futures::{ use futures::{
channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt, channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt,
TryFutureExt as _, TryStreamExt, TryFutureExt as _, TryStreamExt,
@ -29,7 +30,6 @@ use serde_json;
use settings::{Settings, SettingsStore}; use settings::{Settings, SettingsStore};
use std::{ use std::{
any::TypeId, any::TypeId,
collections::HashMap,
convert::TryFrom, convert::TryFrom,
fmt::Write as _, fmt::Write as _,
future::Future, future::Future,

View File

@ -7,12 +7,9 @@ pub use context::*;
pub(crate) use matcher::*; pub(crate) use matcher::*;
use crate::{Action, Keystroke, NoAction}; use crate::{Action, Keystroke, NoAction};
use collections::HashSet; use collections::{HashMap, HashSet};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{ use std::any::{Any, TypeId};
any::{Any, TypeId},
collections::HashMap,
};
/// An opaque identifier of which version of the keymap is currently active. /// An opaque identifier of which version of the keymap is currently active.
/// The keymap's version is changed whenever bindings are added or removed. /// The keymap's version is changed whenever bindings are added or removed.

View File

@ -71,7 +71,7 @@ pub(crate) struct Frame {
pub(crate) reused_views: FxHashSet<EntityId>, pub(crate) reused_views: FxHashSet<EntityId>,
#[cfg(any(test, feature = "test-support"))] #[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 { impl Frame {

View File

@ -8,6 +8,7 @@ use editor::{actions::Cancel, scroll::Autoscroll, Editor};
use file_associations::FileAssociations; use file_associations::FileAssociations;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use collections::{hash_map, HashMap};
use gpui::{ use gpui::{
actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext, actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
@ -22,14 +23,7 @@ use project::{
}; };
use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings}; use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{cmp::Ordering, ffi::OsStr, ops::Range, path::Path, sync::Arc};
cmp::Ordering,
collections::{hash_map, HashMap},
ffi::OsStr,
ops::Range,
path::Path,
sync::Arc,
};
use theme::ThemeSettings; use theme::ThemeSettings;
use ui::{prelude::*, v_flex, ContextMenu, Icon, KeyBinding, Label, ListItem}; use ui::{prelude::*, v_flex, ContextMenu, Icon, KeyBinding, Label, ListItem};
use unicase::UniCase; use unicase::UniCase;
@ -1699,15 +1693,13 @@ impl ClipboardEntry {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use collections::HashSet;
use gpui::{TestAppContext, View, VisualTestContext, WindowHandle}; use gpui::{TestAppContext, View, VisualTestContext, WindowHandle};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use project::{project_settings::ProjectSettings, FakeFs}; use project::{project_settings::ProjectSettings, FakeFs};
use serde_json::json; use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
use std::{ use std::path::{Path, PathBuf};
collections::HashSet,
path::{Path, PathBuf},
};
use workspace::AppState; use workspace::AppState;
#[gpui::test] #[gpui::test]
@ -3509,7 +3501,7 @@ mod tests {
cx: &mut VisualTestContext, cx: &mut VisualTestContext,
) -> Vec<String> { ) -> Vec<String> {
let mut result = Vec::new(); let mut result = Vec::new();
let mut project_entries = HashSet::new(); let mut project_entries = HashSet::default();
let mut has_editor = false; let mut has_editor = false;
panel.update(cx, |panel, cx| { panel.update(cx, |panel, cx| {

View File

@ -25,11 +25,11 @@ use project::{
}; };
use semantic_index::{SemanticIndex, SemanticIndexStatus}; use semantic_index::{SemanticIndex, SemanticIndexStatus};
use collections::HashSet;
use settings::Settings; use settings::Settings;
use smol::stream::StreamExt; use smol::stream::StreamExt;
use std::{ use std::{
any::{Any, TypeId}, any::{Any, TypeId},
collections::HashSet,
mem, mem,
ops::{Not, Range}, ops::{Not, Range},
path::PathBuf, path::PathBuf,
@ -955,7 +955,7 @@ impl ProjectSearchView {
semantic_state: None, semantic_state: None,
semantic_permissioned: None, semantic_permissioned: None,
search_options: options, search_options: options,
panels_with_errors: HashSet::new(), panels_with_errors: HashSet::default(),
active_match_index: None, active_match_index: None,
query_editor_was_focused: false, query_editor_was_focused: false,
included_files_editor, included_files_editor,

View File

@ -3,6 +3,7 @@ use ai::{
models::TruncationDirection, models::TruncationDirection,
}; };
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use collections::HashSet;
use language::{Grammar, Language}; use language::{Grammar, Language};
use rusqlite::{ use rusqlite::{
types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef}, types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef},
@ -12,7 +13,6 @@ use sha1::{Digest, Sha1};
use std::{ use std::{
borrow::Cow, borrow::Cow,
cmp::{self, Reverse}, cmp::{self, Reverse},
collections::HashSet,
ops::Range, ops::Range,
path::Path, path::Path,
sync::Arc, sync::Arc,
@ -267,7 +267,7 @@ impl CodeContextRetriever {
let mut spans = Vec::new(); let mut spans = Vec::new();
let mut collapsed_ranges_within = 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() { for (i, context_match) in matches.iter().enumerate() {
// Items which are collapsible but not embeddable have no item range // Items which are collapsible but not embeddable have no item range
let item_range = if let Some(item_range) = context_match.item_range.clone() { let item_range = if let Some(item_range) = context_match.item_range.clone() {

View File

@ -7,6 +7,7 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
futures.workspace = true futures.workspace = true
indoc.workspace = true indoc.workspace = true
lazy_static.workspace = true lazy_static.workspace = true

View File

@ -1,8 +1,9 @@
use anyhow::Context; use anyhow::Context;
use collections::HashMap;
use futures::{channel::oneshot, Future, FutureExt}; use futures::{channel::oneshot, Future, FutureExt};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::{Mutex, RwLock}; 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 thread_local::ThreadLocal;
use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender}; use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender};

View File

@ -13,6 +13,7 @@ doctest = false
[dependencies] [dependencies]
alacritty_terminal = "0.22.0" alacritty_terminal = "0.22.0"
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
db.workspace = true db.workspace = true
dirs = "4.0.0" dirs = "4.0.0"
futures.workspace = true futures.workspace = true

View File

@ -30,6 +30,7 @@ use mappings::mouse::{
scroll_report, scroll_report,
}; };
use collections::{HashMap, VecDeque};
use procinfo::LocalProcessInfo; use procinfo::LocalProcessInfo;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use settings::Settings; use settings::Settings;
@ -39,7 +40,6 @@ use util::truncate_and_trailoff;
use std::{ use std::{
cmp::{self, min}, cmp::{self, min},
collections::{HashMap, VecDeque},
fmt::Display, fmt::Display,
ops::{Deref, Index, RangeInclusive}, ops::{Deref, Index, RangeInclusive},
os::unix::prelude::AsRawFd, os::unix::prelude::AsRawFd,

View File

@ -1,3 +1,4 @@
use collections::HashMap;
use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels}; use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels};
use schemars::{ use schemars::{
gen::SchemaGenerator, gen::SchemaGenerator,
@ -7,7 +8,7 @@ use schemars::{
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use settings::SettingsJsonSchemaParams; use settings::SettingsJsonSchemaParams;
use std::{collections::HashMap, path::PathBuf}; use std::path::PathBuf;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]

View File

@ -8,11 +8,7 @@ license = "GPL-3.0-or-later"
[features] [features]
default = [] default = []
stories = ["dep:itertools", "dep:story"] stories = ["dep:itertools", "dep:story"]
test-support = [ test-support = ["gpui/test-support", "fs/test-support", "settings/test-support"]
"gpui/test-support",
"fs/test-support",
"settings/test-support"
]
[lib] [lib]
path = "src/theme.rs" path = "src/theme.rs"
@ -20,6 +16,7 @@ doctest = false
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
color.workspace = true color.workspace = true
derive_more.workspace = true derive_more.workspace = true
fs.workspace = true fs.workspace = true

View File

@ -1,8 +1,8 @@
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use collections::HashMap;
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use fs::Fs; use fs::Fs;
use futures::StreamExt; use futures::StreamExt;
@ -64,7 +64,7 @@ impl ThemeRegistry {
pub fn new(assets: Box<dyn AssetSource>) -> Self { pub fn new(assets: Box<dyn AssetSource>) -> Self {
let registry = Self { let registry = Self {
state: RwLock::new(ThemeRegistryState { state: RwLock::new(ThemeRegistryState {
themes: HashMap::new(), themes: HashMap::default(),
}), }),
assets, assets,
}; };

View File

@ -15,6 +15,7 @@ test-support = ["tempfile", "git2"]
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
backtrace = "0.3" backtrace = "0.3"
collections.workspace = true
dirs = "3.0" dirs = "3.0"
futures.workspace = true futures.workspace = true
git2 = { workspace = true, optional = true } git2 = { workspace = true, optional = true }

View File

@ -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 /// Construct a string and a list of offsets within that string using a single
/// string containing embedded position markers. /// string containing embedded position markers.

View File

@ -1,6 +1,7 @@
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use cli::{ipc, IpcHandshake}; use cli::{ipc, IpcHandshake};
use cli::{ipc::IpcSender, CliRequest, CliResponse}; use cli::{ipc::IpcSender, CliRequest, CliResponse};
use collections::HashMap;
use editor::scroll::Autoscroll; use editor::scroll::Autoscroll;
use editor::Editor; use editor::Editor;
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
@ -10,7 +11,6 @@ use gpui::{AppContext, AsyncAppContext, Global};
use itertools::Itertools; use itertools::Itertools;
use language::{Bias, Point}; use language::{Bias, Point};
use release_channel::parse_zed_link; use release_channel::parse_zed_link;
use std::collections::HashMap;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::OsStrExt;
use std::path::Path; use std::path::Path;
@ -176,7 +176,7 @@ pub async fn handle_cli_connection(
if let Some(request) = requests.next().await { if let Some(request) = requests.next().await {
match request { match request {
CliRequest::Open { paths, wait } => { CliRequest::Open { paths, wait } => {
let mut caret_positions = HashMap::new(); let mut caret_positions = HashMap::default();
let paths = if paths.is_empty() { let paths = if paths.is_empty() {
workspace::last_opened_workspace_paths() workspace::last_opened_workspace_paths()

View File

@ -733,6 +733,7 @@ fn open_settings_file(
mod tests { mod tests {
use super::*; use super::*;
use assets::Assets; use assets::Assets;
use collections::HashSet;
use editor::{scroll::Autoscroll, DisplayPoint, Editor}; use editor::{scroll::Autoscroll, DisplayPoint, Editor};
use gpui::{ use gpui::{
actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext, actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext,
@ -742,10 +743,7 @@ mod tests {
use project::{project_settings::ProjectSettings, Project, ProjectPath}; use project::{project_settings::ProjectSettings, Project, ProjectPath};
use serde_json::json; use serde_json::json;
use settings::{handle_settings_file_changes, watch_config_file, SettingsStore}; use settings::{handle_settings_file_changes, watch_config_file, SettingsStore};
use std::{ use std::path::{Path, PathBuf};
collections::HashSet,
path::{Path, PathBuf},
};
use theme::{ThemeRegistry, ThemeSettings}; use theme::{ThemeRegistry, ThemeSettings};
use workspace::{ use workspace::{
item::{Item, ItemHandle}, item::{Item, ItemHandle},