@@ -54,7 +54,7 @@ impl EarlyProps {
54
54
& mut poisoned,
55
55
testfile,
56
56
rdr,
57
- & mut |_ , _ , ln, _ | {
57
+ & mut |HeaderLine { directive : ln, .. } | {
58
58
config. push_name_value_directive ( ln, directives:: AUX_BUILD , & mut props. aux , |r| {
59
59
r. trim ( ) . to_string ( )
60
60
} ) ;
@@ -329,8 +329,8 @@ impl TestProps {
329
329
& mut poisoned,
330
330
testfile,
331
331
file,
332
- & mut |revision , _ , ln, _ | {
333
- if revision . is_some ( ) && revision != cfg {
332
+ & mut |HeaderLine { header_revision , directive : ln, .. } | {
333
+ if header_revision . is_some ( ) && header_revision != cfg {
334
334
return ;
335
335
}
336
336
@@ -677,7 +677,7 @@ fn iter_header<R: Read>(
677
677
poisoned : & mut bool ,
678
678
testfile : & Path ,
679
679
rdr : R ,
680
- it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
680
+ it : & mut dyn FnMut ( HeaderLine < ' _ > ) ,
681
681
) {
682
682
iter_header_extra ( mode, suite, poisoned, testfile, rdr, & [ ] , it)
683
683
}
@@ -800,14 +800,26 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
800
800
"unset-rustc-env" ,
801
801
] ;
802
802
803
+ /// Arguments passed to the callback in [`iter_header`].
804
+ struct HeaderLine < ' ln > {
805
+ /// Contents of the square brackets preceding this header, if present.
806
+ header_revision : Option < & ' ln str > ,
807
+ /// Raw line from the test file, including comment prefix and any revision.
808
+ original_line : & ' ln str ,
809
+ /// Remainder of the directive line, after the initial comment prefix
810
+ /// (`//` or `//@` or `#`) and revision (if any) have been stripped.
811
+ directive : & ' ln str ,
812
+ line_number : usize ,
813
+ }
814
+
803
815
fn iter_header_extra (
804
816
mode : Mode ,
805
817
suite : & str ,
806
818
poisoned : & mut bool ,
807
819
testfile : & Path ,
808
820
rdr : impl Read ,
809
821
extra_directives : & [ & str ] ,
810
- it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
822
+ it : & mut dyn FnMut ( HeaderLine < ' _ > ) ,
811
823
) {
812
824
if testfile. is_dir ( ) {
813
825
return ;
@@ -816,7 +828,7 @@ fn iter_header_extra(
816
828
// Process any extra directives supplied by the caller (e.g. because they
817
829
// are implied by the test mode), with a dummy line number of 0.
818
830
for directive in extra_directives {
819
- it ( None , directive , directive, 0 ) ;
831
+ it ( HeaderLine { header_revision : None , original_line : "" , directive, line_number : 0 } ) ;
820
832
}
821
833
822
834
let comment = if testfile. extension ( ) . is_some_and ( |e| e == "rs" ) {
@@ -841,14 +853,14 @@ fn iter_header_extra(
841
853
// Assume that any directives will be found before the first
842
854
// module or function. This doesn't seem to be an optimization
843
855
// with a warm page cache. Maybe with a cold one.
844
- let orig_ln = & ln;
856
+ let original_line = & ln;
845
857
let ln = ln. trim ( ) ;
846
858
if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
847
859
return ;
848
860
849
861
// First try to accept `ui_test` style comments
850
- } else if let Some ( ( lncfg , ln ) ) = line_directive ( comment, ln) {
851
- it ( lncfg , orig_ln , ln , line_number) ;
862
+ } else if let Some ( ( header_revision , directive ) ) = line_directive ( comment, ln) {
863
+ it ( HeaderLine { header_revision , original_line , directive , line_number } ) ;
852
864
} else if mode == Mode :: Ui && suite == "ui" && !revision_magic_comment. is_match ( ln) {
853
865
let Some ( ( _, rest) ) = line_directive ( "//" , ln) else {
854
866
continue ;
@@ -1177,8 +1189,8 @@ pub fn make_test_description<R: Read>(
1177
1189
path,
1178
1190
src,
1179
1191
extra_directives,
1180
- & mut |revision , og_ln , ln, line_number| {
1181
- if revision . is_some ( ) && revision != cfg {
1192
+ & mut |HeaderLine { header_revision , original_line , directive : ln, line_number } | {
1193
+ if header_revision . is_some ( ) && header_revision != cfg {
1182
1194
return ;
1183
1195
}
1184
1196
@@ -1202,7 +1214,7 @@ pub fn make_test_description<R: Read>(
1202
1214
} ;
1203
1215
}
1204
1216
1205
- if let Some ( ( _, post) ) = og_ln . trim_start ( ) . split_once ( "//" ) {
1217
+ if let Some ( ( _, post) ) = original_line . trim_start ( ) . split_once ( "//" ) {
1206
1218
let post = post. trim_start ( ) ;
1207
1219
if post. starts_with ( "ignore-tidy" )
1208
1220
&& config. mode == Mode :: Ui
0 commit comments