rustdoc rejects html emits with json output

This commit is contained in:
yukang
2026-03-26 22:02:11 +08:00
parent 3a933e5bf5
commit 7e95a22e1f
6 changed files with 31 additions and 0 deletions
+12
View File
@@ -522,6 +522,18 @@ fn println_condition(condition: Condition) {
}
}
if output_format == OutputFormat::Json {
if let Some(emit_flag) = emit.iter().find_map(|emit| match emit {
EmitType::HtmlStaticFiles => Some("html-static-files"),
EmitType::HtmlNonStaticFiles => Some("html-non-static-files"),
EmitType::DepInfo(_) => None,
}) {
dcx.fatal(format!(
"the `--emit={emit_flag}` flag is not supported with `--output-format=json`",
));
}
}
let to_check = matches.opt_strs("check-theme");
if !to_check.is_empty() {
let mut content =
@@ -0,0 +1,2 @@
error: the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
@@ -0,0 +1,2 @@
error: the `--emit=html-static-files` flag is not supported with `--output-format=json`
@@ -0,0 +1,8 @@
//@ revisions: html_static html_non_static
//@ check-fail
//@[html_static] compile-flags: -Z unstable-options --output-format=json --emit=html-static-files
//@[html_non_static] compile-flags: -Z unstable-options --output-format=json --emit=html-non-static-files
//[html_static]~? ERROR the `--emit=html-static-files` flag is not supported with `--output-format=json`
//[html_non_static]~? ERROR the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
pub struct Foo;
@@ -0,0 +1,5 @@
//@ compile-flags: -Z unstable-options --show-coverage --output-format=json --emit=html-non-static-files
//@ check-fail
//~? ERROR the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
pub struct Foo;
@@ -0,0 +1,2 @@
error: the `--emit=html-non-static-files` flag is not supported with `--output-format=json`