@@ -585,16 +585,32 @@ fn phase_cargo_runner(binary: &str, binary_args: env::Args) {
585
585
}
586
586
587
587
let mut cmd = miri ( ) ;
588
- // Forward rustc arguments. We need to patch "--extern" filenames because
589
- // we forced a check-only build without cargo knowing about that: replace `.rlib` suffix by `.rmeta`.
588
+ // Forward rustc arguments.
589
+ // We need to patch "--extern" filenames because we forced a check-only
590
+ // build without cargo knowing about that: replace `.rlib` suffix by
591
+ // `.rmeta`.
592
+ // We also need to remove `--error-format` as cargo specifies that to be JSON,
593
+ // but when we run here, cargo does not interpret the JSON any more. `--json`
594
+ // then also nees to be dropped.
590
595
let mut args = info. args . into_iter ( ) ;
591
596
let extern_flag = "--extern" ;
597
+ let error_format_flag = "--error-format" ;
598
+ let json_flag = "--json" ;
592
599
while let Some ( arg) = args. next ( ) {
593
600
if arg == extern_flag {
601
+ // `--extern` is always passed as a separate argument by cargo.
594
602
let next_arg = args. next ( ) . expect ( "`--extern` should be followed by a filename" ) ;
595
603
let next_arg = next_arg. strip_suffix ( ".rlib" ) . expect ( "all extern filenames should end in `.rlib`" ) ;
596
604
cmd. arg ( extern_flag) ;
597
605
cmd. arg ( format ! ( "{}.rmeta" , next_arg) ) ;
606
+ } else if arg. starts_with ( error_format_flag) {
607
+ let suffix = & arg[ error_format_flag. len ( ) ..] ;
608
+ assert ! ( suffix. starts_with( '=' ) ) ;
609
+ // Drop this argument.
610
+ } else if arg. starts_with ( json_flag) {
611
+ let suffix = & arg[ json_flag. len ( ) ..] ;
612
+ assert ! ( suffix. starts_with( '=' ) ) ;
613
+ // Drop this argument.
598
614
} else {
599
615
cmd. arg ( arg) ;
600
616
}
0 commit comments