Fix/move newly failing rustdoc tests

This commit is contained in:
Guillaume Gomez
2026-08-31 18:19:56 +02:00
parent ab53511d05
commit d4f576d07d
30 changed files with 147 additions and 78 deletions

View File

@@ -0,0 +1,9 @@
// This test ensures that the `foo` decl macro is present in the module sidebar.
// Because these items are not generated into the HTML, we can't make them a `rustdoc-html`
// test, so here we go...
go-to: "file://" + |DOC_PATH| + "/test_docs/details/index.html"
assert-text: (
'//*[@id="rustdoc-modnav"]/ul[@class="block macro"]//a[@href="../macro.decl_macro.html"]',
"decl_macro",
)

View File

@@ -14,6 +14,7 @@
#![feature(macro_derive)]
#![feature(negative_impls)]
#![feature(doc_notable_trait)]
#![feature(decl_macro)]
/*!
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
@@ -822,3 +823,7 @@ pub mod notable {
pub struct Wrapper;
impl Labeled for Wrapper {}
}
pub macro decl_macro {
() => { "bar" }
}

View File

@@ -5,15 +5,15 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
//@has 'foo/index.html'
//@count - '//*[@class="stab portability"]' 2
//@has - '//*[@class="stab portability"]' 'Non-banana'
//@ has 'foo/index.html'
//@ count - '//*[@class="stab portability"]' 2
//@ has - '//*[@class="stab portability"]' 'Non-banana'
//@has 'foo/fn.doc_cfg_doesnt_work.html'
//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
//@ has 'foo/fn.doc_cfg_doesnt_work.html'
//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
//@has 'foo/fn.doc_cfg_works.html'
//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
//@ has 'foo/fn.doc_cfg_works.html'
//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
unsafe extern "C" {
#[cfg(not(feature = "banana"))]

View File

@@ -6,8 +6,8 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
//@has 'foo/trait.Blob.html'
//@has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
//@ has 'foo/trait.Blob.html'
//@ has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
pub trait Blob {}

View File

@@ -6,17 +6,17 @@
#![feature(doc_cfg)]
#![crate_name = "foo"]
//@has 'foo/struct.FlatBanana.html'
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
//@ has 'foo/struct.FlatBanana.html'
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
//@has 'foo/struct.SubBanana.html'
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
//@ has 'foo/struct.SubBanana.html'
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
#[cfg(not(feature = "yoyo"))]
pub use self::banana::*;
//@has 'foo/struct.Yolo.html'
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
//@ has 'foo/struct.Yolo.html'
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
pub use self::banana::SubBanana as Yolo;
#[cfg(not(feature = "banana"))]

View File

@@ -22,36 +22,36 @@ pub trait Foo {
pub struct X;
//@has 'foo/struct.X.html'
//@count - '//*[@id="impl-Bob-for-X"]' 1
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
//@count - '//*[@id="impl-Trait-for-X"]' 1
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/struct.X.html'
//@ count - '//*[@id="impl-Bob-for-X"]' 1
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
//@ count - '//*[@id="impl-Trait-for-X"]' 1
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
// If you need to update this XPath, in particular `item-info`, update all
// the others in this file.
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@has 'foo/trait.Trait.html'
//@count - '//*[@id="impl-Trait-for-X"]' 1
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/trait.Trait.html'
//@ count - '//*[@id="impl-Trait-for-X"]' 1
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp {
impl super::Trait for super::X { fn f(&self) {} }
}
//@has 'foo/trait.Bob.html'
//@count - '//*[@id="impl-Bob-for-X"]' 1
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/trait.Bob.html'
//@ count - '//*[@id="impl-Bob-for-X"]' 1
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg = false)]
mod imp2 {
impl super::Bob for super::X { fn bob(&self) {} }
}
//@has 'foo/trait.Foo.html'
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@ has 'foo/trait.Foo.html'
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
// We use this to force xpath tests to be updated if `item-info` class is changed.
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
mod imp3 {
@@ -60,9 +60,9 @@ mod imp3 {
pub struct Y;
//@has 'foo/struct.Y.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
//@ has 'foo/struct.Y.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp4 {
@@ -71,9 +71,9 @@ mod imp4 {
pub struct Z;
//@has 'foo/struct.Z.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
//@ has 'foo/struct.Z.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
#[doc(auto_cfg = false)]
mod imp5 {
@@ -83,9 +83,9 @@ mod imp5 {
// The "witness" which has the item info.
pub struct W;
//@has 'foo/struct.W.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
//@ has 'foo/struct.W.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 1
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
mod imp6 {
impl super::W { pub fn plain_auto() {} }

View File

@@ -22,36 +22,36 @@ pub trait Foo {
pub struct X;
//@has 'foo/struct.X.html'
//@count - '//*[@id="impl-Bob-for-X"]' 1
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
//@count - '//*[@id="impl-Trait-for-X"]' 1
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/struct.X.html'
//@ count - '//*[@id="impl-Bob-for-X"]' 1
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
//@ count - '//*[@id="impl-Trait-for-X"]' 1
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
// If you need to update this XPath, in particular `item-info`, update all
// the others in this file.
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@has 'foo/trait.Trait.html'
//@count - '//*[@id="impl-Trait-for-X"]' 1
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/trait.Trait.html'
//@ count - '//*[@id="impl-Trait-for-X"]' 1
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp {
impl super::Trait for super::X { fn f(&self) {} }
}
//@has 'foo/trait.Bob.html'
//@count - '//*[@id="impl-Bob-for-X"]' 1
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
//@ has 'foo/trait.Bob.html'
//@ count - '//*[@id="impl-Bob-for-X"]' 1
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg = false)]
mod imp2 {
impl super::Bob for super::X { fn bob(&self) {} }
}
//@has 'foo/trait.Foo.html'
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
//@ has 'foo/trait.Foo.html'
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
// We use this to force xpath tests to be updated if `item-info` class is changed.
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
mod imp3 {
@@ -60,9 +60,9 @@ mod imp3 {
pub struct Y;
//@has 'foo/struct.Y.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
//@ has 'foo/struct.Y.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
mod imp4 {
@@ -71,9 +71,9 @@ mod imp4 {
pub struct Z;
//@has 'foo/struct.Z.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
//@ has 'foo/struct.Z.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
#[doc(auto_cfg = false)]
mod imp5 {
@@ -83,9 +83,9 @@ mod imp5 {
// The "witness" which has the item info.
pub struct W;
//@has 'foo/struct.W.html'
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
//@ has 'foo/struct.W.html'
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]//*[@class="item-info"]' 1
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
mod imp6 {
impl super::W { pub fn plain_auto() {} }

View File

@@ -10,6 +10,7 @@
//@ has foo/impls/bar/trait.Bar.html
//@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
//@ count - '//*[@class="struct"]' 1
#[path = "auxiliary/impls.rs"]
pub mod impls;
#[doc(inline)]

View File

@@ -1,15 +0,0 @@
// This test ensures that the `foo` decl macro is present in the module sidebar.
#![feature(decl_macro)]
#![crate_name = "foo"]
//@has 'foo/bar/index.html'
//@has - '//*[@id="rustdoc-modnav"]/ul[@class="block macro"]//a[@href="../macro.foo.html"]' 'foo'
pub macro foo {
() => { "bar" }
}
/// docs
pub mod bar {
}

View File

@@ -1,5 +1,7 @@
// Test for https://github.com/rust-lang/rust/issues/48463 issue.
//@ check-pass
use std::any::Any;
use std::ops::Deref;

View File

@@ -1,6 +1,8 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
//@ check-pass
pub trait Enumerable {
const N: usize;
}

View File

@@ -1,6 +1,8 @@
// This test verifies that we do not hit recursion limit trying to prove auto-trait bounds for
// reasonably deep structures.
//@ check-pass
#![crate_type="rlib"]
pub struct A01(A02);

View File

@@ -4,6 +4,8 @@
// ignore-tidy-linelength
//@ check-pass
pub type Boom = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<u64, u8>, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>;
pub struct S<T, U>(T, U);

View File

@@ -1,5 +1,7 @@
// Ensure that empty doc comments don't panic.
//@ check-pass
/*!
*/

