diff options
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 19 |
2 files changed, 15 insertions, 10 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index c615d80c3..621236551 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -6,7 +6,7 @@ use ra_db::FileId; | |||
6 | use ra_syntax::ast; | 6 | use ra_syntax::ast; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | Function, Module, Struct, Enum, Const, Static, Trait, TypeAlias, | 9 | Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, |
10 | DefDatabase, HirFileId, Name, Path, | 10 | DefDatabase, HirFileId, Name, Path, |
11 | KnownName, | 11 | KnownName, |
12 | nameres::{ | 12 | nameres::{ |
@@ -495,6 +495,10 @@ where | |||
495 | let s = def!(Struct, ast_id); | 495 | let s = def!(Struct, ast_id); |
496 | PerNs::both(s, s) | 496 | PerNs::both(s, s) |
497 | } | 497 | } |
498 | raw::DefKind::Union(ast_id) => { | ||
499 | let s = def!(Union, ast_id); | ||
500 | PerNs::both(s, s) | ||
501 | } | ||
498 | raw::DefKind::Enum(ast_id) => PerNs::types(def!(Enum, ast_id)), | 502 | raw::DefKind::Enum(ast_id) => PerNs::types(def!(Enum, ast_id)), |
499 | raw::DefKind::Const(ast_id) => PerNs::values(def!(Const, ast_id)), | 503 | raw::DefKind::Const(ast_id) => PerNs::values(def!(Const, ast_id)), |
500 | raw::DefKind::Static(ast_id) => PerNs::values(def!(Static, ast_id)), | 504 | raw::DefKind::Static(ast_id) => PerNs::values(def!(Static, ast_id)), |
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index bd32b264b..1b4dcbb7a 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -1,7 +1,4 @@ | |||
1 | use std::{ | 1 | use std::{sync::Arc, ops::Index}; |
2 | sync::Arc, | ||
3 | ops::Index, | ||
4 | }; | ||
5 | 2 | ||
6 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
7 | use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap}; | 4 | use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap}; |
@@ -10,10 +7,7 @@ use ra_syntax::{ | |||
10 | ast::{self, NameOwner, AttrsOwner}, | 7 | ast::{self, NameOwner, AttrsOwner}, |
11 | }; | 8 | }; |
12 | 9 | ||
13 | use crate::{ | 10 | use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either}; |
14 | DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, | ||
15 | AstIdMap, FileAstId, Either, | ||
16 | }; | ||
17 | 11 | ||
18 | /// `RawItems` is a set of top-level items in a file (except for impls). | 12 | /// `RawItems` is a set of top-level items in a file (except for impls). |
19 | /// | 13 | /// |
@@ -161,6 +155,7 @@ pub(super) struct DefData { | |||
161 | pub(super) enum DefKind { | 155 | pub(super) enum DefKind { |
162 | Function(FileAstId<ast::FnDef>), | 156 | Function(FileAstId<ast::FnDef>), |
163 | Struct(FileAstId<ast::StructDef>), | 157 | Struct(FileAstId<ast::StructDef>), |
158 | Union(FileAstId<ast::StructDef>), | ||
164 | Enum(FileAstId<ast::EnumDef>), | 159 | Enum(FileAstId<ast::EnumDef>), |
165 | Const(FileAstId<ast::ConstDef>), | 160 | Const(FileAstId<ast::ConstDef>), |
166 | Static(FileAstId<ast::StaticDef>), | 161 | Static(FileAstId<ast::StaticDef>), |
@@ -215,7 +210,13 @@ impl RawItemsCollector { | |||
215 | return; | 210 | return; |
216 | } | 211 | } |
217 | ast::ModuleItemKind::StructDef(it) => { | 212 | ast::ModuleItemKind::StructDef(it) => { |
218 | (DefKind::Struct(self.source_ast_id_map.ast_id(it)), it.name()) | 213 | let id = self.source_ast_id_map.ast_id(it); |
214 | let name = it.name(); | ||
215 | if it.is_union() { | ||
216 | (DefKind::Union(id), name) | ||
217 | } else { | ||
218 | (DefKind::Struct(id), name) | ||
219 | } | ||
219 | } | 220 | } |
220 | ast::ModuleItemKind::EnumDef(it) => { | 221 | ast::ModuleItemKind::EnumDef(it) => { |
221 | (DefKind::Enum(self.source_ast_id_map.ast_id(it)), it.name()) | 222 | (DefKind::Enum(self.source_ast_id_map.ast_id(it)), it.name()) |