File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -190,13 +190,21 @@ pub fn parse_position_comments(
190190 let mut i = 0 ;
191191 let lines = source. lines_with_terminator ( ) . collect :: < Vec < _ > > ( ) ;
192192 for assertion in & mut result {
193+ let original_position = assertion. position ;
193194 loop {
194195 let on_assertion_line = assertion_ranges[ i..]
195196 . iter ( )
196197 . any ( |( start, _) | start. row == assertion. position . row ) ;
197198 let on_empty_line = lines[ assertion. position . row ] . len ( ) <= assertion. position . column ;
198199 if on_assertion_line || on_empty_line {
199- assertion. position . row -= 1 ;
200+ if assertion. position . row > 0 {
201+ assertion. position . row -= 1 ;
202+ } else {
203+ return Err ( anyhow ! (
204+ "Error: could not find a line that corresponds to the assertion `{}` located at {original_position}" ,
205+ assertion. expected_capture_name
206+ ) ) ;
207+ }
200208 } else {
201209 while i < assertion_ranges. len ( )
202210 && assertion_ranges[ i] . 0 . row < assertion. position . row
You can’t perform that action at this time.
0 commit comments