diff options
Diffstat (limited to 'crates/ra_hir/src/lib.rs')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 0f84b2d61..ffc99fd5f 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -61,15 +61,18 @@ impl FnId { | |||
61 | pub struct DefId(u32); | 61 | pub struct DefId(u32); |
62 | ra_db::impl_numeric_id!(DefId); | 62 | ra_db::impl_numeric_id!(DefId); |
63 | 63 | ||
64 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
65 | pub(crate) enum DefKind { | ||
66 | Module, | ||
67 | Item, | ||
68 | } | ||
69 | |||
64 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] | 70 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] |
65 | pub enum DefLoc { | 71 | pub struct DefLoc { |
66 | Module { | 72 | pub(crate) kind: DefKind, |
67 | id: ModuleId, | 73 | source_root_id: SourceRootId, |
68 | source_root: SourceRootId, | 74 | module_id: ModuleId, |
69 | }, | 75 | source_item_id: SourceItemId, |
70 | Item { | ||
71 | source_item_id: SourceItemId, | ||
72 | }, | ||
73 | } | 76 | } |
74 | 77 | ||
75 | impl DefId { | 78 | impl DefId { |
@@ -92,12 +95,12 @@ pub enum Def { | |||
92 | impl DefId { | 95 | impl DefId { |
93 | pub fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> { | 96 | pub fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> { |
94 | let loc = self.loc(db); | 97 | let loc = self.loc(db); |
95 | let res = match loc { | 98 | let res = match loc.kind { |
96 | DefLoc::Module { id, source_root } => { | 99 | DefKind::Module => { |
97 | let descr = Module::new(db, source_root, id)?; | 100 | let descr = Module::new(db, loc.source_root_id, loc.module_id)?; |
98 | Def::Module(descr) | 101 | Def::Module(descr) |
99 | } | 102 | } |
100 | DefLoc::Item { .. } => Def::Item, | 103 | DefKind::Item => Def::Item, |
101 | }; | 104 | }; |
102 | Ok(res) | 105 | Ok(res) |
103 | } | 106 | } |