aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/module.rs')
-rw-r--r--crates/ra_hir/src/module.rs17
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};
12use ra_arena::{Arena, RawId, impl_arena_id};
12use ra_db::{SourceRootId, FileId, Cancelable}; 13use ra_db::{SourceRootId, FileId, Cancelable};
13use relative_path::RelativePathBuf; 14use 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
22pub use self::nameres::{ModuleScope, Resolution, Namespace, PerNs}; 22pub 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)]
177pub struct ModuleId(RawId);
178impl_arena_id!(ModuleId);
179
180#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
181pub struct LinkId(RawId);
182impl_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)]
184pub struct ModuleTree { 192pub struct ModuleTree {
185 mods: Arena<ModuleData>, 193 mods: Arena<ModuleId, ModuleData>,
186 links: Arena<LinkData>, 194 links: Arena<LinkId, LinkData>,
187} 195}
188 196
189impl ModuleTree { 197impl ModuleTree {
@@ -210,9 +218,6 @@ pub(crate) enum ModuleSourceNode {
210 Module(ast::ModuleNode), 218 Module(ast::ModuleNode),
211} 219}
212 220
213pub type ModuleId = Id<ModuleData>;
214type LinkId = Id<LinkData>;
215
216#[derive(Clone, Debug, Hash, PartialEq, Eq)] 221#[derive(Clone, Debug, Hash, PartialEq, Eq)]
217pub enum Problem { 222pub enum Problem {
218 UnresolvedModule { 223 UnresolvedModule {