Skip to content

Commit 99e075f

Browse files
authored
Rollup merge of rust-lang#79525 - jyn514:feature-gate-normalize, r=GuillaumeGomez
Add -Z normalize-docs and enable it for compiler docs Works around rust-lang#79459 by only enabling normalization for the compiler itself (and anyone who opts-in on nightly). Eventually I want to remove this and enable normalization by default, but that's turned out to be [really hard](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20do.20I.20normalize.20projection.20types.20to.20a.20single.20type.3F/near/218125195). This uses a command line option instead of a feature gate so it's easier to pass it to all crates at once. Theoretically it's better to use a feature gate instead so that it's easier for people to use on docs.rs, but I'm also not terribly concerned with how easy it to use a temporary hack. Addresses rust-lang#77459.
2 parents 36ce8db + 95a6427 commit 99e075f

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
@@ -731,6 +731,7 @@ impl<'a> Builder<'a> {
731731
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
732732
.env("RUSTDOC_REAL", self.rustdoc(compiler))
733733
.env("RUSTC_BOOTSTRAP", "1")
734+
.arg("-Znormalize_docs")
734735
.arg("-Winvalid_codeblock_attributes");
735736
if self.config.deny_warnings {
736737
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
@@ -1515,9 +1515,12 @@ impl Clean<Type> for hir::Ty<'_> {
15151515
}
15161516

15171517
/// Returns `None` if the type could not be normalized
1518-
#[allow(unreachable_code, unused_variables)]
15191518
fn normalize(cx: &DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
1520-
return None; // HACK: low-churn fix for #79459 while we wait for a trait normalization fix
1519+
// HACK: low-churn fix for #79459 while we wait for a trait normalization fix
1520+
if !cx.tcx.sess.opts.debugging_opts.normalize_docs {
1521+
return None;
1522+
}
1523+
15211524
use crate::rustc_trait_selection::infer::TyCtxtInferExt;
15221525
use crate::rustc_trait_selection::traits::query::normalize::AtExt;
15231526
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)