Skip to content

Commit e0a8361

Browse files
committed
Auto merge of #153895 - notriddle:no-emit-test, r=fmease
rustdoc: error out on `--test` with `--emit` These options don't behave reasonably when combined right now, and there are no tests and no docs for how they should. For the short term, make this a fatal error. If we decide to assign this some semantics, then we can do that at any time.
2 parents 9f0615c + 77eea39 commit e0a8361

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/librustdoc/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,13 @@ impl Options {
462462
return None;
463463
}
464464

465+
let should_test = matches.opt_present("test");
466+
465467
let mut emit = FxIndexMap::<_, EmitType>::default();
466468
for list in matches.opt_strs("emit") {
469+
if should_test {
470+
dcx.fatal("the `--test` flag and the `--emit` flag are not supported together");
471+
}
467472
for kind in list.split(',') {
468473
match kind.parse() {
469474
Ok(kind) => {
@@ -634,7 +639,6 @@ impl Options {
634639
let test_args: Vec<String> =
635640
test_args.iter().flat_map(|s| s.split_whitespace()).map(|s| s.to_string()).collect();
636641

637-
let should_test = matches.opt_present("test");
638642
let no_run = matches.opt_present("no-run");
639643

640644
if !should_test && no_run {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags:--test --emit=dep-info -Z unstable-options
2+
//@ check-fail
3+
//~? ERROR the `--test` flag and the `--emit` flag
4+
5+
//! This example intentionally left blank.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `--test` flag and the `--emit` flag are not supported together
2+

0 commit comments

Comments
 (0)