@@ -57,7 +57,7 @@ impl EarlyProps {
57
57
& mut poisoned,
58
58
testfile,
59
59
rdr,
60
- & mut |DirectiveLine { directive : ln, .. } | {
60
+ & mut |DirectiveLine { raw_directive : ln, .. } | {
61
61
parse_and_update_aux ( config, ln, & mut props. aux ) ;
62
62
config. parse_and_update_revisions ( testfile, ln, & mut props. revisions ) ;
63
63
} ,
@@ -344,8 +344,8 @@ impl TestProps {
344
344
& mut poisoned,
345
345
testfile,
346
346
file,
347
- & mut |DirectiveLine { header_revision , directive : ln, .. } | {
348
- if header_revision . is_some ( ) && header_revision != test_revision {
347
+ & mut |directive @ DirectiveLine { raw_directive : ln, .. } | {
348
+ if !directive . applies_to_test_revision ( test_revision) {
349
349
return ;
350
350
}
351
351
@@ -730,28 +730,37 @@ const KNOWN_HTMLDOCCK_DIRECTIVE_NAMES: &[&str] = &[
730
730
const KNOWN_JSONDOCCK_DIRECTIVE_NAMES : & [ & str ] =
731
731
& [ "count" , "!count" , "has" , "!has" , "is" , "!is" , "ismany" , "!ismany" , "set" , "!set" ] ;
732
732
733
- /// The broken-down contents of a line containing a test header directive,
733
+ /// The (partly) broken-down contents of a line containing a test directive,
734
734
/// which [`iter_header`] passes to its callback function.
735
735
///
736
736
/// For example:
737
737
///
738
738
/// ```text
739
739
/// //@ compile-flags: -O
740
- /// ^^^^^^^^^^^^^^^^^ directive
740
+ /// ^^^^^^^^^^^^^^^^^ raw_directive
741
741
///
742
742
/// //@ [foo] compile-flags: -O
743
- /// ^^^ header_revision
744
- /// ^^^^^^^^^^^^^^^^^ directive
743
+ /// ^^^ revision
744
+ /// ^^^^^^^^^^^^^^^^^ raw_directive
745
745
/// ```
746
746
struct DirectiveLine < ' ln > {
747
747
line_number : usize ,
748
- /// Some header directives start with a revision name in square brackets
748
+ /// Some test directives start with a revision name in square brackets
749
749
/// (e.g. `[foo]`), and only apply to that revision of the test.
750
750
/// If present, this field contains the revision name (e.g. `foo`).
751
- header_revision : Option < & ' ln str > ,
752
- /// The main part of the header directive, after removing the comment prefix
751
+ revision : Option < & ' ln str > ,
752
+ /// The main part of the directive, after removing the comment prefix
753
753
/// and the optional revision specifier.
754
- directive : & ' ln str ,
754
+ ///
755
+ /// This is "raw" because the directive's name and colon-separated value
756
+ /// (if present) have not yet been extracted or checked.
757
+ raw_directive : & ' ln str ,
758
+ }
759
+
760
+ impl < ' ln > DirectiveLine < ' ln > {
761
+ fn applies_to_test_revision ( & self , test_revision : Option < & str > ) -> bool {
762
+ self . revision . is_none ( ) || self . revision == test_revision
763
+ }
755
764
}
756
765
757
766
pub ( crate ) struct CheckDirectiveResult < ' ln > {
@@ -819,8 +828,8 @@ fn iter_header(
819
828
"ignore-cross-compile" ,
820
829
] ;
821
830
// Process the extra implied directives, with a dummy line number of 0.
822
- for directive in extra_directives {
823
- it ( DirectiveLine { line_number : 0 , header_revision : None , directive } ) ;
831
+ for raw_directive in extra_directives {
832
+ it ( DirectiveLine { line_number : 0 , revision : None , raw_directive } ) ;
824
833
}
825
834
}
826
835
@@ -847,14 +856,13 @@ fn iter_header(
847
856
return ;
848
857
}
849
858
850
- let Some ( ( header_revision, non_revisioned_directive_line) ) = line_directive ( comment, ln)
851
- else {
859
+ let Some ( ( revision, raw_directive) ) = line_directive ( comment, ln) else {
852
860
continue ;
853
861
} ;
854
862
855
863
// Perform unknown directive check on Rust files.
856
864
if testfile. extension ( ) . map ( |e| e == "rs" ) . unwrap_or ( false ) {
857
- let directive_ln = non_revisioned_directive_line . trim ( ) ;
865
+ let directive_ln = raw_directive . trim ( ) ;
858
866
859
867
let CheckDirectiveResult { is_known_directive, trailing_directive } =
860
868
check_directive ( directive_ln, mode, ln) ;
@@ -888,11 +896,7 @@ fn iter_header(
888
896
}
889
897
}
890
898
891
- it ( DirectiveLine {
892
- line_number,
893
- header_revision,
894
- directive : non_revisioned_directive_line,
895
- } ) ;
899
+ it ( DirectiveLine { line_number, revision, raw_directive } ) ;
896
900
}
897
901
}
898
902
@@ -1292,8 +1296,8 @@ pub fn make_test_description<R: Read>(
1292
1296
& mut local_poisoned,
1293
1297
path,
1294
1298
src,
1295
- & mut |DirectiveLine { header_revision , directive : ln, line_number } | {
1296
- if header_revision . is_some ( ) && header_revision != test_revision {
1299
+ & mut |directive @ DirectiveLine { line_number , raw_directive : ln, .. } | {
1300
+ if !directive . applies_to_test_revision ( test_revision) {
1297
1301
return ;
1298
1302
}
1299
1303
0 commit comments