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