From ec7ed054e06cb2e23fd3911932766b32014c8fa1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 15:28:50 +0300 Subject: Functions use new id scheme --- crates/ra_hir/src/nameres/lower.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/nameres') diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index 6f003bd66..1f8adc7eb 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs @@ -9,7 +9,7 @@ use rustc_hash::FxHashMap; use crate::{ SourceItemId, Path, ModuleSource, HirDatabase, Name, SourceFileItems, - HirFileId, MacroCallLoc, AsName, PerNs, DefKind, DefLoc, + HirFileId, MacroCallLoc, AsName, PerNs, DefKind, DefLoc, Function, ModuleDef, Module, }; @@ -149,7 +149,14 @@ impl LoweredModule { let name = match item.kind() { ast::ModuleItemKind::StructDef(it) => it.name(), ast::ModuleItemKind::EnumDef(it) => it.name(), - ast::ModuleItemKind::FnDef(it) => it.name(), + ast::ModuleItemKind::FnDef(it) => { + if let Some(name) = it.name() { + let func = Function::from_ast(db, module, file_id, it); + self.declarations + .insert(name.as_name(), PerNs::values(func.into())); + } + return; + } ast::ModuleItemKind::TraitDef(it) => it.name(), ast::ModuleItemKind::TypeDef(it) => it.name(), ast::ModuleItemKind::ImplBlock(_) => { @@ -218,7 +225,7 @@ fn assign_def_id( impl DefKind { fn for_syntax_kind(kind: SyntaxKind) -> PerNs { match kind { - SyntaxKind::FN_DEF => PerNs::values(DefKind::Function), + SyntaxKind::FN_DEF => unreachable!(), SyntaxKind::STRUCT_DEF => PerNs::both(DefKind::Struct, DefKind::StructCtor), SyntaxKind::ENUM_DEF => PerNs::types(DefKind::Enum), SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait), -- cgit v1.2.3