@@ -1027,18 +1027,21 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector, position: Sp
1027
1027
break ' main;
1028
1028
}
1029
1029
}
1030
- let offset = offset. unwrap_or ( 0 ) ;
1031
- let lines = test_s. lines ( ) . map ( |l| map_line ( l) . for_code ( ) ) ;
1032
- let text = lines. collect :: < Vec < & str > > ( ) . join ( "\n " ) ;
1033
- nb_lines += doc[ prev_offset..offset] . lines ( ) . count ( ) ;
1034
- let line = tests. get_line ( ) + ( nb_lines - 1 ) ;
1035
- let filename = tests. get_filename ( ) ;
1036
- tests. add_test ( text. to_owned ( ) ,
1037
- block_info. should_panic , block_info. no_run ,
1038
- block_info. ignore , block_info. test_harness ,
1039
- block_info. compile_fail , block_info. error_codes ,
1040
- line, filename, block_info. allow_fail ) ;
1041
- prev_offset = offset;
1030
+ if let Some ( offset) = offset {
1031
+ let lines = test_s. lines ( ) . map ( |l| map_line ( l) . for_code ( ) ) ;
1032
+ let text = lines. collect :: < Vec < & str > > ( ) . join ( "\n " ) ;
1033
+ nb_lines += doc[ prev_offset..offset] . lines ( ) . count ( ) ;
1034
+ let line = tests. get_line ( ) + ( nb_lines - 1 ) ;
1035
+ let filename = tests. get_filename ( ) ;
1036
+ tests. add_test ( text. to_owned ( ) ,
1037
+ block_info. should_panic , block_info. no_run ,
1038
+ block_info. ignore , block_info. test_harness ,
1039
+ block_info. compile_fail , block_info. error_codes ,
1040
+ line, filename, block_info. allow_fail ) ;
1041
+ prev_offset = offset;
1042
+ } else {
1043
+ break ;
1044
+ }
1042
1045
}
1043
1046
Event :: Start ( Tag :: Header ( level) ) => {
1044
1047
register_header = Some ( level as u32 ) ;
0 commit comments