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"
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",

View File

@ -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,
};

View File

@ -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,

View File

@ -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.

View File

@ -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 {

View File

@ -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| {

View File

@ -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,

View File

@ -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 range
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]
anyhow.workspace = true
collections.workspace = true
futures.workspace = true
indoc.workspace = true
lazy_static.workspace = true

View File

@ -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};

View File

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

View File

@ -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,

View File

@ -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")]

View File

@ -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 = true
color.workspace = true
derive_more.workspace = true
fs.workspace = true

View File

@ -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,
};

View File

@ -15,6 +15,7 @@ test-support = ["tempfile", "git2"]
[dependencies]
anyhow.workspace = true
backtrace = "0.3"
collections.workspace = true
dirs = "3.0"
futures.workspace = 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
/// string containing embedded position markers.

View File

@ -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()

View File

@ -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},