about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-30 12:36:22 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-30 12:36:22 +0200
commit3273d2f7199ed8e678c249ddbdbac78244968901 (patch)
treed0427577767b1f29e4307fec6a19faf2139e55d5
parent202659a43d2bf9444e3d14f5917bf9cc90f72b16 (diff)
error when --no-run is present without --test
-rw-r--r--src/librustdoc/config.rs7
-rw-r--r--src/test/rustdoc-ui/no-run-flag-error.rs5
-rw-r--r--src/test/rustdoc-ui/no-run-flag-error.stderr2
3 files changed, 13 insertions, 1 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 60b42cbb3a0..76aa785636d 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -459,6 +459,12 @@ impl Options {
             test_args.iter().flat_map(|s| s.split_whitespace()).map(|s| s.to_string()).collect();
 
         let should_test = matches.opt_present("test");
+        let no_run = matches.opt_present("no-run");
+
+        if !should_test && no_run {
+            diag.struct_err("option --no-run should be used with --test").emit();
+            return Err(1);
+        }
 
         let output =
             matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc"));
@@ -629,7 +635,6 @@ impl Options {
         let document_hidden = matches.opt_present("document-hidden-items");
         let run_check = matches.opt_present("check");
         let generate_redirect_map = matches.opt_present("generate-redirect-map");
-        let no_run = matches.opt_present("no-run");
 
         let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
 
diff --git a/src/test/rustdoc-ui/no-run-flag-error.rs b/src/test/rustdoc-ui/no-run-flag-error.rs
new file mode 100644
index 00000000000..a42b5a9d684
--- /dev/null
+++ b/src/test/rustdoc-ui/no-run-flag-error.rs
@@ -0,0 +1,5 @@
+// test the behavior of the --no-run flag without the --test flag
+
+// compile-flags:-Z unstable-options --no-run --test-args=--test-threads=1
+
+pub fn f() {}
diff --git a/src/test/rustdoc-ui/no-run-flag-error.stderr b/src/test/rustdoc-ui/no-run-flag-error.stderr
new file mode 100644
index 00000000000..3d34be8a420
--- /dev/null
+++ b/src/test/rustdoc-ui/no-run-flag-error.stderr
@@ -0,0 +1,2 @@
+error: option --no-run should be used with --test
+