File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,11 @@ pub fn fix_maybe_exec_rustc() -> CargoResult<bool> {
281
281
// - If the fix succeeded, show any remaining warnings.
282
282
let mut cmd = Command :: new ( & rustc) ;
283
283
args. apply ( & mut cmd) ;
284
+ for arg in args. format_args {
285
+ // Add any json/error format arguments that Cargo wants. This allows
286
+ // things like colored output to work correctly.
287
+ cmd. arg ( arg) ;
288
+ }
284
289
exit_with ( cmd. status ( ) . context ( "failed to spawn rustc" ) ?) ;
285
290
}
286
291
@@ -587,6 +592,7 @@ struct FixArgs {
587
592
other : Vec < OsString > ,
588
593
rustc : Option < PathBuf > ,
589
594
clippy_args : Vec < String > ,
595
+ format_args : Vec < String > ,
590
596
}
591
597
592
598
enum PrepareFor {
@@ -627,6 +633,7 @@ impl FixArgs {
627
633
if s. starts_with ( "--error-format=" ) || s. starts_with ( "--json=" ) {
628
634
// Cargo may add error-format in some cases, but `cargo
629
635
// fix` wants to add its own.
636
+ ret. format_args . push ( s. to_string ( ) ) ;
630
637
continue ;
631
638
}
632
639
}
Original file line number Diff line number Diff line change @@ -1289,3 +1289,22 @@ fn fix_with_clippy() {
1289
1289
"
1290
1290
) ;
1291
1291
}
1292
+
1293
+ #[ cargo_test]
1294
+ fn fix_color_message ( ) {
1295
+ // Check that color appears in diagnostics.
1296
+ let p = project ( )
1297
+ . file ( "src/lib.rs" , "std::compile_error!{\" color test\" }" )
1298
+ . build ( ) ;
1299
+
1300
+ p. cargo ( "fix --allow-no-vcs --color=always" )
1301
+ . with_stderr_contains ( "[..]\x1b [[..]" )
1302
+ . with_status ( 101 )
1303
+ . run ( ) ;
1304
+
1305
+ p. cargo ( "fix --allow-no-vcs --color=never" )
1306
+ . with_stderr_contains ( "error: color test" )
1307
+ . with_stderr_does_not_contain ( "[..]\x1b [[..]" )
1308
+ . with_status ( 101 )
1309
+ . run ( ) ;
1310
+ }
You can’t perform that action at this time.
0 commit comments