diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/lower.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/lower.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index 435804e2d..0056bdd5a 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs | |||
@@ -11,6 +11,7 @@ use crate::{ | |||
11 | SourceItemId, Path, ModuleSource, HirDatabase, Name, SourceFileItems, | 11 | SourceItemId, Path, ModuleSource, HirDatabase, Name, SourceFileItems, |
12 | HirFileId, MacroCallLoc, AsName, PerNs, DefKind, DefLoc, Function, | 12 | HirFileId, MacroCallLoc, AsName, PerNs, DefKind, DefLoc, Function, |
13 | ModuleDef, Module, Struct, Enum, | 13 | ModuleDef, Module, Struct, Enum, |
14 | ids::LocationCtx, | ||
14 | }; | 15 | }; |
15 | 16 | ||
16 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 17 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -146,10 +147,11 @@ impl LoweredModule { | |||
146 | file_items: &SourceFileItems, | 147 | file_items: &SourceFileItems, |
147 | item: &ast::ModuleItem, | 148 | item: &ast::ModuleItem, |
148 | ) { | 149 | ) { |
150 | let ctx = LocationCtx::new(db, module, file_id); | ||
149 | let name = match item.kind() { | 151 | let name = match item.kind() { |
150 | ast::ModuleItemKind::StructDef(it) => { | 152 | ast::ModuleItemKind::StructDef(it) => { |
151 | if let Some(name) = it.name() { | 153 | if let Some(name) = it.name() { |
152 | let s = Struct::from_ast(db, module, file_id, it); | 154 | let s = Struct { id: ctx.to_def(it) }; |
153 | let s: ModuleDef = s.into(); | 155 | let s: ModuleDef = s.into(); |
154 | self.declarations.insert(name.as_name(), PerNs::both(s, s)); | 156 | self.declarations.insert(name.as_name(), PerNs::both(s, s)); |
155 | } | 157 | } |
@@ -157,7 +159,7 @@ impl LoweredModule { | |||
157 | } | 159 | } |
158 | ast::ModuleItemKind::EnumDef(it) => { | 160 | ast::ModuleItemKind::EnumDef(it) => { |
159 | if let Some(name) = it.name() { | 161 | if let Some(name) = it.name() { |
160 | let e = Enum::from_ast(db, module, file_id, it); | 162 | let e = Enum { id: ctx.to_def(it) }; |
161 | let e: ModuleDef = e.into(); | 163 | let e: ModuleDef = e.into(); |
162 | self.declarations.insert(name.as_name(), PerNs::types(e)); | 164 | self.declarations.insert(name.as_name(), PerNs::types(e)); |
163 | } | 165 | } |
@@ -165,7 +167,7 @@ impl LoweredModule { | |||
165 | } | 167 | } |
166 | ast::ModuleItemKind::FnDef(it) => { | 168 | ast::ModuleItemKind::FnDef(it) => { |
167 | if let Some(name) = it.name() { | 169 | if let Some(name) = it.name() { |
168 | let func = Function::from_ast(db, module, file_id, it); | 170 | let func = Function { id: ctx.to_def(it) }; |
169 | self.declarations | 171 | self.declarations |
170 | .insert(name.as_name(), PerNs::values(func.into())); | 172 | .insert(name.as_name(), PerNs::values(func.into())); |
171 | } | 173 | } |