@@ -38,6 +38,7 @@ impl EarlyProps {
38
38
39
39
iter_header ( testfile,
40
40
None ,
41
+ config,
41
42
& mut |ln| {
42
43
props. ignore =
43
44
props. ignore ||
@@ -300,6 +301,7 @@ impl TestProps {
300
301
let mut has_edition = false ;
301
302
iter_header ( testfile,
302
303
cfg,
304
+ config,
303
305
& mut |ln| {
304
306
if let Some ( ep) = config. parse_error_pattern ( ln) {
305
307
self . error_patterns . push ( ep) ;
@@ -422,10 +424,16 @@ impl TestProps {
422
424
}
423
425
}
424
426
425
- fn iter_header ( testfile : & Path , cfg : Option < & str > , it : & mut dyn FnMut ( & str ) ) {
427
+ const HEADER_PREFIXES : [ [ & str ; 2 ] ; 2 ] = [
428
+ [ "//" , "//[" ] ,
429
+ [ "//@" , "//@[" ] ,
430
+ ] ;
431
+
432
+ fn iter_header ( testfile : & Path , cfg : Option < & str > , config : & Config , it : & mut dyn FnMut ( & str ) ) {
426
433
if testfile. is_dir ( ) {
427
434
return ;
428
435
}
436
+ let header_prefix = HEADER_PREFIXES [ config. strict_headers as usize ] ;
429
437
let rdr = BufReader :: new ( File :: open ( testfile) . unwrap ( ) ) ;
430
438
for ln in rdr. lines ( ) {
431
439
// Assume that any directives will be found before the first
@@ -435,7 +443,7 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
435
443
let ln = ln. trim ( ) ;
436
444
if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
437
445
return ;
438
- } else if let Some ( ln) = ln. strip_prefix ( "//@[" ) {
446
+ } else if let Some ( ln) = ln. strip_prefix ( header_prefix [ 1 ] ) {
439
447
// A comment like `//[foo]` is specific to revision `foo`
440
448
if let Some ( ( lncfg, ln) ) = ln. split_once ( ']' ) {
441
449
if cfg == Some ( lncfg) {
@@ -447,7 +455,7 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
447
455
ln
448
456
)
449
457
}
450
- } else if let Some ( ln) = ln. strip_prefix ( "//@" ) {
458
+ } else if let Some ( ln) = ln. strip_prefix ( header_prefix [ 0 ] ) {
451
459
it ( ln. trim_start ( ) ) ;
452
460
}
453
461
}
0 commit comments