@@ -471,18 +471,21 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector, position: Sp
471471 break ' main;
472472 }
473473 }
474- let offset = offset. unwrap_or ( 0 ) ;
475- let lines = test_s. lines ( ) . map ( |l| map_line ( l) . for_code ( ) ) ;
476- let text = lines. collect :: < Vec < & str > > ( ) . join ( "\n " ) ;
477- nb_lines += doc[ prev_offset..offset] . lines ( ) . count ( ) ;
478- let line = tests. get_line ( ) + ( nb_lines - 1 ) ;
479- let filename = tests. get_filename ( ) ;
480- tests. add_test ( text. to_owned ( ) ,
481- block_info. should_panic , block_info. no_run ,
482- block_info. ignore , block_info. test_harness ,
483- block_info. compile_fail , block_info. error_codes ,
484- line, filename, block_info. allow_fail ) ;
485- prev_offset = offset;
474+ if let Some ( offset) = offset {
475+ let lines = test_s. lines ( ) . map ( |l| map_line ( l) . for_code ( ) ) ;
476+ let text = lines. collect :: < Vec < & str > > ( ) . join ( "\n " ) ;
477+ nb_lines += doc[ prev_offset..offset] . lines ( ) . count ( ) ;
478+ let line = tests. get_line ( ) + ( nb_lines - 1 ) ;
479+ let filename = tests. get_filename ( ) ;
480+ tests. add_test ( text. to_owned ( ) ,
481+ block_info. should_panic , block_info. no_run ,
482+ block_info. ignore , block_info. test_harness ,
483+ block_info. compile_fail , block_info. error_codes ,
484+ line, filename, block_info. allow_fail ) ;
485+ prev_offset = offset;
486+ } else {
487+ break ;
488+ }
486489 }
487490 Event :: Start ( Tag :: Header ( level) ) => {
488491 register_header = Some ( level as u32 ) ;
0 commit comments