Skip to content

Commit 99ed7ea

Browse files
committed
Extract & reuse add_error_format for rustdoc too
1 parent a14f7fe commit 99ed7ea

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
605605
rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat));
606606
}
607607

608-
if bcx.build_config.json_messages() {
609-
rustdoc.arg("--error-format").arg("json");
610-
}
608+
add_error_format(bcx, &mut rustdoc);
611609

612610
if let Some(ref args) = bcx.extra_args_for(unit) {
613611
rustdoc.args(args);
@@ -706,6 +704,14 @@ fn add_color(bcx: &BuildContext, cmd: &mut ProcessBuilder) {
706704
}
707705
}
708706

707+
fn add_error_format(bcx: &BuildContext, cmd: &mut ProcessBuilder) {
708+
match bcx.build_config.message_format {
709+
MessageFormat::Human => (),
710+
MessageFormat::Json => { cmd.arg("--error-format").arg("json"); },
711+
MessageFormat::Short => { cmd.arg("--error-format").arg("short"); },
712+
}
713+
}
714+
709715
fn build_base_args<'a, 'cfg>(
710716
cx: &mut Context<'a, 'cfg>,
711717
cmd: &mut ProcessBuilder,
@@ -732,12 +738,7 @@ fn build_base_args<'a, 'cfg>(
732738

733739
add_path_args(bcx, unit, cmd);
734740
add_color(bcx, cmd);
735-
736-
match bcx.build_config.message_format {
737-
MessageFormat::Human => (),
738-
MessageFormat::Json => { cmd.arg("--error-format").arg("json"); },
739-
MessageFormat::Short => { cmd.arg("--error-format").arg("short"); },
740-
}
741+
add_error_format(bcx, cmd);
741742

742743
if !test {
743744
for crate_type in crate_types.iter() {

0 commit comments

Comments
 (0)