File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -350,15 +350,30 @@ fn handle_explain(code: &str,
350350
351351fn check_cfg ( sopts : & config:: Options ,
352352 output : ErrorOutputType ) {
353- fn is_meta_list ( item : & ast:: MetaItem ) -> bool {
353+ let mut emitter: Box < Emitter > = match output {
354+ config:: ErrorOutputType :: HumanReadable ( color_config) => {
355+ Box :: new ( errors:: emitter:: BasicEmitter :: stderr ( color_config) )
356+ }
357+ config:: ErrorOutputType :: Json => Box :: new ( errors:: json:: JsonEmitter :: basic ( ) ) ,
358+ } ;
359+
360+ let mut saw_invalid_predicate = false ;
361+ for item in sopts. cfg . iter ( ) {
354362 match item. node {
355- ast:: MetaItem_ :: MetaList ( ..) => true ,
356- _ => false ,
363+ ast:: MetaList ( ref pred, _) => {
364+ saw_invalid_predicate = true ;
365+ emitter. emit ( None ,
366+ & format ! ( "invalid predicate in --cfg command line argument: `{}`" ,
367+ pred) ,
368+ None ,
369+ errors:: Level :: Fatal ) ;
370+ }
371+ _ => { } ,
357372 }
358373 }
359374
360- if sopts . cfg . iter ( ) . any ( |item| is_meta_list ( & * item ) ) {
361- early_error ( output , "predicates are not allowed in --cfg" ) ;
375+ if saw_invalid_predicate {
376+ panic ! ( errors :: FatalError ) ;
362377 }
363378}
364379
Original file line number Diff line number Diff line change 99// except according to those terms.
1010
1111// compile-flags: --cfg foo(bar)
12- // error-pattern: predicates are not allowed in --cfg
12+ // error-pattern: invalid predicate in --cfg command line argument: `foo`
1313fn main ( ) { }
You can’t perform that action at this time.
0 commit comments