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(|| {
31
31
static DEPRECATED_LINE_PATTERN : LazyLock < Regex > =
32
32
LazyLock :: new ( || RegexBuilder :: new ( r#"//\s+@"# ) . build ( ) . unwrap ( ) ) ;
33
33
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
+
34
44
struct ErrorReporter < ' a > {
35
45
/// See [`Config::template`].
36
46
template : & ' a str ,
@@ -63,6 +73,13 @@ fn main() -> ExitCode {
63
73
continue ;
64
74
}
65
75
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
+
66
83
let Some ( cap) = LINE_PATTERN . captures ( line) else {
67
84
continue ;
68
85
} ;
You can’t perform that action at this time.
0 commit comments