@@ -54,7 +54,7 @@ impl EarlyProps {
5454 & mut poisoned,
5555 testfile,
5656 rdr,
57- & mut |_ , _ , ln, _ | {
57+ & mut |IterHeaderCallbackArgs { directive : ln, .. } | {
5858 config. push_name_value_directive ( ln, directives:: AUX_BUILD , & mut props. aux , |r| {
5959 r. trim ( ) . to_string ( )
6060 } ) ;
@@ -329,8 +329,8 @@ impl TestProps {
329329 & mut poisoned,
330330 testfile,
331331 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 {
334334 return ;
335335 }
336336
@@ -677,7 +677,7 @@ fn iter_header<R: Read>(
677677 poisoned : & mut bool ,
678678 testfile : & Path ,
679679 rdr : R ,
680- it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
680+ it : & mut dyn FnMut ( IterHeaderCallbackArgs < ' _ > ) ,
681681) {
682682 iter_header_extra ( mode, suite, poisoned, testfile, rdr, & [ ] , it)
683683}
@@ -800,14 +800,25 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
800800 "unset-rustc-env" ,
801801] ;
802802
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+
803814fn iter_header_extra (
804815 mode : Mode ,
805816 suite : & str ,
806817 poisoned : & mut bool ,
807818 testfile : & Path ,
808819 rdr : impl Read ,
809820 extra_directives : & [ & str ] ,
810- it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
821+ it : & mut dyn FnMut ( IterHeaderCallbackArgs < ' _ > ) ,
811822) {
812823 if testfile. is_dir ( ) {
813824 return ;
@@ -816,7 +827,12 @@ fn iter_header_extra(
816827 // Process any extra directives supplied by the caller (e.g. because they
817828 // are implied by the test mode), with a dummy line number of 0.
818829 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+ } ) ;
820836 }
821837
822838 let comment = if testfile. extension ( ) . is_some_and ( |e| e == "rs" ) {
@@ -841,14 +857,14 @@ fn iter_header_extra(
841857 // Assume that any directives will be found before the first
842858 // module or function. This doesn't seem to be an optimization
843859 // with a warm page cache. Maybe with a cold one.
844- let orig_ln = & ln;
860+ let original_line = & ln;
845861 let ln = ln. trim ( ) ;
846862 if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
847863 return ;
848864
849865 // 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 } ) ;
852868 } else if mode == Mode :: Ui && suite == "ui" && !revision_magic_comment. is_match ( ln) {
853869 let Some ( ( _, rest) ) = line_directive ( "//" , ln) else {
854870 continue ;
@@ -1177,8 +1193,13 @@ pub fn make_test_description<R: Read>(
11771193 path,
11781194 src,
11791195 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 {
11821203 return ;
11831204 }
11841205
@@ -1202,7 +1223,7 @@ pub fn make_test_description<R: Read>(
12021223 } ;
12031224 }
12041225
1205- if let Some ( ( _, post) ) = og_ln . trim_start ( ) . split_once ( "//" ) {
1226+ if let Some ( ( _, post) ) = original_line . trim_start ( ) . split_once ( "//" ) {
12061227 let post = post. trim_start ( ) ;
12071228 if post. starts_with ( "ignore-tidy" )
12081229 && config. mode == Mode :: Ui
0 commit comments