Skip to content

Commit 3273d2f

Browse files
committed
error when --no-run is present without --test
1 parent 202659a commit 3273d2f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Diff for: src/librustdoc/config.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,12 @@ impl Options {
459459
test_args.iter().flat_map(|s| s.split_whitespace()).map(|s| s.to_string()).collect();
460460

461461
let should_test = matches.opt_present("test");
462+
let no_run = matches.opt_present("no-run");
463+
464+
if !should_test && no_run {
465+
diag.struct_err("option --no-run should be used with --test").emit();
466+
return Err(1);
467+
}
462468

463469
let output =
464470
matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc"));
@@ -629,7 +635,6 @@ impl Options {
629635
let document_hidden = matches.opt_present("document-hidden-items");
630636
let run_check = matches.opt_present("check");
631637
let generate_redirect_map = matches.opt_present("generate-redirect-map");
632-
let no_run = matches.opt_present("no-run");
633638

634639
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
635640

Diff for: src/test/rustdoc-ui/no-run-flag-error.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// test the behavior of the --no-run flag without the --test flag
2+
3+
// compile-flags:-Z unstable-options --no-run --test-args=--test-threads=1
4+
5+
pub fn f() {}

Diff for: src/test/rustdoc-ui/no-run-flag-error.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: option --no-run should be used with --test
2+

0 commit comments

Comments
 (0)