@@ -6,6 +6,7 @@ use std::io::BufReader;
6
6
use std:: path:: { Path , PathBuf } ;
7
7
use std:: process:: Command ;
8
8
9
+ use regex:: Regex ;
9
10
use tracing:: * ;
10
11
11
12
use crate :: common:: { Config , Debugger , FailMode , Mode , PassMode } ;
@@ -47,7 +48,7 @@ impl EarlyProps {
47
48
pub fn from_reader < R : Read > ( config : & Config , testfile : & Path , rdr : R ) -> Self {
48
49
let mut props = EarlyProps :: default ( ) ;
49
50
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, _| {
51
52
config. push_name_value_directive ( ln, directives:: AUX_BUILD , & mut props. aux , |r| {
52
53
r. trim ( ) . to_string ( )
53
54
} ) ;
@@ -315,7 +316,7 @@ impl TestProps {
315
316
316
317
let mut poisoned = false ;
317
318
318
- iter_header ( config. mode , & mut poisoned, testfile, file, & mut |revision, ln, _| {
319
+ iter_header ( config. mode , & mut poisoned, testfile, file, & mut |revision, _ , ln, _| {
319
320
if revision. is_some ( ) && revision != cfg {
320
321
return ;
321
322
}
@@ -647,7 +648,7 @@ fn iter_header<R: Read>(
647
648
poisoned : & mut bool ,
648
649
testfile : & Path ,
649
650
rdr : R ,
650
- it : & mut dyn FnMut ( Option < & str > , & str , usize ) ,
651
+ it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
651
652
) {
652
653
iter_header_extra ( mode, poisoned, testfile, rdr, & [ ] , it)
653
654
}
@@ -658,7 +659,7 @@ fn iter_header_extra(
658
659
testfile : & Path ,
659
660
rdr : impl Read ,
660
661
extra_directives : & [ & str ] ,
661
- it : & mut dyn FnMut ( Option < & str > , & str , usize ) ,
662
+ it : & mut dyn FnMut ( Option < & str > , & str , & str , usize ) ,
662
663
) {
663
664
if testfile. is_dir ( ) {
664
665
return ;
@@ -667,7 +668,7 @@ fn iter_header_extra(
667
668
// Process any extra directives supplied by the caller (e.g. because they
668
669
// are implied by the test mode), with a dummy line number of 0.
669
670
for directive in extra_directives {
670
- it ( None , directive, 0 ) ;
671
+ it ( None , directive, directive , 0 ) ;
671
672
}
672
673
673
674
let comment = if testfile. extension ( ) . is_some_and ( |e| e == "rs" ) {
@@ -680,6 +681,8 @@ fn iter_header_extra(
680
681
let mut ln = String :: new ( ) ;
681
682
let mut line_number = 0 ;
682
683
684
+ let revision_magic_comment = Regex :: new ( "//(\\ [.*\\ ])~.*" ) . unwrap ( ) ;
685
+
683
686
loop {
684
687
line_number += 1 ;
685
688
ln. clear ( ) ;
@@ -690,14 +693,18 @@ fn iter_header_extra(
690
693
// Assume that any directives will be found before the first
691
694
// module or function. This doesn't seem to be an optimization
692
695
// with a warm page cache. Maybe with a cold one.
696
+ let orig_ln = & ln;
693
697
let ln = ln. trim ( ) ;
694
698
if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
695
699
return ;
696
700
697
701
// First try to accept `ui_test` style comments
698
702
} 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
+ {
701
708
// We have a comment that's *successfully* parsed as an legacy-style directive.
702
709
// We emit an error here to warn the user.
703
710
* poisoned = true ;
@@ -993,7 +1000,7 @@ pub fn make_test_description<R: Read>(
993
1000
path,
994
1001
src,
995
1002
extra_directives,
996
- & mut |revision, ln, line_number| {
1003
+ & mut |revision, orig_ln , ln, line_number| {
997
1004
if revision. is_some ( ) && revision != cfg {
998
1005
return ;
999
1006
}
@@ -1021,7 +1028,7 @@ pub fn make_test_description<R: Read>(
1021
1028
// Do not handle `// ignore-tidy` or `// ignore-tidy-*` because they are tidy directives,
1022
1029
// not compiletest directives (which would begin with `//@` for UI tests).
1023
1030
if config. mode == Mode :: Ui {
1024
- let split = og_ln . trim_start ( ) . split_once ( "//" ) ;
1031
+ let split = orig_ln . trim_start ( ) . split_once ( "//" ) ;
1025
1032
if !split
1026
1033
. map ( |( pre, post) | {
1027
1034
pre. is_empty ( ) && post. trim_start ( ) . starts_with ( "ignore-tidy" )
0 commit comments