Skip to content

added --no-run option for rustdoc #83857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 1, 2021
7 changes: 6 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc-ui/no-run-flag-error.rs
Original file line number Diff line number Diff line change
@@ -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() {}
2 changes: 2 additions & 0 deletions src/test/rustdoc-ui/no-run-flag-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: option --no-run should be used with --test