Ensure that --generate-link-to-definition is only used with HTML output and is unstable

This commit is contained in:
Guillaume Gomez 2021-05-04 11:51:11 +02:00 committed by Guillaume Gomez
parent 2104bf27d4
commit 83dcd30ee0
7 changed files with 32 additions and 0 deletions

View File

@ -659,6 +659,14 @@ impl Options {
let nocapture = matches.opt_present("nocapture");
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
diag.struct_err(
"--generate-link-to-definition option can only be used with HTML output format",
)
.emit();
return Err(1);
}
let (lint_opts, describe_lints, lint_cap) =
get_cmd_lint_options(matches, error_format, &debugging_opts);

View File

@ -0,0 +1,6 @@
// This test purpose is to check that the "--generate-link-to-definition"
// option can only be used on nightly.
// compile-flags: --generate-link-to-definition
pub fn f() {}

View File

@ -0,0 +1,2 @@
error: the `-Z unstable-options` flag must also be passed to enable the flag `generate-link-to-definition`

View File

@ -0,0 +1,6 @@
// This test purpose is to check that the "--generate-link-to-definition"
// option can only be used with HTML generation.
// compile-flags: -Zunstable-options --generate-link-to-definition --output-format json
pub fn f() {}

View File

@ -0,0 +1,2 @@
error: --generate-link-to-definition option can only be used with HTML output format

View File

@ -0,0 +1,6 @@
// This test purpose is to check that the "--generate-link-to-definition"
// option can only be used with HTML generation.
// compile-flags: -Zunstable-options --generate-link-to-definition --show-coverage
pub fn f() {}

View File

@ -0,0 +1,2 @@
error: --generate-link-to-definition option can only be used with HTML output format