From d3df80dfe41e4e3ab7644ae576119a264ba0e7f1 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 27 Jan 2019 17:23:49 +0100 Subject: Cleanup --- crates/ra_hir/src/expr.rs | 8 ++------ crates/ra_hir/src/nameres.rs | 3 +-- crates/ra_hir/src/resolve.rs | 16 +++++++--------- crates/ra_hir/src/source_binder.rs | 8 ++------ 4 files changed, 12 insertions(+), 23 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index e78ba889e..f9f702ae2 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -76,11 +76,7 @@ impl Body { } // needs arbitrary_self_types to be a method... or maybe move to the def? -pub fn resolver_for_expr( - body: Arc, - db: &impl HirDatabase, - expr_id: ExprId, -) -> Resolver<'static> { +pub fn resolver_for_expr(body: Arc, db: &impl HirDatabase, expr_id: ExprId) -> Resolver { let scopes = db.expr_scopes(body.owner); resolver_for_scope(body, db, scopes.scope_for(expr_id)) } @@ -89,7 +85,7 @@ pub fn resolver_for_scope( body: Arc, db: &impl HirDatabase, scope_id: Option, -) -> Resolver<'static> { +) -> Resolver { let mut r = body.owner.resolver(db); let scopes = db.expr_scopes(body.owner); let scope_chain = scopes.scope_chain_for(scope_id).collect::>(); diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 9b020db81..7ec6512b6 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs @@ -25,8 +25,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ Module, ModuleDef, Path, PathKind, PersistentHirDatabase, - Crate, - Name, + Crate, Name, module_tree::{ModuleId, ModuleTree}, nameres::lower::{ImportId, LoweredModule, ImportData}, }; diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 871f7d8f7..3e0af3a43 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs @@ -109,8 +109,6 @@ impl Resolver { self.scopes.iter().rev().find_map(|scope| match scope { Scope::ModuleScope(m) => Some((&*m.item_map, m.module.clone())), - Scope::ModuleScopeRef(m) => Some((m.item_map, m.module.clone())), - _ => None, }) } @@ -197,13 +195,13 @@ impl Scope { fn collect_names(&self, f: &mut FnMut(Name, PerNs)) { match self { Scope::ModuleScope(m) => { - m.item_map[m.module.module_id] - .entries() - .for_each(|(name, res)| { - f(name.clone(), res.def.map(|def| Resolution::Def { def })); - }) - } - Scope::ModuleScopeRef(m) => { + // TODO: should we provide `self` here? + // f( + // Name::self_param(), + // PerNs::types(Resolution::Def { + // def: m.module.into(), + // }), + // ); m.item_map[m.module.module_id] .entries() .for_each(|(name, res)| { diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 621215bfb..ce929cf3e 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -203,7 +203,7 @@ pub fn macro_symbols(db: &impl HirDatabase, file_id: FileId) -> Vec<(SmolStr, Te res } -pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver<'static> { +pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver { let file = db.parse(position.file_id); find_leaf_at_offset(file.syntax(), position.offset) .find_map(|node| { @@ -230,11 +230,7 @@ pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> R .unwrap_or_default() } -pub fn resolver_for_node( - db: &impl HirDatabase, - file_id: FileId, - node: &SyntaxNode, -) -> Resolver<'static> { +pub fn resolver_for_node(db: &impl HirDatabase, file_id: FileId, node: &SyntaxNode) -> Resolver { node.ancestors() .find_map(|node| { if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { -- cgit v1.2.3