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