This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-9
lines changed
Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ use std::sync::Mutex;
1010pub use color_eyre;
1111use color_eyre:: eyre:: Result ;
1212use colored:: * ;
13- use comments :: ErrorMatch ;
13+ use parser :: ErrorMatch ;
1414use regex:: Regex ;
1515use rustc_stderr:: { Level , Message } ;
1616
17- use crate :: comments :: { Comments , Condition } ;
17+ use crate :: parser :: { Comments , Condition } ;
1818
19- mod comments ;
19+ mod parser ;
2020mod rustc_stderr;
2121#[ cfg( test) ]
2222mod tests;
Original file line number Diff line number Diff line change @@ -117,12 +117,8 @@ impl Comments {
117117 let next = args
118118 . next ( )
119119 . expect ( "the `position` above guarantees that there is at least one char" ) ;
120- // FIXME: this replicates the existing flexibility in our syntax. Consider requiring the colon.
121- let args = match next {
122- ':' | ' ' => args. as_str ( ) ,
123- _ => bail ! ( "expected space or `:`, got `{next}`" ) ,
124- } ;
125- ( command, args. trim ( ) )
120+ ensure ! ( next == ':' , "test command must be followed by : (or end the line)" ) ;
121+ ( command, args. as_str ( ) . trim ( ) )
126122 }
127123 } ;
128124
@@ -188,16 +184,19 @@ impl Comments {
188184 self . error_pattern = Some ( ( args. trim ( ) . to_string ( ) , l) ) ;
189185 }
190186 "stderr-per-bitwidth" => {
187+ // args are ignored (can be used as comment)
191188 ensure ! ( !self . stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice" ) ;
192189 self . stderr_per_bitwidth = true ;
193190 }
194191 command => {
195192 if let Some ( s) = command. strip_prefix ( "ignore-" ) {
193+ // args are ignored (can be sue as comment)
196194 self . ignore . push ( Condition :: parse ( s) ) ;
197195 return Ok ( ( ) ) ;
198196 }
199197
200198 if let Some ( s) = command. strip_prefix ( "only-" ) {
199+ // args are ignored (can be sue as comment)
201200 self . only . push ( Condition :: parse ( s) ) ;
202201 return Ok ( ( ) ) ;
203202 }
Original file line number Diff line number Diff line change @@ -53,3 +53,17 @@ use std::mem;
5353 Err ( _) => Ok ( ( ) ) ,
5454 }
5555}
56+
57+ #[ test]
58+ fn missing_colon_fail ( ) -> Result < ( ) > {
59+ init ( ) ;
60+ let s = r"
61+ //@stderr-per-bitwidth hello
62+ use std::mem;
63+
64+ " ;
65+ match Comments :: parse ( Path :: new ( "<dummy>" ) , s) {
66+ Ok ( _) => bail ! ( "expected parsing to fail" ) ,
67+ Err ( _) => Ok ( ( ) ) ,
68+ }
69+ }
You can’t perform that action at this time.
0 commit comments