Rollup merge of #129050 - GuillaumeGomez:generate-link-to-definition-warning, r=notriddle

Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML

Fixes https://github.com/rust-lang/docs.rs/issues/2581.

It's a bit weird to emit an error in this case anyway, a warning is more than enough.

r? ``@notriddle``
This commit is contained in:
Matthias Krüger 2024-08-13 21:11:14 +02:00 committed by GitHub
commit 5ef33d4c61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 12 deletions

View File

@ -733,9 +733,11 @@ fn println_condition(condition: Condition) {
let html_no_source = matches.opt_present("html-no-source");
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
dcx.fatal(
"--generate-link-to-definition option can only be used with HTML output format",
);
dcx.struct_warn(
"`--generate-link-to-definition` option can only be used with HTML output format",
)
.with_note("`--generate-link-to-definition` option will be ignored")
.emit();
}
let scrape_examples_options = ScrapeExamplesOptions::new(matches, dcx);

View File

@ -2,5 +2,6 @@
// option can only be used with HTML generation.
//@ compile-flags: -Zunstable-options --generate-link-to-definition --output-format json
//@ check-pass
pub fn f() {}

View File

@ -1,2 +1,4 @@
error: --generate-link-to-definition option can only be used with HTML output format
warning: `--generate-link-to-definition` option can only be used with HTML output format
|
= note: `--generate-link-to-definition` option will be ignored

View File

@ -1,6 +0,0 @@
// 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

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