@@ -6,6 +6,7 @@ use std::io::BufReader;
66use std:: path:: { Path , PathBuf } ;
77use std:: process:: Command ;
88
9+ use regex:: Regex ;
910use tracing:: * ;
1011
1112use crate :: common:: { Config , Debugger , FailMode , Mode , PassMode } ;
@@ -47,7 +48,7 @@ impl EarlyProps {
4748 pub fn from_reader < R : Read > ( config : & Config , testfile : & Path , rdr : R ) -> Self {
4849 let mut props = EarlyProps :: default ( ) ;
4950 let mut poisoned = false ;
50- iter_header ( config. mode , & mut poisoned, testfile, rdr, & mut |_, ln, _| {
51+ iter_header ( config. mode , & mut poisoned, testfile, rdr, & mut |_, _ , ln, _| {
5152 config. push_name_value_directive ( ln, directives:: AUX_BUILD , & mut props. aux , |r| {
5253 r. trim ( ) . to_string ( )
5354 } ) ;
@@ -315,7 +316,7 @@ impl TestProps {
315316
316317 let mut poisoned = false ;
317318
318- iter_header ( config. mode , & mut poisoned, testfile, file, & mut |revision, ln, _| {
319+ iter_header ( config. mode , & mut poisoned, testfile, file, & mut |revision, _ , ln, _| {
319320 if revision. is_some ( ) && revision != cfg {
320321 return ;
321322 }
@@ -647,7 +648,7 @@ fn iter_header<R: Read>(
647648 poisoned : & mut bool ,
648649 testfile : & Path ,
649650 rdr : R ,
650- it : & mut dyn FnMut ( Option < & str > , & str , usize ) ,
651+ it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
651652) {
652653 iter_header_extra ( mode, poisoned, testfile, rdr, & [ ] , it)
653654}
@@ -658,7 +659,7 @@ fn iter_header_extra(
658659 testfile : & Path ,
659660 rdr : impl Read ,
660661 extra_directives : & [ & str ] ,
661- it : & mut dyn FnMut ( Option < & str > , & str , usize ) ,
662+ it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
662663) {
663664 if testfile. is_dir ( ) {
664665 return ;
@@ -667,7 +668,7 @@ fn iter_header_extra(
667668 // Process any extra directives supplied by the caller (e.g. because they
668669 // are implied by the test mode), with a dummy line number of 0.
669670 for directive in extra_directives {
670- it ( None , directive, 0 ) ;
671+ it ( None , directive, directive , 0 ) ;
671672 }
672673
673674 let comment = if testfile. extension ( ) . is_some_and ( |e| e == "rs" ) {
@@ -680,6 +681,8 @@ fn iter_header_extra(
680681 let mut ln = String :: new ( ) ;
681682 let mut line_number = 0 ;
682683
684+ let revision_magic_comment = Regex :: new ( "//(\\ [.*\\ ])~.*" ) . unwrap ( ) ;
685+
683686 loop {
684687 line_number += 1 ;
685688 ln. clear ( ) ;
@@ -690,14 +693,18 @@ fn iter_header_extra(
690693 // Assume that any directives will be found before the first
691694 // module or function. This doesn't seem to be an optimization
692695 // with a warm page cache. Maybe with a cold one.
696+ let orig_ln = & ln;
693697 let ln = ln. trim ( ) ;
694698 if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
695699 return ;
696700
697701 // First try to accept `ui_test` style comments
698702 } else if let Some ( ( lncfg, ln) ) = line_directive ( comment, ln) {
699- it ( lncfg, ln, line_number) ;
700- } else if mode == Mode :: Ui && matches ! ( line_directive( "//" , ln) , Some ( ( Some ( _) , _) ) ) {
703+ it ( lncfg, orig_ln, ln, line_number) ;
704+ } else if mode == Mode :: Ui
705+ && !revision_magic_comment. is_match ( ln)
706+ && matches ! ( line_directive( "//" , ln) , Some ( ( Some ( _) , _) ) )
707+ {
701708 // We have a comment that's *successfully* parsed as an legacy-style directive.
702709 // We emit an error here to warn the user.
703710 * poisoned = true ;
@@ -993,7 +1000,7 @@ pub fn make_test_description<R: Read>(
9931000 path,
9941001 src,
9951002 extra_directives,
996- & mut |revision, ln, line_number| {
1003+ & mut |revision, orig_ln , ln, line_number| {
9971004 if revision. is_some ( ) && revision != cfg {
9981005 return ;
9991006 }
@@ -1021,7 +1028,7 @@ pub fn make_test_description<R: Read>(
10211028 // Do not handle `// ignore-tidy` or `// ignore-tidy-*` because they are tidy directives,
10221029 // not compiletest directives (which would begin with `//@` for UI tests).
10231030 if config. mode == Mode :: Ui {
1024- let split = og_ln . trim_start ( ) . split_once ( "//" ) ;
1031+ let split = orig_ln . trim_start ( ) . split_once ( "//" ) ;
10251032 if !split
10261033 . map ( |( pre, post) | {
10271034 pre. is_empty ( ) && post. trim_start ( ) . starts_with ( "ignore-tidy" )
0 commit comments