@@ -646,6 +646,8 @@ impl TestProps {
646
646
}
647
647
648
648
/// Extract a `(Option<line_config>, directive)` directive from a line if comment is present.
649
+ ///
650
+ /// See [`HeaderLine`] for a diagram.
649
651
pub fn line_directive < ' line > (
650
652
comment : & str ,
651
653
ln : & ' line str ,
@@ -790,16 +792,32 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
790
792
"unset-rustc-env" ,
791
793
] ;
792
794
793
- /// Arguments passed to the callback in [`iter_header`].
795
+ /// The broken-down contents of a line containing a test header directive,
796
+ /// which [`iter_header`] passes to its callback function.
797
+ ///
798
+ /// For example:
799
+ ///
800
+ /// ```text
801
+ /// //@ compile-flags: -O
802
+ /// ^^^^^^^^^^^^^^^^^ directive
803
+ /// ^^^^^^^^^^^^^^^^^^^^^ original_line
804
+ ///
805
+ /// //@ [foo] compile-flags: -O
806
+ /// ^^^ header_revision
807
+ /// ^^^^^^^^^^^^^^^^^ directive
808
+ /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ original_line
809
+ /// ```
794
810
struct HeaderLine < ' ln > {
795
- /// Contents of the square brackets preceding this header, if present.
796
- header_revision : Option < & ' ln str > ,
811
+ line_number : usize ,
797
812
/// Raw line from the test file, including comment prefix and any revision.
798
813
original_line : & ' ln str ,
799
- /// Remainder of the directive line, after the initial comment prefix
800
- /// (`//` or `//@` or `#`) and revision (if any) have been stripped.
814
+ /// Some header directives start with a revision name in square brackets
815
+ /// (e.g. `[foo]`), and only apply to that revision of the test.
816
+ /// If present, this field contains the revision name (e.g. `foo`).
817
+ header_revision : Option < & ' ln str > ,
818
+ /// The main part of the header directive, after removing the comment prefix
819
+ /// and the optional revision specifier.
801
820
directive : & ' ln str ,
802
- line_number : usize ,
803
821
}
804
822
805
823
fn iter_header (
@@ -831,7 +849,7 @@ fn iter_header(
831
849
] ;
832
850
// Process the extra implied directives, with a dummy line number of 0.
833
851
for directive in extra_directives {
834
- it ( HeaderLine { header_revision : None , original_line : "" , directive , line_number : 0 } ) ;
852
+ it ( HeaderLine { line_number : 0 , original_line : "" , header_revision : None , directive } ) ;
835
853
}
836
854
}
837
855
@@ -865,7 +883,7 @@ fn iter_header(
865
883
866
884
// First try to accept `ui_test` style comments
867
885
} else if let Some ( ( header_revision, directive) ) = line_directive ( comment, ln) {
868
- it ( HeaderLine { header_revision , original_line, directive , line_number } ) ;
886
+ it ( HeaderLine { line_number , original_line, header_revision , directive } ) ;
869
887
} else if mode == Mode :: Ui && suite == "ui" && !REVISION_MAGIC_COMMENT_RE . is_match ( ln) {
870
888
let Some ( ( _, rest) ) = line_directive ( "//" , ln) else {
871
889
continue ;
0 commit comments