Depend on nohash-hasher individually

This commit is contained in:
Ariel Davis 2023-05-04 16:28:15 -07:00
parent 1d678cf6a0
commit 4a1922fd1a
20 changed files with 53 additions and 52 deletions

7
Cargo.lock generated
View File

@ -587,6 +587,7 @@ dependencies = [
"itertools",
"la-arena",
"limit",
"nohash-hasher",
"once_cell",
"profile",
"project-model",
@ -650,6 +651,7 @@ dependencies = [
"ide-diagnostics",
"ide-ssr",
"itertools",
"nohash-hasher",
"oorandom",
"profile",
"pulldown-cmark",
@ -719,6 +721,7 @@ dependencies = [
"limit",
"line-index",
"memchr",
"nohash-hasher",
"once_cell",
"oorandom",
"parser",
@ -764,6 +767,7 @@ dependencies = [
"hir",
"ide-db",
"itertools",
"nohash-hasher",
"parser",
"stdx",
"syntax",
@ -1485,6 +1489,7 @@ dependencies = [
"mbe",
"mimalloc",
"mio",
"nohash-hasher",
"num_cpus",
"oorandom",
"parking_lot 0.12.1",
@ -1708,7 +1713,6 @@ dependencies = [
"backtrace",
"libc",
"miow",
"nohash-hasher",
"winapi",
]
@ -2066,6 +2070,7 @@ version = "0.0.0"
dependencies = [
"fst",
"indexmap",
"nohash-hasher",
"paths",
"rustc-hash",
"stdx",

View File

@ -29,6 +29,7 @@ chalk-derive = "0.89.0"
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
once_cell = "1.17.0"
triomphe.workspace = true
nohash-hasher.workspace = true
typed-arena = "2.0.1"
rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }

View File

@ -8,8 +8,8 @@
};
use hir_def::{db::DefDatabase, ModuleId};
use hir_expand::db::ExpandDatabase;
use nohash_hasher::IntMap;
use rustc_hash::FxHashSet;
use stdx::hash::NoHashHashMap;
use syntax::TextRange;
use test_utils::extract_annotations;
use triomphe::Arc;
@ -102,7 +102,7 @@ pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId {
self.module_for_file_opt(file_id).unwrap()
}
pub(crate) fn extract_annotations(&self) -> NoHashHashMap<FileId, Vec<(TextRange, String)>> {
pub(crate) fn extract_annotations(&self) -> IntMap<FileId, Vec<(TextRange, String)>> {
let mut files = Vec::new();
let crate_graph = self.crate_graph();
for krate in crate_graph.iter() {

View File

@ -24,6 +24,7 @@ arrayvec = "0.7.2"
indexmap = "1.9.1"
memchr = "2.5.0"
triomphe.workspace = true
nohash-hasher.workspace = true
# local deps
base-db.workspace = true

View File

@ -11,9 +11,9 @@
AsAssocItem, DefWithBody, HasAttrs, HasSource, InFile, ModuleSource, Semantics, Visibility,
};
use memchr::memmem::Finder;
use nohash_hasher::IntMap;
use once_cell::unsync::Lazy;
use parser::SyntaxKind;
use stdx::hash::NoHashHashMap;
use syntax::{ast, match_ast, AstNode, TextRange, TextSize};
use triomphe::Arc;
@ -25,7 +25,7 @@
#[derive(Debug, Default, Clone)]
pub struct UsageSearchResult {
pub references: NoHashHashMap<FileId, Vec<FileReference>>,
pub references: IntMap<FileId, Vec<FileReference>>,
}
impl UsageSearchResult {
@ -50,7 +50,7 @@ pub fn file_ranges(&self) -> impl Iterator<Item = FileRange> + '_ {
impl IntoIterator for UsageSearchResult {
type Item = (FileId, Vec<FileReference>);
type IntoIter = <NoHashHashMap<FileId, Vec<FileReference>> as IntoIterator>::IntoIter;
type IntoIter = <IntMap<FileId, Vec<FileReference>> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
self.references.into_iter()
@ -84,17 +84,17 @@ pub enum ReferenceCategory {
/// e.g. for things like local variables.
#[derive(Clone, Debug)]
pub struct SearchScope {
entries: NoHashHashMap<FileId, Option<TextRange>>,
entries: IntMap<FileId, Option<TextRange>>,
}
impl SearchScope {
fn new(entries: NoHashHashMap<FileId, Option<TextRange>>) -> SearchScope {
fn new(entries: IntMap<FileId, Option<TextRange>>) -> SearchScope {
SearchScope { entries }
}
/// Build a search scope spanning the entire crate graph of files.
fn crate_graph(db: &RootDatabase) -> SearchScope {
let mut entries = NoHashHashMap::default();
let mut entries = IntMap::default();
let graph = db.crate_graph();
for krate in graph.iter() {
@ -108,7 +108,7 @@ fn crate_graph(db: &RootDatabase) -> SearchScope {
/// Build a search scope spanning all the reverse dependencies of the given crate.
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
let mut entries = NoHashHashMap::default();
let mut entries = IntMap::default();
for rev_dep in of.transitive_reverse_dependencies(db) {
let root_file = rev_dep.root_file(db);
let source_root_id = db.file_source_root(root_file);
@ -128,7 +128,7 @@ fn krate(db: &RootDatabase, of: hir::Crate) -> SearchScope {
/// Build a search scope spanning the given module and all its submodules.
fn module_and_children(db: &RootDatabase, module: hir::Module) -> SearchScope {
let mut entries = NoHashHashMap::default();
let mut entries = IntMap::default();
let (file_id, range) = {
let InFile { file_id, value } = module.definition_source(db);
@ -161,7 +161,7 @@ fn module_and_children(db: &RootDatabase, module: hir::Module) -> SearchScope {
/// Build an empty search scope.
pub fn empty() -> SearchScope {
SearchScope::new(NoHashHashMap::default())
SearchScope::new(IntMap::default())
}
/// Build a empty search scope spanning the given file.

View File

@ -5,16 +5,16 @@
use std::{collections::hash_map::Entry, iter, mem};
use crate::SnippetCap;
use base_db::{AnchoredPathBuf, FileId};
use stdx::{hash::NoHashHashMap, never};
use nohash_hasher::IntMap;
use stdx::never;
use syntax::{algo, ast, ted, AstNode, SyntaxNode, SyntaxNodePtr, TextRange, TextSize};
use text_edit::{TextEdit, TextEditBuilder};
use crate::SnippetCap;
#[derive(Default, Debug, Clone)]
pub struct SourceChange {
pub source_file_edits: NoHashHashMap<FileId, TextEdit>,
pub source_file_edits: IntMap<FileId, TextEdit>,
pub file_system_edits: Vec<FileSystemEdit>,
pub is_snippet: bool,
}
@ -23,7 +23,7 @@ impl SourceChange {
/// Creates a new SourceChange with the given label
/// from the edits.
pub fn from_edits(
source_file_edits: NoHashHashMap<FileId, TextEdit>,
source_file_edits: IntMap<FileId, TextEdit>,
file_system_edits: Vec<FileSystemEdit>,
) -> Self {
SourceChange { source_file_edits, file_system_edits, is_snippet: false }
@ -77,8 +77,8 @@ fn extend<T: IntoIterator<Item = FileSystemEdit>>(&mut self, iter: T) {
}
}
impl From<NoHashHashMap<FileId, TextEdit>> for SourceChange {
fn from(source_file_edits: NoHashHashMap<FileId, TextEdit>) -> SourceChange {
impl From<IntMap<FileId, TextEdit>> for SourceChange {
fn from(source_file_edits: IntMap<FileId, TextEdit>) -> SourceChange {
SourceChange { source_file_edits, file_system_edits: Vec::new(), is_snippet: false }
}
}

View File

@ -16,6 +16,7 @@ doctest = false
cov-mark = "2.0.0-pre.1"
itertools = "0.10.5"
triomphe.workspace = true
nohash-hasher.workspace = true
# local deps
hir.workspace = true

View File

@ -87,8 +87,8 @@
use crate::{errors::bail, matching::MatchFailureReason};
use hir::Semantics;
use ide_db::base_db::{FileId, FilePosition, FileRange};
use nohash_hasher::IntMap;
use resolving::ResolvedRule;
use stdx::hash::NoHashHashMap;
use syntax::{ast, AstNode, SyntaxNode, TextRange};
use text_edit::TextEdit;
@ -168,9 +168,9 @@ pub fn add_rule(&mut self, rule: SsrRule) -> Result<(), SsrError> {
}
/// Finds matches for all added rules and returns edits for all found matches.
pub fn edits(&self) -> NoHashHashMap<FileId, TextEdit> {
pub fn edits(&self) -> IntMap<FileId, TextEdit> {
use ide_db::base_db::SourceDatabaseExt;
let mut matches_by_file = NoHashHashMap::default();
let mut matches_by_file = IntMap::default();
for m in self.matches().matches {
matches_by_file
.entry(m.range.file_id)

View File

@ -24,6 +24,7 @@ url = "2.3.1"
dot = "0.1.4"
smallvec.workspace = true
triomphe.workspace = true
nohash-hasher.workspace = true
# local deps
cfg.workspace = true

View File

@ -17,7 +17,7 @@
RootDatabase,
};
use itertools::Itertools;
use stdx::hash::NoHashHashMap;
use nohash_hasher::IntMap;
use syntax::{
algo::find_node_at_offset,
ast::{self, HasName},
@ -31,7 +31,7 @@
#[derive(Debug, Clone)]
pub struct ReferenceSearchResult {
pub declaration: Option<Declaration>,
pub references: NoHashHashMap<FileId, Vec<(TextRange, Option<ReferenceCategory>)>>,
pub references: IntMap<FileId, Vec<(TextRange, Option<ReferenceCategory>)>>,
}
#[derive(Debug, Clone)]

View File

@ -46,6 +46,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features =
tracing-log = "0.1.3"
tracing-tree = "0.2.1"
triomphe.workspace = true
nohash-hasher.workspace = true
always-assert = "0.1.2"
# These dependencies are unused, but we pin them to a version here to restrict them for our transitive dependencies
@ -95,7 +96,4 @@ mbe.workspace = true
[features]
jemalloc = ["jemallocator", "profile/jemalloc"]
force-always-assert = ["always-assert/force"]
in-rust-tree = [
"ide/in-rust-tree",
"syntax/in-rust-tree",
]
in-rust-tree = ["ide/in-rust-tree", "syntax/in-rust-tree"]

View File

@ -5,12 +5,12 @@
use ide::FileId;
use ide_db::FxHashMap;
use stdx::hash::{NoHashHashMap, NoHashHashSet};
use nohash_hasher::{IntMap, IntSet};
use triomphe::Arc;
use crate::lsp_ext;
pub(crate) type CheckFixes = Arc<NoHashHashMap<usize, NoHashHashMap<FileId, Vec<Fix>>>>;
pub(crate) type CheckFixes = Arc<IntMap<usize, IntMap<FileId, Vec<Fix>>>>;
#[derive(Debug, Default, Clone)]
pub struct DiagnosticsMapConfig {
@ -21,12 +21,12 @@ pub struct DiagnosticsMapConfig {
#[derive(Debug, Default, Clone)]
pub(crate) struct DiagnosticCollection {
// FIXME: should be NoHashHashMap<FileId, Vec<ra_id::Diagnostic>>
pub(crate) native: NoHashHashMap<FileId, Vec<lsp_types::Diagnostic>>,
// FIXME: should be IntMap<FileId, Vec<ra_id::Diagnostic>>
pub(crate) native: IntMap<FileId, Vec<lsp_types::Diagnostic>>,
// FIXME: should be Vec<flycheck::Diagnostic>
pub(crate) check: NoHashHashMap<usize, NoHashHashMap<FileId, Vec<lsp_types::Diagnostic>>>,
pub(crate) check: IntMap<usize, IntMap<FileId, Vec<lsp_types::Diagnostic>>>,
pub(crate) check_fixes: CheckFixes,
changes: NoHashHashSet<FileId>,
changes: IntSet<FileId>,
}
#[derive(Debug, Clone)]
@ -106,7 +106,7 @@ pub(crate) fn diagnostics_for(
native.chain(check)
}
pub(crate) fn take_changes(&mut self) -> Option<NoHashHashSet<FileId>> {
pub(crate) fn take_changes(&mut self) -> Option<IntSet<FileId>> {
if self.changes.is_empty() {
return None;
}

View File

@ -10,11 +10,11 @@
use ide::{Analysis, AnalysisHost, Cancellable, Change, FileId};
use ide_db::base_db::{CrateId, FileLoader, ProcMacroPaths, SourceDatabase};
use lsp_types::{SemanticTokens, Url};
use nohash_hasher::IntMap;
use parking_lot::{Mutex, RwLock};
use proc_macro_api::ProcMacroServer;
use project_model::{CargoWorkspace, ProjectWorkspace, Target, WorkspaceBuildScripts};
use rustc_hash::FxHashMap;
use stdx::hash::NoHashHashMap;
use triomphe::Arc;
use vfs::AnchoredPathBuf;
@ -70,7 +70,7 @@ pub(crate) struct GlobalState {
pub(crate) flycheck_sender: Sender<flycheck::Message>,
pub(crate) flycheck_receiver: Receiver<flycheck::Message>,
pub(crate) vfs: Arc<RwLock<(vfs::Vfs, NoHashHashMap<FileId, LineEndings>)>>,
pub(crate) vfs: Arc<RwLock<(vfs::Vfs, IntMap<FileId, LineEndings>)>>,
pub(crate) vfs_config_version: u32,
pub(crate) vfs_progress_config_version: u32,
pub(crate) vfs_progress_n_total: usize,
@ -117,7 +117,7 @@ pub(crate) struct GlobalStateSnapshot {
pub(crate) check_fixes: CheckFixes,
mem_docs: MemDocs,
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
vfs: Arc<RwLock<(vfs::Vfs, NoHashHashMap<FileId, LineEndings>)>>,
vfs: Arc<RwLock<(vfs::Vfs, IntMap<FileId, LineEndings>)>>,
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
// used to signal semantic highlighting to fall back to syntax based highlighting until proc-macros have been loaded
pub(crate) proc_macros_loaded: bool,
@ -170,7 +170,7 @@ pub(crate) fn new(sender: Sender<lsp_server::Message>, config: Config) -> Global
flycheck_sender,
flycheck_receiver,
vfs: Arc::new(RwLock::new((vfs::Vfs::default(), NoHashHashMap::default()))),
vfs: Arc::new(RwLock::new((vfs::Vfs::default(), IntMap::default()))),
vfs_config_version: 0,
vfs_progress_config_version: 0,
vfs_progress_n_total: 0,

View File

@ -15,7 +15,6 @@ doctest = false
libc = "0.2.135"
backtrace = { version = "0.3.65", optional = true }
always-assert = { version = "0.1.2", features = ["log"] }
nohash-hasher.workspace = true
# Think twice before adding anything here
[target.'cfg(windows)'.dependencies]

View File

@ -1,5 +0,0 @@
//! Re-exports from [`nohash_hasher`].
pub use nohash_hasher::IntMap as NoHashHashMap;
pub use nohash_hasher::IntSet as NoHashHashSet;
pub use nohash_hasher::IsEnabled;

View File

@ -7,7 +7,6 @@
use std::{cmp::Ordering, ops, time::Instant};
mod macros;
pub mod hash;
pub mod process;
pub mod panic_context;
pub mod non_empty_vec;

View File

@ -15,6 +15,7 @@ doctest = false
rustc-hash = "1.1.0"
fst = "0.4.7"
indexmap = "1.9.1"
nohash-hasher.workspace = true
paths.workspace = true
stdx.workspace = true

View File

@ -5,8 +5,8 @@
use std::fmt;
use fst::{IntoStreamer, Streamer};
use nohash_hasher::IntMap;
use rustc_hash::FxHashMap;
use stdx::hash::NoHashHashMap;
use crate::{AnchoredPath, FileId, Vfs, VfsPath};
@ -14,7 +14,7 @@
#[derive(Default, Clone, Eq, PartialEq)]
pub struct FileSet {
files: FxHashMap<VfsPath, FileId>,
paths: NoHashHashMap<FileId, VfsPath>,
paths: IntMap<FileId, VfsPath>,
}
impl FileSet {

View File

@ -63,7 +63,7 @@
pub struct FileId(pub u32);
/// safe because `FileId` is a newtype of `u32`
impl stdx::hash::IsEnabled for FileId {}
impl nohash_hasher::IsEnabled for FileId {}
/// Storage for all files read by rust-analyzer.
///

View File

@ -5,7 +5,7 @@
#[cfg(test)]
mod tests;
use nohash_hasher::IntMap as NoHashHashMap;
use nohash_hasher::IntMap;
pub use text_size::{TextRange, TextSize};
@ -15,7 +15,7 @@ pub struct LineIndex {
/// Offset the beginning of each line, zero-based.
newlines: Vec<TextSize>,
/// List of non-ASCII characters on each line.
line_wide_chars: NoHashHashMap<u32, Vec<WideChar>>,
line_wide_chars: IntMap<u32, Vec<WideChar>>,
}
/// Line/Column information in native, utf8 format.
@ -80,7 +80,7 @@ fn wide_len(&self, enc: WideEncoding) -> usize {
impl LineIndex {
/// Returns a `LineIndex` for the `text`.
pub fn new(text: &str) -> LineIndex {
let mut line_wide_chars = NoHashHashMap::default();
let mut line_wide_chars = IntMap::default();
let mut wide_chars = Vec::new();
let mut newlines = Vec::with_capacity(16);