File tree 2 files changed +21
-6
lines changed
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,
350
350
351
351
fn check_cfg ( sopts : & config:: Options ,
352
352
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 ( ) {
354
362
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
+ _ => { } ,
357
372
}
358
373
}
359
374
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 ) ;
362
377
}
363
378
}
364
379
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
// 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`
13
13
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments