@@ -15,6 +15,7 @@ use crate::directives::auxiliary::{AuxProps, parse_and_update_aux};
15
15
use crate :: directives:: directive_names:: {
16
16
KNOWN_DIRECTIVE_NAMES , KNOWN_HTMLDOCCK_DIRECTIVE_NAMES , KNOWN_JSONDOCCK_DIRECTIVE_NAMES ,
17
17
} ;
18
+ use crate :: directives:: line:: { DirectiveLine , line_directive} ;
18
19
use crate :: directives:: needs:: CachedNeedsConditions ;
19
20
use crate :: errors:: ErrorKind ;
20
21
use crate :: executor:: { CollectedTestDesc , ShouldPanic } ;
@@ -24,6 +25,7 @@ use crate::util::static_regex;
24
25
pub ( crate ) mod auxiliary;
25
26
mod cfg;
26
27
mod directive_names;
28
+ mod line;
27
29
mod needs;
28
30
#[ cfg( test) ]
29
31
mod tests;
@@ -820,70 +822,6 @@ impl TestProps {
820
822
}
821
823
}
822
824
823
- /// If the given line begins with the appropriate comment prefix for a directive,
824
- /// returns a struct containing various parts of the directive.
825
- fn line_directive < ' line > (
826
- line_number : usize ,
827
- original_line : & ' line str ,
828
- ) -> Option < DirectiveLine < ' line > > {
829
- // Ignore lines that don't start with the comment prefix.
830
- let after_comment =
831
- original_line. trim_start ( ) . strip_prefix ( COMPILETEST_DIRECTIVE_PREFIX ) ?. trim_start ( ) ;
832
-
833
- let revision;
834
- let raw_directive;
835
-
836
- if let Some ( after_open_bracket) = after_comment. strip_prefix ( '[' ) {
837
- // A comment like `//@[foo]` only applies to revision `foo`.
838
- let Some ( ( line_revision, after_close_bracket) ) = after_open_bracket. split_once ( ']' ) else {
839
- panic ! (
840
- "malformed condition directive: expected `{COMPILETEST_DIRECTIVE_PREFIX}[foo]`, found `{original_line}`"
841
- )
842
- } ;
843
-
844
- revision = Some ( line_revision) ;
845
- raw_directive = after_close_bracket. trim_start ( ) ;
846
- } else {
847
- revision = None ;
848
- raw_directive = after_comment;
849
- } ;
850
-
851
- Some ( DirectiveLine { line_number, revision, raw_directive } )
852
- }
853
-
854
- /// The (partly) broken-down contents of a line containing a test directive,
855
- /// which [`iter_directives`] passes to its callback function.
856
- ///
857
- /// For example:
858
- ///
859
- /// ```text
860
- /// //@ compile-flags: -O
861
- /// ^^^^^^^^^^^^^^^^^ raw_directive
862
- ///
863
- /// //@ [foo] compile-flags: -O
864
- /// ^^^ revision
865
- /// ^^^^^^^^^^^^^^^^^ raw_directive
866
- /// ```
867
- struct DirectiveLine < ' ln > {
868
- line_number : usize ,
869
- /// Some test directives start with a revision name in square brackets
870
- /// (e.g. `[foo]`), and only apply to that revision of the test.
871
- /// If present, this field contains the revision name (e.g. `foo`).
872
- revision : Option < & ' ln str > ,
873
- /// The main part of the directive, after removing the comment prefix
874
- /// and the optional revision specifier.
875
- ///
876
- /// This is "raw" because the directive's name and colon-separated value
877
- /// (if present) have not yet been extracted or checked.
878
- raw_directive : & ' ln str ,
879
- }
880
-
881
- impl < ' ln > DirectiveLine < ' ln > {
882
- fn applies_to_test_revision ( & self , test_revision : Option < & str > ) -> bool {
883
- self . revision . is_none ( ) || self . revision == test_revision
884
- }
885
- }
886
-
887
825
pub ( crate ) struct CheckDirectiveResult < ' ln > {
888
826
is_known_directive : bool ,
889
827
trailing_directive : Option < & ' ln str > ,
@@ -916,8 +854,6 @@ fn check_directive<'a>(
916
854
CheckDirectiveResult { is_known_directive, trailing_directive }
917
855
}
918
856
919
- const COMPILETEST_DIRECTIVE_PREFIX : & str = "//@" ;
920
-
921
857
fn iter_directives (
922
858
mode : TestMode ,
923
859
poisoned : & mut bool ,
0 commit comments