diff options
Diffstat (limited to 'crates/ra_hir/src/lib.rs')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 81526fe9c..796970d8a 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -135,6 +135,12 @@ impl DefId { | |||
135 | }; | 135 | }; |
136 | Ok(res) | 136 | Ok(res) |
137 | } | 137 | } |
138 | |||
139 | /// For a module, returns that module; for any other def, returns the containing module. | ||
140 | pub fn module(self, db: &impl HirDatabase) -> Cancelable<Module> { | ||
141 | let loc = self.loc(db); | ||
142 | Module::new(db, loc.source_root_id, loc.module_id) | ||
143 | } | ||
138 | } | 144 | } |
139 | 145 | ||
140 | /// Identifier of item within a specific file. This is stable over reparses, so | 146 | /// Identifier of item within a specific file. This is stable over reparses, so |