Skip to content

Commit 5b1e299

Browse files
authored
Unrolled build for #154421
Rollup merge of #154421 - chenyukang:yukang-fix-154395-rustdoc-json-emit-conflict, r=aDotInTheVoid Rustdoc rejects html emits with json output Fixes #154395
2 parents fda6d37 + 7e95a22 commit 5b1e299

6 files changed

Lines changed: 31 additions & 0 deletions

src/librustdoc/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ impl Options {
522522
}
523523
}
524524

525+
if output_format == OutputFormat::Json {
526+
if let Some(emit_flag) = emit.iter().find_map(|emit| match emit {
527+
EmitType::HtmlStaticFiles => Some("html-static-files"),
528+
EmitType::HtmlNonStaticFiles => Some("html-non-static-files"),
529+
EmitType::DepInfo(_) => None,
530+
}) {
531+
dcx.fatal(format!(
532+
"the `--emit={emit_flag}` flag is not supported with `--output-format=json`",
533+
));
534+
}
535+
}
536+
525537
let to_check = matches.opt_strs("check-theme");
526538
if !to_check.is_empty() {
527539
let mut content =
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `--emit=html-static-files` flag is not supported with `--output-format=json`
2+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ revisions: html_static html_non_static
2+
//@ check-fail
3+
//@[html_static] compile-flags: -Z unstable-options --output-format=json --emit=html-static-files
4+
//@[html_non_static] compile-flags: -Z unstable-options --output-format=json --emit=html-non-static-files
5+
//[html_static]~? ERROR the `--emit=html-static-files` flag is not supported with `--output-format=json`
6+
//[html_non_static]~? ERROR the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
7+
8+
pub struct Foo;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags: -Z unstable-options --show-coverage --output-format=json --emit=html-non-static-files
2+
//@ check-fail
3+
//~? ERROR the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
4+
5+
pub struct Foo;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `--emit=html-non-static-files` flag is not supported with `--output-format=json`
2+

0 commit comments

Comments
 (0)