aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/lib.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 578fde259..760524f6b 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -139,12 +139,21 @@ impl SourceFileItems {
139 self.id_of_unchecked(item) 139 self.id_of_unchecked(item)
140 } 140 }
141 fn id_of_unchecked(&self, item: SyntaxNodeRef) -> SourceFileItemId { 141 fn id_of_unchecked(&self, item: SyntaxNodeRef) -> SourceFileItemId {
142 let (id, _item) = self 142 if let Some((id, _)) = self.arena.iter().find(|(_id, i)| i.borrowed() == item) {
143 .arena 143 return id;
144 .iter() 144 }
145 .find(|(_id, i)| i.borrowed() == item) 145 // This should not happen. Let's try to give a sensible diagnostics.
146 .unwrap(); 146 if let Some((_, i)) = self.arena.iter().find(|(_id, i)| i.range() == item.range()) {
147 id 147 panic!(
148 "unequal syntax nodes with the same range:\n{:?}\n{:?}",
149 item, i
150 )
151 }
152 panic!(
153 "Can't find {:?} in SourceFileItems:\n{:?}",
154 item,
155 self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
156 );
148 } 157 }
149 pub fn id_of_source_file(&self) -> SourceFileItemId { 158 pub fn id_of_source_file(&self) -> SourceFileItemId {
150 let (id, _syntax) = self.arena.iter().next().unwrap(); 159 let (id, _syntax) = self.arena.iter().next().unwrap();