Skip to content

Commit 95a6427

Browse files
committed
Add -Z normalize-docs and enable it for compiler docs
1 parent e37f25a commit 95a6427

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
996996
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
997997
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
998998
"prevent automatic injection of the profiler_builtins crate"),
999+
normalize_docs: bool = (false, parse_bool, [TRACKED],
1000+
"normalize associated items in rustdoc when generating documentation"),
9991001
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
10001002
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
10011003
panic_abort_tests: bool = (false, parse_bool, [TRACKED],

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ impl<'a> Builder<'a> {
730730
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
731731
.env("RUSTDOC_REAL", self.rustdoc(compiler))
732732
.env("RUSTC_BOOTSTRAP", "1")
733+
.arg("-Znormalize_docs")
733734
.arg("-Winvalid_codeblock_attributes");
734735
if self.config.deny_warnings {
735736
cmd.arg("-Dwarnings");

src/bootstrap/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ impl Step for Rustc {
527527
cargo.rustdocflag("--document-private-items");
528528
cargo.rustdocflag("--enable-index-page");
529529
cargo.rustdocflag("-Zunstable-options");
530+
cargo.rustdocflag("-Znormalize-docs");
530531
compile::rustc_cargo(builder, &mut cargo, target);
531532

532533
// Only include compiler crates, no dependencies of those, such as `libc`.

src/librustdoc/clean/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1503,9 +1503,12 @@ impl Clean<Type> for hir::Ty<'_> {
15031503
}
15041504

15051505
/// Returns `None` if the type could not be normalized
1506-
#[allow(unreachable_code, unused_variables)]
15071506
fn normalize(cx: &DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
1508-
return None; // HACK: low-churn fix for #79459 while we wait for a trait normalization fix
1507+
// HACK: low-churn fix for #79459 while we wait for a trait normalization fix
1508+
if !cx.tcx.sess.opts.debugging_opts.normalize_docs {
1509+
return None;
1510+
}
1511+
15091512
use crate::rustc_trait_selection::infer::TyCtxtInferExt;
15101513
use crate::rustc_trait_selection::traits::query::normalize::AtExt;
15111514
use rustc_middle::traits::ObligationCause;

src/test/rustdoc/normalize-assoc-item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore-tidy-linelength
22
// aux-build:normalize-assoc-item.rs
33
// build-aux-docs
4-
// ignore-test
4+
// compile-flags:-Znormalize-docs
55

66
pub trait Trait {
77
type X;

0 commit comments

Comments
 (0)