Skip to content

Rollup of 3 pull requests #83978

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ where
}
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum FnKind<'a> {
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
ItemFn(Ident, &'a Generics<'a>, FnHeader, &'a Visibility<'a>),
14 changes: 7 additions & 7 deletions compiler/rustc_interface/src/callbacks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Throughout the compiler tree, there are several places which want to have
//! access to state or queries while being inside crates that are dependencies
//! of librustc_middle. To facilitate this, we have the
//! of `rustc_middle`. To facilitate this, we have the
//! `rustc_data_structures::AtomicRef` type, which allows us to setup a global
//! static which can then be set in this file at program startup.
//!
@@ -13,8 +13,8 @@ use rustc_errors::{Diagnostic, TRACK_DIAGNOSTICS};
use rustc_middle::ty::tls;
use std::fmt;

/// This is a callback from librustc_ast as it cannot access the implicit state
/// in librustc_middle otherwise.
/// This is a callback from `rustc_ast` as it cannot access the implicit state
/// in `rustc_middle` otherwise.
fn span_debug(span: rustc_span::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
tls::with_opt(|tcx| {
if let Some(tcx) = tcx {
@@ -25,8 +25,8 @@ fn span_debug(span: rustc_span::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result
})
}

/// This is a callback from librustc_ast as it cannot access the implicit state
/// in librustc_middle otherwise. It is used to when diagnostic messages are
/// This is a callback from `rustc_ast` as it cannot access the implicit state
/// in `rustc_middle` otherwise. It is used to when diagnostic messages are
/// emitted and stores them in the current query, if there is one.
fn track_diagnostic(diagnostic: &Diagnostic) {
tls::with_context_opt(|icx| {
@@ -39,8 +39,8 @@ fn track_diagnostic(diagnostic: &Diagnostic) {
})
}

/// This is a callback from librustc_hir as it cannot access the implicit state
/// in librustc_middle otherwise.
/// This is a callback from `rustc_hir` as it cannot access the implicit state
/// in `rustc_middle` otherwise.
fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DefId({}:{}", def_id.krate, def_id.index.index())?;
tls::with_opt(|opt_tcx| {
27 changes: 13 additions & 14 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
@@ -378,6 +378,17 @@ impl Options {
}
}

// check for `--output-format=json`
if !matches!(matches.opt_str("output-format").as_deref(), None | Some("html"))
&& !matches.opt_present("show-coverage")
&& !nightly_options::is_unstable_enabled(matches)
{
rustc_session::early_error(
error_format,
"the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578)",
);
}

let to_check = matches.opt_strs("check-theme");
if !to_check.is_empty() {
let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
@@ -574,13 +585,7 @@ impl Options {
let output_format = match matches.opt_str("output-format") {
Some(s) => match OutputFormat::try_from(s.as_str()) {
Ok(out_fmt) => {
if out_fmt.is_json()
&& !(show_coverage || nightly_options::match_is_nightly_build(matches))
{
diag.struct_err("json output format isn't supported for doc generation")
.emit();
return Err(1);
} else if !out_fmt.is_json() && show_coverage {
if !out_fmt.is_json() && show_coverage {
diag.struct_err(
"html output format isn't supported for the --show-coverage option",
)
@@ -702,16 +707,10 @@ impl Options {

/// Prints deprecation warnings for deprecated options
fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) {
let deprecated_flags = ["input-format", "output-format", "no-defaults", "passes"];
let deprecated_flags = ["input-format", "no-defaults", "passes"];

for flag in deprecated_flags.iter() {
if matches.opt_present(flag) {
if *flag == "output-format"
&& (matches.opt_present("show-coverage")
|| nightly_options::match_is_nightly_build(matches))
{
continue;
}
let mut err = diag.struct_warn(&format!("the `{}` flag is deprecated", flag));
err.note(
"see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
4 changes: 4 additions & 0 deletions src/test/run-make/unstable-flag-required/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-include ../../run-make-fulldeps/tools.mk

all:
$(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr
3 changes: 3 additions & 0 deletions src/test/run-make/unstable-flag-required/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a collection of tests that verify `--unstable-options` is required.
It should eventually be removed in favor of UI tests once compiletest stops
passing --unstable-options by default (#82639).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578)

1 change: 1 addition & 0 deletions src/test/run-make/unstable-flag-required/x.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// nothing to see here
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/output-format-html-stable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// compile-flags: --output-format html
// check-pass
// This tests that `--output-format html` is accepted without `-Z unstable-options`,
// since it has been stable since 1.0.
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
@@ -1600,7 +1600,7 @@ impl<'test> TestCx<'test> {
.args(&self.props.compile_flags);

if self.config.mode == RustdocJson {
rustdoc.arg("--output-format").arg("json");
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
}

if let Some(ref linker) = self.config.linker {