diff options
Diffstat (limited to 'crates/ra_hir/src/module.rs')
-rw-r--r-- | crates/ra_hir/src/module.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_hir/src/module.rs b/crates/ra_hir/src/module.rs index a53b69d20..c70dc54dd 100644 --- a/crates/ra_hir/src/module.rs +++ b/crates/ra_hir/src/module.rs | |||
@@ -9,6 +9,7 @@ use ra_syntax::{ | |||
9 | ast::{self, AstNode, NameOwner}, | 9 | ast::{self, AstNode, NameOwner}, |
10 | SyntaxNode, | 10 | SyntaxNode, |
11 | }; | 11 | }; |
12 | use ra_arena::{Arena, RawId, impl_arena_id}; | ||
12 | use ra_db::{SourceRootId, FileId, Cancelable}; | 13 | use ra_db::{SourceRootId, FileId, Cancelable}; |
13 | use relative_path::RelativePathBuf; | 14 | use relative_path::RelativePathBuf; |
14 | 15 | ||
@@ -16,7 +17,6 @@ use crate::{ | |||
16 | Def, DefKind, DefLoc, DefId, | 17 | Def, DefKind, DefLoc, DefId, |
17 | Name, Path, PathKind, HirDatabase, SourceItemId, SourceFileItemId, Crate, | 18 | Name, Path, PathKind, HirDatabase, SourceItemId, SourceFileItemId, Crate, |
18 | HirFileId, | 19 | HirFileId, |
19 | arena::{Arena, Id}, | ||
20 | }; | 20 | }; |
21 | 21 | ||
22 | pub use self::nameres::{ModuleScope, Resolution, Namespace, PerNs}; | 22 | pub use self::nameres::{ModuleScope, Resolution, Namespace, PerNs}; |
@@ -173,6 +173,14 @@ impl Module { | |||
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
177 | pub struct ModuleId(RawId); | ||
178 | impl_arena_id!(ModuleId); | ||
179 | |||
180 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
181 | pub struct LinkId(RawId); | ||
182 | impl_arena_id!(LinkId); | ||
183 | |||
176 | /// Physically, rust source is organized as a set of files, but logically it is | 184 | /// Physically, rust source is organized as a set of files, but logically it is |
177 | /// organized as a tree of modules. Usually, a single file corresponds to a | 185 | /// organized as a tree of modules. Usually, a single file corresponds to a |
178 | /// single module, but it is not nessary the case. | 186 | /// single module, but it is not nessary the case. |
@@ -182,8 +190,8 @@ impl Module { | |||
182 | /// always have one parent). | 190 | /// always have one parent). |
183 | #[derive(Default, Debug, PartialEq, Eq)] | 191 | #[derive(Default, Debug, PartialEq, Eq)] |
184 | pub struct ModuleTree { | 192 | pub struct ModuleTree { |
185 | mods: Arena<ModuleData>, | 193 | mods: Arena<ModuleId, ModuleData>, |
186 | links: Arena<LinkData>, | 194 | links: Arena<LinkId, LinkData>, |
187 | } | 195 | } |
188 | 196 | ||
189 | impl ModuleTree { | 197 | impl ModuleTree { |
@@ -210,9 +218,6 @@ pub(crate) enum ModuleSourceNode { | |||
210 | Module(ast::ModuleNode), | 218 | Module(ast::ModuleNode), |
211 | } | 219 | } |
212 | 220 | ||
213 | pub type ModuleId = Id<ModuleData>; | ||
214 | type LinkId = Id<LinkData>; | ||
215 | |||
216 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] | 221 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] |
217 | pub enum Problem { | 222 | pub enum Problem { |
218 | UnresolvedModule { | 223 | UnresolvedModule { |