From 95a6427d2c4d4ad53931d1f7e8932a61ba0e9601 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 28 Nov 2020 19:19:41 -0500 Subject: [PATCH] Add -Z normalize-docs and enable it for compiler docs --- compiler/rustc_session/src/options.rs | 2 ++ src/bootstrap/builder.rs | 1 + src/bootstrap/doc.rs | 1 + src/librustdoc/clean/mod.rs | 7 +++++-- src/test/rustdoc/normalize-assoc-item.rs | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index b438be0696ac1..66c709b408098 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -996,6 +996,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"), no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED], "prevent automatic injection of the profiler_builtins crate"), + normalize_docs: bool = (false, parse_bool, [TRACKED], + "normalize associated items in rustdoc when generating documentation"), osx_rpath_install_name: bool = (false, parse_bool, [TRACKED], "pass `-install_name @rpath/...` to the macOS linker (default: no)"), panic_abort_tests: bool = (false, parse_bool, [TRACKED], diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 508d785834fce..4e84e3ea59b38 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -730,6 +730,7 @@ impl<'a> Builder<'a> { .env("CFG_RELEASE_CHANNEL", &self.config.channel) .env("RUSTDOC_REAL", self.rustdoc(compiler)) .env("RUSTC_BOOTSTRAP", "1") + .arg("-Znormalize_docs") .arg("-Winvalid_codeblock_attributes"); if self.config.deny_warnings { cmd.arg("-Dwarnings"); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index af7f7eff89418..919c3a8b5749b 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -527,6 +527,7 @@ impl Step for Rustc { cargo.rustdocflag("--document-private-items"); cargo.rustdocflag("--enable-index-page"); cargo.rustdocflag("-Zunstable-options"); + cargo.rustdocflag("-Znormalize-docs"); compile::rustc_cargo(builder, &mut cargo, target); // Only include compiler crates, no dependencies of those, such as `libc`. diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 13643fbf3d3fb..a136e69f9a617 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1503,9 +1503,12 @@ impl Clean for hir::Ty<'_> { } /// Returns `None` if the type could not be normalized -#[allow(unreachable_code, unused_variables)] fn normalize(cx: &DocContext<'tcx>, ty: Ty<'_>) -> Option> { - return None; // HACK: low-churn fix for #79459 while we wait for a trait normalization fix + // HACK: low-churn fix for #79459 while we wait for a trait normalization fix + if !cx.tcx.sess.opts.debugging_opts.normalize_docs { + return None; + } + use crate::rustc_trait_selection::infer::TyCtxtInferExt; use crate::rustc_trait_selection::traits::query::normalize::AtExt; use rustc_middle::traits::ObligationCause; diff --git a/src/test/rustdoc/normalize-assoc-item.rs b/src/test/rustdoc/normalize-assoc-item.rs index 70b3c66fd2b86..ad1a868ee32b8 100644 --- a/src/test/rustdoc/normalize-assoc-item.rs +++ b/src/test/rustdoc/normalize-assoc-item.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength // aux-build:normalize-assoc-item.rs // build-aux-docs -// ignore-test +// compile-flags:-Znormalize-docs pub trait Trait { type X;