File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -139,12 +139,21 @@ impl SourceFileItems {
139
139
self . id_of_unchecked ( item)
140
140
}
141
141
fn id_of_unchecked ( & self , item : SyntaxNodeRef ) -> SourceFileItemId {
142
- let ( id, _item) = self
143
- . arena
144
- . iter ( )
145
- . find ( |( _id, i) | i. borrowed ( ) == item)
146
- . unwrap ( ) ;
147
- id
142
+ if let Some ( ( id, _) ) = self . arena . iter ( ) . find ( |( _id, i) | i. borrowed ( ) == item) {
143
+ return id;
144
+ }
145
+ // This should not happen. Let's try to give a sensible diagnostics.
146
+ if let Some ( ( _, i) ) = self . arena . iter ( ) . find ( |( _id, i) | i. range ( ) == item. range ( ) ) {
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
158
pub fn id_of_source_file ( & self ) -> SourceFileItemId {
150
159
let ( id, _syntax) = self . arena . iter ( ) . next ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments