aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-12 11:12:26 +0100
committerAleksey Kladov <[email protected]>2019-09-12 11:12:26 +0100
commit0ffd1fdbe4a7dd8707cb7eaf31c15dcd1d4fb101 (patch)
treeb738581d1baeb82537f6481921e9c1a9cfb5db33 /crates/ra_hir
parent3c68da792b52b9071e7e9bdac2b1cf8eb3c9e77b (diff)
fix panic when fetching generics
due to macro expansion, the root node is not always a file
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/impl_block.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index 162ab02b1..d26a024ed 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;
4use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; 4use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
5use ra_syntax::{ 5use ra_syntax::{
6 ast::{self, AstNode}, 6 ast::{self, AstNode},
7 AstPtr, SourceFile, 7 AstPtr,
8}; 8};
9 9
10use crate::{ 10use crate::{
@@ -29,12 +29,12 @@ impl ImplSourceMap {
29 } 29 }
30 30
31 pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> ast::ImplBlock { 31 pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> ast::ImplBlock {
32 let file = match source { 32 let root = match source {
33 ModuleSource::SourceFile(file) => file.clone(), 33 ModuleSource::SourceFile(file) => file.syntax().clone(),
34 ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), 34 ModuleSource::Module(m) => m.syntax().ancestors().last().unwrap(),
35 }; 35 };
36 36
37 self.map[impl_id].to_node(file.syntax()).to_owned() 37 self.map[impl_id].to_node(&root)
38 } 38 }
39} 39}
40 40