aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/module/imp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/module/imp.rs')
-rw-r--r--crates/ra_hir/src/module/imp.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_hir/src/module/imp.rs b/crates/ra_hir/src/module/imp.rs
index 748fdb64e..eded85a63 100644
--- a/crates/ra_hir/src/module/imp.rs
+++ b/crates/ra_hir/src/module/imp.rs
@@ -1,16 +1,13 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_syntax::{ 3use ra_syntax::ast::{self, NameOwner};
4 ast::{self, NameOwner},
5 SmolStr,
6};
7use relative_path::RelativePathBuf; 4use relative_path::RelativePathBuf;
8use rustc_hash::{FxHashMap, FxHashSet}; 5use rustc_hash::{FxHashMap, FxHashSet};
9use arrayvec::ArrayVec; 6use arrayvec::ArrayVec;
10use ra_db::{SourceRoot, SourceRootId, Cancelable, FileId}; 7use ra_db::{SourceRoot, SourceRootId, Cancelable, FileId};
11 8
12use crate::{ 9use crate::{
13 HirDatabase, 10 HirDatabase, Name, AsName,
14}; 11};
15 12
16use super::{ 13use super::{
@@ -20,12 +17,12 @@ use super::{
20 17
21#[derive(Clone, Hash, PartialEq, Eq, Debug)] 18#[derive(Clone, Hash, PartialEq, Eq, Debug)]
22pub enum Submodule { 19pub enum Submodule {
23 Declaration(SmolStr), 20 Declaration(Name),
24 Definition(SmolStr, ModuleSource), 21 Definition(Name, ModuleSource),
25} 22}
26 23
27impl Submodule { 24impl Submodule {
28 fn name(&self) -> &SmolStr { 25 fn name(&self) -> &Name {
29 match self { 26 match self {
30 Submodule::Declaration(name) => name, 27 Submodule::Declaration(name) => name,
31 Submodule::Definition(name, _) => name, 28 Submodule::Definition(name, _) => name,
@@ -35,14 +32,14 @@ impl Submodule {
35 32
36pub(crate) fn modules<'a>( 33pub(crate) fn modules<'a>(
37 root: impl ast::ModuleItemOwner<'a>, 34 root: impl ast::ModuleItemOwner<'a>,
38) -> impl Iterator<Item = (SmolStr, ast::Module<'a>)> { 35) -> impl Iterator<Item = (Name, ast::Module<'a>)> {
39 root.items() 36 root.items()
40 .filter_map(|item| match item { 37 .filter_map(|item| match item {
41 ast::ModuleItem::Module(m) => Some(m), 38 ast::ModuleItem::Module(m) => Some(m),
42 _ => None, 39 _ => None,
43 }) 40 })
44 .filter_map(|module| { 41 .filter_map(|module| {
45 let name = module.name()?.text(); 42 let name = module.name()?.as_name();
46 Some((name, module)) 43 Some((name, module))
47 }) 44 })
48} 45}
@@ -155,7 +152,7 @@ fn build_subtree(
155fn resolve_submodule( 152fn resolve_submodule(
156 db: &impl HirDatabase, 153 db: &impl HirDatabase,
157 source: ModuleSource, 154 source: ModuleSource,
158 name: &SmolStr, 155 name: &Name,
159) -> (Vec<FileId>, Option<Problem>) { 156) -> (Vec<FileId>, Option<Problem>) {
160 // FIXME: handle submodules of inline modules properly 157 // FIXME: handle submodules of inline modules properly
161 let file_id = source.file_id(); 158 let file_id = source.file_id();