aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/parent_module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/parent_module.rs')
-rw-r--r--crates/ra_ide_api/src/parent_module.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs
index 379b3f3a4..e94297fe3 100644
--- a/crates/ra_ide_api/src/parent_module.rs
+++ b/crates/ra_ide_api/src/parent_module.rs
@@ -1,19 +1,16 @@
1use ra_db::{Cancelable, FilePosition}; 1use ra_db::FilePosition;
2 2
3use crate::{NavigationTarget, db::RootDatabase}; 3use crate::{NavigationTarget, db::RootDatabase};
4 4
5/// This returns `Vec` because a module may be included from several places. We 5/// This returns `Vec` because a module may be included from several places. We
6/// don't handle this case yet though, so the Vec has length at most one. 6/// don't handle this case yet though, so the Vec has length at most one.
7pub(crate) fn parent_module( 7pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
8 db: &RootDatabase,
9 position: FilePosition,
10) -> Cancelable<Vec<NavigationTarget>> {
11 let module = match hir::source_binder::module_from_position(db, position) { 8 let module = match hir::source_binder::module_from_position(db, position) {
12 None => return Ok(Vec::new()), 9 None => return Vec::new(),
13 Some(it) => it, 10 Some(it) => it,
14 }; 11 };
15 let nav = NavigationTarget::from_module_to_decl(db, module); 12 let nav = NavigationTarget::from_module_to_decl(db, module);
16 Ok(vec![nav]) 13 vec![nav]
17} 14}
18 15
19#[cfg(test)] 16#[cfg(test)]