aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-09 11:21:54 +0000
committerAleksey Kladov <[email protected]>2018-12-09 11:21:54 +0000
commit5004cb928b2c430a6d7fba59d89f7829982d8baa (patch)
treeb2f98cf3cefb4e047306380311f47de3853c7081 /crates
parent19f6cdcc034a2a91e6112a4ceb32e26413b0aa0d (diff)
verbose assertions in SourceFileItems
Diffstat (limited to 'crates')
-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();