@@ -580,6 +580,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
580580 rustdoc. arg ( "--crate-name" ) . arg ( & unit. target . crate_name ( ) ) ;
581581 add_path_args ( bcx, unit, & mut rustdoc) ;
582582 add_cap_lints ( bcx, unit, & mut rustdoc) ;
583+ add_color ( bcx, & mut rustdoc) ;
583584
584585 if unit. kind != Kind :: Host {
585586 if let Some ( ref target) = bcx. build_config . requested_target {
@@ -672,6 +673,15 @@ fn add_cap_lints(bcx: &BuildContext, unit: &Unit, cmd: &mut ProcessBuilder) {
672673 }
673674}
674675
676+ fn add_color ( bcx : & BuildContext , cmd : & mut ProcessBuilder ) {
677+ let capture_output = bcx. config . cli_unstable ( ) . compile_progress ;
678+ let shell = bcx. config . shell ( ) ;
679+ if capture_output || shell. color_choice ( ) != ColorChoice :: CargoAuto {
680+ let color = if shell. supports_color ( ) { "always" } else { "never" } ;
681+ cmd. args ( & [ "--color" , color] ) ;
682+ }
683+ }
684+
675685fn build_base_args < ' a , ' cfg > (
676686 cx : & mut Context < ' a , ' cfg > ,
677687 cmd : & mut ProcessBuilder ,
@@ -696,17 +706,8 @@ fn build_base_args<'a, 'cfg>(
696706
697707 cmd. arg ( "--crate-name" ) . arg ( & unit. target . crate_name ( ) ) ;
698708
699- add_path_args ( & cx. bcx , unit, cmd) ;
700-
701- match bcx. config . shell ( ) . color_choice ( ) {
702- ColorChoice :: Always => {
703- cmd. arg ( "--color" ) . arg ( "always" ) ;
704- }
705- ColorChoice :: Never => {
706- cmd. arg ( "--color" ) . arg ( "never" ) ;
707- }
708- ColorChoice :: CargoAuto => { }
709- }
709+ add_path_args ( bcx, unit, cmd) ;
710+ add_color ( bcx, cmd) ;
710711
711712 if bcx. build_config . json_messages ( ) {
712713 cmd. arg ( "--error-format" ) . arg ( "json" ) ;
0 commit comments