aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/raw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres/raw.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 636364628..f1896c0cc 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -2,7 +2,7 @@
2 2
3use std::{ops::Index, sync::Arc}; 3use std::{ops::Index, sync::Arc};
4 4
5use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase}; 5use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase, either::Either};
6use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; 6use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, AttrsOwner, NameOwner}, 8 ast::{self, AttrsOwner, NameOwner},
@@ -12,7 +12,6 @@ use ra_syntax::{
12use crate::{ 12use crate::{
13 attr::Attr, 13 attr::Attr,
14 db::DefDatabase2, 14 db::DefDatabase2,
15 either::Either,
16 hygiene::Hygiene, 15 hygiene::Hygiene,
17 name::{AsName, Name}, 16 name::{AsName, Name},
18 path::Path, 17 path::Path,
@@ -41,10 +40,8 @@ pub struct ImportSourceMap {
41type ImportSourcePtr = Either<AstPtr<ast::UseTree>, AstPtr<ast::ExternCrateItem>>; 40type ImportSourcePtr = Either<AstPtr<ast::UseTree>, AstPtr<ast::ExternCrateItem>>;
42type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>; 41type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>;
43 42
44impl ImportSourcePtr { 43fn to_node(ptr: ImportSourcePtr, file: &SourceFile) -> ImportSource {
45 fn to_node(self, file: &SourceFile) -> ImportSource { 44 ptr.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
46 self.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
47 }
48} 45}
49 46
50impl ImportSourceMap { 47impl ImportSourceMap {
@@ -58,7 +55,7 @@ impl ImportSourceMap {
58 ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), 55 ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(),
59 }; 56 };
60 57
61 self.map[import].to_node(&file) 58 to_node(self.map[import], &file)
62 } 59 }
63} 60}
64 61