mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
verbose assertions in SourceFileItems
This commit is contained in:
parent
19f6cdcc03
commit
5004cb928b
1 changed files with 15 additions and 6 deletions
|
@ -139,12 +139,21 @@ impl SourceFileItems {
|
||||||
self.id_of_unchecked(item)
|
self.id_of_unchecked(item)
|
||||||
}
|
}
|
||||||
fn id_of_unchecked(&self, item: SyntaxNodeRef) -> SourceFileItemId {
|
fn id_of_unchecked(&self, item: SyntaxNodeRef) -> SourceFileItemId {
|
||||||
let (id, _item) = self
|
if let Some((id, _)) = self.arena.iter().find(|(_id, i)| i.borrowed() == item) {
|
||||||
.arena
|
return id;
|
||||||
.iter()
|
}
|
||||||
.find(|(_id, i)| i.borrowed() == item)
|
// This should not happen. Let's try to give a sensible diagnostics.
|
||||||
.unwrap();
|
if let Some((_, i)) = self.arena.iter().find(|(_id, i)| i.range() == item.range()) {
|
||||||
id
|
panic!(
|
||||||
|
"unequal syntax nodes with the same range:\n{:?}\n{:?}",
|
||||||
|
item, i
|
||||||
|
)
|
||||||
|
}
|
||||||
|
panic!(
|
||||||
|
"Can't find {:?} in SourceFileItems:\n{:?}",
|
||||||
|
item,
|
||||||
|
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
pub fn id_of_source_file(&self) -> SourceFileItemId {
|
pub fn id_of_source_file(&self) -> SourceFileItemId {
|
||||||
let (id, _syntax) = self.arena.iter().next().unwrap();
|
let (id, _syntax) = self.arena.iter().next().unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue