diff options
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/lower.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index ab6f3a9bc..921ba3c98 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | SyntaxKind, AstNode, SourceFile, TreeArc, SyntaxNodePtr, | 4 | SyntaxKind, AstNode, SourceFile, TreeArc, AstPtr, |
5 | ast::{self, ModuleItemOwner}, | 5 | ast::{self, ModuleItemOwner}, |
6 | }; | 6 | }; |
7 | use ra_db::{SourceRootId}; | 7 | use ra_db::SourceRootId; |
8 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 8 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -72,13 +72,12 @@ pub struct LoweredModule { | |||
72 | 72 | ||
73 | #[derive(Debug, Default, PartialEq, Eq)] | 73 | #[derive(Debug, Default, PartialEq, Eq)] |
74 | pub struct ImportSourceMap { | 74 | pub struct ImportSourceMap { |
75 | map: ArenaMap<ImportId, SyntaxNodePtr>, | 75 | map: ArenaMap<ImportId, AstPtr<ast::PathSegment>>, |
76 | } | 76 | } |
77 | 77 | ||
78 | impl ImportSourceMap { | 78 | impl ImportSourceMap { |
79 | fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { | 79 | fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { |
80 | self.map | 80 | self.map.insert(import, AstPtr::new(segment)) |
81 | .insert(import, SyntaxNodePtr::new(segment.syntax())) | ||
82 | } | 81 | } |
83 | 82 | ||
84 | pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { | 83 | pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { |
@@ -87,9 +86,7 @@ impl ImportSourceMap { | |||
87 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), | 86 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), |
88 | }; | 87 | }; |
89 | 88 | ||
90 | ast::PathSegment::cast(self.map[import].to_node(file)) | 89 | self.map[import].to_node(file).to_owned() |
91 | .unwrap() | ||
92 | .to_owned() | ||
93 | } | 90 | } |
94 | } | 91 | } |
95 | 92 | ||