File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ static LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
3131static DEPRECATED_LINE_PATTERN : LazyLock < Regex > =
3232 LazyLock :: new ( || RegexBuilder :: new ( r#"//\s+@"# ) . build ( ) . unwrap ( ) ) ;
3333
34+ /// ```
35+ /// // Directive on its own line
36+ /// //@ correct-directive
37+ ///
38+ /// // Directive on a line after code
39+ /// struct S; //@ ignored-directive
40+ /// ```
41+ static MIXED_LINE : LazyLock < Regex > =
42+ LazyLock :: new ( || RegexBuilder :: new ( r#".*\S.*//@"# ) . build ( ) . unwrap ( ) ) ;
43+
3444struct ErrorReporter < ' a > {
3545 /// See [`Config::template`].
3646 template : & ' a str ,
@@ -63,6 +73,13 @@ fn main() -> ExitCode {
6373 continue ;
6474 }
6575
76+ if MIXED_LINE . is_match ( line) {
77+ error_reporter. print (
78+ "directives must be on their own line, directives after code are ignored" ,
79+ lineno,
80+ ) ;
81+ }
82+
6683 let Some ( cap) = LINE_PATTERN . captures ( line) else {
6784 continue ;
6885 } ;
You can’t perform that action at this time.
0 commit comments