Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 83dcd30

Browse files
Ensure that --generate-link-to-definition is only used with HTML output and is unstable
1 parent 2104bf2 commit 83dcd30

7 files changed

+32
-0
lines changed

src/librustdoc/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,14 @@ impl Options {
659659
let nocapture = matches.opt_present("nocapture");
660660
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
661661

662+
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
663+
diag.struct_err(
664+
"--generate-link-to-definition option can only be used with HTML output format",
665+
)
666+
.emit();
667+
return Err(1);
668+
}
669+
662670
let (lint_opts, describe_lints, lint_cap) =
663671
get_cmd_lint_options(matches, error_format, &debugging_opts);
664672

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This test purpose is to check that the "--generate-link-to-definition"
2+
// option can only be used on nightly.
3+
4+
// compile-flags: --generate-link-to-definition
5+
6+
pub fn f() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `-Z unstable-options` flag must also be passed to enable the flag `generate-link-to-definition`
2+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This test purpose is to check that the "--generate-link-to-definition"
2+
// option can only be used with HTML generation.
3+
4+
// compile-flags: -Zunstable-options --generate-link-to-definition --output-format json
5+
6+
pub fn f() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: --generate-link-to-definition option can only be used with HTML output format
2+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This test purpose is to check that the "--generate-link-to-definition"
2+
// option can only be used with HTML generation.
3+
4+
// compile-flags: -Zunstable-options --generate-link-to-definition --show-coverage
5+
6+
pub fn f() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: --generate-link-to-definition option can only be used with HTML output format
2+

0 commit comments

Comments
 (0)