View File

@@ -4,6 +4,8 @@
//
// This is a regression test for <https://github.com/rust-lang/rust/issues/151028>.
//@ check-pass
#![crate_name = "foo"]
#[deprecated(note = "use [`std::mem::forget`]")]

View File

@@ -1,5 +1,7 @@
// we need to make sure that intra-doc links on trait impls get resolved in the right scope
//@ check-pass
#![deny(rustdoc::broken_intra_doc_links)]
pub mod inner {

View File

@@ -1,3 +1,5 @@
//@ check-pass
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(intra_doc_pointers)]

View File

@@ -2,6 +2,8 @@
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
// checked for accuracy anyway.
//@ check-pass
#![deny(rustdoc::broken_intra_doc_links)]
/// ooh, i'm a [rebel] just for kicks

View File

@@ -3,6 +3,8 @@
// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't
// crash when we try.
//@ check-pass
extern crate proc_macro;
pub use proc_macro::*;

View File

@@ -1,11 +1,13 @@
// https://github.com/rust-lang/rust/issues/16019
//@ check-pass
macro_rules! define_struct {
($rounds:expr) => (
struct Struct {
sk: [u32; $rounds + 1]
}
)
)
}
define_struct!(2);

View File

@@ -1,5 +1,7 @@
// Regression issue for rustdoc ICE encountered in PR #65252.
//@ check-pass
#![feature(decl_macro)]
fn main() {

View File

@@ -1,8 +1,9 @@
// This code caused a panic in `pulldown-cmark` 0.4.1.
// https://github.com/rust-lang/rust/issues/60482
pub const BASIC_UNICODE: bool = true;
//@ check-pass
pub const BASIC_UNICODE: bool = true;
/// # `BASIC_UNICODE`: `A` `|`
/// ```text

View File

@@ -1,6 +1,8 @@
// Regression test for <https://github.com/rust-lang/rust/pull/113374> to
// ensure it doesn't panic.
//@ check-pass
mod generics {
pub enum WherePredicate {
EqPredicate,

View File

@@ -1,3 +1,5 @@
//@ check-pass
#![crate_type = "lib"]
mod m {

View File

@@ -1,3 +1,5 @@
//@ check-pass
#![crate_type = "lib"]
mod m {

View File

@@ -1,3 +1,5 @@
//@ check-pass
pub mod longhands {
pub use super::*;

View File

@@ -1,3 +1,5 @@
//@ check-pass
/**
*/
pub mod A {

View File

@@ -2,6 +2,8 @@
// Tests that we don't ICE when we have projection predicates
// in our initial ParamEnv
//@ check-pass
pub struct Lines<'a, L>
where
L: Iterator<Item = &'a ()>,

View File

@@ -0,0 +1,32 @@
// Regression test for <https://github.com/rust-lang/rust/issues/112515>.
// It's to ensure that this code doesn't have infinite loop in rustdoc when
// trying to retrieve type alias implementations.
// ignore-tidy-linelength
//@ check-pass
pub type Boom = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<u64, u8>, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>;
pub struct S<T, U>(T, U);
pub trait A {}
pub trait B<T> {
type P;
}
impl A for u64 {}
impl<T, U> A for S<T, U> {}
impl<T> B<u8> for S<T, ()>
where
T: B<u8>,
<T as B<u8>>::P: A,
{
type P = ();
}
impl<T: A, U, V> B<T> for S<U, V> {
type P = ();
}