diff options
Diffstat (limited to 'crates/ra_hir/src/impl_block.rs')
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index ce134b27a..8e62cf66d 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -4,7 +4,7 @@ use std::sync::Arc; | |||
4 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; | 4 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | ast::{self, AstNode}, | 6 | ast::{self, AstNode}, |
7 | AstPtr, SourceFile, TreeArc, | 7 | AstPtr, SourceFile, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -28,9 +28,9 @@ impl ImplSourceMap { | |||
28 | self.map.insert(impl_id, AstPtr::new(impl_block)) | 28 | self.map.insert(impl_id, AstPtr::new(impl_block)) |
29 | } | 29 | } |
30 | 30 | ||
31 | pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> TreeArc<ast::ImplBlock> { | 31 | pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> ast::ImplBlock { |
32 | let file = match source { | 32 | let file = match source { |
33 | ModuleSource::SourceFile(file) => &*file, | 33 | ModuleSource::SourceFile(file) => file.clone(), |
34 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), | 34 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), |
35 | }; | 35 | }; |
36 | 36 | ||
@@ -45,8 +45,8 @@ pub struct ImplBlock { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | impl HasSource for ImplBlock { | 47 | impl HasSource for ImplBlock { |
48 | type Ast = TreeArc<ast::ImplBlock>; | 48 | type Ast = ast::ImplBlock; |
49 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ImplBlock>> { | 49 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::ImplBlock> { |
50 | let source_map = db.impls_in_module_with_source_map(self.module).1; | 50 | let source_map = db.impls_in_module_with_source_map(self.module).1; |
51 | let src = self.module.definition_source(db); | 51 | let src = self.module.definition_source(db); |
52 | Source { file_id: src.file_id, ast: source_map.get(&src.ast, self.impl_id) } | 52 | Source { file_id: src.file_id, ast: source_map.get(&src.ast, self.impl_id) } |
@@ -132,9 +132,9 @@ impl ImplData { | |||
132 | item_list | 132 | item_list |
133 | .impl_items() | 133 | .impl_items() |
134 | .map(|item_node| match item_node.kind() { | 134 | .map(|item_node| match item_node.kind() { |
135 | ast::ImplItemKind::FnDef(it) => Function { id: ctx.to_def(it) }.into(), | 135 | ast::ImplItemKind::FnDef(it) => Function { id: ctx.to_def(&it) }.into(), |
136 | ast::ImplItemKind::ConstDef(it) => Const { id: ctx.to_def(it) }.into(), | 136 | ast::ImplItemKind::ConstDef(it) => Const { id: ctx.to_def(&it) }.into(), |
137 | ast::ImplItemKind::TypeAliasDef(it) => TypeAlias { id: ctx.to_def(it) }.into(), | 137 | ast::ImplItemKind::TypeAliasDef(it) => TypeAlias { id: ctx.to_def(&it) }.into(), |
138 | }) | 138 | }) |
139 | .collect() | 139 | .collect() |
140 | } else { | 140 | } else { |
@@ -202,20 +202,20 @@ impl ModuleImplBlocks { | |||
202 | 202 | ||
203 | let src = m.module.definition_source(db); | 203 | let src = m.module.definition_source(db); |
204 | let node = match &src.ast { | 204 | let node = match &src.ast { |
205 | ModuleSource::SourceFile(node) => node.syntax(), | 205 | ModuleSource::SourceFile(node) => node.syntax().clone(), |
206 | ModuleSource::Module(node) => { | 206 | ModuleSource::Module(node) => { |
207 | node.item_list().expect("inline module should have item list").syntax() | 207 | node.item_list().expect("inline module should have item list").syntax().clone() |
208 | } | 208 | } |
209 | }; | 209 | }; |
210 | 210 | ||
211 | for impl_block_ast in node.children().filter_map(ast::ImplBlock::cast) { | 211 | for impl_block_ast in node.children().filter_map(ast::ImplBlock::cast) { |
212 | let impl_block = ImplData::from_ast(db, src.file_id, m.module, impl_block_ast); | 212 | let impl_block = ImplData::from_ast(db, src.file_id, m.module, &impl_block_ast); |
213 | let id = m.impls.alloc(impl_block); | 213 | let id = m.impls.alloc(impl_block); |
214 | for &impl_item in &m.impls[id].items { | 214 | for &impl_item in &m.impls[id].items { |
215 | m.impls_by_def.insert(impl_item, id); | 215 | m.impls_by_def.insert(impl_item, id); |
216 | } | 216 | } |
217 | 217 | ||
218 | source_map.insert(id, impl_block_ast); | 218 | source_map.insert(id, &impl_block_ast); |
219 | } | 219 | } |
220 | 220 | ||
221 | m | 221 | m |