Skip to content

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

Open
@aDotInTheVoid

Description

@aDotInTheVoid

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

14863ea

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

println!("info: generating a diff against nightly rustdoc");
let suffix =
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
let compare_dir = output_base_dir(self.config, self.testpaths, Some(&suffix));
remove_and_create_dir_all(&compare_dir).unwrap_or_else(|e| {
panic!("failed to remove and recreate output directory `{compare_dir}`: {e}")
});
// We need to create a new struct for the lifetimes on `config` to work.
let new_rustdoc = TestCx {
config: &Config {
// FIXME: use beta or a user-specified rustdoc instead of
// hardcoding the default toolchain
rustdoc_path: Some("rustdoc".into()),

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)

Metadata

Metadata

Assignees

Labels

A-compiletestArea: The compiletest test runnerA-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustA-test-infraArea: test infrastructure (may span bootstrap/compiletest/more)C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions