diff options
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/lower.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index 0056bdd5a..6a86e5fd4 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs | |||
@@ -10,7 +10,7 @@ use rustc_hash::FxHashMap; | |||
10 | use crate::{ | 10 | 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, Const, Static, |
14 | ids::LocationCtx, | 14 | ids::LocationCtx, |
15 | }; | 15 | }; |
16 | 16 | ||
@@ -187,8 +187,22 @@ impl LoweredModule { | |||
187 | // TODO | 187 | // TODO |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | ast::ModuleItemKind::ConstDef(it) => it.name(), | 190 | ast::ModuleItemKind::ConstDef(it) => { |
191 | ast::ModuleItemKind::StaticDef(it) => it.name(), | 191 | if let Some(name) = it.name() { |
192 | let c = Const { id: ctx.to_def(it) }; | ||
193 | self.declarations | ||
194 | .insert(name.as_name(), PerNs::values(c.into())); | ||
195 | } | ||
196 | return; | ||
197 | } | ||
198 | ast::ModuleItemKind::StaticDef(it) => { | ||
199 | if let Some(name) = it.name() { | ||
200 | let s = Static { id: ctx.to_def(it) }; | ||
201 | self.declarations | ||
202 | .insert(name.as_name(), PerNs::values(s.into())); | ||
203 | } | ||
204 | return; | ||
205 | } | ||
192 | ast::ModuleItemKind::Module(_) => { | 206 | ast::ModuleItemKind::Module(_) => { |
193 | // modules are handled separately direclty by nameres | 207 | // modules are handled separately direclty by nameres |
194 | return; | 208 | return; |
@@ -246,8 +260,8 @@ impl DefKind { | |||
246 | SyntaxKind::ENUM_DEF => unreachable!(), | 260 | SyntaxKind::ENUM_DEF => unreachable!(), |
247 | SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait), | 261 | SyntaxKind::TRAIT_DEF => PerNs::types(DefKind::Trait), |
248 | SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type), | 262 | SyntaxKind::TYPE_DEF => PerNs::types(DefKind::Type), |
249 | SyntaxKind::CONST_DEF => PerNs::values(DefKind::Const), | 263 | SyntaxKind::CONST_DEF => unreachable!(), |
250 | SyntaxKind::STATIC_DEF => PerNs::values(DefKind::Static), | 264 | SyntaxKind::STATIC_DEF => unreachable!(), |
251 | _ => PerNs::none(), | 265 | _ => PerNs::none(), |
252 | } | 266 | } |
253 | } | 267 | } |