rust-lang / rust-lang/rust

compiletest: "diff against nightly rustdoc" is actually against default toolchain

Open
#142,254 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-compiletest A-contributor-roadblock A-test-infra C-bug T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

The "diff against nightly" feature for rustdoc tests sometimes stable rustdoc, resulting in a spurious diff

Command used
./x test tests/rustdoc/whitespace-after-where-clause.rs

I'd also modified rustdoc, so that this test fails

Expected behaviour

compiletest prints out a diff between what nightly and in-tree rustdoc produces.

Actual behaviour

compiletest prints out a diff between what nightly and stable rustdoc produces.

This leads to a load of spurious diff:

@@ -409,9 +409,9 @@
             <details class="toggle implementors-toggle">
               <summary>
                 <section id="impl-TryInto%3CU%3E-for-T" class="impl">
-                  <a class="src rightside" href="https://doc.rust-lang.org/1.87.0/src/core/convert/mod.rs.html#791-793">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a>
+                  <a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797-799">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a>
                   <h3 class="code-header">
-                    impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.87.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T
+                    impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T
                   </h3>
                   <div class="where">
                     <h3 class="code-header">
@@ -418,4 +418,4 @@
-                      where U: <a class="trait" href="https://doc.rust-lang.org/1.87.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,
+                      where U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,
                     </h3>
                   </div>
                 </section>
Bootstrap configuration (bootstrap.toml)
profile = "tools"
change-id = "ignore"

[rust]
deny-warnings = false
Operating system

Ubuntu 24.04.1 LTS (Noble Numbat)

HEAD

14863ea0777c68348b3e6e7a8472423d273a52af

Also, this diff to rustdoc which makes it fail the test:

diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs
index 89245fee515..5ce0a3654a9 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -93,7 +93,7 @@ pub(crate) fn synthesize_blanket_impls(
                         generics: clean_ty_generics(
                             cx,
                             tcx.generics_of(impl_def_id),
-                            tcx.explicit_predicates_of(impl_def_id),
+                            tcx.predicates_of(impl_def_id),
                         ),
                         // FIXME(eddyb) compute both `trait_` and `for_` from
                         // the post-inference `trait_ref`, as it's more accurate.
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 7658e7ad35f..93e643bcd6e 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2832,7 +2832,7 @@ fn get_name(
             }),
             ItemKind::Struct(_, generics, variant_data) => StructItem(Struct {
                 ctor_kind: variant_data.ctor_kind(),
-                generics: clean_generics(generics, cx),
+                generics: clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.predicates_of(def_id)),
                 fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
             }),
             ItemKind::Macro(_, macro_def, MacroKind::Bang) => MacroItem(Macro {
Additional context

It looks like compiletest uses the default toolchain, rather than nightly

https://github.com/rust-lang/rust/blob/14863ea0777c68348b3e6e7a8472423d273a52af/src/tools/compiletest/src/runtest.rs#L1961-L1975

For me, that's stable. Doing rustup override set nightly fixes this.

Build Log (as a gist, because it's too long for github issues)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/tools/compiletest/src/runtest.rs at lines 1961-1975, then run ./x test tests/rustdoc/whitespace-after-where-clause.rs with the reported toolchain setup. Trace which rustdoc executable the "diff against nightly" path invokes. Done means the comparison uses nightly and in-tree rustdoc as expected, including when rustdoc is modified so the test fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.