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