@@ -54,7 +54,7 @@ impl EarlyProps {
54
54
& mut poisoned,
55
55
testfile,
56
56
rdr,
57
- & mut |_ , _ , ln, _ | {
57
+ & mut |IterHeaderCallbackArgs { 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 |IterHeaderCallbackArgs { 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 ( IterHeaderCallbackArgs < ' _ > ) ,
681
681
) {
682
682
iter_header_extra ( mode, suite, poisoned, testfile, rdr, & [ ] , it)
683
683
}
@@ -800,14 +800,25 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
800
800
"unset-rustc-env" ,
801
801
] ;
802
802
803
+ struct IterHeaderCallbackArgs < ' ln > {
804
+ /// Contents of the square brackets preceding this header, if present.
805
+ header_revision : Option < & ' ln str > ,
806
+ /// Raw line from the test file, including comment prefix and any revision.
807
+ original_line : & ' ln str ,
808
+ /// Remainder of the directive line, after the initial comment prefix
809
+ /// (`//` or `//@` or `#`) and revision (if any) have been stripped.
810
+ directive : & ' ln str ,
811
+ line_number : usize ,
812
+ }
813
+
803
814
fn iter_header_extra (
804
815
mode : Mode ,
805
816
suite : & str ,
806
817
poisoned : & mut bool ,
807
818
testfile : & Path ,
808
819
rdr : impl Read ,
809
820
extra_directives : & [ & str ] ,
810
- it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
821
+ it : & mut dyn FnMut ( IterHeaderCallbackArgs < ' _ > ) ,
811
822
) {
812
823
if testfile. is_dir ( ) {
813
824
return ;
@@ -816,7 +827,12 @@ fn iter_header_extra(
816
827
// Process any extra directives supplied by the caller (e.g. because they
817
828
// are implied by the test mode), with a dummy line number of 0.
818
829
for directive in extra_directives {
819
- it ( None , directive, directive, 0 ) ;
830
+ it ( IterHeaderCallbackArgs {
831
+ header_revision : None ,
832
+ original_line : directive,
833
+ directive,
834
+ line_number : 0 ,
835
+ } ) ;
820
836
}
821
837
822
838
let comment = if testfile. extension ( ) . is_some_and ( |e| e == "rs" ) {
@@ -841,14 +857,14 @@ fn iter_header_extra(
841
857
// Assume that any directives will be found before the first
842
858
// module or function. This doesn't seem to be an optimization
843
859
// with a warm page cache. Maybe with a cold one.
844
- let orig_ln = & ln;
860
+ let original_line = & ln;
845
861
let ln = ln. trim ( ) ;
846
862
if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
847
863
return ;
848
864
849
865
// 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) ;
866
+ } else if let Some ( ( header_revision , directive ) ) = line_directive ( comment, ln) {
867
+ it ( IterHeaderCallbackArgs { header_revision , original_line , directive , line_number } ) ;
852
868
} else if mode == Mode :: Ui && suite == "ui" && !revision_magic_comment. is_match ( ln) {
853
869
let Some ( ( _, rest) ) = line_directive ( "//" , ln) else {
854
870
continue ;
@@ -1177,8 +1193,13 @@ pub fn make_test_description<R: Read>(
1177
1193
path,
1178
1194
src,
1179
1195
extra_directives,
1180
- & mut |revision, og_ln, ln, line_number| {
1181
- if revision. is_some ( ) && revision != cfg {
1196
+ & mut |IterHeaderCallbackArgs {
1197
+ header_revision,
1198
+ original_line,
1199
+ directive : ln,
1200
+ line_number,
1201
+ } | {
1202
+ if header_revision. is_some ( ) && header_revision != cfg {
1182
1203
return ;
1183
1204
}
1184
1205
@@ -1202,7 +1223,7 @@ pub fn make_test_description<R: Read>(
1202
1223
} ;
1203
1224
}
1204
1225
1205
- if let Some ( ( _, post) ) = og_ln . trim_start ( ) . split_once ( "//" ) {
1226
+ if let Some ( ( _, post) ) = original_line . trim_start ( ) . split_once ( "//" ) {
1206
1227
let post = post. trim_start ( ) ;
1207
1228
if post. starts_with ( "ignore-tidy" )
1208
1229
&& config. mode == Mode :: Ui
0 commit comments