"ra_syntax 0.1.0",
"rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.1.0",
"test_utils 0.1.0",
]
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_syntax 0.1.0",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
"ra_syntax 0.1.0",
"rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "rustc-hash"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "rustc_version"
version = "0.2.3"
"checksum ron 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9fa11b7a38511d46ff1959ae46ebb60bd8a746f17bdd0206b4c8de7559ac47b"
"checksum rowan 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4a1a7366ece9deee5e7df8316a136d585d5c5042854c2297f7f1aee3014c9130"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
+"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
ra_syntax = { path = "../ra_syntax" }
ra_editor = { path = "../ra_editor" }
salsa = { path = "../salsa" }
+rustc-hash = "1.0"
[dev-dependencies]
test_utils = { path = "../test_utils" }
sync::Arc,
any::Any,
hash::{Hash, Hasher},
- collections::hash_map::{DefaultHasher, HashMap},
+ collections::hash_map::{DefaultHasher},
iter,
};
+use rustc_hash::FxHashMap;
use salsa;
use {FileId, imp::FileResolverImp};
use super::{State, Query, QueryCtx};
#[derive(Debug)]
pub(super) struct Db {
- names: Arc<HashMap<salsa::QueryTypeId, &'static str>>,
+ names: Arc<FxHashMap<salsa::QueryTypeId, &'static str>>,
pub(super) imp: salsa::Db<State, Data>,
}
pub(super) struct QueryRegistry {
config: Option<salsa::QueryConfig<State, Data>>,
- names: HashMap<salsa::QueryTypeId, &'static str>,
+ names: FxHashMap<salsa::QueryTypeId, &'static str>,
}
impl QueryRegistry {
(Arc::new(res), fingerprint)
})
);
- let mut names = HashMap::new();
+ let mut names = FxHashMap::default();
names.insert(FILE_TEXT, "FILE_TEXT");
names.insert(FILE_SET, "FILE_SET");
QueryRegistry { config: Some(config), names }
atomic::{AtomicBool, Ordering::SeqCst},
},
fmt,
- collections::{HashSet, VecDeque},
+ collections::VecDeque,
iter,
};
use relative_path::RelativePath;
+use rustc_hash::FxHashSet;
use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit, resolve_local_name};
use ra_syntax::{
TextUnit, TextRange, SmolStr, File, AstNode,
data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver)));
}
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
- let mut visited = HashSet::new();
+ let mut visited = FxHashSet::default();
for &file_id in graph.crate_roots.values() {
if !visited.insert(file_id) {
panic!("duplicate crate root: {:?}", file_id);
let mut res = Vec::new();
let mut work = VecDeque::new();
work.push_back(file_id);
- let mut visited = HashSet::new();
+ let mut visited = FxHashSet::default();
while let Some(id) = work.pop_front() {
if let Some(crate_id) = crate_graph.crate_id_for_crate_root(id) {
res.push(crate_id);
extern crate crossbeam_channel;
extern crate im;
extern crate salsa;
+extern crate rustc_hash;
mod symbol_index;
mod module_map;
use std::{
sync::Arc,
- collections::HashMap,
fmt::Debug,
};
use relative_path::{RelativePath, RelativePathBuf};
use ra_syntax::{File, TextRange, TextUnit, AtomEdit};
use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp};
+use rustc_hash::FxHashMap;
pub use ra_editor::{
StructureNode, LineIndex, FileSymbol,
#[derive(Debug, Clone, Default)]
pub struct CrateGraph {
- pub crate_roots: HashMap<CrateId, FileId>,
+ pub crate_roots: FxHashMap<CrateId, FileId>,
}
pub trait FileResolver: Debug + Send + Sync + 'static {
use std::{
- collections::HashMap,
sync::Arc,
panic,
};
use once_cell::sync::OnceCell;
use rayon::prelude::*;
+use rustc_hash::FxHashMap;
use ra_editor::LineIndex;
use ra_syntax::File;
#[derive(Debug)]
pub(crate) struct ReadonlySourceRoot {
symbol_index: Arc<SymbolIndex>,
- file_map: HashMap<FileId, FileData>,
+ file_map: FxHashMap<FileId, FileData>,
module_tree: Arc<ModuleTreeDescriptor>,
}
let symbol_index = SymbolIndex::for_files(
modules.par_iter().map(|it| (it.0, it.1.clone()))
);
- let file_map: HashMap<FileId, FileData> = files
+ let file_map: FxHashMap<FileId, FileData> = files
.into_iter()
.map(|(id, text)| (id, FileData::new(text)))
.collect();
extern crate relative_path;
extern crate ra_analysis;
+extern crate rustc_hash;
extern crate test_utils;
use std::{
sync::Arc,
- collections::HashMap,
};
+use rustc_hash::FxHashMap;
use relative_path::{RelativePath, RelativePathBuf};
use ra_analysis::{Analysis, AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId};
use test_utils::assert_eq_dbg;
let crate_graph = CrateGraph {
crate_roots: {
- let mut m = HashMap::new();
+ let mut m = FxHashMap::default();
m.insert(CrateId(1), FileId(1));
m
},
itertools = "0.7.8"
superslice = "0.1.0"
join_to_string = "0.1.1"
+rustc-hash = "1.0"
ra_syntax = { path = "../ra_syntax" }
-use std::collections::{HashSet, HashMap};
+use rustc_hash::{FxHashMap, FxHashSet};
use ra_syntax::{
File, TextUnit, AstNode, SyntaxNodeRef, SyntaxKind::*,
}
fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) {
- let mut params = HashMap::new();
+ let mut params = FxHashMap::default();
for node in ctx.ancestors() {
let _ = visitor_ctx(&mut params)
.visit::<ast::Root, _>(process)
})
});
- fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut HashMap<String, (u32, ast::Param<'a>)>) {
+ fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut FxHashMap<String, (u32, ast::Param<'a>)>) {
node.functions()
.filter_map(|it| it.param_list())
.flat_map(|it| it.params())
}
fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<CompletionItem>) {
- let mut shadowed = HashSet::new();
+ let mut shadowed = FxHashSet::default();
acc.extend(
scopes.scope_chain(name_ref.syntax())
.flat_map(|scope| scopes.entries(scope).iter())
-use std::collections::HashSet;
+use rustc_hash::FxHashSet;
use ra_syntax::{
File, TextRange, SyntaxNodeRef,
pub fn folding_ranges(file: &File) -> Vec<Fold> {
let mut res = vec![];
- let mut visited = HashSet::new();
+ let mut visited = FxHashSet::default();
for node in file.syntax().descendants() {
if visited.contains(&node) {
fn contiguous_range_for<'a>(
kind: SyntaxKind,
node: SyntaxNodeRef<'a>,
- visited: &mut HashSet<SyntaxNodeRef<'a>>,
+ visited: &mut FxHashSet<SyntaxNodeRef<'a>>,
) -> Option<TextRange> {
visited.insert(node);
extern crate superslice;
extern crate itertools;
extern crate join_to_string;
+extern crate rustc_hash;
#[cfg(test)]
#[macro_use]
extern crate test_utils as _test_utils;
-use std::{
- fmt,
- collections::HashMap,
-};
+use std::fmt;
+use rustc_hash::FxHashMap;
use ra_syntax::{
SyntaxNodeRef, SyntaxNode, SmolStr, AstNode,
pub struct FnScopes {
pub self_param: Option<SyntaxNode>,
scopes: Vec<ScopeData>,
- scope_for: HashMap<SyntaxNode, ScopeId>,
+ scope_for: FxHashMap<SyntaxNode, ScopeId>,
}
impl FnScopes {
.and_then(|it| it.self_param())
.map(|it| it.syntax().owned()),
scopes: Vec::new(),
- scope_for: HashMap::new()
+ scope_for: FxHashMap::default()
};
let root = scopes.root_scope();
scopes.add_params_bindings(root, fn_def.param_list());
}
pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> {
- use std::collections::HashSet;
+ use rustc_hash::FxHashSet;
- let mut shadowed = HashSet::new();
+ let mut shadowed = FxHashSet::default();
let ret = scopes.scope_chain(name_ref.syntax())
.flat_map(|scope| scopes.entries(scope).iter())
.filter(|entry| shadowed.insert(entry.name()))
cargo_metadata = "0.6.0"
text_unit = { version = "0.1.2", features = ["serde"] }
smol_str = { version = "0.1.5", features = ["serde"] }
+rustc-hash = "1.0"
ra_syntax = { path = "../ra_syntax" }
ra_editor = { path = "../ra_editor" }
extern crate im;
extern crate relative_path;
extern crate cargo_metadata;
+extern crate rustc_hash;
extern crate gen_lsp_server;
extern crate ra_editor;
-use std::collections::{HashMap};
+use rustc_hash::FxHashMap;
use languageserver_types::{
Diagnostic, DiagnosticSeverity, DocumentSymbol,
bin: "cargo".to_string(),
args,
env: {
- let mut m = HashMap::new();
+ let mut m = FxHashMap::default();
m.insert(
"RUST_BACKTRACE".to_string(),
"short".to_string(),
use std::{
path::PathBuf,
- collections::{HashMap},
};
use serde::{Serialize, de::DeserializeOwned};
RawRequest, RawNotification, RawMessage, RawResponse, ErrorCode,
handle_shutdown,
};
+use rustc_hash::FxHashMap;
use {
req,
info!("server initialized, serving requests");
let mut state = ServerWorldState::new();
- let mut pending_requests = HashMap::new();
+ let mut pending_requests = FxHashMap::default();
let mut subs = Subscriptions::new();
let main_res = main_loop_inner(
internal_mode,
fs_worker: Worker<PathBuf, (PathBuf, Vec<FileEvent>)>,
ws_worker: Worker<PathBuf, Result<CargoWorkspace>>,
state: &mut ServerWorldState,
- pending_requests: &mut HashMap<u64, JobHandle>,
+ pending_requests: &mut FxHashMap<u64, JobHandle>,
subs: &mut Subscriptions,
) -> Result<()> {
let (libdata_sender, libdata_receiver) = unbounded();
fn on_task(
task: Task,
msg_sender: &Sender<RawMessage>,
- pending_requests: &mut HashMap<u64, JobHandle>,
+ pending_requests: &mut FxHashMap<u64, JobHandle>,
) {
match task {
Task::Respond(response) => {
fn on_request(
world: &mut ServerWorldState,
- pending_requests: &mut HashMap<u64, JobHandle>,
+ pending_requests: &mut FxHashMap<u64, JobHandle>,
pool: &ThreadPool,
sender: &Sender<Task>,
req: RawRequest,
fn on_notification(
msg_sender: &Sender<RawMessage>,
state: &mut ServerWorldState,
- pending_requests: &mut HashMap<u64, JobHandle>,
+ pending_requests: &mut FxHashMap<u64, JobHandle>,
subs: &mut Subscriptions,
not: RawNotification,
) -> Result<()> {
-use std::collections::HashSet;
+use rustc_hash::FxHashSet;
use ra_analysis::FileId;
pub struct Subscriptions {
- subs: HashSet<FileId>,
+ subs: FxHashSet<FileId>,
}
impl Subscriptions {
pub fn new() -> Subscriptions {
- Subscriptions { subs: HashSet::new() }
+ Subscriptions { subs: FxHashSet::default() }
}
pub fn add_sub(&mut self, file_id: FileId) {
self.subs.insert(file_id);
use std::{
- collections::{HashMap, HashSet},
path::{Path, PathBuf},
};
+use rustc_hash::{FxHashMap, FxHashSet};
use cargo_metadata::{metadata_run, CargoOpt};
use ra_syntax::SmolStr;
true,
Some(CargoOpt::AllFeatures)
).map_err(|e| format_err!("cargo metadata failed: {}", e))?;
- let mut pkg_by_id = HashMap::new();
+ let mut pkg_by_id = FxHashMap::default();
let mut packages = Vec::new();
let mut targets = Vec::new();
- let ws_members: HashSet<String> = meta.workspace_members
+ let ws_members: FxHashSet<String> = meta.workspace_members
.into_iter()
.map(|it| it.raw)
.collect();
-use std::collections::HashMap;
+use rustc_hash::FxHashMap;
use languageserver_types::{TextDocumentIdentifier, Range, Url, Position, Location};
use url_serde;
pub label: String,
pub bin: String,
pub args: Vec<String>,
- pub env: HashMap<String, String>,
+ pub env: FxHashMap<String, String>,
}
#[derive(Serialize, Debug)]
use std::{
fs,
path::{PathBuf, Path},
- collections::HashMap,
sync::Arc,
};
+use rustc_hash::FxHashMap;
use languageserver_types::Url;
use ra_analysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId, LibraryData, FileResolver};
pub workspaces: Arc<Vec<CargoWorkspace>>,
pub analysis_host: AnalysisHost,
pub path_map: PathMap,
- pub mem_map: HashMap<FileId, Option<String>>,
+ pub mem_map: FxHashMap<FileId, Option<String>>,
}
#[derive(Clone)]
workspaces: Arc::new(Vec::new()),
analysis_host: AnalysisHost::new(),
path_map: PathMap::new(),
- mem_map: HashMap::new(),
+ mem_map: FxHashMap::default(),
}
}
pub fn apply_fs_changes(&mut self, events: Vec<FileEvent>) {
Ok(file_id)
}
pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) {
- let mut crate_roots = HashMap::new();
+ let mut crate_roots = FxHashMap::default();
ws.iter()
.flat_map(|ws| {
ws.packages()