aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/scope
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/scope')
-rw-r--r--crates/ra_editor/src/scope/fn_scope.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_editor/src/scope/fn_scope.rs b/crates/ra_editor/src/scope/fn_scope.rs
index 65d85279f..9a48bda02 100644
--- a/crates/ra_editor/src/scope/fn_scope.rs
+++ b/crates/ra_editor/src/scope/fn_scope.rs
@@ -1,7 +1,5 @@
1use std::{ 1use std::fmt;
2 fmt, 2use rustc_hash::FxHashMap;
3 collections::HashMap,
4};
5 3
6use ra_syntax::{ 4use ra_syntax::{
7 SyntaxNodeRef, SyntaxNode, SmolStr, AstNode, 5 SyntaxNodeRef, SyntaxNode, SmolStr, AstNode,
@@ -15,7 +13,7 @@ type ScopeId = usize;
15pub struct FnScopes { 13pub struct FnScopes {
16 pub self_param: Option<SyntaxNode>, 14 pub self_param: Option<SyntaxNode>,
17 scopes: Vec<ScopeData>, 15 scopes: Vec<ScopeData>,
18 scope_for: HashMap<SyntaxNode, ScopeId>, 16 scope_for: FxHashMap<SyntaxNode, ScopeId>,
19} 17}
20 18
21impl FnScopes { 19impl FnScopes {
@@ -25,7 +23,7 @@ impl FnScopes {
25 .and_then(|it| it.self_param()) 23 .and_then(|it| it.self_param())
26 .map(|it| it.syntax().owned()), 24 .map(|it| it.syntax().owned()),
27 scopes: Vec::new(), 25 scopes: Vec::new(),
28 scope_for: HashMap::new() 26 scope_for: FxHashMap::default()
29 }; 27 };
30 let root = scopes.root_scope(); 28 let root = scopes.root_scope();
31 scopes.add_params_bindings(root, fn_def.param_list()); 29 scopes.add_params_bindings(root, fn_def.param_list());
@@ -242,9 +240,9 @@ struct ScopeData {
242} 240}
243 241
244pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> { 242pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> {
245 use std::collections::HashSet; 243 use rustc_hash::FxHashSet;
246 244
247 let mut shadowed = HashSet::new(); 245 let mut shadowed = FxHashSet::default();
248 let ret = scopes.scope_chain(name_ref.syntax()) 246 let ret = scopes.scope_chain(name_ref.syntax())
249 .flat_map(|scope| scopes.entries(scope).iter()) 247 .flat_map(|scope| scopes.entries(scope).iter())
250 .filter(|entry| shadowed.insert(entry.name())) 248 .filter(|entry| shadowed.insert(entry.name()))