From b796179f9888b0aff6edf9c393274d9f792a0700 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 15:10:21 +0200 Subject: Created `tests/rustdoc/reexports` subfolder to limit number of files at the top level --- tests/rustdoc/alias-reexport.rs | 17 --- tests/rustdoc/alias-reexport2.rs | 17 --- tests/rustdoc/anonymous-reexport-108931.rs | 22 ---- tests/rustdoc/anonymous-reexport.rs | 26 ---- tests/rustdoc/auxiliary/alias-reexport.rs | 3 - tests/rustdoc/auxiliary/alias-reexport2.rs | 12 -- .../issue-113982-doc_auto_cfg-reexport-foreign.rs | 3 - tests/rustdoc/auxiliary/issue-28927-1.rs | 4 - tests/rustdoc/auxiliary/issue-28927-2.rs | 1 - tests/rustdoc/auxiliary/primitive-reexport.rs | 9 -- tests/rustdoc/auxiliary/reexport-check.rs | 2 - tests/rustdoc/auxiliary/reexport-doc-aux.rs | 5 - tests/rustdoc/auxiliary/reexports.rs | 66 ---------- tests/rustdoc/blanket-reexport-item.rs | 8 -- tests/rustdoc/cfg_doc_reexport.rs | 36 ------ tests/rustdoc/doc-hidden-reexports-109449.rs | 143 --------------------- .../doc_auto_cfg-reexport-foreign-113982.rs | 20 --- tests/rustdoc/duplicated-glob-reexport-60522.rs | 39 ------ tests/rustdoc/enum-variant-reexport-35488.rs | 16 --- tests/rustdoc/foreigntype-reexport.rs | 56 -------- .../glob-reexport-attribute-merge-120487.rs | 32 ----- .../glob-reexport-attribute-merge-doc-auto-cfg.rs | 29 ----- tests/rustdoc/ice-reexport-crate-root-28927.rs | 9 -- tests/rustdoc/local-reexport-doc.rs | 16 --- tests/rustdoc/no-compiler-reexport.rs | 7 - tests/rustdoc/overlapping-reexport-105735-2.rs | 26 ---- tests/rustdoc/overlapping-reexport-105735.rs | 22 ---- tests/rustdoc/primitive-reexport.rs | 29 ----- .../rustdoc/pub-reexport-of-pub-reexport-46506.rs | 24 ---- tests/rustdoc/reexport-attr-merge.rs | 33 ----- tests/rustdoc/reexport-cfg.rs | 30 ----- tests/rustdoc/reexport-check.rs | 20 --- tests/rustdoc/reexport-dep-foreign-fn.rs | 12 -- .../rustdoc/reexport-doc-hidden-inside-private.rs | 16 --- tests/rustdoc/reexport-doc-hidden.rs | 25 ---- tests/rustdoc/reexport-doc.rs | 8 -- tests/rustdoc/reexport-hidden-macro.rs | 22 ---- tests/rustdoc/reexport-macro.rs | 23 ---- tests/rustdoc/reexport-of-doc-hidden.rs | 42 ------ tests/rustdoc/reexport-of-reexport-108679.rs | 30 ----- ...rt-stability-tags-deprecated-and-portability.rs | 48 ------- ...port-stability-tags-unstable-and-portability.rs | 61 --------- .../rustdoc/reexport-trait-from-hidden-111064-2.rs | 41 ------ tests/rustdoc/reexport-trait-from-hidden-111064.rs | 21 --- tests/rustdoc/reexport/alias-reexport.rs | 17 +++ tests/rustdoc/reexport/alias-reexport2.rs | 17 +++ .../rustdoc/reexport/anonymous-reexport-108931.rs | 22 ++++ tests/rustdoc/reexport/anonymous-reexport.rs | 26 ++++ tests/rustdoc/reexport/auxiliary/alias-reexport.rs | 3 + .../rustdoc/reexport/auxiliary/alias-reexport2.rs | 12 ++ tests/rustdoc/reexport/auxiliary/all-item-types.rs | 22 ++++ .../issue-113982-doc_auto_cfg-reexport-foreign.rs | 3 + tests/rustdoc/reexport/auxiliary/issue-28927-1.rs | 4 + tests/rustdoc/reexport/auxiliary/issue-28927-2.rs | 1 + .../reexport/auxiliary/primitive-reexport.rs | 9 ++ tests/rustdoc/reexport/auxiliary/reexport-check.rs | 2 + .../rustdoc/reexport/auxiliary/reexport-doc-aux.rs | 5 + tests/rustdoc/reexport/auxiliary/reexports.rs | 66 ++++++++++ tests/rustdoc/reexport/blanket-reexport-item.rs | 8 ++ tests/rustdoc/reexport/cfg_doc_reexport.rs | 36 ++++++ .../reexport/doc-hidden-reexports-109449.rs | 143 +++++++++++++++++++++ .../doc_auto_cfg-reexport-foreign-113982.rs | 20 +++ .../reexport/duplicated-glob-reexport-60522.rs | 39 ++++++ .../reexport/enum-variant-reexport-35488.rs | 16 +++ tests/rustdoc/reexport/foreigntype-reexport.rs | 56 ++++++++ .../glob-reexport-attribute-merge-120487.rs | 32 +++++ .../glob-reexport-attribute-merge-doc-auto-cfg.rs | 29 +++++ .../reexport/ice-reexport-crate-root-28927.rs | 9 ++ tests/rustdoc/reexport/local-reexport-doc.rs | 16 +++ tests/rustdoc/reexport/no-compiler-reexport.rs | 7 + .../reexport/overlapping-reexport-105735-2.rs | 26 ++++ .../reexport/overlapping-reexport-105735.rs | 22 ++++ tests/rustdoc/reexport/primitive-reexport.rs | 29 +++++ .../reexport/pub-reexport-of-pub-reexport-46506.rs | 24 ++++ tests/rustdoc/reexport/reexport-attr-merge.rs | 33 +++++ tests/rustdoc/reexport/reexport-cfg.rs | 30 +++++ tests/rustdoc/reexport/reexport-check.rs | 20 +++ tests/rustdoc/reexport/reexport-dep-foreign-fn.rs | 12 ++ .../reexport/reexport-doc-hidden-inside-private.rs | 16 +++ tests/rustdoc/reexport/reexport-doc-hidden.rs | 25 ++++ tests/rustdoc/reexport/reexport-doc.rs | 8 ++ tests/rustdoc/reexport/reexport-hidden-macro.rs | 22 ++++ tests/rustdoc/reexport/reexport-macro.rs | 23 ++++ tests/rustdoc/reexport/reexport-of-doc-hidden.rs | 42 ++++++ .../reexport/reexport-of-reexport-108679.rs | 30 +++++ ...rt-stability-tags-deprecated-and-portability.rs | 48 +++++++ ...port-stability-tags-unstable-and-portability.rs | 61 +++++++++ .../reexport-trait-from-hidden-111064-2.rs | 41 ++++++ .../reexport/reexport-trait-from-hidden-111064.rs | 21 +++ tests/rustdoc/reexport/reexports-of-same-name.rs | 26 ++++ tests/rustdoc/reexport/reexports-priv.rs | 135 +++++++++++++++++++ tests/rustdoc/reexport/reexports.rs | 129 +++++++++++++++++++ tests/rustdoc/reexports-of-same-name.rs | 26 ---- tests/rustdoc/reexports-priv.rs | 135 ------------------- tests/rustdoc/reexports.rs | 129 ------------------- 95 files changed, 1443 insertions(+), 1421 deletions(-) delete mode 100644 tests/rustdoc/alias-reexport.rs delete mode 100644 tests/rustdoc/alias-reexport2.rs delete mode 100644 tests/rustdoc/anonymous-reexport-108931.rs delete mode 100644 tests/rustdoc/anonymous-reexport.rs delete mode 100644 tests/rustdoc/auxiliary/alias-reexport.rs delete mode 100644 tests/rustdoc/auxiliary/alias-reexport2.rs delete mode 100644 tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs delete mode 100644 tests/rustdoc/auxiliary/issue-28927-1.rs delete mode 100644 tests/rustdoc/auxiliary/issue-28927-2.rs delete mode 100644 tests/rustdoc/auxiliary/primitive-reexport.rs delete mode 100644 tests/rustdoc/auxiliary/reexport-check.rs delete mode 100644 tests/rustdoc/auxiliary/reexport-doc-aux.rs delete mode 100644 tests/rustdoc/auxiliary/reexports.rs delete mode 100644 tests/rustdoc/blanket-reexport-item.rs delete mode 100644 tests/rustdoc/cfg_doc_reexport.rs delete mode 100644 tests/rustdoc/doc-hidden-reexports-109449.rs delete mode 100644 tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs delete mode 100644 tests/rustdoc/duplicated-glob-reexport-60522.rs delete mode 100644 tests/rustdoc/enum-variant-reexport-35488.rs delete mode 100644 tests/rustdoc/foreigntype-reexport.rs delete mode 100644 tests/rustdoc/glob-reexport-attribute-merge-120487.rs delete mode 100644 tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs delete mode 100644 tests/rustdoc/ice-reexport-crate-root-28927.rs delete mode 100644 tests/rustdoc/local-reexport-doc.rs delete mode 100644 tests/rustdoc/no-compiler-reexport.rs delete mode 100644 tests/rustdoc/overlapping-reexport-105735-2.rs delete mode 100644 tests/rustdoc/overlapping-reexport-105735.rs delete mode 100644 tests/rustdoc/primitive-reexport.rs delete mode 100644 tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs delete mode 100644 tests/rustdoc/reexport-attr-merge.rs delete mode 100644 tests/rustdoc/reexport-cfg.rs delete mode 100644 tests/rustdoc/reexport-check.rs delete mode 100644 tests/rustdoc/reexport-dep-foreign-fn.rs delete mode 100644 tests/rustdoc/reexport-doc-hidden-inside-private.rs delete mode 100644 tests/rustdoc/reexport-doc-hidden.rs delete mode 100644 tests/rustdoc/reexport-doc.rs delete mode 100644 tests/rustdoc/reexport-hidden-macro.rs delete mode 100644 tests/rustdoc/reexport-macro.rs delete mode 100644 tests/rustdoc/reexport-of-doc-hidden.rs delete mode 100644 tests/rustdoc/reexport-of-reexport-108679.rs delete mode 100644 tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs delete mode 100644 tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs delete mode 100644 tests/rustdoc/reexport-trait-from-hidden-111064-2.rs delete mode 100644 tests/rustdoc/reexport-trait-from-hidden-111064.rs create mode 100644 tests/rustdoc/reexport/alias-reexport.rs create mode 100644 tests/rustdoc/reexport/alias-reexport2.rs create mode 100644 tests/rustdoc/reexport/anonymous-reexport-108931.rs create mode 100644 tests/rustdoc/reexport/anonymous-reexport.rs create mode 100644 tests/rustdoc/reexport/auxiliary/alias-reexport.rs create mode 100644 tests/rustdoc/reexport/auxiliary/alias-reexport2.rs create mode 100644 tests/rustdoc/reexport/auxiliary/all-item-types.rs create mode 100644 tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs create mode 100644 tests/rustdoc/reexport/auxiliary/issue-28927-1.rs create mode 100644 tests/rustdoc/reexport/auxiliary/issue-28927-2.rs create mode 100644 tests/rustdoc/reexport/auxiliary/primitive-reexport.rs create mode 100644 tests/rustdoc/reexport/auxiliary/reexport-check.rs create mode 100644 tests/rustdoc/reexport/auxiliary/reexport-doc-aux.rs create mode 100644 tests/rustdoc/reexport/auxiliary/reexports.rs create mode 100644 tests/rustdoc/reexport/blanket-reexport-item.rs create mode 100644 tests/rustdoc/reexport/cfg_doc_reexport.rs create mode 100644 tests/rustdoc/reexport/doc-hidden-reexports-109449.rs create mode 100644 tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs create mode 100644 tests/rustdoc/reexport/duplicated-glob-reexport-60522.rs create mode 100644 tests/rustdoc/reexport/enum-variant-reexport-35488.rs create mode 100644 tests/rustdoc/reexport/foreigntype-reexport.rs create mode 100644 tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs create mode 100644 tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs create mode 100644 tests/rustdoc/reexport/ice-reexport-crate-root-28927.rs create mode 100644 tests/rustdoc/reexport/local-reexport-doc.rs create mode 100644 tests/rustdoc/reexport/no-compiler-reexport.rs create mode 100644 tests/rustdoc/reexport/overlapping-reexport-105735-2.rs create mode 100644 tests/rustdoc/reexport/overlapping-reexport-105735.rs create mode 100644 tests/rustdoc/reexport/primitive-reexport.rs create mode 100644 tests/rustdoc/reexport/pub-reexport-of-pub-reexport-46506.rs create mode 100644 tests/rustdoc/reexport/reexport-attr-merge.rs create mode 100644 tests/rustdoc/reexport/reexport-cfg.rs create mode 100644 tests/rustdoc/reexport/reexport-check.rs create mode 100644 tests/rustdoc/reexport/reexport-dep-foreign-fn.rs create mode 100644 tests/rustdoc/reexport/reexport-doc-hidden-inside-private.rs create mode 100644 tests/rustdoc/reexport/reexport-doc-hidden.rs create mode 100644 tests/rustdoc/reexport/reexport-doc.rs create mode 100644 tests/rustdoc/reexport/reexport-hidden-macro.rs create mode 100644 tests/rustdoc/reexport/reexport-macro.rs create mode 100644 tests/rustdoc/reexport/reexport-of-doc-hidden.rs create mode 100644 tests/rustdoc/reexport/reexport-of-reexport-108679.rs create mode 100644 tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs create mode 100644 tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs create mode 100644 tests/rustdoc/reexport/reexport-trait-from-hidden-111064-2.rs create mode 100644 tests/rustdoc/reexport/reexport-trait-from-hidden-111064.rs create mode 100644 tests/rustdoc/reexport/reexports-of-same-name.rs create mode 100644 tests/rustdoc/reexport/reexports-priv.rs create mode 100644 tests/rustdoc/reexport/reexports.rs delete mode 100644 tests/rustdoc/reexports-of-same-name.rs delete mode 100644 tests/rustdoc/reexports-priv.rs delete mode 100644 tests/rustdoc/reexports.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs deleted file mode 100644 index 41f1f8df0f6..00000000000 --- a/tests/rustdoc/alias-reexport.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ aux-build:alias-reexport.rs -//@ aux-build:alias-reexport2.rs - -#![crate_name = "foo"] -#![feature(lazy_type_alias)] -#![allow(incomplete_features)] - -extern crate alias_reexport2; - -//@ has 'foo/reexport/fn.foo.html' -//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' -//@ has 'foo/reexport/fn.foo2.html' -//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' -//@ has 'foo/reexport/type.Reexported.html' -//@ has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' -#[doc(inline)] -pub use alias_reexport2 as reexport; diff --git a/tests/rustdoc/alias-reexport2.rs b/tests/rustdoc/alias-reexport2.rs deleted file mode 100644 index 2fb69b922c8..00000000000 --- a/tests/rustdoc/alias-reexport2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// gate-test-lazy_type_alias -//@ aux-build:alias-reexport.rs - -#![crate_name = "foo"] -#![feature(lazy_type_alias)] -#![allow(incomplete_features)] - -extern crate alias_reexport; - -use alias_reexport::Reexported; - -//@ has 'foo/fn.foo.html' -//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' -pub fn foo() -> Reexported { 0 } -//@ has 'foo/fn.foo2.html' -//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' -pub fn foo2() -> Result { Ok(0) } diff --git a/tests/rustdoc/anonymous-reexport-108931.rs b/tests/rustdoc/anonymous-reexport-108931.rs deleted file mode 100644 index b995c89b614..00000000000 --- a/tests/rustdoc/anonymous-reexport-108931.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Ensuring that anonymous re-exports are always inlined. -// https://github.com/rust-lang/rust/issues/108931 - -#![crate_name = "foo"] - -pub mod foo { - pub struct Foo; -} - -mod bar { - pub struct Bar; -} - -//@ has 'foo/index.html' -// We check that the only "h2" present are "Re-exports" and "Modules". -//@ count - '//*[@id="main-content"]/h2' 2 -//@ has - '//*[@id="main-content"]/h2' 'Re-exports' -//@ has - '//*[@id="main-content"]/h2' 'Modules' -//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use foo::Foo as _;' -//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use bar::Bar as _;' -pub use foo::Foo as _; -pub use bar::Bar as _; diff --git a/tests/rustdoc/anonymous-reexport.rs b/tests/rustdoc/anonymous-reexport.rs deleted file mode 100644 index bf5fa93f953..00000000000 --- a/tests/rustdoc/anonymous-reexport.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![crate_name = "foo"] - -// This test ensures we don't display anonymous (non-inline) re-exports of public items. - -//@ has 'foo/index.html' -//@ has - '//*[@id="main-content"]' '' -// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports". -//@ count - '//*[@id="main-content"]/h2' 2 -//@ has - '//*[@id="main-content"]/h2' 'Structs' -//@ has - '//*[@id="main-content"]/h2' 'Re-exports' -// The 3 re-exports. -//@ count - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 3 -// The public struct. -//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1 - -mod ext { - pub trait Foo {} - pub trait Bar {} - pub struct S; -} - -pub use crate::ext::Foo as _; -pub use crate::ext::Bar as _; -pub use crate::ext::S as _; - -pub struct Bla; diff --git a/tests/rustdoc/auxiliary/alias-reexport.rs b/tests/rustdoc/auxiliary/alias-reexport.rs deleted file mode 100644 index 14fafc02d36..00000000000 --- a/tests/rustdoc/auxiliary/alias-reexport.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![feature(lazy_type_alias)] - -pub type Reexported = u8; diff --git a/tests/rustdoc/auxiliary/alias-reexport2.rs b/tests/rustdoc/auxiliary/alias-reexport2.rs deleted file mode 100644 index ee1f242c1d4..00000000000 --- a/tests/rustdoc/auxiliary/alias-reexport2.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(lazy_type_alias)] - -extern crate alias_reexport; - -pub use alias_reexport::Reexported; - -//@ has 'foo/fn.foo.html' -//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo() -> Reexported' -pub fn foo() -> Reexported { 0 } -//@ has 'foo/fn.foo2.html' -//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo2() -> Result' -pub fn foo2() -> Result { Ok(0) } diff --git a/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs deleted file mode 100644 index a1a716f5a41..00000000000 --- a/tests/rustdoc/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_name = "colors"] - -pub struct Color; diff --git a/tests/rustdoc/auxiliary/issue-28927-1.rs b/tests/rustdoc/auxiliary/issue-28927-1.rs deleted file mode 100644 index 688c73428dd..00000000000 --- a/tests/rustdoc/auxiliary/issue-28927-1.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod detail { - pub extern crate issue_28927_2 as inner2; -} -pub use detail::inner2 as bar; diff --git a/tests/rustdoc/auxiliary/issue-28927-2.rs b/tests/rustdoc/auxiliary/issue-28927-2.rs deleted file mode 100644 index 7c0937fce20..00000000000 --- a/tests/rustdoc/auxiliary/issue-28927-2.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Baz; diff --git a/tests/rustdoc/auxiliary/primitive-reexport.rs b/tests/rustdoc/auxiliary/primitive-reexport.rs deleted file mode 100644 index 7c85038674b..00000000000 --- a/tests/rustdoc/auxiliary/primitive-reexport.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ compile-flags: --emit metadata --crate-type lib -//@ edition: 2018 - -#![crate_name = "foo"] - -pub mod bar { - pub use bool; - pub use char as my_char; -} diff --git a/tests/rustdoc/auxiliary/reexport-check.rs b/tests/rustdoc/auxiliary/reexport-check.rs deleted file mode 100644 index 672ccb1cf0e..00000000000 --- a/tests/rustdoc/auxiliary/reexport-check.rs +++ /dev/null @@ -1,2 +0,0 @@ -/// Docs in original -pub struct S; diff --git a/tests/rustdoc/auxiliary/reexport-doc-aux.rs b/tests/rustdoc/auxiliary/reexport-doc-aux.rs deleted file mode 100644 index 3400717eba1..00000000000 --- a/tests/rustdoc/auxiliary/reexport-doc-aux.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub struct Foo; - -impl Foo { - pub fn foo() {} -} diff --git a/tests/rustdoc/auxiliary/reexports.rs b/tests/rustdoc/auxiliary/reexports.rs deleted file mode 100644 index 4336993a36e..00000000000 --- a/tests/rustdoc/auxiliary/reexports.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![feature(decl_macro)] - -pub macro addr_of($place:expr) { - &raw const $place -} - -pub macro addr_of_crate($place:expr) { - &raw const $place -} - -pub macro addr_of_super($place:expr) { - &raw const $place -} - -pub macro addr_of_self($place:expr) { - &raw const $place -} - -pub macro addr_of_local($place:expr) { - &raw const $place -} - -pub struct Foo; -pub struct FooCrate; -pub struct FooSuper; -pub struct FooSelf; -pub struct FooLocal; - -pub enum Bar { Foo, } -pub enum BarCrate { Foo, } -pub enum BarSuper { Foo, } -pub enum BarSelf { Foo, } -pub enum BarLocal { Foo, } - -pub fn foo() {} -pub fn foo_crate() {} -pub fn foo_super() {} -pub fn foo_self() {} -pub fn foo_local() {} - -pub type Type = i32; -pub type TypeCrate = i32; -pub type TypeSuper = i32; -pub type TypeSelf = i32; -pub type TypeLocal = i32; - -pub union Union { - a: i8, - b: i8, -} -pub union UnionCrate { - a: i8, - b: i8, -} -pub union UnionSuper { - a: i8, - b: i8, -} -pub union UnionSelf { - a: i8, - b: i8, -} -pub union UnionLocal { - a: i8, - b: i8, -} diff --git a/tests/rustdoc/blanket-reexport-item.rs b/tests/rustdoc/blanket-reexport-item.rs deleted file mode 100644 index 199a47019a2..00000000000 --- a/tests/rustdoc/blanket-reexport-item.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-T"]//h3[@class="code-header"]' 'impl Into for T' -pub struct S2 {} -mod m { - pub struct S {} -} -pub use m::*; diff --git a/tests/rustdoc/cfg_doc_reexport.rs b/tests/rustdoc/cfg_doc_reexport.rs deleted file mode 100644 index 44ec3663284..00000000000 --- a/tests/rustdoc/cfg_doc_reexport.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![feature(doc_cfg)] -#![feature(no_core, lang_items)] - -#![crate_name = "foo"] -#![no_core] - -#[lang = "sized"] -trait Sized {} - -//@ has 'foo/index.html' -//@ has - '//dt/*[@class="stab portability"]' 'foobar' -//@ has - '//dt/*[@class="stab portability"]' 'bar' - -#[doc(cfg(feature = "foobar"))] -mod imp_priv { - //@ has 'foo/struct.BarPriv.html' - //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on crate feature foobar only.' - pub struct BarPriv {} - impl BarPriv { - pub fn test() {} - } -} -#[doc(cfg(feature = "foobar"))] -pub use crate::imp_priv::*; - -pub mod bar { - //@ has 'foo/bar/struct.Bar.html' - //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on crate feature bar only.' - #[doc(cfg(feature = "bar"))] - pub struct Bar; -} - -#[doc(cfg(feature = "bar"))] -pub use bar::Bar; diff --git a/tests/rustdoc/doc-hidden-reexports-109449.rs b/tests/rustdoc/doc-hidden-reexports-109449.rs deleted file mode 100644 index 78b9214300a..00000000000 --- a/tests/rustdoc/doc-hidden-reexports-109449.rs +++ /dev/null @@ -1,143 +0,0 @@ -// Test to enforce rules over re-exports inlining from -// . - -#![crate_name = "foo"] - -mod private_module { - #[doc(hidden)] - pub struct Public; - #[doc(hidden)] - pub type Bar = (); -} - -#[doc(hidden)] -mod module { - pub struct Public2; - pub type Bar2 = (); -} - -#[doc(hidden)] -pub type Bar3 = (); -#[doc(hidden)] -pub struct FooFoo; - -// Checking that re-exporting a `#[doc(hidden)]` item will NOT inline it. -pub mod single_reexport { - //@ has 'foo/single_reexport/index.html' - - // First we check that we have 4 type aliases. - //@ count - '//*[@id="main-content"]/*[@class="item-table reexports"]//code' 0 - - // Then we check that we have the correct link for each re-export. - - //@ !has - '//*[@href="struct.Foo.html"]' 'Foo' - //@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' - pub use crate::private_module::Public as Foo; - //@ !has - '//*[@href="type.Foo2.html"]' 'Foo2' - //@ !has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' - pub use crate::private_module::Bar as Foo2; - //@ !has - '//*[@href="type.Yo.html"]' 'Yo' - //@ !has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' - pub use crate::Bar3 as Yo; - //@ !has - '//*[@href="struct.Yo2.html"]' 'Yo2' - //@ !has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' - pub use crate::FooFoo as Yo2; - - // Checking that each file is also created as expected. - //@ !has 'foo/single_reexport/struct.Foo.html' - //@ !has 'foo/single_reexport/type.Foo2.html' - //@ !has 'foo/single_reexport/type.Yo.html' - //@ !has 'foo/single_reexport/struct.Yo2.html' -} - -// However, re-exporting an item inheriting `#[doc(hidden)]` will inline it. -pub mod single_reexport_inherit_hidden { - //@ has 'foo/single_reexport_inherit_hidden/index.html' - - //@ has - '//*[@href="struct.Foo3.html"]' 'Foo3' - pub use crate::module::Public2 as Foo3; - //@ has - '//*[@href="type.Foo4.html"]' 'Foo4' - pub use crate::module::Bar2 as Foo4; - - //@ has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' - //@ has 'foo/single_reexport_inherit_hidden/type.Foo4.html' -} - -pub mod single_reexport_no_inline { - // First we ensure that we only have re-exports and no inlined items. - //@ has 'foo/single_reexport_no_inline/index.html' - //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' - - // Now we check that we don't have links to the items, just `pub use`. - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' - //@ !has - '//*[@id="main-content"]//a' 'XFoo' - #[doc(no_inline)] - pub use crate::private_module::Public as XFoo; - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' - //@ !has - '//*[@id="main-content"]//a' 'Foo2' - #[doc(no_inline)] - pub use crate::private_module::Bar as Foo2; - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' - //@ !has - '//*[@id="main-content"]//a' 'Yo' - #[doc(no_inline)] - pub use crate::Bar3 as Yo; - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' - //@ !has - '//*[@id="main-content"]//a' 'Yo2' - #[doc(no_inline)] - pub use crate::FooFoo as Yo2; - //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' - //@ !has - '//*[@id="main-content"]//a' 'Foo3' - #[doc(no_inline)] - pub use crate::module::Public2 as Foo3; - //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' - //@ !has - '//*[@id="main-content"]//a' 'Foo4' - #[doc(no_inline)] - pub use crate::module::Bar2 as Foo4; -} - -// Checking that glob re-exports don't inline `#[doc(hidden)]` items. -pub mod glob_reexport { - // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items - // should be inlined. - //@ has 'foo/glob_reexport/index.html' - //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' - - // Now we check we have 1 re-export and 2 inlined items. - // If not item from a glob re-export is visible, we don't show the re-export. - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' - pub use crate::private_module::*; - //@ has - '//*[@id="main-content"]//*' 'pub use crate::*;' - pub use crate::*; - // This one should be inlined. - //@ !has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' - //@ has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' - //@ has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' - // And we check that the two files were created too. - //@ has 'foo/glob_reexport/struct.Public2.html' - //@ has 'foo/glob_reexport/type.Bar2.html' - pub use crate::module::*; -} - -mod private { - /// Original. - pub struct Bar3; -} - -// Checking that `#[doc(hidden)]` re-exports documentation isn't generated. -pub mod doc_hidden_reexport { - //@ has 'foo/doc_hidden_reexport/index.html' - // Ensure there is only one item in this page and that it's a struct. - //@ count - '//dt' 1 - //@ has - '//a[@class="struct"]' 'Reexport' - // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. - //@ has - '//dd' 'Visible. Original.' - /// Visible. - pub use self::Bar3 as Reexport; - /// Hidden. - #[doc(hidden)] - pub use crate::private::Bar3; -} diff --git a/tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs b/tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs deleted file mode 100644 index 76b25127a9c..00000000000 --- a/tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs - -// https://github.com/rust-lang/rust/issues/113982 -#![feature(no_core, doc_auto_cfg)] -#![no_core] -#![crate_name = "foo"] - -extern crate colors; - -//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' -//@ has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ -// 'Available on non-crate feature colors only.' -#[cfg(not(feature = "colors"))] -pub use colors::*; - -//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' -//@ has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ -// 'Available on non-crate feature fruits only.' -#[cfg(not(feature = "fruits"))] -pub use colors::Color as Red; diff --git a/tests/rustdoc/duplicated-glob-reexport-60522.rs b/tests/rustdoc/duplicated-glob-reexport-60522.rs deleted file mode 100644 index a75a21c2dac..00000000000 --- a/tests/rustdoc/duplicated-glob-reexport-60522.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Regression test for . -// This test ensures that the `banana` and `peach` modules don't appear twice -// and that the visible modules are not the re-exported ones. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Modules' -//@ count - '//*[@id="main-content"]/*[@class="item-table"]//*[@class="mod"]' 2 -//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'banana' -//@ has - '//*[@id="main-content"]//*[@href="banana/index.html"]' 'banana' -//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'peach' -//@ has - '//*[@id="main-content"]//*[@href="peach/index.html"]' 'peach' - -pub use crate::my_crate::*; - -mod my_crate { - pub mod banana { - pub struct Yellow; - } - pub mod peach { - pub struct Pink; - } -} - -//@ has 'foo/banana/index.html' -//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 -//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Brown' -pub mod banana { - pub struct Brown; -} - -//@ has 'foo/peach/index.html' -//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 -//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Pungent' -pub mod peach { - pub struct Pungent; -} diff --git a/tests/rustdoc/enum-variant-reexport-35488.rs b/tests/rustdoc/enum-variant-reexport-35488.rs deleted file mode 100644 index b8e42ef7a89..00000000000 --- a/tests/rustdoc/enum-variant-reexport-35488.rs +++ /dev/null @@ -1,16 +0,0 @@ -// https://github.com/rust-lang/rust/issues/35488 -#![crate_name="foo"] - -mod foo { - pub enum Foo { - Bar, - } - pub use self::Foo::*; -} - -//@ has 'foo/index.html' '//code' 'pub use self::Foo::*;' -//@ has 'foo/enum.Foo.html' -pub use self::foo::*; - -//@ has 'foo/index.html' '//code' 'pub use std::option::Option::None;' -pub use std::option::Option::None; diff --git a/tests/rustdoc/foreigntype-reexport.rs b/tests/rustdoc/foreigntype-reexport.rs deleted file mode 100644 index 22c1852adf5..00000000000 --- a/tests/rustdoc/foreigntype-reexport.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![feature(extern_types)] - -mod sub { - extern "C" { - /// Another extern type. - pub type C2; - pub fn f2(); - pub static K: usize; - } -} - -pub mod sub2 { - extern "C" { - //@ has foreigntype_reexport/sub2/foreigntype.C.html - pub type C; - //@ has foreigntype_reexport/sub2/fn.f.html - pub fn f(); - //@ has foreigntype_reexport/sub2/static.K3.html - pub static K3: usize; - } -} - -mod sub3 { - extern "C" { - pub type C4; - pub fn f4(); - pub static K4: usize; - type X4; - } -} - -//@ has foreigntype_reexport/foreigntype.C2.html -//@ has foreigntype_reexport/fn.f2.html -//@ has foreigntype_reexport/static.K2.html -//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C2' -//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f2' -//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K2' -pub use self::sub::{f2, C2, K as K2}; - -//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C' -//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f' -//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K3' -//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::C as C3;' -//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::f as f3;' -//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::K3;' -pub use self::sub2::{f as f3, C as C3, K3}; - -//@ has foreigntype_reexport/foreigntype.C4.html -//@ has foreigntype_reexport/fn.f4.html -//@ has foreigntype_reexport/static.K4.html -//@ !has foreigntype_reexport/foreigntype.X4.html -//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C4' -//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f4' -//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K4' -//@ !has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'X4' -pub use self::sub3::*; diff --git a/tests/rustdoc/glob-reexport-attribute-merge-120487.rs b/tests/rustdoc/glob-reexport-attribute-merge-120487.rs deleted file mode 100644 index 5b918e0ffd9..00000000000 --- a/tests/rustdoc/glob-reexport-attribute-merge-120487.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This test ensures that non-glob reexports don't get their attributes merge with -// the reexported item whereas glob reexports do. -// Regression test for . - -#![crate_name = "foo"] -#![feature(doc_cfg)] - -//@ has 'foo/index.html' -// There are two items. -//@ count - '//*[@class="item-table"]/dt' 2 -// Only one of them should have an attribute. -//@ count - '//*[@class="item-table"]/dt/*[@class="stab portability"]' 1 - -mod a { - #[doc(cfg(not(feature = "a")))] - #[cfg(not(feature = "a"))] - pub struct Test1; -} - -mod b { - #[doc(cfg(not(feature = "a")))] - #[cfg(not(feature = "a"))] - pub struct Test2; -} - -//@ has 'foo/struct.Test1.html' -//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' -pub use a::*; -//@ has 'foo/struct.Test2.html' -//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 -pub use b::Test2; diff --git a/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs deleted file mode 100644 index d0a2165ec8a..00000000000 --- a/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This test ensures that non-glob reexports don't get their attributes merge with -// the reexported item whereas glob reexports do with the `doc_auto_cfg` feature. - -#![crate_name = "foo"] -#![feature(doc_auto_cfg)] - -//@ has 'foo/index.html' -// There are two items. -//@ count - '//*[@class="item-table"]/dt' 2 -// Only one of them should have an attribute. -//@ count - '//*[@class="item-table"]/dt/*[@class="stab portability"]' 1 - -mod a { - #[cfg(not(feature = "a"))] - pub struct Test1; -} - -mod b { - #[cfg(not(feature = "a"))] - pub struct Test2; -} - -//@ has 'foo/struct.Test1.html' -//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' -pub use a::*; -//@ has 'foo/struct.Test2.html' -//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 -pub use b::Test2; diff --git a/tests/rustdoc/ice-reexport-crate-root-28927.rs b/tests/rustdoc/ice-reexport-crate-root-28927.rs deleted file mode 100644 index b4215f7d1aa..00000000000 --- a/tests/rustdoc/ice-reexport-crate-root-28927.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:issue-28927-2.rs -//@ aux-build:issue-28927-1.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/28927 -#![crate_name="issue_28927"] - -pub extern crate issue_28927_1 as inner1; -pub use inner1 as foo; diff --git a/tests/rustdoc/local-reexport-doc.rs b/tests/rustdoc/local-reexport-doc.rs deleted file mode 100644 index 6db8f999d29..00000000000 --- a/tests/rustdoc/local-reexport-doc.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This test ensures that the reexports of local items also get the doc from -// the reexport. - -#![crate_name = "foo"] - -//@ has 'foo/fn.g.html' -//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' \ -// 'outer module inner module' - -mod inner_mod { - /// inner module - pub fn g() {} -} - -/// outer module -pub use inner_mod::g; diff --git a/tests/rustdoc/no-compiler-reexport.rs b/tests/rustdoc/no-compiler-reexport.rs deleted file mode 100644 index 355d47d7ba7..00000000000 --- a/tests/rustdoc/no-compiler-reexport.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items - -#![crate_name = "foo"] - -//@ !has 'foo/index.html' '//code' 'extern crate std;' -//@ !has 'foo/index.html' '//code' 'use std::prelude' -pub struct Foo; diff --git a/tests/rustdoc/overlapping-reexport-105735-2.rs b/tests/rustdoc/overlapping-reexport-105735-2.rs deleted file mode 100644 index fa43924ff4e..00000000000 --- a/tests/rustdoc/overlapping-reexport-105735-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. -// https://github.com/rust-lang/rust/issues/105735 - -#![crate_name = "foo"] -#![no_std] - -//@ has 'foo/index.html' -//@ has - '//dt/a[@class="type"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' -// We also ensure we don't have another item displayed. -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' - -mod other { - pub type AtomicU8 = (); -} - -mod thing { - pub use crate::other::AtomicU8; - - #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); -} - -pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/overlapping-reexport-105735.rs b/tests/rustdoc/overlapping-reexport-105735.rs deleted file mode 100644 index d1b5c0b6749..00000000000 --- a/tests/rustdoc/overlapping-reexport-105735.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. -// https://github.com/rust-lang/rust/issues/105735 - -#![crate_name = "foo"] -#![no_std] - -//@ has 'foo/index.html' -//@ has - '//dt/a[@class="struct"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' -// We also ensure we don't have another item displayed. -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' - -mod thing { - pub use core::sync::atomic::AtomicU8; - - #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); -} - -pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/primitive-reexport.rs b/tests/rustdoc/primitive-reexport.rs deleted file mode 100644 index 9b23b24fc93..00000000000 --- a/tests/rustdoc/primitive-reexport.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ aux-build: primitive-reexport.rs -//@ compile-flags: --extern foo -//@ edition: 2018 - -#![crate_name = "bar"] - -//@ has bar/p/index.html -//@ has - '//code' 'pub use bool;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -//@ has - '//code' 'pub use char as my_char;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' -pub mod p { - pub use foo::bar::*; -} - -//@ has bar/baz/index.html -//@ has - '//code' 'pub use bool;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -//@ has - '//code' 'pub use char as my_char;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' -pub use foo::bar as baz; - -//@ has bar/index.html -//@ has - '//code' 'pub use str;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.str.html"]' 'str' -//@ has - '//code' 'pub use i32 as my_i32;' -//@ has - '//code/a[@href="{{channel}}/std/primitive.i32.html"]' 'i32' -pub use str; -pub use i32 as my_i32; diff --git a/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs b/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs deleted file mode 100644 index f9569902927..00000000000 --- a/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs +++ /dev/null @@ -1,24 +0,0 @@ -// This is a regression test for . -// This test ensures that if public re-exported is re-exported, it won't be inlined. - -#![crate_name = "foo"] - -//@ has 'foo/associations/index.html' -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' -//@ has - '//*[@id="main-content"]//a[@href="trait.GroupedBy.html"]' 'GroupedBy' -//@ has 'foo/associations/trait.GroupedBy.html' -pub mod associations { - mod belongs_to { - pub trait GroupedBy {} - } - pub use self::belongs_to::GroupedBy; -} - -//@ has 'foo/prelude/index.html' -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' -//@ has - '//*[@id="main-content"]//*[@id="reexport.GroupedBy"]' 'pub use associations::GroupedBy;' -pub mod prelude { - pub use associations::GroupedBy; -} diff --git a/tests/rustdoc/reexport-attr-merge.rs b/tests/rustdoc/reexport-attr-merge.rs deleted file mode 100644 index aef302eb0b2..00000000000 --- a/tests/rustdoc/reexport-attr-merge.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Regression test for . -// The goal is to ensure that `doc(hidden)`, `doc(inline)` and `doc(no_inline)` -// are not copied from an item when inlined. - -#![crate_name = "foo"] -#![feature(doc_cfg)] - -//@ has 'foo/index.html' - -#[doc(hidden, cfg(feature = "foo"))] -pub struct Foo; - -#[doc(hidden, no_inline, cfg(feature = "bar"))] -pub use Foo as Foo1; - -#[doc(hidden, inline)] -pub use Foo1 as Foo2; - -// First we ensure that only the reexport `Bar2` and the inlined struct `Bar` -// are inlined. -//@ count - '//a[@class="struct"]' 1 -// Then we check that `cfg` is displayed for base item, but not for intermediate re-exports. -//@ has - '//*[@class="stab portability"]' 'foo' -//@ !has - '//*[@class="stab portability"]' 'bar' -// And finally we check that the only element displayed is `Bar`. -//@ has - '//a[@class="struct"]' 'Bar' -#[doc(inline)] -pub use Foo2 as Bar; - -// This one should appear but `Bar2` won't be linked because there is no -// `#[doc(inline)]`. -//@ !has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;' -pub use Foo2 as Bar2; diff --git a/tests/rustdoc/reexport-cfg.rs b/tests/rustdoc/reexport-cfg.rs deleted file mode 100644 index 73b66824316..00000000000 --- a/tests/rustdoc/reexport-cfg.rs +++ /dev/null @@ -1,30 +0,0 @@ -// This test ensures that only the re-export `cfg` will be displayed and that it won't -// include `cfg`s from the previous chained items. - -#![crate_name = "foo"] -#![feature(doc_auto_cfg, doc_cfg)] - -mod foo { - #[cfg(not(feature = "foo"))] - pub struct Bar; - - #[doc(cfg(not(feature = "bar")))] - pub struct Bar2; -} - -//@ has 'foo/index.html' -//@ has - '//dt' 'BabarNon-lie' -#[cfg(not(feature = "lie"))] -pub use crate::foo::Bar as Babar; - -//@ has - '//dt' 'Babar2Non-cake' -#[doc(cfg(not(feature = "cake")))] -pub use crate::foo::Bar2 as Babar2; - -//@ has - '//*[@class="item-table reexports"]/dt' 'pub use crate::Babar as Elephant;Non-robot' -#[cfg(not(feature = "robot"))] -pub use crate::Babar as Elephant; - -//@ has - '//*[@class="item-table reexports"]/dt' 'pub use crate::Babar2 as Elephant2;Non-cat' -#[doc(cfg(not(feature = "cat")))] -pub use crate::Babar2 as Elephant2; diff --git a/tests/rustdoc/reexport-check.rs b/tests/rustdoc/reexport-check.rs deleted file mode 100644 index fc10e3aadd0..00000000000 --- a/tests/rustdoc/reexport-check.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build:reexport-check.rs -#![crate_name = "foo"] - -extern crate reexport_check; - -//@ !has 'foo/index.html' '//code' 'pub use self::i32;' -//@ has 'foo/i32/index.html' -#[allow(deprecated, deprecated_in_future)] -pub use std::i32; -//@ !has 'foo/index.html' '//code' 'pub use self::string::String;' -//@ has 'foo/index.html' '//dt' 'String' -pub use std::string::String; - -// i32 is deprecated, String is not -//@ count 'foo/index.html' '//span[@class="stab deprecated"]' 1 - -//@ has 'foo/index.html' '//dd' 'Docs in original' -// this is a no-op, but shows what happens if there's an attribute that isn't a doc-comment -#[doc(inline)] -pub use reexport_check::S; diff --git a/tests/rustdoc/reexport-dep-foreign-fn.rs b/tests/rustdoc/reexport-dep-foreign-fn.rs deleted file mode 100644 index 1b63fcff017..00000000000 --- a/tests/rustdoc/reexport-dep-foreign-fn.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ aux-build:all-item-types.rs - -// This test is to ensure there is no problem on handling foreign functions -// coming from a dependency. - -#![crate_name = "foo"] - -extern crate all_item_types; - -//@ has 'foo/fn.foo_ffn.html' -//@ has - '//*[@class="rust item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' -pub use all_item_types::foo_ffn; diff --git a/tests/rustdoc/reexport-doc-hidden-inside-private.rs b/tests/rustdoc/reexport-doc-hidden-inside-private.rs deleted file mode 100644 index bae2aa78ec7..00000000000 --- a/tests/rustdoc/reexport-doc-hidden-inside-private.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This test ensures that a re-export of `#[doc(hidden)]` item inside a private -// module will still be displayed (the re-export, not the item). - -#![crate_name = "foo"] - -mod private_module { - #[doc(hidden)] - pub struct Public; -} - -//@ has 'foo/index.html' -//@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' -pub use crate::private_module::Public as Foo; -// Glob re-exports with no visible items should not be displayed. -//@ count - '//*[@class="item-table reexports"]/dt' 0 -pub use crate::private_module::*; diff --git a/tests/rustdoc/reexport-doc-hidden.rs b/tests/rustdoc/reexport-doc-hidden.rs deleted file mode 100644 index 1468e9ad957..00000000000 --- a/tests/rustdoc/reexport-doc-hidden.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Part of . -// This test ensures that reexporting a `doc(hidden)` item will -// still show the reexport. - -#![crate_name = "foo"] - -#[doc(hidden)] -pub type Type = u32; - -//@ has 'foo/index.html' -//@ !has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;' -pub use crate::Type as Type2; - -//@ count - '//*[@id="reexport.Type3"]' 0 -#[doc(hidden)] -pub use crate::Type as Type3; - -#[macro_export] -#[doc(hidden)] -macro_rules! foo { - () => {}; -} - -//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' -pub use crate::foo as Macro; diff --git a/tests/rustdoc/reexport-doc.rs b/tests/rustdoc/reexport-doc.rs deleted file mode 100644 index 0c20de41231..00000000000 --- a/tests/rustdoc/reexport-doc.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:reexport-doc-aux.rs - -extern crate reexport_doc_aux as dep; - -//@ has 'reexport_doc/struct.Foo.html' -//@ count - '//p' 'These are the docs for Foo.' 1 -/// These are the docs for Foo. -pub use dep::Foo; diff --git a/tests/rustdoc/reexport-hidden-macro.rs b/tests/rustdoc/reexport-hidden-macro.rs deleted file mode 100644 index 7345149c645..00000000000 --- a/tests/rustdoc/reexport-hidden-macro.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Ensure that inlined reexport of hidden macros is working as expected. -// Part of . - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2' -//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' - -//@ has 'foo/macro.Macro2.html' -//@ has - '//*[@class="docblock"]' 'Displayed' - -#[macro_export] -#[doc(hidden)] -macro_rules! foo { - () => {}; -} - -pub use crate::foo as Macro; -/// Displayed -#[doc(inline)] -pub use crate::foo as Macro2; diff --git a/tests/rustdoc/reexport-macro.rs b/tests/rustdoc/reexport-macro.rs deleted file mode 100644 index 7e041eb90ba..00000000000 --- a/tests/rustdoc/reexport-macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Ensure that macros are correctly reexported and that they get both the comment from the -// `pub use` and from the macro. - -#![crate_name = "foo"] - -//@ has 'foo/macro.foo.html' -//@ !has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' -//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'y' -#[macro_use] -mod my_module { - /// y - #[macro_export] - macro_rules! foo { - () => (); - } -} - -//@ has 'foo/another_mod/macro.bar.html' -//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' -pub mod another_mod { - /// x - pub use crate::foo as bar; -} diff --git a/tests/rustdoc/reexport-of-doc-hidden.rs b/tests/rustdoc/reexport-of-doc-hidden.rs deleted file mode 100644 index e901d0ff8a2..00000000000 --- a/tests/rustdoc/reexport-of-doc-hidden.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This test ensures that all re-exports of doc hidden elements are displayed. - -#![crate_name = "foo"] - -#[doc(hidden)] -pub struct Bar; - -#[macro_export] -#[doc(hidden)] -macro_rules! foo { - () => {}; -} - -//@ has 'foo/index.html' -//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' -pub use crate::foo as Macro; -//@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' -pub use crate::foo as Macro2; -//@ !has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;' -pub use crate::Bar as Boo; -//@ !has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;' -pub use crate::Bar as Boo2; - -pub fn fofo() {} - -//@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' -pub use crate::fofo as f1; -//@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' -pub use crate::fofo as f2; - -pub mod sub { - //@ has 'foo/sub/index.html' - //@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' - pub use crate::foo as Macro; - //@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' - pub use crate::foo as Macro2; - - //@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' - pub use crate::fofo as f1; - //@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' - pub use crate::fofo as f2; -} diff --git a/tests/rustdoc/reexport-of-reexport-108679.rs b/tests/rustdoc/reexport-of-reexport-108679.rs deleted file mode 100644 index 0d2faf71d32..00000000000 --- a/tests/rustdoc/reexport-of-reexport-108679.rs +++ /dev/null @@ -1,30 +0,0 @@ -// This test ensures that the `struct.B.html` only exists in `a`: -// since `a::B` is public (and inlined too), `self::a::B` doesn't -// need to be inlined as well. - -#![crate_name = "foo"] - -pub mod a { - //@ has 'foo/a/index.html' - // Should only contain "Structs". - //@ count - '//*[@id="main-content"]//*[@class="item-table"]' 1 - //@ has - '//*[@id="structs"]' 'Structs' - //@ has - '//*[@id="main-content"]//a[@href="struct.A.html"]' 'A' - //@ has - '//*[@id="main-content"]//a[@href="struct.B.html"]' 'B' - mod b { - pub struct B; - } - pub use self::b::B; - pub struct A; -} - -//@ has 'foo/index.html' -//@ !has - '//*[@id="structs"]' 'Structs' -//@ has - '//*[@id="reexports"]' 'Re-exports' -//@ has - '//*[@id="modules"]' 'Modules' -//@ has - '//*[@id="main-content"]//*[@id="reexport.A"]' 'pub use self::a::A;' -//@ has - '//*[@id="main-content"]//*[@id="reexport.B"]' 'pub use self::a::B;' -// Should only contain "Modules" and "Re-exports". -//@ count - '//*[@id="main-content"]//*[@class="item-table"]' 1 -//@ count - '//*[@id="main-content"]//*[@class="item-table reexports"]' 1 -pub use self::a::{A, B}; diff --git a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs b/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs deleted file mode 100644 index f83f28f458e..00000000000 --- a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![crate_name = "foo"] -#![feature(doc_cfg)] - -pub mod tag { - #[deprecated(since = "0.1.8", note = "Use bar() instead")] - pub trait Deprecated {} - - #[doc(cfg(feature = "sync"))] - pub trait Portability {} - - #[deprecated(since = "0.1.8", note = "Use bar() instead")] - #[doc(cfg(feature = "sync"))] - pub trait Both {} - - pub trait None {} -} - -//@ has foo/mod1/index.html -pub mod mod1 { - //@ has - '//code' 'pub use tag::Deprecated;' - //@ has - '//span' 'Deprecated' - //@ !has - '//span' 'sync' - pub use tag::Deprecated; -} - -//@ has foo/mod2/index.html -pub mod mod2 { - //@ has - '//code' 'pub use tag::Portability;' - //@ !has - '//span' 'Deprecated' - //@ !has - '//span' 'sync' - pub use tag::Portability; -} - -//@ has foo/mod3/index.html -pub mod mod3 { - //@ has - '//code' 'pub use tag::Both;' - //@ has - '//span' 'Deprecated' - //@ !has - '//span' 'sync' - pub use tag::Both; -} - -//@ has foo/mod4/index.html -pub mod mod4 { - //@ has - '//code' 'pub use tag::None;' - //@ !has - '//span' 'Deprecated' - //@ !has - '//span' 'sync' - pub use tag::None; -} diff --git a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs b/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs deleted file mode 100644 index adf3eed204a..00000000000 --- a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![crate_name = "foo"] -#![feature(doc_cfg)] -#![feature(staged_api)] -#![stable(feature = "rust1", since = "1.0.0")] - -#[stable(feature = "rust1", since = "1.0.0")] -pub mod tag { - #[unstable(feature = "humans", issue = "none")] - pub trait Unstable {} - - #[stable(feature = "rust1", since = "1.0.0")] - #[doc(cfg(feature = "sync"))] - pub trait Portability {} - - #[unstable(feature = "humans", issue = "none")] - #[doc(cfg(feature = "sync"))] - pub trait Both {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub trait None {} -} - -//@ has foo/mod1/index.html -#[stable(feature = "rust1", since = "1.0.0")] -pub mod mod1 { - //@ has - '//code' 'pub use tag::Unstable;' - //@ has - '//span' 'Experimental' - //@ !has - '//span' 'sync' - #[stable(feature = "rust1", since = "1.0.0")] - pub use tag::Unstable; -} - -//@ has foo/mod2/index.html -#[stable(feature = "rust1", since = "1.0.0")] -pub mod mod2 { - //@ has - '//code' 'pub use tag::Portability;' - //@ !has - '//span' 'Experimental' - //@ !has - '//span' 'sync' - #[stable(feature = "rust1", since = "1.0.0")] - pub use tag::Portability; -} - -//@ has foo/mod3/index.html -#[stable(feature = "rust1", since = "1.0.0")] -pub mod mod3 { - //@ has - '//code' 'pub use tag::Both;' - //@ has - '//span' 'Experimental' - //@ !has - '//span' 'sync' - #[stable(feature = "rust1", since = "1.0.0")] - pub use tag::Both; -} - -//@ has foo/mod4/index.html -#[stable(feature = "rust1", since = "1.0.0")] -pub mod mod4 { - //@ has - '//code' 'pub use tag::None;' - //@ !has - '//span' 'Experimental' - //@ !has - '//span' 'sync' - #[stable(feature = "rust1", since = "1.0.0")] - pub use tag::None; -} diff --git a/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs b/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs deleted file mode 100644 index 61060b3ff7c..00000000000 --- a/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Regression test for . -#![feature(no_core, lang_items)] -#![no_core] -#![crate_name = "foo"] - -#[lang = "sized"] -trait Sized {} - -//@ files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ -// 'visible']" -//@ files "foo/hidden" "['inner']" -//@ files "foo/hidden/inner" "['trait.Foo.html']" -//@ files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" - -//@ !has 'foo/hidden/index.html' -//@ !has 'foo/hidden/inner/index.html' -// FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 -//@ has 'foo/hidden/inner/trait.Foo.html' -//@ matchesraw - '' -#[doc(hidden)] -pub mod hidden { - pub mod inner { - pub trait Foo { - /// Hello, world! - fn test(); - } - } -} - -//@ has 'foo/visible/index.html' -//@ has 'foo/visible/trait.Foo.html' -#[doc(inline)] -pub use hidden::inner as visible; - -//@ has 'foo/struct.Bar.html' -//@ count - '//*[@id="impl-Foo-for-Bar"]' 1 -pub struct Bar; - -impl visible::Foo for Bar { - fn test() {} -} diff --git a/tests/rustdoc/reexport-trait-from-hidden-111064.rs b/tests/rustdoc/reexport-trait-from-hidden-111064.rs deleted file mode 100644 index 8b9ad7616ea..00000000000 --- a/tests/rustdoc/reexport-trait-from-hidden-111064.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Regression test for . -// Methods from a re-exported trait inside a `#[doc(hidden)]` item should -// be visible. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ has - '//*[@id="main-content"]//dt/a[@href="trait.Foo.html"]' 'Foo' - -//@ has 'foo/trait.Foo.html' -//@ has - '//*[@id="main-content"]//*[@class="code-header"]' 'fn test()' - -#[doc(hidden)] -mod hidden { - pub trait Foo { - /// Hello, world! - fn test(); - } -} - -pub use hidden::Foo; diff --git a/tests/rustdoc/reexport/alias-reexport.rs b/tests/rustdoc/reexport/alias-reexport.rs new file mode 100644 index 00000000000..41f1f8df0f6 --- /dev/null +++ b/tests/rustdoc/reexport/alias-reexport.rs @@ -0,0 +1,17 @@ +//@ aux-build:alias-reexport.rs +//@ aux-build:alias-reexport2.rs + +#![crate_name = "foo"] +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +extern crate alias_reexport2; + +//@ has 'foo/reexport/fn.foo.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +//@ has 'foo/reexport/fn.foo2.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' +//@ has 'foo/reexport/type.Reexported.html' +//@ has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' +#[doc(inline)] +pub use alias_reexport2 as reexport; diff --git a/tests/rustdoc/reexport/alias-reexport2.rs b/tests/rustdoc/reexport/alias-reexport2.rs new file mode 100644 index 00000000000..2fb69b922c8 --- /dev/null +++ b/tests/rustdoc/reexport/alias-reexport2.rs @@ -0,0 +1,17 @@ +// gate-test-lazy_type_alias +//@ aux-build:alias-reexport.rs + +#![crate_name = "foo"] +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +extern crate alias_reexport; + +use alias_reexport::Reexported; + +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +pub fn foo() -> Reexported { 0 } +//@ has 'foo/fn.foo2.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' +pub fn foo2() -> Result { Ok(0) } diff --git a/tests/rustdoc/reexport/anonymous-reexport-108931.rs b/tests/rustdoc/reexport/anonymous-reexport-108931.rs new file mode 100644 index 00000000000..b995c89b614 --- /dev/null +++ b/tests/rustdoc/reexport/anonymous-reexport-108931.rs @@ -0,0 +1,22 @@ +// Ensuring that anonymous re-exports are always inlined. +// https://github.com/rust-lang/rust/issues/108931 + +#![crate_name = "foo"] + +pub mod foo { + pub struct Foo; +} + +mod bar { + pub struct Bar; +} + +//@ has 'foo/index.html' +// We check that the only "h2" present are "Re-exports" and "Modules". +//@ count - '//*[@id="main-content"]/h2' 2 +//@ has - '//*[@id="main-content"]/h2' 'Re-exports' +//@ has - '//*[@id="main-content"]/h2' 'Modules' +//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use foo::Foo as _;' +//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use bar::Bar as _;' +pub use foo::Foo as _; +pub use bar::Bar as _; diff --git a/tests/rustdoc/reexport/anonymous-reexport.rs b/tests/rustdoc/reexport/anonymous-reexport.rs new file mode 100644 index 00000000000..bf5fa93f953 --- /dev/null +++ b/tests/rustdoc/reexport/anonymous-reexport.rs @@ -0,0 +1,26 @@ +#![crate_name = "foo"] + +// This test ensures we don't display anonymous (non-inline) re-exports of public items. + +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]' '' +// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports". +//@ count - '//*[@id="main-content"]/h2' 2 +//@ has - '//*[@id="main-content"]/h2' 'Structs' +//@ has - '//*[@id="main-content"]/h2' 'Re-exports' +// The 3 re-exports. +//@ count - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 3 +// The public struct. +//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1 + +mod ext { + pub trait Foo {} + pub trait Bar {} + pub struct S; +} + +pub use crate::ext::Foo as _; +pub use crate::ext::Bar as _; +pub use crate::ext::S as _; + +pub struct Bla; diff --git a/tests/rustdoc/reexport/auxiliary/alias-reexport.rs b/tests/rustdoc/reexport/auxiliary/alias-reexport.rs new file mode 100644 index 00000000000..14fafc02d36 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/alias-reexport.rs @@ -0,0 +1,3 @@ +#![feature(lazy_type_alias)] + +pub type Reexported = u8; diff --git a/tests/rustdoc/reexport/auxiliary/alias-reexport2.rs b/tests/rustdoc/reexport/auxiliary/alias-reexport2.rs new file mode 100644 index 00000000000..ee1f242c1d4 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/alias-reexport2.rs @@ -0,0 +1,12 @@ +#![feature(lazy_type_alias)] + +extern crate alias_reexport; + +pub use alias_reexport::Reexported; + +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo() -> Reexported' +pub fn foo() -> Reexported { 0 } +//@ has 'foo/fn.foo2.html' +//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo2() -> Result' +pub fn foo2() -> Result { Ok(0) } diff --git a/tests/rustdoc/reexport/auxiliary/all-item-types.rs b/tests/rustdoc/reexport/auxiliary/all-item-types.rs new file mode 100644 index 00000000000..f94bd998717 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/all-item-types.rs @@ -0,0 +1,22 @@ +#![feature(extern_types)] + +pub mod foo_mod {} +extern "C" { + pub fn foo_ffn(); + pub static FOO_FSTATIC: FooStruct; + pub type FooFType; +} +pub fn foo_fn() {} +pub trait FooTrait {} +pub struct FooStruct; +pub enum FooEnum {} +pub union FooUnion { + x: (), +} +pub type FooType = FooStruct; +pub static FOO_STATIC: FooStruct = FooStruct; +pub const FOO_CONSTANT: FooStruct = FooStruct; +#[macro_export] +macro_rules! foo_macro { + () => (); +} diff --git a/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs new file mode 100644 index 00000000000..a1a716f5a41 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs @@ -0,0 +1,3 @@ +#![crate_name = "colors"] + +pub struct Color; diff --git a/tests/rustdoc/reexport/auxiliary/issue-28927-1.rs b/tests/rustdoc/reexport/auxiliary/issue-28927-1.rs new file mode 100644 index 00000000000..688c73428dd --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/issue-28927-1.rs @@ -0,0 +1,4 @@ +mod detail { + pub extern crate issue_28927_2 as inner2; +} +pub use detail::inner2 as bar; diff --git a/tests/rustdoc/reexport/auxiliary/issue-28927-2.rs b/tests/rustdoc/reexport/auxiliary/issue-28927-2.rs new file mode 100644 index 00000000000..7c0937fce20 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/issue-28927-2.rs @@ -0,0 +1 @@ +pub struct Baz; diff --git a/tests/rustdoc/reexport/auxiliary/primitive-reexport.rs b/tests/rustdoc/reexport/auxiliary/primitive-reexport.rs new file mode 100644 index 00000000000..7c85038674b --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/primitive-reexport.rs @@ -0,0 +1,9 @@ +//@ compile-flags: --emit metadata --crate-type lib +//@ edition: 2018 + +#![crate_name = "foo"] + +pub mod bar { + pub use bool; + pub use char as my_char; +} diff --git a/tests/rustdoc/reexport/auxiliary/reexport-check.rs b/tests/rustdoc/reexport/auxiliary/reexport-check.rs new file mode 100644 index 00000000000..672ccb1cf0e --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/reexport-check.rs @@ -0,0 +1,2 @@ +/// Docs in original +pub struct S; diff --git a/tests/rustdoc/reexport/auxiliary/reexport-doc-aux.rs b/tests/rustdoc/reexport/auxiliary/reexport-doc-aux.rs new file mode 100644 index 00000000000..3400717eba1 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/reexport-doc-aux.rs @@ -0,0 +1,5 @@ +pub struct Foo; + +impl Foo { + pub fn foo() {} +} diff --git a/tests/rustdoc/reexport/auxiliary/reexports.rs b/tests/rustdoc/reexport/auxiliary/reexports.rs new file mode 100644 index 00000000000..4336993a36e --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/reexports.rs @@ -0,0 +1,66 @@ +#![feature(decl_macro)] + +pub macro addr_of($place:expr) { + &raw const $place +} + +pub macro addr_of_crate($place:expr) { + &raw const $place +} + +pub macro addr_of_super($place:expr) { + &raw const $place +} + +pub macro addr_of_self($place:expr) { + &raw const $place +} + +pub macro addr_of_local($place:expr) { + &raw const $place +} + +pub struct Foo; +pub struct FooCrate; +pub struct FooSuper; +pub struct FooSelf; +pub struct FooLocal; + +pub enum Bar { Foo, } +pub enum BarCrate { Foo, } +pub enum BarSuper { Foo, } +pub enum BarSelf { Foo, } +pub enum BarLocal { Foo, } + +pub fn foo() {} +pub fn foo_crate() {} +pub fn foo_super() {} +pub fn foo_self() {} +pub fn foo_local() {} + +pub type Type = i32; +pub type TypeCrate = i32; +pub type TypeSuper = i32; +pub type TypeSelf = i32; +pub type TypeLocal = i32; + +pub union Union { + a: i8, + b: i8, +} +pub union UnionCrate { + a: i8, + b: i8, +} +pub union UnionSuper { + a: i8, + b: i8, +} +pub union UnionSelf { + a: i8, + b: i8, +} +pub union UnionLocal { + a: i8, + b: i8, +} diff --git a/tests/rustdoc/reexport/blanket-reexport-item.rs b/tests/rustdoc/reexport/blanket-reexport-item.rs new file mode 100644 index 00000000000..199a47019a2 --- /dev/null +++ b/tests/rustdoc/reexport/blanket-reexport-item.rs @@ -0,0 +1,8 @@ +#![crate_name = "foo"] + +//@ has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-T"]//h3[@class="code-header"]' 'impl Into for T' +pub struct S2 {} +mod m { + pub struct S {} +} +pub use m::*; diff --git a/tests/rustdoc/reexport/cfg_doc_reexport.rs b/tests/rustdoc/reexport/cfg_doc_reexport.rs new file mode 100644 index 00000000000..44ec3663284 --- /dev/null +++ b/tests/rustdoc/reexport/cfg_doc_reexport.rs @@ -0,0 +1,36 @@ +#![feature(doc_cfg)] +#![feature(no_core, lang_items)] + +#![crate_name = "foo"] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +//@ has 'foo/index.html' +//@ has - '//dt/*[@class="stab portability"]' 'foobar' +//@ has - '//dt/*[@class="stab portability"]' 'bar' + +#[doc(cfg(feature = "foobar"))] +mod imp_priv { + //@ has 'foo/struct.BarPriv.html' + //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on crate feature foobar only.' + pub struct BarPriv {} + impl BarPriv { + pub fn test() {} + } +} +#[doc(cfg(feature = "foobar"))] +pub use crate::imp_priv::*; + +pub mod bar { + //@ has 'foo/bar/struct.Bar.html' + //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on crate feature bar only.' + #[doc(cfg(feature = "bar"))] + pub struct Bar; +} + +#[doc(cfg(feature = "bar"))] +pub use bar::Bar; diff --git a/tests/rustdoc/reexport/doc-hidden-reexports-109449.rs b/tests/rustdoc/reexport/doc-hidden-reexports-109449.rs new file mode 100644 index 00000000000..78b9214300a --- /dev/null +++ b/tests/rustdoc/reexport/doc-hidden-reexports-109449.rs @@ -0,0 +1,143 @@ +// Test to enforce rules over re-exports inlining from +// . + +#![crate_name = "foo"] + +mod private_module { + #[doc(hidden)] + pub struct Public; + #[doc(hidden)] + pub type Bar = (); +} + +#[doc(hidden)] +mod module { + pub struct Public2; + pub type Bar2 = (); +} + +#[doc(hidden)] +pub type Bar3 = (); +#[doc(hidden)] +pub struct FooFoo; + +// Checking that re-exporting a `#[doc(hidden)]` item will NOT inline it. +pub mod single_reexport { + //@ has 'foo/single_reexport/index.html' + + // First we check that we have 4 type aliases. + //@ count - '//*[@id="main-content"]/*[@class="item-table reexports"]//code' 0 + + // Then we check that we have the correct link for each re-export. + + //@ !has - '//*[@href="struct.Foo.html"]' 'Foo' + //@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' + pub use crate::private_module::Public as Foo; + //@ !has - '//*[@href="type.Foo2.html"]' 'Foo2' + //@ !has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' + pub use crate::private_module::Bar as Foo2; + //@ !has - '//*[@href="type.Yo.html"]' 'Yo' + //@ !has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' + pub use crate::Bar3 as Yo; + //@ !has - '//*[@href="struct.Yo2.html"]' 'Yo2' + //@ !has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' + pub use crate::FooFoo as Yo2; + + // Checking that each file is also created as expected. + //@ !has 'foo/single_reexport/struct.Foo.html' + //@ !has 'foo/single_reexport/type.Foo2.html' + //@ !has 'foo/single_reexport/type.Yo.html' + //@ !has 'foo/single_reexport/struct.Yo2.html' +} + +// However, re-exporting an item inheriting `#[doc(hidden)]` will inline it. +pub mod single_reexport_inherit_hidden { + //@ has 'foo/single_reexport_inherit_hidden/index.html' + + //@ has - '//*[@href="struct.Foo3.html"]' 'Foo3' + pub use crate::module::Public2 as Foo3; + //@ has - '//*[@href="type.Foo4.html"]' 'Foo4' + pub use crate::module::Bar2 as Foo4; + + //@ has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' + //@ has 'foo/single_reexport_inherit_hidden/type.Foo4.html' +} + +pub mod single_reexport_no_inline { + // First we ensure that we only have re-exports and no inlined items. + //@ has 'foo/single_reexport_no_inline/index.html' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' + + // Now we check that we don't have links to the items, just `pub use`. + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' + //@ !has - '//*[@id="main-content"]//a' 'XFoo' + #[doc(no_inline)] + pub use crate::private_module::Public as XFoo; + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' + //@ !has - '//*[@id="main-content"]//a' 'Foo2' + #[doc(no_inline)] + pub use crate::private_module::Bar as Foo2; + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' + //@ !has - '//*[@id="main-content"]//a' 'Yo' + #[doc(no_inline)] + pub use crate::Bar3 as Yo; + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' + //@ !has - '//*[@id="main-content"]//a' 'Yo2' + #[doc(no_inline)] + pub use crate::FooFoo as Yo2; + //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' + //@ !has - '//*[@id="main-content"]//a' 'Foo3' + #[doc(no_inline)] + pub use crate::module::Public2 as Foo3; + //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' + //@ !has - '//*[@id="main-content"]//a' 'Foo4' + #[doc(no_inline)] + pub use crate::module::Bar2 as Foo4; +} + +// Checking that glob re-exports don't inline `#[doc(hidden)]` items. +pub mod glob_reexport { + // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items + // should be inlined. + //@ has 'foo/glob_reexport/index.html' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' + + // Now we check we have 1 re-export and 2 inlined items. + // If not item from a glob re-export is visible, we don't show the re-export. + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' + pub use crate::private_module::*; + //@ has - '//*[@id="main-content"]//*' 'pub use crate::*;' + pub use crate::*; + // This one should be inlined. + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' + //@ has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' + //@ has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' + // And we check that the two files were created too. + //@ has 'foo/glob_reexport/struct.Public2.html' + //@ has 'foo/glob_reexport/type.Bar2.html' + pub use crate::module::*; +} + +mod private { + /// Original. + pub struct Bar3; +} + +// Checking that `#[doc(hidden)]` re-exports documentation isn't generated. +pub mod doc_hidden_reexport { + //@ has 'foo/doc_hidden_reexport/index.html' + // Ensure there is only one item in this page and that it's a struct. + //@ count - '//dt' 1 + //@ has - '//a[@class="struct"]' 'Reexport' + // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. + //@ has - '//dd' 'Visible. Original.' + /// Visible. + pub use self::Bar3 as Reexport; + /// Hidden. + #[doc(hidden)] + pub use crate::private::Bar3; +} diff --git a/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs b/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs new file mode 100644 index 00000000000..76b25127a9c --- /dev/null +++ b/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs @@ -0,0 +1,20 @@ +//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs + +// https://github.com/rust-lang/rust/issues/113982 +#![feature(no_core, doc_auto_cfg)] +#![no_core] +#![crate_name = "foo"] + +extern crate colors; + +//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' +//@ has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ +// 'Available on non-crate feature colors only.' +#[cfg(not(feature = "colors"))] +pub use colors::*; + +//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' +//@ has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ +// 'Available on non-crate feature fruits only.' +#[cfg(not(feature = "fruits"))] +pub use colors::Color as Red; diff --git a/tests/rustdoc/reexport/duplicated-glob-reexport-60522.rs b/tests/rustdoc/reexport/duplicated-glob-reexport-60522.rs new file mode 100644 index 00000000000..a75a21c2dac --- /dev/null +++ b/tests/rustdoc/reexport/duplicated-glob-reexport-60522.rs @@ -0,0 +1,39 @@ +// Regression test for . +// This test ensures that the `banana` and `peach` modules don't appear twice +// and that the visible modules are not the re-exported ones. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Modules' +//@ count - '//*[@id="main-content"]/*[@class="item-table"]//*[@class="mod"]' 2 +//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'banana' +//@ has - '//*[@id="main-content"]//*[@href="banana/index.html"]' 'banana' +//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'peach' +//@ has - '//*[@id="main-content"]//*[@href="peach/index.html"]' 'peach' + +pub use crate::my_crate::*; + +mod my_crate { + pub mod banana { + pub struct Yellow; + } + pub mod peach { + pub struct Pink; + } +} + +//@ has 'foo/banana/index.html' +//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 +//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Brown' +pub mod banana { + pub struct Brown; +} + +//@ has 'foo/peach/index.html' +//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 +//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Pungent' +pub mod peach { + pub struct Pungent; +} diff --git a/tests/rustdoc/reexport/enum-variant-reexport-35488.rs b/tests/rustdoc/reexport/enum-variant-reexport-35488.rs new file mode 100644 index 00000000000..b8e42ef7a89 --- /dev/null +++ b/tests/rustdoc/reexport/enum-variant-reexport-35488.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/35488 +#![crate_name="foo"] + +mod foo { + pub enum Foo { + Bar, + } + pub use self::Foo::*; +} + +//@ has 'foo/index.html' '//code' 'pub use self::Foo::*;' +//@ has 'foo/enum.Foo.html' +pub use self::foo::*; + +//@ has 'foo/index.html' '//code' 'pub use std::option::Option::None;' +pub use std::option::Option::None; diff --git a/tests/rustdoc/reexport/foreigntype-reexport.rs b/tests/rustdoc/reexport/foreigntype-reexport.rs new file mode 100644 index 00000000000..22c1852adf5 --- /dev/null +++ b/tests/rustdoc/reexport/foreigntype-reexport.rs @@ -0,0 +1,56 @@ +#![feature(extern_types)] + +mod sub { + extern "C" { + /// Another extern type. + pub type C2; + pub fn f2(); + pub static K: usize; + } +} + +pub mod sub2 { + extern "C" { + //@ has foreigntype_reexport/sub2/foreigntype.C.html + pub type C; + //@ has foreigntype_reexport/sub2/fn.f.html + pub fn f(); + //@ has foreigntype_reexport/sub2/static.K3.html + pub static K3: usize; + } +} + +mod sub3 { + extern "C" { + pub type C4; + pub fn f4(); + pub static K4: usize; + type X4; + } +} + +//@ has foreigntype_reexport/foreigntype.C2.html +//@ has foreigntype_reexport/fn.f2.html +//@ has foreigntype_reexport/static.K2.html +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C2' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f2' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K2' +pub use self::sub::{f2, C2, K as K2}; + +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K3' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::C as C3;' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::f as f3;' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::K3;' +pub use self::sub2::{f as f3, C as C3, K3}; + +//@ has foreigntype_reexport/foreigntype.C4.html +//@ has foreigntype_reexport/fn.f4.html +//@ has foreigntype_reexport/static.K4.html +//@ !has foreigntype_reexport/foreigntype.X4.html +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C4' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f4' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K4' +//@ !has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'X4' +pub use self::sub3::*; diff --git a/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs b/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs new file mode 100644 index 00000000000..5b918e0ffd9 --- /dev/null +++ b/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs @@ -0,0 +1,32 @@ +// This test ensures that non-glob reexports don't get their attributes merge with +// the reexported item whereas glob reexports do. +// Regression test for . + +#![crate_name = "foo"] +#![feature(doc_cfg)] + +//@ has 'foo/index.html' +// There are two items. +//@ count - '//*[@class="item-table"]/dt' 2 +// Only one of them should have an attribute. +//@ count - '//*[@class="item-table"]/dt/*[@class="stab portability"]' 1 + +mod a { + #[doc(cfg(not(feature = "a")))] + #[cfg(not(feature = "a"))] + pub struct Test1; +} + +mod b { + #[doc(cfg(not(feature = "a")))] + #[cfg(not(feature = "a"))] + pub struct Test2; +} + +//@ has 'foo/struct.Test1.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' +pub use a::*; +//@ has 'foo/struct.Test2.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 +pub use b::Test2; diff --git a/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs new file mode 100644 index 00000000000..d0a2165ec8a --- /dev/null +++ b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs @@ -0,0 +1,29 @@ +// This test ensures that non-glob reexports don't get their attributes merge with +// the reexported item whereas glob reexports do with the `doc_auto_cfg` feature. + +#![crate_name = "foo"] +#![feature(doc_auto_cfg)] + +//@ has 'foo/index.html' +// There are two items. +//@ count - '//*[@class="item-table"]/dt' 2 +// Only one of them should have an attribute. +//@ count - '//*[@class="item-table"]/dt/*[@class="stab portability"]' 1 + +mod a { + #[cfg(not(feature = "a"))] + pub struct Test1; +} + +mod b { + #[cfg(not(feature = "a"))] + pub struct Test2; +} + +//@ has 'foo/struct.Test1.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' +pub use a::*; +//@ has 'foo/struct.Test2.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 +pub use b::Test2; diff --git a/tests/rustdoc/reexport/ice-reexport-crate-root-28927.rs b/tests/rustdoc/reexport/ice-reexport-crate-root-28927.rs new file mode 100644 index 00000000000..b4215f7d1aa --- /dev/null +++ b/tests/rustdoc/reexport/ice-reexport-crate-root-28927.rs @@ -0,0 +1,9 @@ +//@ aux-build:issue-28927-2.rs +//@ aux-build:issue-28927-1.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/28927 +#![crate_name="issue_28927"] + +pub extern crate issue_28927_1 as inner1; +pub use inner1 as foo; diff --git a/tests/rustdoc/reexport/local-reexport-doc.rs b/tests/rustdoc/reexport/local-reexport-doc.rs new file mode 100644 index 00000000000..6db8f999d29 --- /dev/null +++ b/tests/rustdoc/reexport/local-reexport-doc.rs @@ -0,0 +1,16 @@ +// This test ensures that the reexports of local items also get the doc from +// the reexport. + +#![crate_name = "foo"] + +//@ has 'foo/fn.g.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' \ +// 'outer module inner module' + +mod inner_mod { + /// inner module + pub fn g() {} +} + +/// outer module +pub use inner_mod::g; diff --git a/tests/rustdoc/reexport/no-compiler-reexport.rs b/tests/rustdoc/reexport/no-compiler-reexport.rs new file mode 100644 index 00000000000..355d47d7ba7 --- /dev/null +++ b/tests/rustdoc/reexport/no-compiler-reexport.rs @@ -0,0 +1,7 @@ +//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items + +#![crate_name = "foo"] + +//@ !has 'foo/index.html' '//code' 'extern crate std;' +//@ !has 'foo/index.html' '//code' 'use std::prelude' +pub struct Foo; diff --git a/tests/rustdoc/reexport/overlapping-reexport-105735-2.rs b/tests/rustdoc/reexport/overlapping-reexport-105735-2.rs new file mode 100644 index 00000000000..fa43924ff4e --- /dev/null +++ b/tests/rustdoc/reexport/overlapping-reexport-105735-2.rs @@ -0,0 +1,26 @@ +// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// https://github.com/rust-lang/rust/issues/105735 + +#![crate_name = "foo"] +#![no_std] + +//@ has 'foo/index.html' +//@ has - '//dt/a[@class="type"]' 'AtomicU8' +//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +// We also ensure we don't have another item displayed. +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' + +mod other { + pub type AtomicU8 = (); +} + +mod thing { + pub use crate::other::AtomicU8; + + #[allow(non_upper_case_globals)] + pub const AtomicU8: () = (); +} + +pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/reexport/overlapping-reexport-105735.rs b/tests/rustdoc/reexport/overlapping-reexport-105735.rs new file mode 100644 index 00000000000..d1b5c0b6749 --- /dev/null +++ b/tests/rustdoc/reexport/overlapping-reexport-105735.rs @@ -0,0 +1,22 @@ +// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// https://github.com/rust-lang/rust/issues/105735 + +#![crate_name = "foo"] +#![no_std] + +//@ has 'foo/index.html' +//@ has - '//dt/a[@class="struct"]' 'AtomicU8' +//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +// We also ensure we don't have another item displayed. +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' + +mod thing { + pub use core::sync::atomic::AtomicU8; + + #[allow(non_upper_case_globals)] + pub const AtomicU8: () = (); +} + +pub use crate::thing::AtomicU8; diff --git a/tests/rustdoc/reexport/primitive-reexport.rs b/tests/rustdoc/reexport/primitive-reexport.rs new file mode 100644 index 00000000000..9b23b24fc93 --- /dev/null +++ b/tests/rustdoc/reexport/primitive-reexport.rs @@ -0,0 +1,29 @@ +//@ aux-build: primitive-reexport.rs +//@ compile-flags: --extern foo +//@ edition: 2018 + +#![crate_name = "bar"] + +//@ has bar/p/index.html +//@ has - '//code' 'pub use bool;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//code' 'pub use char as my_char;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub mod p { + pub use foo::bar::*; +} + +//@ has bar/baz/index.html +//@ has - '//code' 'pub use bool;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//code' 'pub use char as my_char;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub use foo::bar as baz; + +//@ has bar/index.html +//@ has - '//code' 'pub use str;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.str.html"]' 'str' +//@ has - '//code' 'pub use i32 as my_i32;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.i32.html"]' 'i32' +pub use str; +pub use i32 as my_i32; diff --git a/tests/rustdoc/reexport/pub-reexport-of-pub-reexport-46506.rs b/tests/rustdoc/reexport/pub-reexport-of-pub-reexport-46506.rs new file mode 100644 index 00000000000..f9569902927 --- /dev/null +++ b/tests/rustdoc/reexport/pub-reexport-of-pub-reexport-46506.rs @@ -0,0 +1,24 @@ +// This is a regression test for . +// This test ensures that if public re-exported is re-exported, it won't be inlined. + +#![crate_name = "foo"] + +//@ has 'foo/associations/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' +//@ has - '//*[@id="main-content"]//a[@href="trait.GroupedBy.html"]' 'GroupedBy' +//@ has 'foo/associations/trait.GroupedBy.html' +pub mod associations { + mod belongs_to { + pub trait GroupedBy {} + } + pub use self::belongs_to::GroupedBy; +} + +//@ has 'foo/prelude/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' +//@ has - '//*[@id="main-content"]//*[@id="reexport.GroupedBy"]' 'pub use associations::GroupedBy;' +pub mod prelude { + pub use associations::GroupedBy; +} diff --git a/tests/rustdoc/reexport/reexport-attr-merge.rs b/tests/rustdoc/reexport/reexport-attr-merge.rs new file mode 100644 index 00000000000..aef302eb0b2 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-attr-merge.rs @@ -0,0 +1,33 @@ +// Regression test for . +// The goal is to ensure that `doc(hidden)`, `doc(inline)` and `doc(no_inline)` +// are not copied from an item when inlined. + +#![crate_name = "foo"] +#![feature(doc_cfg)] + +//@ has 'foo/index.html' + +#[doc(hidden, cfg(feature = "foo"))] +pub struct Foo; + +#[doc(hidden, no_inline, cfg(feature = "bar"))] +pub use Foo as Foo1; + +#[doc(hidden, inline)] +pub use Foo1 as Foo2; + +// First we ensure that only the reexport `Bar2` and the inlined struct `Bar` +// are inlined. +//@ count - '//a[@class="struct"]' 1 +// Then we check that `cfg` is displayed for base item, but not for intermediate re-exports. +//@ has - '//*[@class="stab portability"]' 'foo' +//@ !has - '//*[@class="stab portability"]' 'bar' +// And finally we check that the only element displayed is `Bar`. +//@ has - '//a[@class="struct"]' 'Bar' +#[doc(inline)] +pub use Foo2 as Bar; + +// This one should appear but `Bar2` won't be linked because there is no +// `#[doc(inline)]`. +//@ !has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;' +pub use Foo2 as Bar2; diff --git a/tests/rustdoc/reexport/reexport-cfg.rs b/tests/rustdoc/reexport/reexport-cfg.rs new file mode 100644 index 00000000000..73b66824316 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-cfg.rs @@ -0,0 +1,30 @@ +// This test ensures that only the re-export `cfg` will be displayed and that it won't +// include `cfg`s from the previous chained items. + +#![crate_name = "foo"] +#![feature(doc_auto_cfg, doc_cfg)] + +mod foo { + #[cfg(not(feature = "foo"))] + pub struct Bar; + + #[doc(cfg(not(feature = "bar")))] + pub struct Bar2; +} + +//@ has 'foo/index.html' +//@ has - '//dt' 'BabarNon-lie' +#[cfg(not(feature = "lie"))] +pub use crate::foo::Bar as Babar; + +//@ has - '//dt' 'Babar2Non-cake' +#[doc(cfg(not(feature = "cake")))] +pub use crate::foo::Bar2 as Babar2; + +//@ has - '//*[@class="item-table reexports"]/dt' 'pub use crate::Babar as Elephant;Non-robot' +#[cfg(not(feature = "robot"))] +pub use crate::Babar as Elephant; + +//@ has - '//*[@class="item-table reexports"]/dt' 'pub use crate::Babar2 as Elephant2;Non-cat' +#[doc(cfg(not(feature = "cat")))] +pub use crate::Babar2 as Elephant2; diff --git a/tests/rustdoc/reexport/reexport-check.rs b/tests/rustdoc/reexport/reexport-check.rs new file mode 100644 index 00000000000..fc10e3aadd0 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-check.rs @@ -0,0 +1,20 @@ +//@ aux-build:reexport-check.rs +#![crate_name = "foo"] + +extern crate reexport_check; + +//@ !has 'foo/index.html' '//code' 'pub use self::i32;' +//@ has 'foo/i32/index.html' +#[allow(deprecated, deprecated_in_future)] +pub use std::i32; +//@ !has 'foo/index.html' '//code' 'pub use self::string::String;' +//@ has 'foo/index.html' '//dt' 'String' +pub use std::string::String; + +// i32 is deprecated, String is not +//@ count 'foo/index.html' '//span[@class="stab deprecated"]' 1 + +//@ has 'foo/index.html' '//dd' 'Docs in original' +// this is a no-op, but shows what happens if there's an attribute that isn't a doc-comment +#[doc(inline)] +pub use reexport_check::S; diff --git a/tests/rustdoc/reexport/reexport-dep-foreign-fn.rs b/tests/rustdoc/reexport/reexport-dep-foreign-fn.rs new file mode 100644 index 00000000000..1b63fcff017 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-dep-foreign-fn.rs @@ -0,0 +1,12 @@ +//@ aux-build:all-item-types.rs + +// This test is to ensure there is no problem on handling foreign functions +// coming from a dependency. + +#![crate_name = "foo"] + +extern crate all_item_types; + +//@ has 'foo/fn.foo_ffn.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' +pub use all_item_types::foo_ffn; diff --git a/tests/rustdoc/reexport/reexport-doc-hidden-inside-private.rs b/tests/rustdoc/reexport/reexport-doc-hidden-inside-private.rs new file mode 100644 index 00000000000..bae2aa78ec7 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-doc-hidden-inside-private.rs @@ -0,0 +1,16 @@ +// This test ensures that a re-export of `#[doc(hidden)]` item inside a private +// module will still be displayed (the re-export, not the item). + +#![crate_name = "foo"] + +mod private_module { + #[doc(hidden)] + pub struct Public; +} + +//@ has 'foo/index.html' +//@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' +pub use crate::private_module::Public as Foo; +// Glob re-exports with no visible items should not be displayed. +//@ count - '//*[@class="item-table reexports"]/dt' 0 +pub use crate::private_module::*; diff --git a/tests/rustdoc/reexport/reexport-doc-hidden.rs b/tests/rustdoc/reexport/reexport-doc-hidden.rs new file mode 100644 index 00000000000..1468e9ad957 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-doc-hidden.rs @@ -0,0 +1,25 @@ +// Part of . +// This test ensures that reexporting a `doc(hidden)` item will +// still show the reexport. + +#![crate_name = "foo"] + +#[doc(hidden)] +pub type Type = u32; + +//@ has 'foo/index.html' +//@ !has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;' +pub use crate::Type as Type2; + +//@ count - '//*[@id="reexport.Type3"]' 0 +#[doc(hidden)] +pub use crate::Type as Type3; + +#[macro_export] +#[doc(hidden)] +macro_rules! foo { + () => {}; +} + +//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +pub use crate::foo as Macro; diff --git a/tests/rustdoc/reexport/reexport-doc.rs b/tests/rustdoc/reexport/reexport-doc.rs new file mode 100644 index 00000000000..0c20de41231 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-doc.rs @@ -0,0 +1,8 @@ +//@ aux-build:reexport-doc-aux.rs + +extern crate reexport_doc_aux as dep; + +//@ has 'reexport_doc/struct.Foo.html' +//@ count - '//p' 'These are the docs for Foo.' 1 +/// These are the docs for Foo. +pub use dep::Foo; diff --git a/tests/rustdoc/reexport/reexport-hidden-macro.rs b/tests/rustdoc/reexport/reexport-hidden-macro.rs new file mode 100644 index 00000000000..7345149c645 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-hidden-macro.rs @@ -0,0 +1,22 @@ +// Ensure that inlined reexport of hidden macros is working as expected. +// Part of . + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2' +//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' + +//@ has 'foo/macro.Macro2.html' +//@ has - '//*[@class="docblock"]' 'Displayed' + +#[macro_export] +#[doc(hidden)] +macro_rules! foo { + () => {}; +} + +pub use crate::foo as Macro; +/// Displayed +#[doc(inline)] +pub use crate::foo as Macro2; diff --git a/tests/rustdoc/reexport/reexport-macro.rs b/tests/rustdoc/reexport/reexport-macro.rs new file mode 100644 index 00000000000..7e041eb90ba --- /dev/null +++ b/tests/rustdoc/reexport/reexport-macro.rs @@ -0,0 +1,23 @@ +// Ensure that macros are correctly reexported and that they get both the comment from the +// `pub use` and from the macro. + +#![crate_name = "foo"] + +//@ has 'foo/macro.foo.html' +//@ !has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'y' +#[macro_use] +mod my_module { + /// y + #[macro_export] + macro_rules! foo { + () => (); + } +} + +//@ has 'foo/another_mod/macro.bar.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' +pub mod another_mod { + /// x + pub use crate::foo as bar; +} diff --git a/tests/rustdoc/reexport/reexport-of-doc-hidden.rs b/tests/rustdoc/reexport/reexport-of-doc-hidden.rs new file mode 100644 index 00000000000..e901d0ff8a2 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-of-doc-hidden.rs @@ -0,0 +1,42 @@ +// This test ensures that all re-exports of doc hidden elements are displayed. + +#![crate_name = "foo"] + +#[doc(hidden)] +pub struct Bar; + +#[macro_export] +#[doc(hidden)] +macro_rules! foo { + () => {}; +} + +//@ has 'foo/index.html' +//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +pub use crate::foo as Macro; +//@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' +pub use crate::foo as Macro2; +//@ !has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;' +pub use crate::Bar as Boo; +//@ !has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;' +pub use crate::Bar as Boo2; + +pub fn fofo() {} + +//@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' +pub use crate::fofo as f1; +//@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' +pub use crate::fofo as f2; + +pub mod sub { + //@ has 'foo/sub/index.html' + //@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' + pub use crate::foo as Macro; + //@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' + pub use crate::foo as Macro2; + + //@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' + pub use crate::fofo as f1; + //@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' + pub use crate::fofo as f2; +} diff --git a/tests/rustdoc/reexport/reexport-of-reexport-108679.rs b/tests/rustdoc/reexport/reexport-of-reexport-108679.rs new file mode 100644 index 00000000000..0d2faf71d32 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-of-reexport-108679.rs @@ -0,0 +1,30 @@ +// This test ensures that the `struct.B.html` only exists in `a`: +// since `a::B` is public (and inlined too), `self::a::B` doesn't +// need to be inlined as well. + +#![crate_name = "foo"] + +pub mod a { + //@ has 'foo/a/index.html' + // Should only contain "Structs". + //@ count - '//*[@id="main-content"]//*[@class="item-table"]' 1 + //@ has - '//*[@id="structs"]' 'Structs' + //@ has - '//*[@id="main-content"]//a[@href="struct.A.html"]' 'A' + //@ has - '//*[@id="main-content"]//a[@href="struct.B.html"]' 'B' + mod b { + pub struct B; + } + pub use self::b::B; + pub struct A; +} + +//@ has 'foo/index.html' +//@ !has - '//*[@id="structs"]' 'Structs' +//@ has - '//*[@id="reexports"]' 'Re-exports' +//@ has - '//*[@id="modules"]' 'Modules' +//@ has - '//*[@id="main-content"]//*[@id="reexport.A"]' 'pub use self::a::A;' +//@ has - '//*[@id="main-content"]//*[@id="reexport.B"]' 'pub use self::a::B;' +// Should only contain "Modules" and "Re-exports". +//@ count - '//*[@id="main-content"]//*[@class="item-table"]' 1 +//@ count - '//*[@id="main-content"]//*[@class="item-table reexports"]' 1 +pub use self::a::{A, B}; diff --git a/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs b/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs new file mode 100644 index 00000000000..f83f28f458e --- /dev/null +++ b/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs @@ -0,0 +1,48 @@ +#![crate_name = "foo"] +#![feature(doc_cfg)] + +pub mod tag { + #[deprecated(since = "0.1.8", note = "Use bar() instead")] + pub trait Deprecated {} + + #[doc(cfg(feature = "sync"))] + pub trait Portability {} + + #[deprecated(since = "0.1.8", note = "Use bar() instead")] + #[doc(cfg(feature = "sync"))] + pub trait Both {} + + pub trait None {} +} + +//@ has foo/mod1/index.html +pub mod mod1 { + //@ has - '//code' 'pub use tag::Deprecated;' + //@ has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' + pub use tag::Deprecated; +} + +//@ has foo/mod2/index.html +pub mod mod2 { + //@ has - '//code' 'pub use tag::Portability;' + //@ !has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' + pub use tag::Portability; +} + +//@ has foo/mod3/index.html +pub mod mod3 { + //@ has - '//code' 'pub use tag::Both;' + //@ has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' + pub use tag::Both; +} + +//@ has foo/mod4/index.html +pub mod mod4 { + //@ has - '//code' 'pub use tag::None;' + //@ !has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' + pub use tag::None; +} diff --git a/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs b/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs new file mode 100644 index 00000000000..adf3eed204a --- /dev/null +++ b/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs @@ -0,0 +1,61 @@ +#![crate_name = "foo"] +#![feature(doc_cfg)] +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +#[stable(feature = "rust1", since = "1.0.0")] +pub mod tag { + #[unstable(feature = "humans", issue = "none")] + pub trait Unstable {} + + #[stable(feature = "rust1", since = "1.0.0")] + #[doc(cfg(feature = "sync"))] + pub trait Portability {} + + #[unstable(feature = "humans", issue = "none")] + #[doc(cfg(feature = "sync"))] + pub trait Both {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub trait None {} +} + +//@ has foo/mod1/index.html +#[stable(feature = "rust1", since = "1.0.0")] +pub mod mod1 { + //@ has - '//code' 'pub use tag::Unstable;' + //@ has - '//span' 'Experimental' + //@ !has - '//span' 'sync' + #[stable(feature = "rust1", since = "1.0.0")] + pub use tag::Unstable; +} + +//@ has foo/mod2/index.html +#[stable(feature = "rust1", since = "1.0.0")] +pub mod mod2 { + //@ has - '//code' 'pub use tag::Portability;' + //@ !has - '//span' 'Experimental' + //@ !has - '//span' 'sync' + #[stable(feature = "rust1", since = "1.0.0")] + pub use tag::Portability; +} + +//@ has foo/mod3/index.html +#[stable(feature = "rust1", since = "1.0.0")] +pub mod mod3 { + //@ has - '//code' 'pub use tag::Both;' + //@ has - '//span' 'Experimental' + //@ !has - '//span' 'sync' + #[stable(feature = "rust1", since = "1.0.0")] + pub use tag::Both; +} + +//@ has foo/mod4/index.html +#[stable(feature = "rust1", since = "1.0.0")] +pub mod mod4 { + //@ has - '//code' 'pub use tag::None;' + //@ !has - '//span' 'Experimental' + //@ !has - '//span' 'sync' + #[stable(feature = "rust1", since = "1.0.0")] + pub use tag::None; +} diff --git a/tests/rustdoc/reexport/reexport-trait-from-hidden-111064-2.rs b/tests/rustdoc/reexport/reexport-trait-from-hidden-111064-2.rs new file mode 100644 index 00000000000..61060b3ff7c --- /dev/null +++ b/tests/rustdoc/reexport/reexport-trait-from-hidden-111064-2.rs @@ -0,0 +1,41 @@ +// Regression test for . +#![feature(no_core, lang_items)] +#![no_core] +#![crate_name = "foo"] + +#[lang = "sized"] +trait Sized {} + +//@ files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ +// 'visible']" +//@ files "foo/hidden" "['inner']" +//@ files "foo/hidden/inner" "['trait.Foo.html']" +//@ files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" + +//@ !has 'foo/hidden/index.html' +//@ !has 'foo/hidden/inner/index.html' +// FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 +//@ has 'foo/hidden/inner/trait.Foo.html' +//@ matchesraw - '' +#[doc(hidden)] +pub mod hidden { + pub mod inner { + pub trait Foo { + /// Hello, world! + fn test(); + } + } +} + +//@ has 'foo/visible/index.html' +//@ has 'foo/visible/trait.Foo.html' +#[doc(inline)] +pub use hidden::inner as visible; + +//@ has 'foo/struct.Bar.html' +//@ count - '//*[@id="impl-Foo-for-Bar"]' 1 +pub struct Bar; + +impl visible::Foo for Bar { + fn test() {} +} diff --git a/tests/rustdoc/reexport/reexport-trait-from-hidden-111064.rs b/tests/rustdoc/reexport/reexport-trait-from-hidden-111064.rs new file mode 100644 index 00000000000..8b9ad7616ea --- /dev/null +++ b/tests/rustdoc/reexport/reexport-trait-from-hidden-111064.rs @@ -0,0 +1,21 @@ +// Regression test for . +// Methods from a re-exported trait inside a `#[doc(hidden)]` item should +// be visible. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]//dt/a[@href="trait.Foo.html"]' 'Foo' + +//@ has 'foo/trait.Foo.html' +//@ has - '//*[@id="main-content"]//*[@class="code-header"]' 'fn test()' + +#[doc(hidden)] +mod hidden { + pub trait Foo { + /// Hello, world! + fn test(); + } +} + +pub use hidden::Foo; diff --git a/tests/rustdoc/reexport/reexports-of-same-name.rs b/tests/rustdoc/reexport/reexports-of-same-name.rs new file mode 100644 index 00000000000..6e5d328b081 --- /dev/null +++ b/tests/rustdoc/reexport/reexports-of-same-name.rs @@ -0,0 +1,26 @@ +// This test ensures that there are 4 imports as expected: +// * 2 for `Foo` +// * 2 for `Bar` + +#![crate_name = "foo"] + +//@ has 'foo/index.html' + +pub mod nested { + /// Foo the struct + pub struct Foo {} + + #[allow(non_snake_case)] + /// Foo the function + pub fn Foo() {} +} + +//@ count - '//*[@id="main-content"]//code' 'pub use nested::Foo;' 2 +//@ has - '//*[@id="reexport.Foo"]//a[@href="nested/struct.Foo.html"]' 'Foo' +//@ has - '//*[@id="reexport.Foo-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' +pub use nested::Foo; + +//@ count - '//*[@id="main-content"]//code' 'pub use Foo as Bar;' 2 +//@ has - '//*[@id="reexport.Bar"]//a[@href="nested/struct.Foo.html"]' 'Foo' +//@ has - '//*[@id="reexport.Bar-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' +pub use Foo as Bar; diff --git a/tests/rustdoc/reexport/reexports-priv.rs b/tests/rustdoc/reexport/reexports-priv.rs new file mode 100644 index 00000000000..4521b4feebc --- /dev/null +++ b/tests/rustdoc/reexport/reexports-priv.rs @@ -0,0 +1,135 @@ +//@ aux-build: reexports.rs +//@ compile-flags: --document-private-items + +#![crate_name = "foo"] + +extern crate reexports; + +//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' +pub use reexports::addr_of; +//@ !has 'foo/macro.addr_of_crate.html' +pub(crate) use reexports::addr_of_crate; +//@ !has 'foo/macro.addr_of_self.html' +pub(self) use reexports::addr_of_self; +//@ !has 'foo/macro.addr_of_local.html' +use reexports::addr_of_local; + +//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' +pub use reexports::Foo; +//@ !has 'foo/struct.FooCrate.html' +pub(crate) use reexports::FooCrate; +//@ !has 'foo/struct.FooSelf.html' +pub(self) use reexports::FooSelf; +//@ !has 'foo/struct.FooLocal.html' +use reexports::FooLocal; + +//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' +pub use reexports::Bar; +//@ !has 'foo/enum.BarCrate.html' +pub(crate) use reexports::BarCrate; +//@ !has 'foo/enum.BarSelf.html' +pub(self) use reexports::BarSelf; +//@ !has 'foo/enum.BarLocal.html' +use reexports::BarLocal; + +//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' +pub use reexports::foo; +//@ !has 'foo/fn.foo_crate.html' +pub(crate) use reexports::foo_crate; +//@ !has 'foo/fn.foo_self.html' +pub(self) use reexports::foo_self; +//@ !has 'foo/fn.foo_local.html' +use reexports::foo_local; + +//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' +pub use reexports::Type; +//@ !has 'foo/type.TypeCrate.html' +pub(crate) use reexports::TypeCrate; +//@ !has 'foo/type.TypeSelf.html' +pub(self) use reexports::TypeSelf; +//@ !has 'foo/type.TypeLocal.html' +use reexports::TypeLocal; + +//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' +pub use reexports::Union; +//@ !has 'foo/union.UnionCrate.html' +pub(crate) use reexports::UnionCrate; +//@ !has 'foo/union.UnionSelf.html' +pub(self) use reexports::UnionSelf; +//@ !has 'foo/union.UnionLocal.html' +use reexports::UnionLocal; + +pub mod outer { + pub mod inner { + //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' + pub use reexports::addr_of; + //@ has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="rust item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' + pub(crate) use reexports::addr_of_crate; + //@ has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="rust item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' + pub(super) use reexports::addr_of_super; + //@ !has 'foo/outer/inner/macro.addr_of_self.html' + pub(self) use reexports::addr_of_self; + //@ !has 'foo/outer/inner/macro.addr_of_local.html' + use reexports::addr_of_local; + + //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' + pub use reexports::Foo; + //@ has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) struct FooCrate;' + pub(crate) use reexports::FooCrate; + //@ has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) struct FooSuper;' + pub(super) use reexports::FooSuper; + //@ !has 'foo/outer/inner/struct.FooSelf.html' + pub(self) use reexports::FooSelf; + //@ !has 'foo/outer/inner/struct.FooLocal.html' + use reexports::FooLocal; + + //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' + pub use reexports::Bar; + //@ has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) enum BarCrate {' + pub(crate) use reexports::BarCrate; + //@ has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) enum BarSuper {' + pub(super) use reexports::BarSuper; + //@ !has 'foo/outer/inner/enum.BarSelf.html' + pub(self) use reexports::BarSelf; + //@ !has 'foo/outer/inner/enum.BarLocal.html' + use reexports::BarLocal; + + //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' + pub use reexports::foo; + //@ has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' + pub(crate) use reexports::foo_crate; + //@ has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' + pub(super) use::reexports::foo_super; + //@ !has 'foo/outer/inner/fn.foo_self.html' + pub(self) use reexports::foo_self; + //@ !has 'foo/outer/inner/fn.foo_local.html' + use reexports::foo_local; + + //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' + pub use reexports::Type; + //@ has 'foo/outer/inner/type.TypeCrate.html' '//pre[@class="rust item-decl"]' 'pub(crate) type TypeCrate =' + pub(crate) use reexports::TypeCrate; + //@ has 'foo/outer/inner/type.TypeSuper.html' '//pre[@class="rust item-decl"]' 'pub(in outer) type TypeSuper =' + pub(super) use reexports::TypeSuper; + //@ !has 'foo/outer/inner/type.TypeSelf.html' + pub(self) use reexports::TypeSelf; + //@ !has 'foo/outer/inner/type.TypeLocal.html' + use reexports::TypeLocal; + + //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' + pub use reexports::Union; + //@ has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) union UnionCrate {' + pub(crate) use reexports::UnionCrate; + //@ has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) union UnionSuper {' + pub(super) use reexports::UnionSuper; + //@ !has 'foo/outer/inner/union.UnionSelf.html' + pub(self) use reexports::UnionSelf; + //@ !has 'foo/outer/inner/union.UnionLocal.html' + use reexports::UnionLocal; + } +} + +mod re_re_exports { + //@ !has 'foo/re_re_exports/union.Union.html' + use crate::reexports::Union; +} diff --git a/tests/rustdoc/reexport/reexports.rs b/tests/rustdoc/reexport/reexports.rs new file mode 100644 index 00000000000..b17e9cd719a --- /dev/null +++ b/tests/rustdoc/reexport/reexports.rs @@ -0,0 +1,129 @@ +//@ aux-build: reexports.rs + +#![crate_name = "foo"] + +extern crate reexports; + +//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' +pub use reexports::addr_of; +//@ !has 'foo/macro.addr_of_crate.html' +pub(crate) use reexports::addr_of_crate; +//@ !has 'foo/macro.addr_of_self.html' +pub(self) use reexports::addr_of_self; +//@ !has 'foo/macro.addr_of_local.html' +use reexports::addr_of_local; + +//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' +pub use reexports::Foo; +//@ !has 'foo/struct.FooCrate.html' +pub(crate) use reexports::FooCrate; +//@ !has 'foo/struct.FooSelf.html' +pub(self) use reexports::FooSelf; +//@ !has 'foo/struct.FooLocal.html' +use reexports::FooLocal; + +//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' +pub use reexports::Bar; +//@ !has 'foo/enum.BarCrate.html' +pub(crate) use reexports::BarCrate; +//@ !has 'foo/enum.BarSelf.html' +pub(self) use reexports::BarSelf; +//@ !has 'foo/enum.BarLocal.html' +use reexports::BarLocal; + +//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' +pub use reexports::foo; +//@ !has 'foo/fn.foo_crate.html' +pub(crate) use reexports::foo_crate; +//@ !has 'foo/fn.foo_self.html' +pub(self) use reexports::foo_self; +//@ !has 'foo/fn.foo_local.html' +use reexports::foo_local; + +//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' +pub use reexports::Type; +//@ !has 'foo/type.TypeCrate.html' +pub(crate) use reexports::TypeCrate; +//@ !has 'foo/type.TypeSelf.html' +pub(self) use reexports::TypeSelf; +//@ !has 'foo/type.TypeLocal.html' +use reexports::TypeLocal; + +//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' +pub use reexports::Union; +//@ !has 'foo/union.UnionCrate.html' +pub(crate) use reexports::UnionCrate; +//@ !has 'foo/union.UnionSelf.html' +pub(self) use reexports::UnionSelf; +//@ !has 'foo/union.UnionLocal.html' +use reexports::UnionLocal; + +pub mod outer { + pub mod inner { + //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' + pub use reexports::addr_of; + //@ !has 'foo/outer/inner/macro.addr_of_crate.html' + pub(crate) use reexports::addr_of_crate; + //@ !has 'foo/outer/inner/macro.addr_of_super.html' + pub(super) use reexports::addr_of_super; + //@ !has 'foo/outer/inner/macro.addr_of_self.html' + pub(self) use reexports::addr_of_self; + //@ !has 'foo/outer/inner/macro.addr_of_local.html' + use reexports::addr_of_local; + + //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' + pub use reexports::Foo; + //@ !has 'foo/outer/inner/struct.FooCrate.html' + pub(crate) use reexports::FooCrate; + //@ !has 'foo/outer/inner/struct.FooSuper.html' + pub(super) use reexports::FooSuper; + //@ !has 'foo/outer/inner/struct.FooSelf.html' + pub(self) use reexports::FooSelf; + //@ !has 'foo/outer/inner/struct.FooLocal.html' + use reexports::FooLocal; + + //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' + pub use reexports::Bar; + //@ !has 'foo/outer/inner/enum.BarCrate.html' + pub(crate) use reexports::BarCrate; + //@ !has 'foo/outer/inner/enum.BarSuper.html' + pub(super) use reexports::BarSuper; + //@ !has 'foo/outer/inner/enum.BarSelf.html' + pub(self) use reexports::BarSelf; + //@ !has 'foo/outer/inner/enum.BarLocal.html' + use reexports::BarLocal; + + //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' + pub use reexports::foo; + //@ !has 'foo/outer/inner/fn.foo_crate.html' + pub(crate) use reexports::foo_crate; + //@ !has 'foo/outer/inner/fn.foo_super.html' + pub(super) use::reexports::foo_super; + //@ !has 'foo/outer/inner/fn.foo_self.html' + pub(self) use reexports::foo_self; + //@ !has 'foo/outer/inner/fn.foo_local.html' + use reexports::foo_local; + + //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' + pub use reexports::Type; + //@ !has 'foo/outer/inner/type.TypeCrate.html' + pub(crate) use reexports::TypeCrate; + //@ !has 'foo/outer/inner/type.TypeSuper.html' + pub(super) use reexports::TypeSuper; + //@ !has 'foo/outer/inner/type.TypeSelf.html' + pub(self) use reexports::TypeSelf; + //@ !has 'foo/outer/inner/type.TypeLocal.html' + use reexports::TypeLocal; + + //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' + pub use reexports::Union; + //@ !has 'foo/outer/inner/union.UnionCrate.html' + pub(crate) use reexports::UnionCrate; + //@ !has 'foo/outer/inner/union.UnionSuper.html' + pub(super) use reexports::UnionSuper; + //@ !has 'foo/outer/inner/union.UnionSelf.html' + pub(self) use reexports::UnionSelf; + //@ !has 'foo/outer/inner/union.UnionLocal.html' + use reexports::UnionLocal; + } +} diff --git a/tests/rustdoc/reexports-of-same-name.rs b/tests/rustdoc/reexports-of-same-name.rs deleted file mode 100644 index 6e5d328b081..00000000000 --- a/tests/rustdoc/reexports-of-same-name.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This test ensures that there are 4 imports as expected: -// * 2 for `Foo` -// * 2 for `Bar` - -#![crate_name = "foo"] - -//@ has 'foo/index.html' - -pub mod nested { - /// Foo the struct - pub struct Foo {} - - #[allow(non_snake_case)] - /// Foo the function - pub fn Foo() {} -} - -//@ count - '//*[@id="main-content"]//code' 'pub use nested::Foo;' 2 -//@ has - '//*[@id="reexport.Foo"]//a[@href="nested/struct.Foo.html"]' 'Foo' -//@ has - '//*[@id="reexport.Foo-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' -pub use nested::Foo; - -//@ count - '//*[@id="main-content"]//code' 'pub use Foo as Bar;' 2 -//@ has - '//*[@id="reexport.Bar"]//a[@href="nested/struct.Foo.html"]' 'Foo' -//@ has - '//*[@id="reexport.Bar-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' -pub use Foo as Bar; diff --git a/tests/rustdoc/reexports-priv.rs b/tests/rustdoc/reexports-priv.rs deleted file mode 100644 index 4521b4feebc..00000000000 --- a/tests/rustdoc/reexports-priv.rs +++ /dev/null @@ -1,135 +0,0 @@ -//@ aux-build: reexports.rs -//@ compile-flags: --document-private-items - -#![crate_name = "foo"] - -extern crate reexports; - -//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' -pub use reexports::addr_of; -//@ !has 'foo/macro.addr_of_crate.html' -pub(crate) use reexports::addr_of_crate; -//@ !has 'foo/macro.addr_of_self.html' -pub(self) use reexports::addr_of_self; -//@ !has 'foo/macro.addr_of_local.html' -use reexports::addr_of_local; - -//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' -pub use reexports::Foo; -//@ !has 'foo/struct.FooCrate.html' -pub(crate) use reexports::FooCrate; -//@ !has 'foo/struct.FooSelf.html' -pub(self) use reexports::FooSelf; -//@ !has 'foo/struct.FooLocal.html' -use reexports::FooLocal; - -//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' -pub use reexports::Bar; -//@ !has 'foo/enum.BarCrate.html' -pub(crate) use reexports::BarCrate; -//@ !has 'foo/enum.BarSelf.html' -pub(self) use reexports::BarSelf; -//@ !has 'foo/enum.BarLocal.html' -use reexports::BarLocal; - -//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' -pub use reexports::foo; -//@ !has 'foo/fn.foo_crate.html' -pub(crate) use reexports::foo_crate; -//@ !has 'foo/fn.foo_self.html' -pub(self) use reexports::foo_self; -//@ !has 'foo/fn.foo_local.html' -use reexports::foo_local; - -//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' -pub use reexports::Type; -//@ !has 'foo/type.TypeCrate.html' -pub(crate) use reexports::TypeCrate; -//@ !has 'foo/type.TypeSelf.html' -pub(self) use reexports::TypeSelf; -//@ !has 'foo/type.TypeLocal.html' -use reexports::TypeLocal; - -//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' -pub use reexports::Union; -//@ !has 'foo/union.UnionCrate.html' -pub(crate) use reexports::UnionCrate; -//@ !has 'foo/union.UnionSelf.html' -pub(self) use reexports::UnionSelf; -//@ !has 'foo/union.UnionLocal.html' -use reexports::UnionLocal; - -pub mod outer { - pub mod inner { - //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' - pub use reexports::addr_of; - //@ has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="rust item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' - pub(crate) use reexports::addr_of_crate; - //@ has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="rust item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' - pub(super) use reexports::addr_of_super; - //@ !has 'foo/outer/inner/macro.addr_of_self.html' - pub(self) use reexports::addr_of_self; - //@ !has 'foo/outer/inner/macro.addr_of_local.html' - use reexports::addr_of_local; - - //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' - pub use reexports::Foo; - //@ has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) struct FooCrate;' - pub(crate) use reexports::FooCrate; - //@ has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) struct FooSuper;' - pub(super) use reexports::FooSuper; - //@ !has 'foo/outer/inner/struct.FooSelf.html' - pub(self) use reexports::FooSelf; - //@ !has 'foo/outer/inner/struct.FooLocal.html' - use reexports::FooLocal; - - //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' - pub use reexports::Bar; - //@ has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) enum BarCrate {' - pub(crate) use reexports::BarCrate; - //@ has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) enum BarSuper {' - pub(super) use reexports::BarSuper; - //@ !has 'foo/outer/inner/enum.BarSelf.html' - pub(self) use reexports::BarSelf; - //@ !has 'foo/outer/inner/enum.BarLocal.html' - use reexports::BarLocal; - - //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' - pub use reexports::foo; - //@ has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' - pub(crate) use reexports::foo_crate; - //@ has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' - pub(super) use::reexports::foo_super; - //@ !has 'foo/outer/inner/fn.foo_self.html' - pub(self) use reexports::foo_self; - //@ !has 'foo/outer/inner/fn.foo_local.html' - use reexports::foo_local; - - //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' - pub use reexports::Type; - //@ has 'foo/outer/inner/type.TypeCrate.html' '//pre[@class="rust item-decl"]' 'pub(crate) type TypeCrate =' - pub(crate) use reexports::TypeCrate; - //@ has 'foo/outer/inner/type.TypeSuper.html' '//pre[@class="rust item-decl"]' 'pub(in outer) type TypeSuper =' - pub(super) use reexports::TypeSuper; - //@ !has 'foo/outer/inner/type.TypeSelf.html' - pub(self) use reexports::TypeSelf; - //@ !has 'foo/outer/inner/type.TypeLocal.html' - use reexports::TypeLocal; - - //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' - pub use reexports::Union; - //@ has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) union UnionCrate {' - pub(crate) use reexports::UnionCrate; - //@ has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) union UnionSuper {' - pub(super) use reexports::UnionSuper; - //@ !has 'foo/outer/inner/union.UnionSelf.html' - pub(self) use reexports::UnionSelf; - //@ !has 'foo/outer/inner/union.UnionLocal.html' - use reexports::UnionLocal; - } -} - -mod re_re_exports { - //@ !has 'foo/re_re_exports/union.Union.html' - use crate::reexports::Union; -} diff --git a/tests/rustdoc/reexports.rs b/tests/rustdoc/reexports.rs deleted file mode 100644 index b17e9cd719a..00000000000 --- a/tests/rustdoc/reexports.rs +++ /dev/null @@ -1,129 +0,0 @@ -//@ aux-build: reexports.rs - -#![crate_name = "foo"] - -extern crate reexports; - -//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' -pub use reexports::addr_of; -//@ !has 'foo/macro.addr_of_crate.html' -pub(crate) use reexports::addr_of_crate; -//@ !has 'foo/macro.addr_of_self.html' -pub(self) use reexports::addr_of_self; -//@ !has 'foo/macro.addr_of_local.html' -use reexports::addr_of_local; - -//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' -pub use reexports::Foo; -//@ !has 'foo/struct.FooCrate.html' -pub(crate) use reexports::FooCrate; -//@ !has 'foo/struct.FooSelf.html' -pub(self) use reexports::FooSelf; -//@ !has 'foo/struct.FooLocal.html' -use reexports::FooLocal; - -//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' -pub use reexports::Bar; -//@ !has 'foo/enum.BarCrate.html' -pub(crate) use reexports::BarCrate; -//@ !has 'foo/enum.BarSelf.html' -pub(self) use reexports::BarSelf; -//@ !has 'foo/enum.BarLocal.html' -use reexports::BarLocal; - -//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' -pub use reexports::foo; -//@ !has 'foo/fn.foo_crate.html' -pub(crate) use reexports::foo_crate; -//@ !has 'foo/fn.foo_self.html' -pub(self) use reexports::foo_self; -//@ !has 'foo/fn.foo_local.html' -use reexports::foo_local; - -//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' -pub use reexports::Type; -//@ !has 'foo/type.TypeCrate.html' -pub(crate) use reexports::TypeCrate; -//@ !has 'foo/type.TypeSelf.html' -pub(self) use reexports::TypeSelf; -//@ !has 'foo/type.TypeLocal.html' -use reexports::TypeLocal; - -//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' -pub use reexports::Union; -//@ !has 'foo/union.UnionCrate.html' -pub(crate) use reexports::UnionCrate; -//@ !has 'foo/union.UnionSelf.html' -pub(self) use reexports::UnionSelf; -//@ !has 'foo/union.UnionLocal.html' -use reexports::UnionLocal; - -pub mod outer { - pub mod inner { - //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' - pub use reexports::addr_of; - //@ !has 'foo/outer/inner/macro.addr_of_crate.html' - pub(crate) use reexports::addr_of_crate; - //@ !has 'foo/outer/inner/macro.addr_of_super.html' - pub(super) use reexports::addr_of_super; - //@ !has 'foo/outer/inner/macro.addr_of_self.html' - pub(self) use reexports::addr_of_self; - //@ !has 'foo/outer/inner/macro.addr_of_local.html' - use reexports::addr_of_local; - - //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' - pub use reexports::Foo; - //@ !has 'foo/outer/inner/struct.FooCrate.html' - pub(crate) use reexports::FooCrate; - //@ !has 'foo/outer/inner/struct.FooSuper.html' - pub(super) use reexports::FooSuper; - //@ !has 'foo/outer/inner/struct.FooSelf.html' - pub(self) use reexports::FooSelf; - //@ !has 'foo/outer/inner/struct.FooLocal.html' - use reexports::FooLocal; - - //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' - pub use reexports::Bar; - //@ !has 'foo/outer/inner/enum.BarCrate.html' - pub(crate) use reexports::BarCrate; - //@ !has 'foo/outer/inner/enum.BarSuper.html' - pub(super) use reexports::BarSuper; - //@ !has 'foo/outer/inner/enum.BarSelf.html' - pub(self) use reexports::BarSelf; - //@ !has 'foo/outer/inner/enum.BarLocal.html' - use reexports::BarLocal; - - //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' - pub use reexports::foo; - //@ !has 'foo/outer/inner/fn.foo_crate.html' - pub(crate) use reexports::foo_crate; - //@ !has 'foo/outer/inner/fn.foo_super.html' - pub(super) use::reexports::foo_super; - //@ !has 'foo/outer/inner/fn.foo_self.html' - pub(self) use reexports::foo_self; - //@ !has 'foo/outer/inner/fn.foo_local.html' - use reexports::foo_local; - - //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' - pub use reexports::Type; - //@ !has 'foo/outer/inner/type.TypeCrate.html' - pub(crate) use reexports::TypeCrate; - //@ !has 'foo/outer/inner/type.TypeSuper.html' - pub(super) use reexports::TypeSuper; - //@ !has 'foo/outer/inner/type.TypeSelf.html' - pub(self) use reexports::TypeSelf; - //@ !has 'foo/outer/inner/type.TypeLocal.html' - use reexports::TypeLocal; - - //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' - pub use reexports::Union; - //@ !has 'foo/outer/inner/union.UnionCrate.html' - pub(crate) use reexports::UnionCrate; - //@ !has 'foo/outer/inner/union.UnionSuper.html' - pub(super) use reexports::UnionSuper; - //@ !has 'foo/outer/inner/union.UnionSelf.html' - pub(self) use reexports::UnionSelf; - //@ !has 'foo/outer/inner/union.UnionLocal.html' - use reexports::UnionLocal; - } -} -- cgit 1.4.1-3-g733a5 From 099f730dcf95404e3f272cb2690a25077b9f2a4b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 15:21:06 +0200 Subject: Created `tests/rustdoc/source-code-pages` subfolder to limit number of files at the top level --- tests/rustdoc/assoc-type-source-link.rs | 26 -------- tests/rustdoc/auxiliary/issue-26606-macro.rs | 4 -- tests/rustdoc/auxiliary/issue-34274.rs | 3 - tests/rustdoc/auxiliary/source-code-bar.rs | 17 ------ tests/rustdoc/auxiliary/source_code.rs | 1 - tests/rustdoc/auxiliary/src-links-external.rs | 1 - tests/rustdoc/check-source-code-urls-to-def-std.rs | 42 ------------- tests/rustdoc/check-source-code-urls-to-def.rs | 71 ---------------------- tests/rustdoc/doc-hidden-source.rs | 16 ----- tests/rustdoc/html-no-source.rs | 30 --------- tests/rustdoc/source-code-highlight.rs | 29 --------- .../source-code-pages/assoc-type-source-link.rs | 26 ++++++++ .../auxiliary/issue-26606-macro.rs | 4 ++ .../source-code-pages/auxiliary/issue-34274.rs | 3 + .../source-code-pages/auxiliary/source-code-bar.rs | 17 ++++++ .../source-code-pages/auxiliary/source_code.rs | 1 + .../auxiliary/src-links-external.rs | 1 + .../check-source-code-urls-to-def-std.rs | 42 +++++++++++++ .../check-source-code-urls-to-def.rs | 71 ++++++++++++++++++++++ .../rustdoc/source-code-pages/doc-hidden-source.rs | 16 +++++ tests/rustdoc/source-code-pages/html-no-source.rs | 30 +++++++++ .../source-code-pages/source-code-highlight.rs | 29 +++++++++ tests/rustdoc/source-code-pages/source-file.rs | 5 ++ .../source-code-pages/source-line-numbers.rs | 35 +++++++++++ .../source-code-pages/source-version-separator.rs | 30 +++++++++ .../src-link-external-macro-26606.rs | 14 +++++ .../source-code-pages/src-links-auto-impls.rs | 12 ++++ .../source-code-pages/src-links-external.rs | 13 ++++ .../src-links-implementor-43893.rs | 21 +++++++ .../source-code-pages/src-links-inlined-34274.rs | 11 ++++ tests/rustdoc/source-code-pages/src-links.rs | 51 ++++++++++++++++ .../src-links/compiletest-ignore-dir | 0 tests/rustdoc/source-code-pages/src-links/fizz.rs | 1 + tests/rustdoc/source-code-pages/src-links/mod.rs | 19 ++++++ .../src-mod-path-absolute-26995.rs | 10 +++ .../version-separator-without-source.rs | 23 +++++++ tests/rustdoc/source-file.rs | 5 -- tests/rustdoc/source-line-numbers.rs | 35 ----------- tests/rustdoc/source-version-separator.rs | 30 --------- tests/rustdoc/src-link-external-macro-26606.rs | 14 ----- tests/rustdoc/src-links-auto-impls.rs | 12 ---- tests/rustdoc/src-links-external.rs | 13 ---- tests/rustdoc/src-links-implementor-43893.rs | 21 ------- tests/rustdoc/src-links-inlined-34274.rs | 11 ---- tests/rustdoc/src-links.rs | 51 ---------------- tests/rustdoc/src-links/compiletest-ignore-dir | 0 tests/rustdoc/src-links/fizz.rs | 1 - tests/rustdoc/src-links/mod.rs | 19 ------ tests/rustdoc/src-mod-path-absolute-26995.rs | 10 --- tests/rustdoc/version-separator-without-source.rs | 23 ------- 50 files changed, 485 insertions(+), 485 deletions(-) delete mode 100644 tests/rustdoc/assoc-type-source-link.rs delete mode 100644 tests/rustdoc/auxiliary/issue-26606-macro.rs delete mode 100644 tests/rustdoc/auxiliary/issue-34274.rs delete mode 100644 tests/rustdoc/auxiliary/source-code-bar.rs delete mode 100644 tests/rustdoc/auxiliary/source_code.rs delete mode 100644 tests/rustdoc/auxiliary/src-links-external.rs delete mode 100644 tests/rustdoc/check-source-code-urls-to-def-std.rs delete mode 100644 tests/rustdoc/check-source-code-urls-to-def.rs delete mode 100644 tests/rustdoc/doc-hidden-source.rs delete mode 100644 tests/rustdoc/html-no-source.rs delete mode 100644 tests/rustdoc/source-code-highlight.rs create mode 100644 tests/rustdoc/source-code-pages/assoc-type-source-link.rs create mode 100644 tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs create mode 100644 tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs create mode 100644 tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs create mode 100644 tests/rustdoc/source-code-pages/auxiliary/source_code.rs create mode 100644 tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs create mode 100644 tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs create mode 100644 tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs create mode 100644 tests/rustdoc/source-code-pages/doc-hidden-source.rs create mode 100644 tests/rustdoc/source-code-pages/html-no-source.rs create mode 100644 tests/rustdoc/source-code-pages/source-code-highlight.rs create mode 100644 tests/rustdoc/source-code-pages/source-file.rs create mode 100644 tests/rustdoc/source-code-pages/source-line-numbers.rs create mode 100644 tests/rustdoc/source-code-pages/source-version-separator.rs create mode 100644 tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs create mode 100644 tests/rustdoc/source-code-pages/src-links-auto-impls.rs create mode 100644 tests/rustdoc/source-code-pages/src-links-external.rs create mode 100644 tests/rustdoc/source-code-pages/src-links-implementor-43893.rs create mode 100644 tests/rustdoc/source-code-pages/src-links-inlined-34274.rs create mode 100644 tests/rustdoc/source-code-pages/src-links.rs create mode 100644 tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir create mode 100644 tests/rustdoc/source-code-pages/src-links/fizz.rs create mode 100644 tests/rustdoc/source-code-pages/src-links/mod.rs create mode 100644 tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs create mode 100644 tests/rustdoc/source-code-pages/version-separator-without-source.rs delete mode 100644 tests/rustdoc/source-file.rs delete mode 100644 tests/rustdoc/source-line-numbers.rs delete mode 100644 tests/rustdoc/source-version-separator.rs delete mode 100644 tests/rustdoc/src-link-external-macro-26606.rs delete mode 100644 tests/rustdoc/src-links-auto-impls.rs delete mode 100644 tests/rustdoc/src-links-external.rs delete mode 100644 tests/rustdoc/src-links-implementor-43893.rs delete mode 100644 tests/rustdoc/src-links-inlined-34274.rs delete mode 100644 tests/rustdoc/src-links.rs delete mode 100644 tests/rustdoc/src-links/compiletest-ignore-dir delete mode 100644 tests/rustdoc/src-links/fizz.rs delete mode 100644 tests/rustdoc/src-links/mod.rs delete mode 100644 tests/rustdoc/src-mod-path-absolute-26995.rs delete mode 100644 tests/rustdoc/version-separator-without-source.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/assoc-type-source-link.rs b/tests/rustdoc/assoc-type-source-link.rs deleted file mode 100644 index a955a67a457..00000000000 --- a/tests/rustdoc/assoc-type-source-link.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This test ensures that the source links are generated for impl associated types. - -#![crate_name = "foo"] -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] - -//@ has 'foo/struct.Bar.html' -pub struct Bar; - -impl Bar { - //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a' 'Source' - //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a/@href' \ - // '../src/foo/assoc-type-source-link.rs.html#14' - pub type Y = u8; -} - -pub trait Foo { - type Z; -} - -impl Foo for Bar { - //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a' 'Source' - //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a/@href' \ - // '../src/foo/assoc-type-source-link.rs.html#25' - type Z = u8; -} diff --git a/tests/rustdoc/auxiliary/issue-26606-macro.rs b/tests/rustdoc/auxiliary/issue-26606-macro.rs deleted file mode 100644 index d60d32526aa..00000000000 --- a/tests/rustdoc/auxiliary/issue-26606-macro.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[macro_export] -macro_rules! make_item ( - ($name: ident) => (pub const $name: usize = 42;) -); diff --git a/tests/rustdoc/auxiliary/issue-34274.rs b/tests/rustdoc/auxiliary/issue-34274.rs deleted file mode 100644 index c46660579a8..00000000000 --- a/tests/rustdoc/auxiliary/issue-34274.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern "C" { - pub fn extern_c_fn(); -} diff --git a/tests/rustdoc/auxiliary/source-code-bar.rs b/tests/rustdoc/auxiliary/source-code-bar.rs deleted file mode 100644 index 8700d688ef7..00000000000 --- a/tests/rustdoc/auxiliary/source-code-bar.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! just some other file. :) - -use crate::Foo; - -pub struct Bar { - field: Foo, -} - -pub struct Bar2 { - field: crate::Foo, -} - -pub mod sub { - pub trait Trait { - fn tadam() {} - } -} diff --git a/tests/rustdoc/auxiliary/source_code.rs b/tests/rustdoc/auxiliary/source_code.rs deleted file mode 100644 index 72a5c1a0ae9..00000000000 --- a/tests/rustdoc/auxiliary/source_code.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct SourceCode; diff --git a/tests/rustdoc/auxiliary/src-links-external.rs b/tests/rustdoc/auxiliary/src-links-external.rs deleted file mode 100644 index 4a835673a59..00000000000 --- a/tests/rustdoc/auxiliary/src-links-external.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Foo; diff --git a/tests/rustdoc/check-source-code-urls-to-def-std.rs b/tests/rustdoc/check-source-code-urls-to-def-std.rs deleted file mode 100644 index 42468f7dde6..00000000000 --- a/tests/rustdoc/check-source-code-urls-to-def-std.rs +++ /dev/null @@ -1,42 +0,0 @@ -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/check-source-code-urls-to-def-std.rs.html' - -fn babar() {} - -//@ has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' -//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str' -//@ has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -//@ has - '//a[@href="#7"]' 'babar' -pub fn foo(a: u32, b: &str, c: String) { - let x = 12; - let y: bool = true; - babar(); -} - -macro_rules! yolo { () => {}} - -fn bar(a: i32) {} - -macro_rules! bar { - ($a:ident) => { bar($a) } -} - -macro_rules! data { - ($x:expr) => { $x * 2 } -} - -pub fn another_foo() { - // This is known limitation: if the macro doesn't generate anything, the visitor - // can't find any item or anything that could tell us that it comes from expansion. - //@ !has - '//a[@href="#19"]' 'yolo!' - yolo!(); - //@ has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!' - eprintln!(); - //@ has - '//a[@href="#27-29"]' 'data!' - let x = data!(4); - //@ has - '//a[@href="#23-25"]' 'bar!' - bar!(x); -} diff --git a/tests/rustdoc/check-source-code-urls-to-def.rs b/tests/rustdoc/check-source-code-urls-to-def.rs deleted file mode 100644 index d701b88bf9f..00000000000 --- a/tests/rustdoc/check-source-code-urls-to-def.rs +++ /dev/null @@ -1,71 +0,0 @@ -//@ compile-flags: -Zunstable-options --generate-link-to-definition -//@ aux-build:source_code.rs -//@ build-aux-docs - -#![feature(rustc_attrs)] - -#![crate_name = "foo"] - -extern crate source_code; - -//@ has 'src/foo/check-source-code-urls-to-def.rs.html' - -//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' -#[path = "auxiliary/source-code-bar.rs"] -pub mod bar; - -//@ count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4 -use bar::Bar; -//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self' -//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' -use bar::sub::{self, Trait}; - -pub struct Foo; - -impl Foo { - fn hello(&self) {} -} - -fn babar() {} - -//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html' -//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html' -//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html' -// The 5 links to line 23 and the line 23 itself. -//@ count - '//pre[@class="rust"]//a[@href="#23"]' 6 -//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \ -// 'source_code::SourceCode' -pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { - let x = 12; - let y: Foo = Foo; - let z: Bar = bar::Bar { field: Foo }; - babar(); - //@ has - '//pre[@class="rust"]//a[@href="#26"]' 'hello' - y.hello(); -} - -//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait' -//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' -pub fn foo2(t: &T, v: &V, b: bool) {} - -pub trait AnotherTrait {} -pub trait WhyNot {} - -//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'AnotherTrait' -//@ has - '//pre[@class="rust"]//a[@href="#52"]' 'WhyNot' -pub fn foo3(t: &T, v: &V) -where - T: AnotherTrait, - V: WhyNot -{} - -pub trait AnotherTrait2 {} - -//@ has - '//pre[@class="rust"]//a[@href="#62"]' 'AnotherTrait2' -pub fn foo4() { - let x: Vec<&dyn AnotherTrait2> = Vec::new(); -} - -//@ has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' -#[rustc_doc_primitive = "bool"] -mod whatever {} diff --git a/tests/rustdoc/doc-hidden-source.rs b/tests/rustdoc/doc-hidden-source.rs deleted file mode 100644 index b6bc622dd58..00000000000 --- a/tests/rustdoc/doc-hidden-source.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Test for . - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ !has - '//*[@id="main-content"]//*[@class="struct"]' 'Bar' -#[doc(hidden)] -pub struct Bar; - -//@ !has - '//*' 'pub use crate::Bar as A;' -pub use crate::Bar as A; -//@ !has - '//*' 'pub use crate::A as B;' -pub use crate::A as B; -//@ has - '//dt/a[@class="struct"]' 'C' -#[doc(inline)] -pub use crate::Bar as C; diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs deleted file mode 100644 index 248afbd00ef..00000000000 --- a/tests/rustdoc/html-no-source.rs +++ /dev/null @@ -1,30 +0,0 @@ -//@ compile-flags: -Zunstable-options --html-no-source - -// This test ensures that the `--html-no-source` flag disables -// the creation of the `src` folder. - -#![feature(staged_api)] -#![stable(feature = "bar", since = "1.0")] -#![crate_name = "foo"] - -// Ensures that there is no items in the corresponding "src" folder. -//@ files 'src/foo' '[]' - -//@ has foo/fn.foo.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' -//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' -#[stable(feature = "bar", since = "1.0")] -pub fn foo() {} - -//@ has foo/struct.Bar.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' -//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' -#[stable(feature = "bar", since = "1.0")] -pub struct Bar; - -impl Bar { - //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' - //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' - #[stable(feature = "foobar", since = "2.0")] - pub fn bar() {} -} diff --git a/tests/rustdoc/source-code-highlight.rs b/tests/rustdoc/source-code-highlight.rs deleted file mode 100644 index f1c905e64c0..00000000000 --- a/tests/rustdoc/source-code-highlight.rs +++ /dev/null @@ -1,29 +0,0 @@ -// We need this option to be enabled for the `foo` macro declaration to ensure -// that the link on the ident is not including whitespace characters. - -//@ compile-flags: -Zunstable-options --generate-link-to-definition -#![crate_name = "foo"] - -//@ has 'src/foo/source-code-highlight.rs.html' - -//@ hasraw - 'foo' -#[macro_export] -macro_rules! foo { - () => {} -} - -//@ hasraw - 'foo!' -foo! {} - -//@ hasraw - 'f' -#[rustfmt::skip] -pub fn f () {} -//@ hasraw - 'Bar' -//@ hasraw - 'Bar' -//@ hasraw - 'u32' -#[rustfmt::skip] -pub struct Bar ( u32 ); -//@ hasraw - 'Foo' -pub enum Foo { - A, -} diff --git a/tests/rustdoc/source-code-pages/assoc-type-source-link.rs b/tests/rustdoc/source-code-pages/assoc-type-source-link.rs new file mode 100644 index 00000000000..a955a67a457 --- /dev/null +++ b/tests/rustdoc/source-code-pages/assoc-type-source-link.rs @@ -0,0 +1,26 @@ +// This test ensures that the source links are generated for impl associated types. + +#![crate_name = "foo"] +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +//@ has 'foo/struct.Bar.html' +pub struct Bar; + +impl Bar { + //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a' 'Source' + //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a/@href' \ + // '../src/foo/assoc-type-source-link.rs.html#14' + pub type Y = u8; +} + +pub trait Foo { + type Z; +} + +impl Foo for Bar { + //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a' 'Source' + //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a/@href' \ + // '../src/foo/assoc-type-source-link.rs.html#25' + type Z = u8; +} diff --git a/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs b/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs new file mode 100644 index 00000000000..d60d32526aa --- /dev/null +++ b/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs @@ -0,0 +1,4 @@ +#[macro_export] +macro_rules! make_item ( + ($name: ident) => (pub const $name: usize = 42;) +); diff --git a/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs b/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs new file mode 100644 index 00000000000..c46660579a8 --- /dev/null +++ b/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs @@ -0,0 +1,3 @@ +extern "C" { + pub fn extern_c_fn(); +} diff --git a/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs b/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs new file mode 100644 index 00000000000..8700d688ef7 --- /dev/null +++ b/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs @@ -0,0 +1,17 @@ +//! just some other file. :) + +use crate::Foo; + +pub struct Bar { + field: Foo, +} + +pub struct Bar2 { + field: crate::Foo, +} + +pub mod sub { + pub trait Trait { + fn tadam() {} + } +} diff --git a/tests/rustdoc/source-code-pages/auxiliary/source_code.rs b/tests/rustdoc/source-code-pages/auxiliary/source_code.rs new file mode 100644 index 00000000000..72a5c1a0ae9 --- /dev/null +++ b/tests/rustdoc/source-code-pages/auxiliary/source_code.rs @@ -0,0 +1 @@ +pub struct SourceCode; diff --git a/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs b/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs new file mode 100644 index 00000000000..4a835673a59 --- /dev/null +++ b/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs @@ -0,0 +1 @@ +pub struct Foo; diff --git a/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs new file mode 100644 index 00000000000..42468f7dde6 --- /dev/null +++ b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs @@ -0,0 +1,42 @@ +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/check-source-code-urls-to-def-std.rs.html' + +fn babar() {} + +//@ has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str' +//@ has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//a[@href="#7"]' 'babar' +pub fn foo(a: u32, b: &str, c: String) { + let x = 12; + let y: bool = true; + babar(); +} + +macro_rules! yolo { () => {}} + +fn bar(a: i32) {} + +macro_rules! bar { + ($a:ident) => { bar($a) } +} + +macro_rules! data { + ($x:expr) => { $x * 2 } +} + +pub fn another_foo() { + // This is known limitation: if the macro doesn't generate anything, the visitor + // can't find any item or anything that could tell us that it comes from expansion. + //@ !has - '//a[@href="#19"]' 'yolo!' + yolo!(); + //@ has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!' + eprintln!(); + //@ has - '//a[@href="#27-29"]' 'data!' + let x = data!(4); + //@ has - '//a[@href="#23-25"]' 'bar!' + bar!(x); +} diff --git a/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs new file mode 100644 index 00000000000..d701b88bf9f --- /dev/null +++ b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs @@ -0,0 +1,71 @@ +//@ compile-flags: -Zunstable-options --generate-link-to-definition +//@ aux-build:source_code.rs +//@ build-aux-docs + +#![feature(rustc_attrs)] + +#![crate_name = "foo"] + +extern crate source_code; + +//@ has 'src/foo/check-source-code-urls-to-def.rs.html' + +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' +#[path = "auxiliary/source-code-bar.rs"] +pub mod bar; + +//@ count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4 +use bar::Bar; +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' +use bar::sub::{self, Trait}; + +pub struct Foo; + +impl Foo { + fn hello(&self) {} +} + +fn babar() {} + +//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html' +//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html' +//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html' +// The 5 links to line 23 and the line 23 itself. +//@ count - '//pre[@class="rust"]//a[@href="#23"]' 6 +//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \ +// 'source_code::SourceCode' +pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { + let x = 12; + let y: Foo = Foo; + let z: Bar = bar::Bar { field: Foo }; + babar(); + //@ has - '//pre[@class="rust"]//a[@href="#26"]' 'hello' + y.hello(); +} + +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' +pub fn foo2(t: &T, v: &V, b: bool) {} + +pub trait AnotherTrait {} +pub trait WhyNot {} + +//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'AnotherTrait' +//@ has - '//pre[@class="rust"]//a[@href="#52"]' 'WhyNot' +pub fn foo3(t: &T, v: &V) +where + T: AnotherTrait, + V: WhyNot +{} + +pub trait AnotherTrait2 {} + +//@ has - '//pre[@class="rust"]//a[@href="#62"]' 'AnotherTrait2' +pub fn foo4() { + let x: Vec<&dyn AnotherTrait2> = Vec::new(); +} + +//@ has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' +#[rustc_doc_primitive = "bool"] +mod whatever {} diff --git a/tests/rustdoc/source-code-pages/doc-hidden-source.rs b/tests/rustdoc/source-code-pages/doc-hidden-source.rs new file mode 100644 index 00000000000..b6bc622dd58 --- /dev/null +++ b/tests/rustdoc/source-code-pages/doc-hidden-source.rs @@ -0,0 +1,16 @@ +// Test for . + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ !has - '//*[@id="main-content"]//*[@class="struct"]' 'Bar' +#[doc(hidden)] +pub struct Bar; + +//@ !has - '//*' 'pub use crate::Bar as A;' +pub use crate::Bar as A; +//@ !has - '//*' 'pub use crate::A as B;' +pub use crate::A as B; +//@ has - '//dt/a[@class="struct"]' 'C' +#[doc(inline)] +pub use crate::Bar as C; diff --git a/tests/rustdoc/source-code-pages/html-no-source.rs b/tests/rustdoc/source-code-pages/html-no-source.rs new file mode 100644 index 00000000000..248afbd00ef --- /dev/null +++ b/tests/rustdoc/source-code-pages/html-no-source.rs @@ -0,0 +1,30 @@ +//@ compile-flags: -Zunstable-options --html-no-source + +// This test ensures that the `--html-no-source` flag disables +// the creation of the `src` folder. + +#![feature(staged_api)] +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] + +// Ensures that there is no items in the corresponding "src" folder. +//@ files 'src/foo' '[]' + +//@ has foo/fn.foo.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' +//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +//@ has foo/struct.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' +//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' + //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +} diff --git a/tests/rustdoc/source-code-pages/source-code-highlight.rs b/tests/rustdoc/source-code-pages/source-code-highlight.rs new file mode 100644 index 00000000000..f1c905e64c0 --- /dev/null +++ b/tests/rustdoc/source-code-pages/source-code-highlight.rs @@ -0,0 +1,29 @@ +// We need this option to be enabled for the `foo` macro declaration to ensure +// that the link on the ident is not including whitespace characters. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition +#![crate_name = "foo"] + +//@ has 'src/foo/source-code-highlight.rs.html' + +//@ hasraw - 'foo' +#[macro_export] +macro_rules! foo { + () => {} +} + +//@ hasraw - 'foo!' +foo! {} + +//@ hasraw - 'f' +#[rustfmt::skip] +pub fn f () {} +//@ hasraw - 'Bar' +//@ hasraw - 'Bar' +//@ hasraw - 'u32' +#[rustfmt::skip] +pub struct Bar ( u32 ); +//@ hasraw - 'Foo' +pub enum Foo { + A, +} diff --git a/tests/rustdoc/source-code-pages/source-file.rs b/tests/rustdoc/source-code-pages/source-file.rs new file mode 100644 index 00000000000..6cff5edf146 --- /dev/null +++ b/tests/rustdoc/source-code-pages/source-file.rs @@ -0,0 +1,5 @@ +#![crate_name = "foo"] + +//@ hasraw src-files.js source-file.rs + +pub struct Foo; diff --git a/tests/rustdoc/source-code-pages/source-line-numbers.rs b/tests/rustdoc/source-code-pages/source-line-numbers.rs new file mode 100644 index 00000000000..0b654b1a004 --- /dev/null +++ b/tests/rustdoc/source-code-pages/source-line-numbers.rs @@ -0,0 +1,35 @@ +// This test ensures that we have the expected number of line generated. + +#![crate_name = "foo"] + +//@ has 'src/foo/source-line-numbers.rs.html' +//@ count - '//a[@data-nosnippet]' 35 +//@ has - '//a[@id="35"]' '35' + +#[ +macro_export +] +macro_rules! bar { + ($x:ident) => {{ + $x += 2; + $x *= 2; + }} +} + +/* +multi line +comment +*/ +fn x(_: u8, _: u8) {} + +fn foo() { + let mut y = 0; + bar!(y); + println!(" + {y} + "); + x( + 1, + 2, + ); +} diff --git a/tests/rustdoc/source-code-pages/source-version-separator.rs b/tests/rustdoc/source-code-pages/source-version-separator.rs new file mode 100644 index 00000000000..78b9d364d21 --- /dev/null +++ b/tests/rustdoc/source-code-pages/source-version-separator.rs @@ -0,0 +1,30 @@ +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] +#![feature(staged_api)] + +//@ has foo/trait.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source' +#[stable(feature = "bar", since = "1.0")] +pub trait Bar { + //@ has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0.0 · Source' + #[stable(feature = "foobar", since = "3.0")] + fn foo(); +} + +//@ has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · Source' + +//@ has foo/struct.Foo.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source' +#[stable(feature = "baz", since = "1.0")] +pub struct Foo; + +impl Foo { + //@ has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · Source' + #[stable(feature = "foobar", since = "3.0")] + pub fn foofoo() {} +} + +#[stable(feature = "yolo", since = "4.0")] +impl Bar for Foo { + fn foo() {} +} diff --git a/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs b/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs new file mode 100644 index 00000000000..0ce829f06f5 --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs @@ -0,0 +1,14 @@ +//@ aux-build:issue-26606-macro.rs +//@ ignore-cross-compile +//@ build-aux-docs + +// https://github.com/rust-lang/rust/issues/26606 +#![crate_name="issue_26606"] + +//@ has issue_26606_macro/macro.make_item.html +#[macro_use] +extern crate issue_26606_macro; + +//@ has issue_26606/constant.FOO.html +//@ has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'Source' +make_item!(FOO); diff --git a/tests/rustdoc/source-code-pages/src-links-auto-impls.rs b/tests/rustdoc/source-code-pages/src-links-auto-impls.rs new file mode 100644 index 00000000000..5a777f59b7e --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links-auto-impls.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Unsized.html +//@ has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' +//@ !has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'Source' +//@ has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' +//@ !has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'Source' +//@ has - '//*[@id="impl-Any-for-T"]/h3[@class="code-header"]' 'impl Any for T' +//@ has - '//*[@id="impl-Any-for-T"]//a[@class="src rightside"]' 'Source' +pub struct Unsized { + data: [u8], +} diff --git a/tests/rustdoc/source-code-pages/src-links-external.rs b/tests/rustdoc/source-code-pages/src-links-external.rs new file mode 100644 index 00000000000..e8acbf1b9b4 --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links-external.rs @@ -0,0 +1,13 @@ +//@ aux-build:src-links-external.rs +//@ build-aux-docs +//@ ignore-cross-compile + +#![crate_name = "foo"] + +extern crate src_links_external; + +//@ has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' +#[doc(inline)] +pub use src_links_external as bar; + +//@ has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' diff --git a/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs b/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs new file mode 100644 index 00000000000..d9abdcde08d --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs @@ -0,0 +1,21 @@ +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/43893 + +#![crate_name = "foo"] + +pub trait SomeTrait {} +pub struct SomeStruct; + +//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#11' +impl SomeTrait for usize {} + +//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#14-16' +impl SomeTrait for SomeStruct { + // deliberately multi-line impl +} + +pub trait AnotherTrait {} + +//@ has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#21' +impl AnotherTrait for T {} diff --git a/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs b/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs new file mode 100644 index 00000000000..8675ae4736e --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs @@ -0,0 +1,11 @@ +//@ aux-build:issue-34274.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/34274 +#![crate_name = "foo"] + +extern crate issue_34274; + +//@ has foo/fn.extern_c_fn.html '//a/@href' '../src/issue_34274/issue-34274.rs.html#2' +pub use issue_34274::extern_c_fn; diff --git a/tests/rustdoc/source-code-pages/src-links.rs b/tests/rustdoc/source-code-pages/src-links.rs new file mode 100644 index 00000000000..24039a5d84e --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links.rs @@ -0,0 +1,51 @@ +#![crate_name = "foo"] + +//! Dox +//@ has src/foo/src-links.rs.html +//@ has foo/index.html '//a/@href' '../src/foo/src-links.rs.html' + +#[path = "src-links/mod.rs"] +pub mod qux; + +//@ has src/foo/src-links.rs.html +//@ has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html' +#[path = "src-links/../src-links/fizz.rs"] +pub mod fizz; + +//@ has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html' +pub mod bar { + + /// Dox + //@ has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html' + pub mod baz { + /// Dox + //@ has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html' + pub fn baz() { } + } + + /// Dox + //@ has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html' + pub trait Foobar { fn dummy(&self) { } } + + //@ has foo/bar/struct.Foo.html '//a/@href' '../../src/foo/src-links.rs.html' + pub struct Foo { x: i32, y: u32 } + + //@ has foo/bar/fn.prawns.html '//a/@href' '../../src/foo/src-links.rs.html' + pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { } +} + +/// Dox +//@ has foo/fn.modfn.html '//a/@href' '../src/foo/src-links.rs.html' +pub fn modfn() { } + +// same hierarchy as above, but just for the submodule + +//@ has src/foo/src-links/mod.rs.html +//@ has foo/qux/index.html '//a/@href' '../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/index.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/baz/index.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/baz/fn.baz.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/trait.Foobar.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html' diff --git a/tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir b/tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/rustdoc/source-code-pages/src-links/fizz.rs b/tests/rustdoc/source-code-pages/src-links/fizz.rs new file mode 100644 index 00000000000..d2b76b1cec8 --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links/fizz.rs @@ -0,0 +1 @@ +pub struct Buzz; diff --git a/tests/rustdoc/source-code-pages/src-links/mod.rs b/tests/rustdoc/source-code-pages/src-links/mod.rs new file mode 100644 index 00000000000..27b2396811a --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-links/mod.rs @@ -0,0 +1,19 @@ +//! Dox +pub mod bar { + + /// Dox + pub mod baz { + /// Dox + pub fn baz() { } + } + + /// Dox + pub trait Foobar { fn dummy(&self) { } } + + pub struct Foo { x: i32, y: u32 } + + pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { } +} + +/// Dox +pub fn modfn() { } diff --git a/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs b/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs new file mode 100644 index 00000000000..f754b64977f --- /dev/null +++ b/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs @@ -0,0 +1,10 @@ +//@ ignore-windows +//@ compile-flags: --no-defaults + +// https://github.com/rust-lang/rust/issues/26995 +#![crate_name="issue_26995"] + +//@ has src/issue_26995/dev/null.html +//@ has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html' +#[path="/dev/null"] +pub mod null; diff --git a/tests/rustdoc/source-code-pages/version-separator-without-source.rs b/tests/rustdoc/source-code-pages/version-separator-without-source.rs new file mode 100644 index 00000000000..7cd1780f1d3 --- /dev/null +++ b/tests/rustdoc/source-code-pages/version-separator-without-source.rs @@ -0,0 +1,23 @@ +#![doc(html_no_source)] +#![feature(staged_api)] +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] + +//@ has foo/fn.foo.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' +//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +//@ has foo/struct.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' +//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' + //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +} diff --git a/tests/rustdoc/source-file.rs b/tests/rustdoc/source-file.rs deleted file mode 100644 index 6cff5edf146..00000000000 --- a/tests/rustdoc/source-file.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "foo"] - -//@ hasraw src-files.js source-file.rs - -pub struct Foo; diff --git a/tests/rustdoc/source-line-numbers.rs b/tests/rustdoc/source-line-numbers.rs deleted file mode 100644 index 0b654b1a004..00000000000 --- a/tests/rustdoc/source-line-numbers.rs +++ /dev/null @@ -1,35 +0,0 @@ -// This test ensures that we have the expected number of line generated. - -#![crate_name = "foo"] - -//@ has 'src/foo/source-line-numbers.rs.html' -//@ count - '//a[@data-nosnippet]' 35 -//@ has - '//a[@id="35"]' '35' - -#[ -macro_export -] -macro_rules! bar { - ($x:ident) => {{ - $x += 2; - $x *= 2; - }} -} - -/* -multi line -comment -*/ -fn x(_: u8, _: u8) {} - -fn foo() { - let mut y = 0; - bar!(y); - println!(" - {y} - "); - x( - 1, - 2, - ); -} diff --git a/tests/rustdoc/source-version-separator.rs b/tests/rustdoc/source-version-separator.rs deleted file mode 100644 index 78b9d364d21..00000000000 --- a/tests/rustdoc/source-version-separator.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![stable(feature = "bar", since = "1.0")] -#![crate_name = "foo"] -#![feature(staged_api)] - -//@ has foo/trait.Bar.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source' -#[stable(feature = "bar", since = "1.0")] -pub trait Bar { - //@ has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0.0 · Source' - #[stable(feature = "foobar", since = "3.0")] - fn foo(); -} - -//@ has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · Source' - -//@ has foo/struct.Foo.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source' -#[stable(feature = "baz", since = "1.0")] -pub struct Foo; - -impl Foo { - //@ has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · Source' - #[stable(feature = "foobar", since = "3.0")] - pub fn foofoo() {} -} - -#[stable(feature = "yolo", since = "4.0")] -impl Bar for Foo { - fn foo() {} -} diff --git a/tests/rustdoc/src-link-external-macro-26606.rs b/tests/rustdoc/src-link-external-macro-26606.rs deleted file mode 100644 index 0ce829f06f5..00000000000 --- a/tests/rustdoc/src-link-external-macro-26606.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ aux-build:issue-26606-macro.rs -//@ ignore-cross-compile -//@ build-aux-docs - -// https://github.com/rust-lang/rust/issues/26606 -#![crate_name="issue_26606"] - -//@ has issue_26606_macro/macro.make_item.html -#[macro_use] -extern crate issue_26606_macro; - -//@ has issue_26606/constant.FOO.html -//@ has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'Source' -make_item!(FOO); diff --git a/tests/rustdoc/src-links-auto-impls.rs b/tests/rustdoc/src-links-auto-impls.rs deleted file mode 100644 index 5a777f59b7e..00000000000 --- a/tests/rustdoc/src-links-auto-impls.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Unsized.html -//@ has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' -//@ !has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'Source' -//@ has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' -//@ !has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'Source' -//@ has - '//*[@id="impl-Any-for-T"]/h3[@class="code-header"]' 'impl Any for T' -//@ has - '//*[@id="impl-Any-for-T"]//a[@class="src rightside"]' 'Source' -pub struct Unsized { - data: [u8], -} diff --git a/tests/rustdoc/src-links-external.rs b/tests/rustdoc/src-links-external.rs deleted file mode 100644 index e8acbf1b9b4..00000000000 --- a/tests/rustdoc/src-links-external.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:src-links-external.rs -//@ build-aux-docs -//@ ignore-cross-compile - -#![crate_name = "foo"] - -extern crate src_links_external; - -//@ has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' -#[doc(inline)] -pub use src_links_external as bar; - -//@ has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' diff --git a/tests/rustdoc/src-links-implementor-43893.rs b/tests/rustdoc/src-links-implementor-43893.rs deleted file mode 100644 index d9abdcde08d..00000000000 --- a/tests/rustdoc/src-links-implementor-43893.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/43893 - -#![crate_name = "foo"] - -pub trait SomeTrait {} -pub struct SomeStruct; - -//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#11' -impl SomeTrait for usize {} - -//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#14-16' -impl SomeTrait for SomeStruct { - // deliberately multi-line impl -} - -pub trait AnotherTrait {} - -//@ has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#21' -impl AnotherTrait for T {} diff --git a/tests/rustdoc/src-links-inlined-34274.rs b/tests/rustdoc/src-links-inlined-34274.rs deleted file mode 100644 index 8675ae4736e..00000000000 --- a/tests/rustdoc/src-links-inlined-34274.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:issue-34274.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/34274 -#![crate_name = "foo"] - -extern crate issue_34274; - -//@ has foo/fn.extern_c_fn.html '//a/@href' '../src/issue_34274/issue-34274.rs.html#2' -pub use issue_34274::extern_c_fn; diff --git a/tests/rustdoc/src-links.rs b/tests/rustdoc/src-links.rs deleted file mode 100644 index 24039a5d84e..00000000000 --- a/tests/rustdoc/src-links.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![crate_name = "foo"] - -//! Dox -//@ has src/foo/src-links.rs.html -//@ has foo/index.html '//a/@href' '../src/foo/src-links.rs.html' - -#[path = "src-links/mod.rs"] -pub mod qux; - -//@ has src/foo/src-links.rs.html -//@ has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html' -#[path = "src-links/../src-links/fizz.rs"] -pub mod fizz; - -//@ has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html' -pub mod bar { - - /// Dox - //@ has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html' - pub mod baz { - /// Dox - //@ has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html' - pub fn baz() { } - } - - /// Dox - //@ has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html' - pub trait Foobar { fn dummy(&self) { } } - - //@ has foo/bar/struct.Foo.html '//a/@href' '../../src/foo/src-links.rs.html' - pub struct Foo { x: i32, y: u32 } - - //@ has foo/bar/fn.prawns.html '//a/@href' '../../src/foo/src-links.rs.html' - pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { } -} - -/// Dox -//@ has foo/fn.modfn.html '//a/@href' '../src/foo/src-links.rs.html' -pub fn modfn() { } - -// same hierarchy as above, but just for the submodule - -//@ has src/foo/src-links/mod.rs.html -//@ has foo/qux/index.html '//a/@href' '../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/index.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/baz/index.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/baz/fn.baz.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/trait.Foobar.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -//@ has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html' diff --git a/tests/rustdoc/src-links/compiletest-ignore-dir b/tests/rustdoc/src-links/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/rustdoc/src-links/fizz.rs b/tests/rustdoc/src-links/fizz.rs deleted file mode 100644 index d2b76b1cec8..00000000000 --- a/tests/rustdoc/src-links/fizz.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Buzz; diff --git a/tests/rustdoc/src-links/mod.rs b/tests/rustdoc/src-links/mod.rs deleted file mode 100644 index 27b2396811a..00000000000 --- a/tests/rustdoc/src-links/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Dox -pub mod bar { - - /// Dox - pub mod baz { - /// Dox - pub fn baz() { } - } - - /// Dox - pub trait Foobar { fn dummy(&self) { } } - - pub struct Foo { x: i32, y: u32 } - - pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { } -} - -/// Dox -pub fn modfn() { } diff --git a/tests/rustdoc/src-mod-path-absolute-26995.rs b/tests/rustdoc/src-mod-path-absolute-26995.rs deleted file mode 100644 index f754b64977f..00000000000 --- a/tests/rustdoc/src-mod-path-absolute-26995.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ ignore-windows -//@ compile-flags: --no-defaults - -// https://github.com/rust-lang/rust/issues/26995 -#![crate_name="issue_26995"] - -//@ has src/issue_26995/dev/null.html -//@ has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html' -#[path="/dev/null"] -pub mod null; diff --git a/tests/rustdoc/version-separator-without-source.rs b/tests/rustdoc/version-separator-without-source.rs deleted file mode 100644 index 7cd1780f1d3..00000000000 --- a/tests/rustdoc/version-separator-without-source.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![doc(html_no_source)] -#![feature(staged_api)] -#![stable(feature = "bar", since = "1.0")] -#![crate_name = "foo"] - -//@ has foo/fn.foo.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' -//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' -#[stable(feature = "bar", since = "1.0")] -pub fn foo() {} - -//@ has foo/struct.Bar.html -//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0' -//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source' -#[stable(feature = "bar", since = "1.0")] -pub struct Bar; - -impl Bar { - //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' - //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' - #[stable(feature = "foobar", since = "2.0")] - pub fn bar() {} -} -- cgit 1.4.1-3-g733a5 From b374996ab8d3d8a10fdf1ffcf2b1c3de3fdbbf64 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 15:50:06 +0200 Subject: Created `tests/rustdoc/anchors` subfolder to limit number of files at the top level --- .../anchor-id-duplicate-method-name-25001.rs | 46 --------------- tests/rustdoc/anchor-id-trait-method-15169.rs | 7 --- tests/rustdoc/anchor-id-trait-tymethod-28478.rs | 34 ----------- tests/rustdoc/anchors.no_const_anchor.html | 1 - tests/rustdoc/anchors.no_const_anchor2.html | 1 - tests/rustdoc/anchors.no_method_anchor.html | 1 - tests/rustdoc/anchors.no_trait_method_anchor.html | 1 - tests/rustdoc/anchors.no_tymethod_anchor.html | 1 - tests/rustdoc/anchors.no_type_anchor.html | 1 - tests/rustdoc/anchors.no_type_anchor2.html | 1 - tests/rustdoc/anchors.rs | 49 ---------------- .../anchor-id-duplicate-method-name-25001.rs | 46 +++++++++++++++ .../anchors/anchor-id-trait-method-15169.rs | 7 +++ .../anchors/anchor-id-trait-tymethod-28478.rs | 34 +++++++++++ tests/rustdoc/anchors/anchors.no_const_anchor.html | 1 + .../rustdoc/anchors/anchors.no_const_anchor2.html | 1 + .../rustdoc/anchors/anchors.no_method_anchor.html | 1 + .../anchors/anchors.no_trait_method_anchor.html | 1 + .../anchors/anchors.no_tymethod_anchor.html | 1 + tests/rustdoc/anchors/anchors.no_type_anchor.html | 1 + tests/rustdoc/anchors/anchors.no_type_anchor2.html | 1 + tests/rustdoc/anchors/anchors.rs | 49 ++++++++++++++++ tests/rustdoc/anchors/auxiliary/issue-86620-1.rs | 11 ++++ .../rustdoc/anchors/disambiguate-anchors-32890.rs | 20 +++++++ .../anchors/disambiguate-anchors-header-29449.rs | 28 ++++++++++ .../extern-default-method.no_href_on_anchor.html | 1 + .../anchors/method-anchor-in-blanket-impl-86620.rs | 11 ++++ .../anchors/trait-impl-items-links-and-anchors.rs | 65 ++++++++++++++++++++++ tests/rustdoc/auxiliary/issue-86620-1.rs | 11 ---- tests/rustdoc/disambiguate-anchors-32890.rs | 20 ------- tests/rustdoc/disambiguate-anchors-header-29449.rs | 28 ---------- .../extern-default-method.no_href_on_anchor.html | 1 - .../rustdoc/method-anchor-in-blanket-impl-86620.rs | 11 ---- .../rustdoc/trait-impl-items-links-and-anchors.rs | 65 ---------------------- 34 files changed, 279 insertions(+), 279 deletions(-) delete mode 100644 tests/rustdoc/anchor-id-duplicate-method-name-25001.rs delete mode 100644 tests/rustdoc/anchor-id-trait-method-15169.rs delete mode 100644 tests/rustdoc/anchor-id-trait-tymethod-28478.rs delete mode 100644 tests/rustdoc/anchors.no_const_anchor.html delete mode 100644 tests/rustdoc/anchors.no_const_anchor2.html delete mode 100644 tests/rustdoc/anchors.no_method_anchor.html delete mode 100644 tests/rustdoc/anchors.no_trait_method_anchor.html delete mode 100644 tests/rustdoc/anchors.no_tymethod_anchor.html delete mode 100644 tests/rustdoc/anchors.no_type_anchor.html delete mode 100644 tests/rustdoc/anchors.no_type_anchor2.html delete mode 100644 tests/rustdoc/anchors.rs create mode 100644 tests/rustdoc/anchors/anchor-id-duplicate-method-name-25001.rs create mode 100644 tests/rustdoc/anchors/anchor-id-trait-method-15169.rs create mode 100644 tests/rustdoc/anchors/anchor-id-trait-tymethod-28478.rs create mode 100644 tests/rustdoc/anchors/anchors.no_const_anchor.html create mode 100644 tests/rustdoc/anchors/anchors.no_const_anchor2.html create mode 100644 tests/rustdoc/anchors/anchors.no_method_anchor.html create mode 100644 tests/rustdoc/anchors/anchors.no_trait_method_anchor.html create mode 100644 tests/rustdoc/anchors/anchors.no_tymethod_anchor.html create mode 100644 tests/rustdoc/anchors/anchors.no_type_anchor.html create mode 100644 tests/rustdoc/anchors/anchors.no_type_anchor2.html create mode 100644 tests/rustdoc/anchors/anchors.rs create mode 100644 tests/rustdoc/anchors/auxiliary/issue-86620-1.rs create mode 100644 tests/rustdoc/anchors/disambiguate-anchors-32890.rs create mode 100644 tests/rustdoc/anchors/disambiguate-anchors-header-29449.rs create mode 100644 tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html create mode 100644 tests/rustdoc/anchors/method-anchor-in-blanket-impl-86620.rs create mode 100644 tests/rustdoc/anchors/trait-impl-items-links-and-anchors.rs delete mode 100644 tests/rustdoc/auxiliary/issue-86620-1.rs delete mode 100644 tests/rustdoc/disambiguate-anchors-32890.rs delete mode 100644 tests/rustdoc/disambiguate-anchors-header-29449.rs delete mode 100644 tests/rustdoc/extern-default-method.no_href_on_anchor.html delete mode 100644 tests/rustdoc/method-anchor-in-blanket-impl-86620.rs delete mode 100644 tests/rustdoc/trait-impl-items-links-and-anchors.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs deleted file mode 100644 index d7f4e587d5e..00000000000 --- a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs +++ /dev/null @@ -1,46 +0,0 @@ -// https://github.com/rust-lang/rust/issues/25001 -#![crate_name="issue_25001"] - -//@ has issue_25001/struct.Foo.html -pub struct Foo(T); - -pub trait Bar { - type Item; - - fn quux(self); -} - -impl Foo { - //@ has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()' - pub fn pass() {} -} -impl Foo { - //@ has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize' - pub fn pass() -> usize { 42 } -} -impl Foo { - //@ has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize' - pub fn pass() -> isize { 42 } -} - -impl Bar for Foo { - //@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' 'type Item = T' - type Item=T; - - //@ has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)' - fn quux(self) {} -} -impl<'a, T> Bar for &'a Foo { - //@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item = &'a T" - type Item=&'a T; - - //@ has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)' - fn quux(self) {} -} -impl<'a, T> Bar for &'a mut Foo { - //@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T" - type Item=&'a mut T; - - //@ has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)' - fn quux(self) {} -} diff --git a/tests/rustdoc/anchor-id-trait-method-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs deleted file mode 100644 index 19eeeaee9d1..00000000000 --- a/tests/rustdoc/anchor-id-trait-method-15169.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' - -// https://github.com/rust-lang/rust/issues/15169 -#![crate_name="issue_15169"] - -#[derive(PartialEq)] -pub struct Foo; diff --git a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs deleted file mode 100644 index e7adba7d06e..00000000000 --- a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs +++ /dev/null @@ -1,34 +0,0 @@ -// https://github.com/rust-lang/rust/issues/28478 -#![crate_name="issue_28478"] - -#![feature(associated_type_defaults)] - -//@ has issue_28478/trait.Bar.html -pub trait Bar { - //@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()' - //@ has - '//*[@href="#associatedtype.Bar"]' 'Bar' - type Bar = (); - //@ has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize' - //@ has - '//*[@href="#associatedconstant.Baz"]' 'Baz' - const Baz: usize = 7; - //@ has - '//*[@id="tymethod.bar"]' 'fn bar' - fn bar(); - //@ has - '//*[@id="method.baz"]' 'fn baz' - fn baz() { } -} - -//@ has issue_28478/struct.Foo.html -pub struct Foo; - -impl Foo { - //@ has - '//*[@href="#method.foo"]' 'foo' - pub fn foo() {} -} - -impl Bar for Foo { - //@ has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar' - //@ has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz' - //@ has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar' - fn bar() {} - //@ has - '//*[@href="trait.Bar.html#method.baz"]' 'baz' -} diff --git a/tests/rustdoc/anchors.no_const_anchor.html b/tests/rustdoc/anchors.no_const_anchor.html deleted file mode 100644 index 07a7507fa2e..00000000000 --- a/tests/rustdoc/anchors.no_const_anchor.html +++ /dev/null @@ -1 +0,0 @@ -
Source

const YOLO: u32

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_const_anchor2.html b/tests/rustdoc/anchors.no_const_anchor2.html deleted file mode 100644 index 091dac3e4b2..00000000000 --- a/tests/rustdoc/anchors.no_const_anchor2.html +++ /dev/null @@ -1 +0,0 @@ -
Source

pub const X: i32 = 0i32

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_method_anchor.html b/tests/rustdoc/anchors.no_method_anchor.html deleted file mode 100644 index 89f9898624c..00000000000 --- a/tests/rustdoc/anchors.no_method_anchor.html +++ /dev/null @@ -1 +0,0 @@ -
Source

pub fn new() -> Self

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_trait_method_anchor.html b/tests/rustdoc/anchors.no_trait_method_anchor.html deleted file mode 100644 index 51656a3e58f..00000000000 --- a/tests/rustdoc/anchors.no_trait_method_anchor.html +++ /dev/null @@ -1 +0,0 @@ -
Source

fn bar()

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_tymethod_anchor.html b/tests/rustdoc/anchors.no_tymethod_anchor.html deleted file mode 100644 index 49ee624bdbc..00000000000 --- a/tests/rustdoc/anchors.no_tymethod_anchor.html +++ /dev/null @@ -1 +0,0 @@ -
Source

fn foo()

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_type_anchor.html b/tests/rustdoc/anchors.no_type_anchor.html deleted file mode 100644 index c5ac3c93818..00000000000 --- a/tests/rustdoc/anchors.no_type_anchor.html +++ /dev/null @@ -1 +0,0 @@ -
Source

type T

\ No newline at end of file diff --git a/tests/rustdoc/anchors.no_type_anchor2.html b/tests/rustdoc/anchors.no_type_anchor2.html deleted file mode 100644 index 14dd31d87b6..00000000000 --- a/tests/rustdoc/anchors.no_type_anchor2.html +++ /dev/null @@ -1 +0,0 @@ -
Source

pub type Y = u32

\ No newline at end of file diff --git a/tests/rustdoc/anchors.rs b/tests/rustdoc/anchors.rs deleted file mode 100644 index 255ef87351c..00000000000 --- a/tests/rustdoc/anchors.rs +++ /dev/null @@ -1,49 +0,0 @@ -// This test ensures that anchors are generated in the right places. - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -pub struct Foo; - -//@ has 'foo/trait.Bar.html' -pub trait Bar { - // There should be no anchors here. - //@ snapshot no_type_anchor - '//*[@id="associatedtype.T"]' - type T; - // There should be no anchors here. - //@ snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]' - const YOLO: u32; - - // There should be no anchors here. - //@ snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]' - fn foo(); - // There should be no anchors here. - //@ snapshot no_trait_method_anchor - '//*[@id="method.bar"]' - fn bar() {} -} - -//@ has 'foo/struct.Foo.html' -impl Bar for Foo { - //@ has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' '' - type T = u32; - //@ has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' '' - const YOLO: u32 = 0; - - //@ has - '//*[@id="method.foo"]/a[@class="anchor"]' '' - fn foo() {} - // Same check for provided "bar" method. - //@ has - '//*[@id="method.bar"]/a[@class="anchor"]' '' -} - -impl Foo { - //@ snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]' - // There should be no anchors here. - pub const X: i32 = 0; - //@ snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]' - // There should be no anchors here. - pub type Y = u32; - //@ snapshot no_method_anchor - '//*[@id="method.new"]' - // There should be no anchors here. - pub fn new() -> Self { Self } -} diff --git a/tests/rustdoc/anchors/anchor-id-duplicate-method-name-25001.rs b/tests/rustdoc/anchors/anchor-id-duplicate-method-name-25001.rs new file mode 100644 index 00000000000..d7f4e587d5e --- /dev/null +++ b/tests/rustdoc/anchors/anchor-id-duplicate-method-name-25001.rs @@ -0,0 +1,46 @@ +// https://github.com/rust-lang/rust/issues/25001 +#![crate_name="issue_25001"] + +//@ has issue_25001/struct.Foo.html +pub struct Foo(T); + +pub trait Bar { + type Item; + + fn quux(self); +} + +impl Foo { + //@ has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()' + pub fn pass() {} +} +impl Foo { + //@ has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize' + pub fn pass() -> usize { 42 } +} +impl Foo { + //@ has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize' + pub fn pass() -> isize { 42 } +} + +impl Bar for Foo { + //@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' 'type Item = T' + type Item=T; + + //@ has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)' + fn quux(self) {} +} +impl<'a, T> Bar for &'a Foo { + //@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item = &'a T" + type Item=&'a T; + + //@ has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)' + fn quux(self) {} +} +impl<'a, T> Bar for &'a mut Foo { + //@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T" + type Item=&'a mut T; + + //@ has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)' + fn quux(self) {} +} diff --git a/tests/rustdoc/anchors/anchor-id-trait-method-15169.rs b/tests/rustdoc/anchors/anchor-id-trait-method-15169.rs new file mode 100644 index 00000000000..19eeeaee9d1 --- /dev/null +++ b/tests/rustdoc/anchors/anchor-id-trait-method-15169.rs @@ -0,0 +1,7 @@ +//@ has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' + +// https://github.com/rust-lang/rust/issues/15169 +#![crate_name="issue_15169"] + +#[derive(PartialEq)] +pub struct Foo; diff --git a/tests/rustdoc/anchors/anchor-id-trait-tymethod-28478.rs b/tests/rustdoc/anchors/anchor-id-trait-tymethod-28478.rs new file mode 100644 index 00000000000..e7adba7d06e --- /dev/null +++ b/tests/rustdoc/anchors/anchor-id-trait-tymethod-28478.rs @@ -0,0 +1,34 @@ +// https://github.com/rust-lang/rust/issues/28478 +#![crate_name="issue_28478"] + +#![feature(associated_type_defaults)] + +//@ has issue_28478/trait.Bar.html +pub trait Bar { + //@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()' + //@ has - '//*[@href="#associatedtype.Bar"]' 'Bar' + type Bar = (); + //@ has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize' + //@ has - '//*[@href="#associatedconstant.Baz"]' 'Baz' + const Baz: usize = 7; + //@ has - '//*[@id="tymethod.bar"]' 'fn bar' + fn bar(); + //@ has - '//*[@id="method.baz"]' 'fn baz' + fn baz() { } +} + +//@ has issue_28478/struct.Foo.html +pub struct Foo; + +impl Foo { + //@ has - '//*[@href="#method.foo"]' 'foo' + pub fn foo() {} +} + +impl Bar for Foo { + //@ has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar' + //@ has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz' + //@ has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar' + fn bar() {} + //@ has - '//*[@href="trait.Bar.html#method.baz"]' 'baz' +} diff --git a/tests/rustdoc/anchors/anchors.no_const_anchor.html b/tests/rustdoc/anchors/anchors.no_const_anchor.html new file mode 100644 index 00000000000..07a7507fa2e --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_const_anchor.html @@ -0,0 +1 @@ +
Source

const YOLO: u32

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_const_anchor2.html b/tests/rustdoc/anchors/anchors.no_const_anchor2.html new file mode 100644 index 00000000000..091dac3e4b2 --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_const_anchor2.html @@ -0,0 +1 @@ +
Source

pub const X: i32 = 0i32

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_method_anchor.html b/tests/rustdoc/anchors/anchors.no_method_anchor.html new file mode 100644 index 00000000000..89f9898624c --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_method_anchor.html @@ -0,0 +1 @@ +
Source

pub fn new() -> Self

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_trait_method_anchor.html b/tests/rustdoc/anchors/anchors.no_trait_method_anchor.html new file mode 100644 index 00000000000..51656a3e58f --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_trait_method_anchor.html @@ -0,0 +1 @@ +
Source

fn bar()

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_tymethod_anchor.html b/tests/rustdoc/anchors/anchors.no_tymethod_anchor.html new file mode 100644 index 00000000000..49ee624bdbc --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_tymethod_anchor.html @@ -0,0 +1 @@ +
Source

fn foo()

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_type_anchor.html b/tests/rustdoc/anchors/anchors.no_type_anchor.html new file mode 100644 index 00000000000..c5ac3c93818 --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_type_anchor.html @@ -0,0 +1 @@ +
Source

type T

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.no_type_anchor2.html b/tests/rustdoc/anchors/anchors.no_type_anchor2.html new file mode 100644 index 00000000000..14dd31d87b6 --- /dev/null +++ b/tests/rustdoc/anchors/anchors.no_type_anchor2.html @@ -0,0 +1 @@ +
Source

pub type Y = u32

\ No newline at end of file diff --git a/tests/rustdoc/anchors/anchors.rs b/tests/rustdoc/anchors/anchors.rs new file mode 100644 index 00000000000..255ef87351c --- /dev/null +++ b/tests/rustdoc/anchors/anchors.rs @@ -0,0 +1,49 @@ +// This test ensures that anchors are generated in the right places. + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +pub struct Foo; + +//@ has 'foo/trait.Bar.html' +pub trait Bar { + // There should be no anchors here. + //@ snapshot no_type_anchor - '//*[@id="associatedtype.T"]' + type T; + // There should be no anchors here. + //@ snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]' + const YOLO: u32; + + // There should be no anchors here. + //@ snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]' + fn foo(); + // There should be no anchors here. + //@ snapshot no_trait_method_anchor - '//*[@id="method.bar"]' + fn bar() {} +} + +//@ has 'foo/struct.Foo.html' +impl Bar for Foo { + //@ has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' '' + type T = u32; + //@ has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' '' + const YOLO: u32 = 0; + + //@ has - '//*[@id="method.foo"]/a[@class="anchor"]' '' + fn foo() {} + // Same check for provided "bar" method. + //@ has - '//*[@id="method.bar"]/a[@class="anchor"]' '' +} + +impl Foo { + //@ snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]' + // There should be no anchors here. + pub const X: i32 = 0; + //@ snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]' + // There should be no anchors here. + pub type Y = u32; + //@ snapshot no_method_anchor - '//*[@id="method.new"]' + // There should be no anchors here. + pub fn new() -> Self { Self } +} diff --git a/tests/rustdoc/anchors/auxiliary/issue-86620-1.rs b/tests/rustdoc/anchors/auxiliary/issue-86620-1.rs new file mode 100644 index 00000000000..f6debf6fb4e --- /dev/null +++ b/tests/rustdoc/anchors/auxiliary/issue-86620-1.rs @@ -0,0 +1,11 @@ +#![crate_name = "issue_86620_1"] + +pub trait VZip { + fn vzip() -> usize; +} + +impl VZip for T { + fn vzip() -> usize { + 0 + } +} diff --git a/tests/rustdoc/anchors/disambiguate-anchors-32890.rs b/tests/rustdoc/anchors/disambiguate-anchors-32890.rs new file mode 100644 index 00000000000..0b726d5fba4 --- /dev/null +++ b/tests/rustdoc/anchors/disambiguate-anchors-32890.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/issues/32890 +#![crate_name="issue_32890"] + +//@ has issue_32890/struct.Foo.html +pub struct Foo(T); + +impl Foo { + //@ has - '//a[@href="#method.pass"]' 'pass' + pub fn pass() {} +} + +impl Foo { + //@ has - '//a[@href="#method.pass-1"]' 'pass' + pub fn pass() {} +} + +impl Foo { + //@ has - '//a[@href="#method.pass-2"]' 'pass' + pub fn pass() {} +} diff --git a/tests/rustdoc/anchors/disambiguate-anchors-header-29449.rs b/tests/rustdoc/anchors/disambiguate-anchors-header-29449.rs new file mode 100644 index 00000000000..feb0632775e --- /dev/null +++ b/tests/rustdoc/anchors/disambiguate-anchors-header-29449.rs @@ -0,0 +1,28 @@ +// https://github.com/rust-lang/rust/issues/29449 +#![crate_name="issue_29449"] + +//@ has issue_29449/struct.Foo.html +pub struct Foo; + +impl Foo { + //@ has - '//*[@id="examples"]' 'Examples' + //@ has - '//*[@id="examples"]/a[@href="#examples"]' '§' + //@ has - '//*[@id="panics"]' 'Panics' + //@ has - '//*[@id="panics"]/a[@href="#panics"]' '§' + /// # Examples + /// # Panics + pub fn bar() {} + + //@ has - '//*[@id="examples-1"]' 'Examples' + //@ has - '//*[@id="examples-1"]/a[@href="#examples-1"]' '§' + /// # Examples + pub fn bar_1() {} + + //@ has - '//*[@id="examples-2"]' 'Examples' + //@ has - '//*[@id="examples-2"]/a[@href="#examples-2"]' '§' + //@ has - '//*[@id="panics-1"]' 'Panics' + //@ has - '//*[@id="panics-1"]/a[@href="#panics-1"]' '§' + /// # Examples + /// # Panics + pub fn bar_2() {} +} diff --git a/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html new file mode 100644 index 00000000000..ef14836ccb8 --- /dev/null +++ b/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html @@ -0,0 +1 @@ +provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/anchors/method-anchor-in-blanket-impl-86620.rs b/tests/rustdoc/anchors/method-anchor-in-blanket-impl-86620.rs new file mode 100644 index 00000000000..89e8712169a --- /dev/null +++ b/tests/rustdoc/anchors/method-anchor-in-blanket-impl-86620.rs @@ -0,0 +1,11 @@ +//@ aux-build:issue-86620-1.rs +#![crate_name = "foo"] +// https://github.com/rust-lang/rust/issues/86620 + +extern crate issue_86620_1; + +use issue_86620_1::*; + +//@ !has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="fnname"]/@href' #tymethod.vzip +//@ has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="anchor"]/@href' #method.vzip +pub struct S; diff --git a/tests/rustdoc/anchors/trait-impl-items-links-and-anchors.rs b/tests/rustdoc/anchors/trait-impl-items-links-and-anchors.rs new file mode 100644 index 00000000000..c1845a33b9d --- /dev/null +++ b/tests/rustdoc/anchors/trait-impl-items-links-and-anchors.rs @@ -0,0 +1,65 @@ +pub trait MyTrait { + type Assoc; + const VALUE: u32 = 12; + fn trait_function(&self); + fn defaulted(&self) {} + fn defaulted_override(&self) {} +} + +impl MyTrait for String { + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1 + type Assoc = (); + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-1 + const VALUE: u32 = 5; + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function + fn trait_function(&self) {} + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fn"]/@href' #method.defaulted_override + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="anchor"]/@href' #method.defaulted_override-1 + fn defaulted_override(&self) {} +} + +impl MyTrait for Vec { + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2 + type Assoc = (); + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-2 + const VALUE: u32 = 5; + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function-1"]//a[@class="anchor"]/@href' #method.trait_function-1 + fn trait_function(&self) {} + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fn"]/@href' #method.defaulted_override + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="anchor"]/@href' #method.defaulted_override-2 + fn defaulted_override(&self) {} +} + +impl MyTrait for MyStruct { + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3 + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc + type Assoc = bool; + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3 + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE + const VALUE: u32 = 20; + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' trait.MyTrait.html#tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function + fn trait_function(&self) {} + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted_override + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override + fn defaulted_override(&self) {} + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="anchor"]/@href' #method.defaulted +} + +pub struct MyStruct; + +// We check that associated items with default values aren't generated in the implementors list. +impl MyTrait for (u8, u8) { + //@ !has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' + type Assoc = bool; + fn trait_function(&self) {} +} diff --git a/tests/rustdoc/auxiliary/issue-86620-1.rs b/tests/rustdoc/auxiliary/issue-86620-1.rs deleted file mode 100644 index f6debf6fb4e..00000000000 --- a/tests/rustdoc/auxiliary/issue-86620-1.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![crate_name = "issue_86620_1"] - -pub trait VZip { - fn vzip() -> usize; -} - -impl VZip for T { - fn vzip() -> usize { - 0 - } -} diff --git a/tests/rustdoc/disambiguate-anchors-32890.rs b/tests/rustdoc/disambiguate-anchors-32890.rs deleted file mode 100644 index 0b726d5fba4..00000000000 --- a/tests/rustdoc/disambiguate-anchors-32890.rs +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/rust-lang/rust/issues/32890 -#![crate_name="issue_32890"] - -//@ has issue_32890/struct.Foo.html -pub struct Foo(T); - -impl Foo { - //@ has - '//a[@href="#method.pass"]' 'pass' - pub fn pass() {} -} - -impl Foo { - //@ has - '//a[@href="#method.pass-1"]' 'pass' - pub fn pass() {} -} - -impl Foo { - //@ has - '//a[@href="#method.pass-2"]' 'pass' - pub fn pass() {} -} diff --git a/tests/rustdoc/disambiguate-anchors-header-29449.rs b/tests/rustdoc/disambiguate-anchors-header-29449.rs deleted file mode 100644 index feb0632775e..00000000000 --- a/tests/rustdoc/disambiguate-anchors-header-29449.rs +++ /dev/null @@ -1,28 +0,0 @@ -// https://github.com/rust-lang/rust/issues/29449 -#![crate_name="issue_29449"] - -//@ has issue_29449/struct.Foo.html -pub struct Foo; - -impl Foo { - //@ has - '//*[@id="examples"]' 'Examples' - //@ has - '//*[@id="examples"]/a[@href="#examples"]' '§' - //@ has - '//*[@id="panics"]' 'Panics' - //@ has - '//*[@id="panics"]/a[@href="#panics"]' '§' - /// # Examples - /// # Panics - pub fn bar() {} - - //@ has - '//*[@id="examples-1"]' 'Examples' - //@ has - '//*[@id="examples-1"]/a[@href="#examples-1"]' '§' - /// # Examples - pub fn bar_1() {} - - //@ has - '//*[@id="examples-2"]' 'Examples' - //@ has - '//*[@id="examples-2"]/a[@href="#examples-2"]' '§' - //@ has - '//*[@id="panics-1"]' 'Panics' - //@ has - '//*[@id="panics-1"]/a[@href="#panics-1"]' '§' - /// # Examples - /// # Panics - pub fn bar_2() {} -} diff --git a/tests/rustdoc/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/extern-default-method.no_href_on_anchor.html deleted file mode 100644 index ef14836ccb8..00000000000 --- a/tests/rustdoc/extern-default-method.no_href_on_anchor.html +++ /dev/null @@ -1 +0,0 @@ -provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs b/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs deleted file mode 100644 index 89e8712169a..00000000000 --- a/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:issue-86620-1.rs -#![crate_name = "foo"] -// https://github.com/rust-lang/rust/issues/86620 - -extern crate issue_86620_1; - -use issue_86620_1::*; - -//@ !has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="fnname"]/@href' #tymethod.vzip -//@ has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="anchor"]/@href' #method.vzip -pub struct S; diff --git a/tests/rustdoc/trait-impl-items-links-and-anchors.rs b/tests/rustdoc/trait-impl-items-links-and-anchors.rs deleted file mode 100644 index c1845a33b9d..00000000000 --- a/tests/rustdoc/trait-impl-items-links-and-anchors.rs +++ /dev/null @@ -1,65 +0,0 @@ -pub trait MyTrait { - type Assoc; - const VALUE: u32 = 12; - fn trait_function(&self); - fn defaulted(&self) {} - fn defaulted_override(&self) {} -} - -impl MyTrait for String { - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1 - type Assoc = (); - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-1 - const VALUE: u32 = 5; - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function - fn trait_function(&self) {} - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fn"]/@href' #method.defaulted_override - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="anchor"]/@href' #method.defaulted_override-1 - fn defaulted_override(&self) {} -} - -impl MyTrait for Vec { - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2 - type Assoc = (); - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-2 - const VALUE: u32 = 5; - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function-1"]//a[@class="anchor"]/@href' #method.trait_function-1 - fn trait_function(&self) {} - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fn"]/@href' #method.defaulted_override - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="anchor"]/@href' #method.defaulted_override-2 - fn defaulted_override(&self) {} -} - -impl MyTrait for MyStruct { - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3 - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc - type Assoc = bool; - //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3 - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE - const VALUE: u32 = 20; - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' trait.MyTrait.html#tymethod.trait_function - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function - fn trait_function(&self) {} - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted_override - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override - fn defaulted_override(&self) {} - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted - //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="anchor"]/@href' #method.defaulted -} - -pub struct MyStruct; - -// We check that associated items with default values aren't generated in the implementors list. -impl MyTrait for (u8, u8) { - //@ !has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' - type Assoc = bool; - fn trait_function(&self) {} -} -- cgit 1.4.1-3-g733a5 From ff971d001d3440fa609f8c5370432c6b77a5ac6e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:28:15 +0200 Subject: Created `tests/rustdoc/auto` subfolder to limit number of files at the top level --- tests/rustdoc/auto-impl-for-trait.rs | 16 ------------ tests/rustdoc/auto-impl-primitive.rs | 10 -------- .../auto-trait-bounds-by-associated-type-50159.rs | 26 ------------------- .../auto-trait-bounds-inference-variables-54705.rs | 30 ---------------------- tests/rustdoc/auto-trait-bounds-where-51236.rs | 17 ------------ tests/rustdoc/auto-trait-negative-impl-55321.rs | 21 --------------- tests/rustdoc/auto-trait-not-send.rs | 8 ------ tests/rustdoc/auto-traits.rs | 13 ---------- tests/rustdoc/auto/auto-impl-for-trait.rs | 16 ++++++++++++ tests/rustdoc/auto/auto-impl-primitive.rs | 10 ++++++++ .../auto-trait-bounds-by-associated-type-50159.rs | 26 +++++++++++++++++++ .../auto-trait-bounds-inference-variables-54705.rs | 30 ++++++++++++++++++++++ .../rustdoc/auto/auto-trait-bounds-where-51236.rs | 17 ++++++++++++ .../rustdoc/auto/auto-trait-negative-impl-55321.rs | 21 +++++++++++++++ tests/rustdoc/auto/auto-trait-not-send.rs | 8 ++++++ tests/rustdoc/auto/auto-traits.rs | 13 ++++++++++ tests/rustdoc/auto/auto_aliases.rs | 6 +++++ tests/rustdoc/auto/auxiliary/auto-traits.rs | 3 +++ tests/rustdoc/auto_aliases.rs | 6 ----- tests/rustdoc/auxiliary/auto-traits.rs | 3 --- 20 files changed, 150 insertions(+), 150 deletions(-) delete mode 100644 tests/rustdoc/auto-impl-for-trait.rs delete mode 100644 tests/rustdoc/auto-impl-primitive.rs delete mode 100644 tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs delete mode 100644 tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs delete mode 100644 tests/rustdoc/auto-trait-bounds-where-51236.rs delete mode 100644 tests/rustdoc/auto-trait-negative-impl-55321.rs delete mode 100644 tests/rustdoc/auto-trait-not-send.rs delete mode 100644 tests/rustdoc/auto-traits.rs create mode 100644 tests/rustdoc/auto/auto-impl-for-trait.rs create mode 100644 tests/rustdoc/auto/auto-impl-primitive.rs create mode 100644 tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs create mode 100644 tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs create mode 100644 tests/rustdoc/auto/auto-trait-bounds-where-51236.rs create mode 100644 tests/rustdoc/auto/auto-trait-negative-impl-55321.rs create mode 100644 tests/rustdoc/auto/auto-trait-not-send.rs create mode 100644 tests/rustdoc/auto/auto-traits.rs create mode 100644 tests/rustdoc/auto/auto_aliases.rs create mode 100644 tests/rustdoc/auto/auxiliary/auto-traits.rs delete mode 100644 tests/rustdoc/auto_aliases.rs delete mode 100644 tests/rustdoc/auxiliary/auto-traits.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/auto-impl-for-trait.rs b/tests/rustdoc/auto-impl-for-trait.rs deleted file mode 100644 index bc658fbfc8c..00000000000 --- a/tests/rustdoc/auto-impl-for-trait.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Test for https://github.com/rust-lang/rust/issues/48463 issue. - -use std::any::Any; -use std::ops::Deref; - -pub struct AnyValue { - val: Box, -} - -impl Deref for AnyValue { - type Target = Any; - - fn deref(&self) -> &Any { - &*self.val - } -} diff --git a/tests/rustdoc/auto-impl-primitive.rs b/tests/rustdoc/auto-impl-primitive.rs deleted file mode 100644 index 3dab02506ca..00000000000 --- a/tests/rustdoc/auto-impl-primitive.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(rustc_attrs)] - -#![crate_name = "foo"] - -pub use std::fs::File; - -//@ has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' -#[rustc_doc_primitive = "i16"] -/// I love poneys! -mod prim {} diff --git a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs deleted file mode 100644 index 2803c4da437..00000000000 --- a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs +++ /dev/null @@ -1,26 +0,0 @@ -// https://github.com/rust-lang/rust/issues/50159 -#![crate_name = "foo"] - -pub trait Signal { - type Item; -} - -pub trait Signal2 { - type Item2; -} - -impl Signal2 for B -where - B: Signal, -{ - type Item2 = C; -} - -//@ has foo/struct.Switch.html -//@ has - '//h3[@class="code-header"]' 'impl Send for Switchwhere ::Item: Send' -//@ has - '//h3[@class="code-header"]' 'impl Sync for Switchwhere ::Item: Sync' -//@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 -pub struct Switch { - pub inner: ::Item2, -} diff --git a/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs b/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs deleted file mode 100644 index ef159fca872..00000000000 --- a/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs +++ /dev/null @@ -1,30 +0,0 @@ -// https://github.com/rust-lang/rust/issues/54705 -#![crate_name="foo"] - -pub trait ScopeHandle<'scope> {} - -//@ has foo/struct.ScopeFutureContents.html -//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" -// -//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl<'scope, S> Sync for ScopeFutureContents<'scope, S>where S: Sync" -pub struct ScopeFutureContents<'scope, S> - where S: ScopeHandle<'scope>, -{ - dummy: &'scope S, - this: Box>, -} - -struct ScopeFuture<'scope, S> - where S: ScopeHandle<'scope>, -{ - contents: ScopeFutureContents<'scope, S>, -} - -unsafe impl<'scope, S> Send for ScopeFuture<'scope, S> - where S: ScopeHandle<'scope>, -{} -unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S> - where S: ScopeHandle<'scope>, -{} diff --git a/tests/rustdoc/auto-trait-bounds-where-51236.rs b/tests/rustdoc/auto-trait-bounds-where-51236.rs deleted file mode 100644 index c892b6d0abf..00000000000 --- a/tests/rustdoc/auto-trait-bounds-where-51236.rs +++ /dev/null @@ -1,17 +0,0 @@ -// https://github.com/rust-lang/rust/issues/51236 -#![crate_name="foo"] - -use std::marker::PhantomData; - -pub mod traits { - pub trait Owned<'a> { - type Reader; - } -} - -//@ has foo/struct.Owned.html -//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Send for Ownedwhere >::Reader: Send" -pub struct Owned where T: for<'a> ::traits::Owned<'a> { - marker: PhantomData<>::Reader>, -} diff --git a/tests/rustdoc/auto-trait-negative-impl-55321.rs b/tests/rustdoc/auto-trait-negative-impl-55321.rs deleted file mode 100644 index 147f44da117..00000000000 --- a/tests/rustdoc/auto-trait-negative-impl-55321.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/55321 -#![crate_name="foo"] - -#![feature(negative_impls)] - -//@ has foo/struct.A.html -//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Send for A" -//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Sync for A" -pub struct A(); - -impl !Send for A {} -impl !Sync for A {} - -//@ has foo/struct.B.html -//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Send for B" -//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Sync for B" -pub struct B(A, Box); diff --git a/tests/rustdoc/auto-trait-not-send.rs b/tests/rustdoc/auto-trait-not-send.rs deleted file mode 100644 index 0a31952f5e1..00000000000 --- a/tests/rustdoc/auto-trait-not-send.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/struct.Foo.html' -//@ has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo' -//@ has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo' -pub struct Foo(*const i8); -pub trait Whatever: Send {} -impl Whatever for T {} diff --git a/tests/rustdoc/auto-traits.rs b/tests/rustdoc/auto-traits.rs deleted file mode 100644 index dce406ed3e3..00000000000 --- a/tests/rustdoc/auto-traits.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:auto-traits.rs - -#![feature(auto_traits)] - -#![crate_name = "foo"] - -extern crate auto_traits; - -//@ has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo' -pub unsafe auto trait Foo {} - -//@ has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar' -pub use auto_traits::Bar; diff --git a/tests/rustdoc/auto/auto-impl-for-trait.rs b/tests/rustdoc/auto/auto-impl-for-trait.rs new file mode 100644 index 00000000000..bc658fbfc8c --- /dev/null +++ b/tests/rustdoc/auto/auto-impl-for-trait.rs @@ -0,0 +1,16 @@ +// Test for https://github.com/rust-lang/rust/issues/48463 issue. + +use std::any::Any; +use std::ops::Deref; + +pub struct AnyValue { + val: Box, +} + +impl Deref for AnyValue { + type Target = Any; + + fn deref(&self) -> &Any { + &*self.val + } +} diff --git a/tests/rustdoc/auto/auto-impl-primitive.rs b/tests/rustdoc/auto/auto-impl-primitive.rs new file mode 100644 index 00000000000..3dab02506ca --- /dev/null +++ b/tests/rustdoc/auto/auto-impl-primitive.rs @@ -0,0 +1,10 @@ +#![feature(rustc_attrs)] + +#![crate_name = "foo"] + +pub use std::fs::File; + +//@ has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' +#[rustc_doc_primitive = "i16"] +/// I love poneys! +mod prim {} diff --git a/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs new file mode 100644 index 00000000000..2803c4da437 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/50159 +#![crate_name = "foo"] + +pub trait Signal { + type Item; +} + +pub trait Signal2 { + type Item2; +} + +impl Signal2 for B +where + B: Signal, +{ + type Item2 = C; +} + +//@ has foo/struct.Switch.html +//@ has - '//h3[@class="code-header"]' 'impl Send for Switchwhere ::Item: Send' +//@ has - '//h3[@class="code-header"]' 'impl Sync for Switchwhere ::Item: Sync' +//@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 +pub struct Switch { + pub inner: ::Item2, +} diff --git a/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs b/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs new file mode 100644 index 00000000000..ef159fca872 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs @@ -0,0 +1,30 @@ +// https://github.com/rust-lang/rust/issues/54705 +#![crate_name="foo"] + +pub trait ScopeHandle<'scope> {} + +//@ has foo/struct.ScopeFutureContents.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" +// +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Sync for ScopeFutureContents<'scope, S>where S: Sync" +pub struct ScopeFutureContents<'scope, S> + where S: ScopeHandle<'scope>, +{ + dummy: &'scope S, + this: Box>, +} + +struct ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{ + contents: ScopeFutureContents<'scope, S>, +} + +unsafe impl<'scope, S> Send for ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{} +unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{} diff --git a/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs b/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs new file mode 100644 index 00000000000..c892b6d0abf --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/51236 +#![crate_name="foo"] + +use std::marker::PhantomData; + +pub mod traits { + pub trait Owned<'a> { + type Reader; + } +} + +//@ has foo/struct.Owned.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Send for Ownedwhere >::Reader: Send" +pub struct Owned where T: for<'a> ::traits::Owned<'a> { + marker: PhantomData<>::Reader>, +} diff --git a/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs b/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs new file mode 100644 index 00000000000..147f44da117 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/55321 +#![crate_name="foo"] + +#![feature(negative_impls)] + +//@ has foo/struct.A.html +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Send for A" +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Sync for A" +pub struct A(); + +impl !Send for A {} +impl !Sync for A {} + +//@ has foo/struct.B.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Send for B" +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Sync for B" +pub struct B(A, Box); diff --git a/tests/rustdoc/auto/auto-trait-not-send.rs b/tests/rustdoc/auto/auto-trait-not-send.rs new file mode 100644 index 00000000000..0a31952f5e1 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-not-send.rs @@ -0,0 +1,8 @@ +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +//@ has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo' +//@ has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo' +pub struct Foo(*const i8); +pub trait Whatever: Send {} +impl Whatever for T {} diff --git a/tests/rustdoc/auto/auto-traits.rs b/tests/rustdoc/auto/auto-traits.rs new file mode 100644 index 00000000000..dce406ed3e3 --- /dev/null +++ b/tests/rustdoc/auto/auto-traits.rs @@ -0,0 +1,13 @@ +//@ aux-build:auto-traits.rs + +#![feature(auto_traits)] + +#![crate_name = "foo"] + +extern crate auto_traits; + +//@ has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo' +pub unsafe auto trait Foo {} + +//@ has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar' +pub use auto_traits::Bar; diff --git a/tests/rustdoc/auto/auto_aliases.rs b/tests/rustdoc/auto/auto_aliases.rs new file mode 100644 index 00000000000..920aba805cd --- /dev/null +++ b/tests/rustdoc/auto/auto_aliases.rs @@ -0,0 +1,6 @@ +#![feature(auto_traits)] + +//@ has auto_aliases/trait.Bar.html '//*[@data-aliases="auto_aliases::Foo"]' 'impl Bar for Foo' +pub struct Foo; + +pub auto trait Bar {} diff --git a/tests/rustdoc/auto/auxiliary/auto-traits.rs b/tests/rustdoc/auto/auxiliary/auto-traits.rs new file mode 100644 index 00000000000..84976c73bee --- /dev/null +++ b/tests/rustdoc/auto/auxiliary/auto-traits.rs @@ -0,0 +1,3 @@ +#![feature(auto_traits)] + +pub unsafe auto trait Bar {} diff --git a/tests/rustdoc/auto_aliases.rs b/tests/rustdoc/auto_aliases.rs deleted file mode 100644 index 920aba805cd..00000000000 --- a/tests/rustdoc/auto_aliases.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(auto_traits)] - -//@ has auto_aliases/trait.Bar.html '//*[@data-aliases="auto_aliases::Foo"]' 'impl Bar for Foo' -pub struct Foo; - -pub auto trait Bar {} diff --git a/tests/rustdoc/auxiliary/auto-traits.rs b/tests/rustdoc/auxiliary/auto-traits.rs deleted file mode 100644 index 84976c73bee..00000000000 --- a/tests/rustdoc/auxiliary/auto-traits.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![feature(auto_traits)] - -pub unsafe auto trait Bar {} -- cgit 1.4.1-3-g733a5 From 9db7de5915314a3924548f2b1645d09ba2644dad Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:31:58 +0200 Subject: Created `tests/rustdoc/jump-to-def` subfolder to limit number of files at the top level --- tests/rustdoc/auxiliary/jump-to-def-macro.rs | 6 --- tests/rustdoc/jump-to-def-doc-links-calls.rs | 27 ----------- tests/rustdoc/jump-to-def-doc-links.rs | 51 --------------------- tests/rustdoc/jump-to-def-macro.rs | 15 ------- tests/rustdoc/jump-to-def-pats.rs | 52 ---------------------- tests/rustdoc/jump-to-def-prelude-types.rs | 23 ---------- .../jump-to-def/auxiliary/jump-to-def-macro.rs | 6 +++ .../jump-to-def/jump-to-def-doc-links-calls.rs | 27 +++++++++++ tests/rustdoc/jump-to-def/jump-to-def-doc-links.rs | 51 +++++++++++++++++++++ tests/rustdoc/jump-to-def/jump-to-def-macro.rs | 15 +++++++ tests/rustdoc/jump-to-def/jump-to-def-pats.rs | 52 ++++++++++++++++++++++ .../jump-to-def/jump-to-def-prelude-types.rs | 23 ++++++++++ .../jump-to-def/jump-to-non-local-method.rs | 48 ++++++++++++++++++++ tests/rustdoc/jump-to-non-local-method.rs | 48 -------------------- 14 files changed, 222 insertions(+), 222 deletions(-) delete mode 100644 tests/rustdoc/auxiliary/jump-to-def-macro.rs delete mode 100644 tests/rustdoc/jump-to-def-doc-links-calls.rs delete mode 100644 tests/rustdoc/jump-to-def-doc-links.rs delete mode 100644 tests/rustdoc/jump-to-def-macro.rs delete mode 100644 tests/rustdoc/jump-to-def-pats.rs delete mode 100644 tests/rustdoc/jump-to-def-prelude-types.rs create mode 100644 tests/rustdoc/jump-to-def/auxiliary/jump-to-def-macro.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-def-doc-links-calls.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-def-doc-links.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-def-macro.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-def-pats.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-def-prelude-types.rs create mode 100644 tests/rustdoc/jump-to-def/jump-to-non-local-method.rs delete mode 100644 tests/rustdoc/jump-to-non-local-method.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/auxiliary/jump-to-def-macro.rs b/tests/rustdoc/auxiliary/jump-to-def-macro.rs deleted file mode 100644 index f442b9461e8..00000000000 --- a/tests/rustdoc/auxiliary/jump-to-def-macro.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[macro_export] -macro_rules! symbols { - ($name:ident = $value:expr) => { - pub const $name: isize = $value; - } -} diff --git a/tests/rustdoc/jump-to-def-doc-links-calls.rs b/tests/rustdoc/jump-to-def-doc-links-calls.rs deleted file mode 100644 index 61856978773..00000000000 --- a/tests/rustdoc/jump-to-def-doc-links-calls.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-def-doc-links-calls.rs.html' - -//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' -pub struct Bar; - -impl std::default::Default for Bar { - //@ has - '//a[@href="#20-22"]' 'Self::new' - fn default() -> Self { - Self::new() - } -} - -//@ has - '//a[@href="#8"]' 'Bar' -impl Bar { - //@ has - '//a[@href="#24-26"]' 'Self::bar' - pub fn new()-> Self { - Self::bar() - } - - pub fn bar() -> Self { - Self - } -} diff --git a/tests/rustdoc/jump-to-def-doc-links.rs b/tests/rustdoc/jump-to-def-doc-links.rs deleted file mode 100644 index 2abb52e0a00..00000000000 --- a/tests/rustdoc/jump-to-def-doc-links.rs +++ /dev/null @@ -1,51 +0,0 @@ -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-def-doc-links.rs.html' - -//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' -//@ has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' -pub struct Bar; pub struct Foo; - -//@ has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' -pub enum Enum { - Variant1(String), - Variant2(u8), -} - -//@ has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' -pub struct Struct { - pub a: u8, - b: Foo, -} - -impl Struct { - pub fn foo() {} - pub fn foo2(&self) {} - fn bar() {} - fn bar(&self) {} -} - -//@ has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' -pub trait Trait { - fn foo(); -} - -impl Trait for Struct { - fn foo() {} -} - -//@ has - '//a[@href="../../foo/union.Union.html"]' 'Union' -pub union Union { - pub a: u16, - pub f: u32, -} - -//@ has - '//a[@href="../../foo/fn.bar.html"]' 'bar' -pub fn bar(b: Bar) { - let x = Foo; -} - -//@ has - '//a[@href="../../foo/bar/index.html"]' 'bar' -pub mod bar {} diff --git a/tests/rustdoc/jump-to-def-macro.rs b/tests/rustdoc/jump-to-def-macro.rs deleted file mode 100644 index 680477937c6..00000000000 --- a/tests/rustdoc/jump-to-def-macro.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:jump-to-def-macro.rs -//@ build-aux-docs -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-def-macro.rs.html' - -#[macro_use] -extern crate jump_to_def_macro; - -//@ has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!' -symbols! { - A = 12 -} diff --git a/tests/rustdoc/jump-to-def-pats.rs b/tests/rustdoc/jump-to-def-pats.rs deleted file mode 100644 index 147902b44cf..00000000000 --- a/tests/rustdoc/jump-to-def-pats.rs +++ /dev/null @@ -1,52 +0,0 @@ -// This test ensures that patterns also get a link generated. - -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-def-pats.rs.html' - -use std::fmt; - -pub enum MyEnum { - Ok(T), - Err(E), - Some(T), - None, -} - -pub enum X { - A, -} - -pub fn foo() -> Result<(), ()> { - // FIXME: would be nice to be able to check both the class and the href at the same time so - // we could check the text as well... - //@ has - '//a[@class="prelude-val"]/@href' '{{channel}}/core/result/enum.Result.html#variant.Ok' - //@ has - '//a[@href="{{channel}}/core/result/enum.Result.html#variant.Ok"]' 'Ok' - Ok(()) -} - -impl fmt::Display for MyEnum { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - //@ has - '//a[@href="#12"]' 'Self::Ok' - Self::Ok(_) => f.write_str("MyEnum::Ok"), - //@ has - '//a[@href="#13"]' 'MyEnum::Err' - MyEnum::Err(_) => f.write_str("MyEnum::Err"), - //@ has - '//a[@href="#14"]' 'Self::Some' - Self::Some(_) => f.write_str("MyEnum::Some"), - //@ has - '//a[@href="#15"]' 'Self::None' - Self::None => f.write_str("MyEnum::None"), - } - } -} - -impl X { - fn p(&self) -> &str { - match self { - //@ has - '//a[@href="#19"]' 'Self::A' - Self::A => "X::A", - } - } -} diff --git a/tests/rustdoc/jump-to-def-prelude-types.rs b/tests/rustdoc/jump-to-def-prelude-types.rs deleted file mode 100644 index 43617b1bc9d..00000000000 --- a/tests/rustdoc/jump-to-def-prelude-types.rs +++ /dev/null @@ -1,23 +0,0 @@ -// This test checks that prelude types like `Result` and `Option` still get a link generated. - -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-def-prelude-types.rs.html' -// FIXME: would be nice to be able to check both the class and the href at the same time so -// we could check the text as well... -//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/result/enum.Result.html' -//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/option/enum.Option.html' -pub fn foo() -> Result, ()> { Err(()) } - -// This part is to ensure that they are not linking to the actual prelude ty. -pub mod bar { - struct Result; - struct Option; - - //@ has - '//a[@href="#16"]' 'Result' - pub fn bar() -> Result { Result } - //@ has - '//a[@href="#17"]' 'Option' - pub fn bar2() -> Option { Option } -} diff --git a/tests/rustdoc/jump-to-def/auxiliary/jump-to-def-macro.rs b/tests/rustdoc/jump-to-def/auxiliary/jump-to-def-macro.rs new file mode 100644 index 00000000000..f442b9461e8 --- /dev/null +++ b/tests/rustdoc/jump-to-def/auxiliary/jump-to-def-macro.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! symbols { + ($name:ident = $value:expr) => { + pub const $name: isize = $value; + } +} diff --git a/tests/rustdoc/jump-to-def/jump-to-def-doc-links-calls.rs b/tests/rustdoc/jump-to-def/jump-to-def-doc-links-calls.rs new file mode 100644 index 00000000000..61856978773 --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-def-doc-links-calls.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-doc-links-calls.rs.html' + +//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +pub struct Bar; + +impl std::default::Default for Bar { + //@ has - '//a[@href="#20-22"]' 'Self::new' + fn default() -> Self { + Self::new() + } +} + +//@ has - '//a[@href="#8"]' 'Bar' +impl Bar { + //@ has - '//a[@href="#24-26"]' 'Self::bar' + pub fn new()-> Self { + Self::bar() + } + + pub fn bar() -> Self { + Self + } +} diff --git a/tests/rustdoc/jump-to-def/jump-to-def-doc-links.rs b/tests/rustdoc/jump-to-def/jump-to-def-doc-links.rs new file mode 100644 index 00000000000..2abb52e0a00 --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-def-doc-links.rs @@ -0,0 +1,51 @@ +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-doc-links.rs.html' + +//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +//@ has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' +pub struct Bar; pub struct Foo; + +//@ has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' +pub enum Enum { + Variant1(String), + Variant2(u8), +} + +//@ has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' +pub struct Struct { + pub a: u8, + b: Foo, +} + +impl Struct { + pub fn foo() {} + pub fn foo2(&self) {} + fn bar() {} + fn bar(&self) {} +} + +//@ has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' +pub trait Trait { + fn foo(); +} + +impl Trait for Struct { + fn foo() {} +} + +//@ has - '//a[@href="../../foo/union.Union.html"]' 'Union' +pub union Union { + pub a: u16, + pub f: u32, +} + +//@ has - '//a[@href="../../foo/fn.bar.html"]' 'bar' +pub fn bar(b: Bar) { + let x = Foo; +} + +//@ has - '//a[@href="../../foo/bar/index.html"]' 'bar' +pub mod bar {} diff --git a/tests/rustdoc/jump-to-def/jump-to-def-macro.rs b/tests/rustdoc/jump-to-def/jump-to-def-macro.rs new file mode 100644 index 00000000000..680477937c6 --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-def-macro.rs @@ -0,0 +1,15 @@ +//@ aux-build:jump-to-def-macro.rs +//@ build-aux-docs +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-macro.rs.html' + +#[macro_use] +extern crate jump_to_def_macro; + +//@ has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!' +symbols! { + A = 12 +} diff --git a/tests/rustdoc/jump-to-def/jump-to-def-pats.rs b/tests/rustdoc/jump-to-def/jump-to-def-pats.rs new file mode 100644 index 00000000000..147902b44cf --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-def-pats.rs @@ -0,0 +1,52 @@ +// This test ensures that patterns also get a link generated. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-pats.rs.html' + +use std::fmt; + +pub enum MyEnum { + Ok(T), + Err(E), + Some(T), + None, +} + +pub enum X { + A, +} + +pub fn foo() -> Result<(), ()> { + // FIXME: would be nice to be able to check both the class and the href at the same time so + // we could check the text as well... + //@ has - '//a[@class="prelude-val"]/@href' '{{channel}}/core/result/enum.Result.html#variant.Ok' + //@ has - '//a[@href="{{channel}}/core/result/enum.Result.html#variant.Ok"]' 'Ok' + Ok(()) +} + +impl fmt::Display for MyEnum { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + //@ has - '//a[@href="#12"]' 'Self::Ok' + Self::Ok(_) => f.write_str("MyEnum::Ok"), + //@ has - '//a[@href="#13"]' 'MyEnum::Err' + MyEnum::Err(_) => f.write_str("MyEnum::Err"), + //@ has - '//a[@href="#14"]' 'Self::Some' + Self::Some(_) => f.write_str("MyEnum::Some"), + //@ has - '//a[@href="#15"]' 'Self::None' + Self::None => f.write_str("MyEnum::None"), + } + } +} + +impl X { + fn p(&self) -> &str { + match self { + //@ has - '//a[@href="#19"]' 'Self::A' + Self::A => "X::A", + } + } +} diff --git a/tests/rustdoc/jump-to-def/jump-to-def-prelude-types.rs b/tests/rustdoc/jump-to-def/jump-to-def-prelude-types.rs new file mode 100644 index 00000000000..43617b1bc9d --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-def-prelude-types.rs @@ -0,0 +1,23 @@ +// This test checks that prelude types like `Result` and `Option` still get a link generated. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-prelude-types.rs.html' +// FIXME: would be nice to be able to check both the class and the href at the same time so +// we could check the text as well... +//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/result/enum.Result.html' +//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/option/enum.Option.html' +pub fn foo() -> Result, ()> { Err(()) } + +// This part is to ensure that they are not linking to the actual prelude ty. +pub mod bar { + struct Result; + struct Option; + + //@ has - '//a[@href="#16"]' 'Result' + pub fn bar() -> Result { Result } + //@ has - '//a[@href="#17"]' 'Option' + pub fn bar2() -> Option { Option } +} diff --git a/tests/rustdoc/jump-to-def/jump-to-non-local-method.rs b/tests/rustdoc/jump-to-def/jump-to-non-local-method.rs new file mode 100644 index 00000000000..e2f530425f0 --- /dev/null +++ b/tests/rustdoc/jump-to-def/jump-to-non-local-method.rs @@ -0,0 +1,48 @@ +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-non-local-method.rs.html' + +//@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' +use std::sync::atomic::AtomicIsize; +//@ has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' +use std::io::Read; +//@ has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' +use std::io; +//@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'std::process::exit' +use std::process::exit; +use std::cmp::Ordering; +use std::marker::PhantomData; + +pub fn bar2(readable: T) { + //@ has - '//a[@href="{{channel}}/std/io/trait.Read.html#tymethod.read"]' 'read' + let _ = readable.read(&mut []); +} + +pub fn bar() { + //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'AtomicIsize::new' + let _ = AtomicIsize::new(0); + //@ has - '//a[@href="#48"]' 'local_private' + local_private(); +} + +pub fn extern_call() { + //@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'exit' + exit(0); +} + +pub fn macro_call() -> Result<(), ()> { + //@ has - '//a[@href="{{channel}}/core/macro.try.html"]' 'try!' + try!(Err(())); + Ok(()) +} + +pub fn variant() { + //@ has - '//a[@href="{{channel}}/core/cmp/enum.Ordering.html#variant.Less"]' 'Ordering::Less' + let _ = Ordering::Less; + //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData' + let _: PhantomData:: = PhantomData; +} + +fn local_private() {} diff --git a/tests/rustdoc/jump-to-non-local-method.rs b/tests/rustdoc/jump-to-non-local-method.rs deleted file mode 100644 index e2f530425f0..00000000000 --- a/tests/rustdoc/jump-to-non-local-method.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ compile-flags: -Zunstable-options --generate-link-to-definition - -#![crate_name = "foo"] - -//@ has 'src/foo/jump-to-non-local-method.rs.html' - -//@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' -use std::sync::atomic::AtomicIsize; -//@ has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' -use std::io::Read; -//@ has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' -use std::io; -//@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'std::process::exit' -use std::process::exit; -use std::cmp::Ordering; -use std::marker::PhantomData; - -pub fn bar2(readable: T) { - //@ has - '//a[@href="{{channel}}/std/io/trait.Read.html#tymethod.read"]' 'read' - let _ = readable.read(&mut []); -} - -pub fn bar() { - //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'AtomicIsize::new' - let _ = AtomicIsize::new(0); - //@ has - '//a[@href="#48"]' 'local_private' - local_private(); -} - -pub fn extern_call() { - //@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'exit' - exit(0); -} - -pub fn macro_call() -> Result<(), ()> { - //@ has - '//a[@href="{{channel}}/core/macro.try.html"]' 'try!' - try!(Err(())); - Ok(()) -} - -pub fn variant() { - //@ has - '//a[@href="{{channel}}/core/cmp/enum.Ordering.html#variant.Less"]' 'Ordering::Less' - let _ = Ordering::Less; - //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData' - let _: PhantomData:: = PhantomData; -} - -fn local_private() {} -- cgit 1.4.1-3-g733a5 From a00b39961a9b45c788b86ef9f874d886f5403280 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:32:47 +0200 Subject: Move intra-doc tests into the expected subfolder --- tests/rustdoc/ice-intra-doc-links-107995.rs | 28 ---------------------- .../intra-doc-link-method-trait-impl-72340.rs | 21 ---------------- .../intra-doc/ice-intra-doc-links-107995.rs | 28 ++++++++++++++++++++++ .../intra-doc-link-method-trait-impl-72340.rs | 21 ++++++++++++++++ 4 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 tests/rustdoc/ice-intra-doc-links-107995.rs delete mode 100644 tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs create mode 100644 tests/rustdoc/intra-doc/ice-intra-doc-links-107995.rs create mode 100644 tests/rustdoc/intra-doc/intra-doc-link-method-trait-impl-72340.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/ice-intra-doc-links-107995.rs b/tests/rustdoc/ice-intra-doc-links-107995.rs deleted file mode 100644 index 57669909aa1..00000000000 --- a/tests/rustdoc/ice-intra-doc-links-107995.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Regression test for . - -#![crate_name = "foo"] - -//@ has 'foo/fn.foo.html' -//@ has - '//*[@class="docblock"]//a[@href="fn.bar.html"]' 'bar`' -/// A foo, see also [ bar`] -pub fn foo() {} - -//@ has 'foo/fn.bar.html' -//@ has - '//*[@class="docblock"]' 'line Path line' -//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' -#[doc = "line ["] -#[doc = "Path"] -#[doc = "] line"] -pub fn bar() {} - -//@ has 'foo/fn.another.html' -//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' -/// [ `Path`] -pub fn another() {} - -//@ has 'foo/fn.last.html' -//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' -/// [ Path`] -pub fn last() {} - -pub struct Path; diff --git a/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs b/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs deleted file mode 100644 index 0cf46bb3f95..00000000000 --- a/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/72340 - -#![crate_name = "foo"] - -pub struct Body; - -impl Body { - pub fn empty() -> Self { - Body - } - -} - -impl Default for Body { - //@ has foo/struct.Body.html '//a/@href' 'struct.Body.html#method.empty' - - /// Returns [`Body::empty()`](Body::empty). - fn default() -> Body { - Body::empty() - } -} diff --git a/tests/rustdoc/intra-doc/ice-intra-doc-links-107995.rs b/tests/rustdoc/intra-doc/ice-intra-doc-links-107995.rs new file mode 100644 index 00000000000..57669909aa1 --- /dev/null +++ b/tests/rustdoc/intra-doc/ice-intra-doc-links-107995.rs @@ -0,0 +1,28 @@ +// Regression test for . + +#![crate_name = "foo"] + +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="docblock"]//a[@href="fn.bar.html"]' 'bar`' +/// A foo, see also [ bar`] +pub fn foo() {} + +//@ has 'foo/fn.bar.html' +//@ has - '//*[@class="docblock"]' 'line Path line' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +#[doc = "line ["] +#[doc = "Path"] +#[doc = "] line"] +pub fn bar() {} + +//@ has 'foo/fn.another.html' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +/// [ `Path`] +pub fn another() {} + +//@ has 'foo/fn.last.html' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +/// [ Path`] +pub fn last() {} + +pub struct Path; diff --git a/tests/rustdoc/intra-doc/intra-doc-link-method-trait-impl-72340.rs b/tests/rustdoc/intra-doc/intra-doc-link-method-trait-impl-72340.rs new file mode 100644 index 00000000000..0cf46bb3f95 --- /dev/null +++ b/tests/rustdoc/intra-doc/intra-doc-link-method-trait-impl-72340.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/72340 + +#![crate_name = "foo"] + +pub struct Body; + +impl Body { + pub fn empty() -> Self { + Body + } + +} + +impl Default for Body { + //@ has foo/struct.Body.html '//a/@href' 'struct.Body.html#method.empty' + + /// Returns [`Body::empty()`](Body::empty). + fn default() -> Body { + Body::empty() + } +} -- cgit 1.4.1-3-g733a5 From eee6c9753588fe1888d3ddb264f9516e7ac56997 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:34:16 +0200 Subject: Created `tests/rustdoc/private` subfolder to limit number of files at the top level --- tests/rustdoc/doc-hidden-private-67851-both.rs | 10 ---- tests/rustdoc/doc-hidden-private-67851-hidden.rs | 10 ---- tests/rustdoc/doc-hidden-private-67851-neither.rs | 9 --- tests/rustdoc/doc-hidden-private-67851-private.rs | 10 ---- tests/rustdoc/empty-impl-block-private-with-doc.rs | 44 --------------- tests/rustdoc/empty-impl-block-private.rs | 40 -------------- tests/rustdoc/empty-mod-private.rs | 19 ------- tests/rustdoc/enum-variant-private-46767.rs | 10 ---- tests/rustdoc/files-creation-private.rs | 22 -------- tests/rustdoc/hidden-private.rs | 50 ----------------- .../inline-private-with-intermediate-doc-hidden.rs | 23 -------- tests/rustdoc/inner-private-110422.rs | 64 ---------------------- tests/rustdoc/macro-document-private-duplicate.rs | 25 --------- tests/rustdoc/macro-document-private.rs | 19 ------- tests/rustdoc/macro-private-not-documented.rs | 19 ------- tests/rustdoc/missing-private-inlining-109258.rs | 27 --------- tests/rustdoc/private-fields-tuple-struct.rs | 15 ----- tests/rustdoc/private-non-local-fields-2.rs | 11 ---- tests/rustdoc/private-non-local-fields.rs | 9 --- tests/rustdoc/private-type-alias.rs | 31 ----------- tests/rustdoc/private-type-cycle-110629.rs | 21 ------- tests/rustdoc/private-use-decl-macro-47038.rs | 12 ---- tests/rustdoc/private-use.rs | 13 ----- .../private/doc-hidden-private-67851-both.rs | 10 ++++ .../private/doc-hidden-private-67851-hidden.rs | 10 ++++ .../private/doc-hidden-private-67851-neither.rs | 9 +++ .../private/doc-hidden-private-67851-private.rs | 10 ++++ .../private/empty-impl-block-private-with-doc.rs | 44 +++++++++++++++ tests/rustdoc/private/empty-impl-block-private.rs | 40 ++++++++++++++ tests/rustdoc/private/empty-mod-private.rs | 19 +++++++ .../rustdoc/private/enum-variant-private-46767.rs | 10 ++++ tests/rustdoc/private/files-creation-private.rs | 22 ++++++++ tests/rustdoc/private/hidden-private.rs | 50 +++++++++++++++++ .../inline-private-with-intermediate-doc-hidden.rs | 23 ++++++++ tests/rustdoc/private/inner-private-110422.rs | 64 ++++++++++++++++++++++ .../private/macro-document-private-duplicate.rs | 25 +++++++++ tests/rustdoc/private/macro-document-private.rs | 19 +++++++ .../private/macro-private-not-documented.rs | 19 +++++++ .../private/missing-private-inlining-109258.rs | 27 +++++++++ .../rustdoc/private/private-fields-tuple-struct.rs | 15 +++++ .../rustdoc/private/private-non-local-fields-2.rs | 11 ++++ tests/rustdoc/private/private-non-local-fields.rs | 9 +++ tests/rustdoc/private/private-type-alias.rs | 31 +++++++++++ tests/rustdoc/private/private-type-cycle-110629.rs | 21 +++++++ .../private/private-use-decl-macro-47038.rs | 12 ++++ tests/rustdoc/private/private-use.rs | 13 +++++ .../public-impl-mention-private-generic-46380-2.rs | 12 ++++ tests/rustdoc/private/traits-in-bodies-private.rs | 13 +++++ .../public-impl-mention-private-generic-46380-2.rs | 12 ---- tests/rustdoc/traits-in-bodies-private.rs | 13 ----- 50 files changed, 538 insertions(+), 538 deletions(-) delete mode 100644 tests/rustdoc/doc-hidden-private-67851-both.rs delete mode 100644 tests/rustdoc/doc-hidden-private-67851-hidden.rs delete mode 100644 tests/rustdoc/doc-hidden-private-67851-neither.rs delete mode 100644 tests/rustdoc/doc-hidden-private-67851-private.rs delete mode 100644 tests/rustdoc/empty-impl-block-private-with-doc.rs delete mode 100644 tests/rustdoc/empty-impl-block-private.rs delete mode 100644 tests/rustdoc/empty-mod-private.rs delete mode 100644 tests/rustdoc/enum-variant-private-46767.rs delete mode 100644 tests/rustdoc/files-creation-private.rs delete mode 100644 tests/rustdoc/hidden-private.rs delete mode 100644 tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs delete mode 100644 tests/rustdoc/inner-private-110422.rs delete mode 100644 tests/rustdoc/macro-document-private-duplicate.rs delete mode 100644 tests/rustdoc/macro-document-private.rs delete mode 100644 tests/rustdoc/macro-private-not-documented.rs delete mode 100644 tests/rustdoc/missing-private-inlining-109258.rs delete mode 100644 tests/rustdoc/private-fields-tuple-struct.rs delete mode 100644 tests/rustdoc/private-non-local-fields-2.rs delete mode 100644 tests/rustdoc/private-non-local-fields.rs delete mode 100644 tests/rustdoc/private-type-alias.rs delete mode 100644 tests/rustdoc/private-type-cycle-110629.rs delete mode 100644 tests/rustdoc/private-use-decl-macro-47038.rs delete mode 100644 tests/rustdoc/private-use.rs create mode 100644 tests/rustdoc/private/doc-hidden-private-67851-both.rs create mode 100644 tests/rustdoc/private/doc-hidden-private-67851-hidden.rs create mode 100644 tests/rustdoc/private/doc-hidden-private-67851-neither.rs create mode 100644 tests/rustdoc/private/doc-hidden-private-67851-private.rs create mode 100644 tests/rustdoc/private/empty-impl-block-private-with-doc.rs create mode 100644 tests/rustdoc/private/empty-impl-block-private.rs create mode 100644 tests/rustdoc/private/empty-mod-private.rs create mode 100644 tests/rustdoc/private/enum-variant-private-46767.rs create mode 100644 tests/rustdoc/private/files-creation-private.rs create mode 100644 tests/rustdoc/private/hidden-private.rs create mode 100644 tests/rustdoc/private/inline-private-with-intermediate-doc-hidden.rs create mode 100644 tests/rustdoc/private/inner-private-110422.rs create mode 100644 tests/rustdoc/private/macro-document-private-duplicate.rs create mode 100644 tests/rustdoc/private/macro-document-private.rs create mode 100644 tests/rustdoc/private/macro-private-not-documented.rs create mode 100644 tests/rustdoc/private/missing-private-inlining-109258.rs create mode 100644 tests/rustdoc/private/private-fields-tuple-struct.rs create mode 100644 tests/rustdoc/private/private-non-local-fields-2.rs create mode 100644 tests/rustdoc/private/private-non-local-fields.rs create mode 100644 tests/rustdoc/private/private-type-alias.rs create mode 100644 tests/rustdoc/private/private-type-cycle-110629.rs create mode 100644 tests/rustdoc/private/private-use-decl-macro-47038.rs create mode 100644 tests/rustdoc/private/private-use.rs create mode 100644 tests/rustdoc/private/public-impl-mention-private-generic-46380-2.rs create mode 100644 tests/rustdoc/private/traits-in-bodies-private.rs delete mode 100644 tests/rustdoc/public-impl-mention-private-generic-46380-2.rs delete mode 100644 tests/rustdoc/traits-in-bodies-private.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/doc-hidden-private-67851-both.rs b/tests/rustdoc/doc-hidden-private-67851-both.rs deleted file mode 100644 index 2e2190d8755..00000000000 --- a/tests/rustdoc/doc-hidden-private-67851-both.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Zunstable-options --document-private-items --document-hidden-items -// https://github.com/rust-lang/rust/issues/67851 -#![crate_name="foo"] - -//@ has foo/struct.Hidden.html -#[doc(hidden)] -pub struct Hidden; - -//@ has foo/struct.Private.html -struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-hidden.rs b/tests/rustdoc/doc-hidden-private-67851-hidden.rs deleted file mode 100644 index a811a04a668..00000000000 --- a/tests/rustdoc/doc-hidden-private-67851-hidden.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Zunstable-options --document-hidden-items -// https://github.com/rust-lang/rust/issues/67851 -#![crate_name="foo"] - -//@ has foo/struct.Hidden.html -#[doc(hidden)] -pub struct Hidden; - -//@ !has foo/struct.Private.html -struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-neither.rs b/tests/rustdoc/doc-hidden-private-67851-neither.rs deleted file mode 100644 index 1f70ceefe44..00000000000 --- a/tests/rustdoc/doc-hidden-private-67851-neither.rs +++ /dev/null @@ -1,9 +0,0 @@ -// https://github.com/rust-lang/rust/issues/67851 -#![crate_name="foo"] - -//@ !has foo/struct.Hidden.html -#[doc(hidden)] -pub struct Hidden; - -//@ !has foo/struct.Private.html -struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-private.rs b/tests/rustdoc/doc-hidden-private-67851-private.rs deleted file mode 100644 index f6f546ad5ea..00000000000 --- a/tests/rustdoc/doc-hidden-private-67851-private.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: --document-private-items -// https://github.com/rust-lang/rust/issues/67851 -#![crate_name="foo"] - -//@ !has foo/struct.Hidden.html -#[doc(hidden)] -pub struct Hidden; - -//@ has foo/struct.Private.html -struct Private; diff --git a/tests/rustdoc/empty-impl-block-private-with-doc.rs b/tests/rustdoc/empty-impl-block-private-with-doc.rs deleted file mode 100644 index 5dc7e1aed7a..00000000000 --- a/tests/rustdoc/empty-impl-block-private-with-doc.rs +++ /dev/null @@ -1,44 +0,0 @@ -//@ compile-flags: --document-private-items - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Foo.html' -pub struct Foo; - -// There are 3 impl blocks with public item and one that should not be displayed -// by default because it only contains private items (but not in this case because -// we used `--document-private-items`). -//@ count - '//*[@class="impl"]' 'impl Foo' 4 - -// Impl block only containing private items should not be displayed unless the -// `--document-private-items` flag is used. -/// Private -impl Foo { - const BAR: u32 = 0; - type FOO = i32; - fn hello() {} -} - -// But if any element of the impl block is public, it should be displayed. -/// Not private -impl Foo { - pub const BAR: u32 = 0; - type FOO = i32; - fn hello() {} -} - -/// Not private -impl Foo { - const BAR: u32 = 0; - pub type FOO = i32; - fn hello() {} -} - -/// Not private -impl Foo { - const BAR: u32 = 0; - type FOO = i32; - pub fn hello() {} -} diff --git a/tests/rustdoc/empty-impl-block-private.rs b/tests/rustdoc/empty-impl-block-private.rs deleted file mode 100644 index 2ee65d1a969..00000000000 --- a/tests/rustdoc/empty-impl-block-private.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Foo.html' -pub struct Foo; - -// There are 3 impl blocks with public item and one that should not be displayed -// because it only contains private items. -//@ count - '//*[@class="impl"]' 'impl Foo' 3 - -// Impl block only containing private items should not be displayed. -/// Private -impl Foo { - const BAR: u32 = 0; - type FOO = i32; - fn hello() {} -} - -// But if any element of the impl block is public, it should be displayed. -/// Not private -impl Foo { - pub const BAR: u32 = 0; - type FOO = i32; - fn hello() {} -} - -/// Not private -impl Foo { - const BAR: u32 = 0; - pub type FOO = i32; - fn hello() {} -} - -/// Not private -impl Foo { - const BAR: u32 = 0; - type FOO = i32; - pub fn hello() {} -} diff --git a/tests/rustdoc/empty-mod-private.rs b/tests/rustdoc/empty-mod-private.rs deleted file mode 100644 index 5a8638cd5f5..00000000000 --- a/tests/rustdoc/empty-mod-private.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ compile-flags: --document-private-items - -//@ has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' -//@ hasraw 'empty_mod_private/sidebar-items.js' 'foo' -//@ matches 'empty_mod_private/foo/index.html' '//h1' 'Module foo' -//@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private' -mod foo {} - -//@ has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar' -//@ hasraw 'empty_mod_private/sidebar-items.js' 'bar' -//@ matches 'empty_mod_private/bar/index.html' '//h1' 'Module bar' -//@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private' -mod bar { - //@ has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz' - //@ hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz' - //@ matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module baz' - //@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private::bar' - mod baz {} -} diff --git a/tests/rustdoc/enum-variant-private-46767.rs b/tests/rustdoc/enum-variant-private-46767.rs deleted file mode 100644 index cc93684e723..00000000000 --- a/tests/rustdoc/enum-variant-private-46767.rs +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/rust-lang/rust/issues/46767 -#![crate_name = "foo"] - -mod private { - pub enum Enum{Variant} -} -pub use self::private::Enum::*; - -//@ !has-dir foo/private -//@ !has foo/index.html '//a/@href' 'private/index.html' diff --git a/tests/rustdoc/files-creation-private.rs b/tests/rustdoc/files-creation-private.rs deleted file mode 100644 index 54579380f0b..00000000000 --- a/tests/rustdoc/files-creation-private.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![crate_name="foo"] - -//@ files "foo" \ -// '["index.html", "all.html", "sidebar-items.js", "foo", "bar", "private", "struct.Bar.html"]' -//@ files "foo/bar" '["index.html", "sidebar-items.js"]' - -//@ !has "foo/priv/index.html" -//@ !has "foo/priv/struct.Foo.html" -mod private { - pub struct Foo; -} - -//@ has "foo/struct.Bar.html" -pub use crate::private::Foo as Bar; - -//@ !has "foo/foo/index.html" -mod foo { - pub mod subfoo {} -} - -//@ has "foo/bar/index.html" -pub use crate::foo::subfoo as bar; diff --git a/tests/rustdoc/hidden-private.rs b/tests/rustdoc/hidden-private.rs deleted file mode 100644 index 658e093cc23..00000000000 --- a/tests/rustdoc/hidden-private.rs +++ /dev/null @@ -1,50 +0,0 @@ -// This is a regression test for . -// It ensures that the items in the `doc(hidden)` const block don't show up in the -// generated docs. - -//@ compile-flags: --document-private-items - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ count - '//*[@class="item-table"]//a[@class="struct"]' 2 -//@ count - '//*[@class="item-table"]//a[@class="trait"]' 1 -//@ count - '//*[@class="item-table"]//a[@class="macro"]' 0 -#[doc(hidden)] -const _: () = { - macro_rules! stry { - () => {}; - } - - struct ShouldBeHidden; - - //@ has 'foo/struct.Foo.html' - //@ !has - '//*[@class="code-header"]' 'impl Bar for Foo' - #[doc(hidden)] - impl Bar for Foo { - fn bar(&self) { - struct SHouldAlsoBeHidden; - } - } - - //@ has 'foo/struct.Private.html' - //@ has - '//*[@id="impl-Bar-for-Private"]/*[@class="code-header"]' 'impl Bar for Private' - //@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar(&self)' - impl Bar for Private { - fn bar(&self) {} - } - - //@ has - '//*[@id="impl-Private"]/*[@class="code-header"]' 'impl Private' - //@ has - '//*[@id="method.tralala"]/*[@class="code-header"]' 'fn tralala()' - impl Private { - fn tralala() {} - } -}; - - -struct Private; -pub struct Foo; - -pub trait Bar { - fn bar(&self); -} diff --git a/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs b/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs deleted file mode 100644 index d27ecbad169..00000000000 --- a/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs +++ /dev/null @@ -1,23 +0,0 @@ -// This test ensures that if a private item is re-exported with an intermediate -// `#[doc(hidden)]` re-export, it'll still be inlined (and not include any attribute -// from the doc hidden re-export. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// There should only be one struct displayed. -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -//@ has - '//*[@id="main-content"]//a[@href="struct.Reexport.html"]' 'Reexport' -//@ has - '//*[@id="main-content"]//dd' 'Visible. Original.' - -mod private { - /// Original. - pub struct Bar3; -} - -/// Hidden. -#[doc(hidden)] -pub use crate::private::Bar3; -/// Visible. -pub use self::Bar3 as Reexport; diff --git a/tests/rustdoc/inner-private-110422.rs b/tests/rustdoc/inner-private-110422.rs deleted file mode 100644 index 31e28676879..00000000000 --- a/tests/rustdoc/inner-private-110422.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Regression test for . -// This test ensures that inner items (except for implementations and macros) -// don't appear in documentation. - -//@ compile-flags: --document-private-items - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// Checking there is no "trait" entry. -//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 4 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Macros' - -//@ has - '//a[@href="fn.foo.html"]' 'foo' -fn foo() { - fn bar() {} - - //@ has - '//a[@class="macro"]' 'visible_macro' - //@ !has - '//a[@class="macro"]' 'non_visible_macro' - //@ has 'foo/macro.visible_macro.html' - //@ !has 'foo/macro.non_visible_macro.html' - #[macro_export] - macro_rules! visible_macro { - () => {} - } - - macro_rules! non_visible_macro { - () => {} - } -} - -//@ has 'foo/index.html' -//@ has - '//a[@href="struct.Bar.html"]' 'Bar' -struct Bar; - -const BAR: i32 = { - //@ !has - '//a[@href="fn.yo.html"]' 'yo' - //@ !has 'foo/fn.yo.html' - fn yo() {} - - //@ !has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' - //@ !has 'foo/trait.Foo.html' - trait Foo { - fn babar() {} - } - impl Foo for Bar {} - - //@ has 'foo/struct.Bar.html' - //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' - //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 - // We now check that the `Foo` trait is not documented nor visible on `Bar` page. - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Implementations' - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Auto Trait Implementations' - //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Blanket Implementations' - //@ !has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' - impl Bar { - fn foo() {} - } - - 1 -}; diff --git a/tests/rustdoc/macro-document-private-duplicate.rs b/tests/rustdoc/macro-document-private-duplicate.rs deleted file mode 100644 index 35cdc60dfdc..00000000000 --- a/tests/rustdoc/macro-document-private-duplicate.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ ignore-test (fails spuriously, see issue #89228) - -// FIXME: If two macros in the same module have the same name -// (yes, that's a thing), rustdoc lists both of them on the index page, -// but only documents the first one on the page for the macro. -// Fortunately, this can only happen in document private items mode, -// but it still isn't ideal behavior. -// -// See https://github.com/rust-lang/rust/pull/88019#discussion_r693920453 -// -//@ compile-flags: --document-private-items - -//@ hasraw macro_document_private_duplicate/index.html 'Doc 1.' -//@ hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' -/// Doc 1. -macro_rules! a_macro { - () => () -} - -//@ hasraw macro_document_private_duplicate/index.html 'Doc 2.' -//@ !hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' -/// Doc 2. -macro_rules! a_macro { - () => () -} diff --git a/tests/rustdoc/macro-document-private.rs b/tests/rustdoc/macro-document-private.rs deleted file mode 100644 index 224e31f8312..00000000000 --- a/tests/rustdoc/macro-document-private.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Checks that private macros are documented when `--document-private-items` -// is present. -// -// This is a regression test for issue #73754. -// -//@ compile-flags: --document-private-items - -#![feature(decl_macro)] - - -//@ has macro_document_private/macro.some_macro.html -macro some_macro { - (a: tt) => {} -} - -//@ has macro_document_private/macro.another_macro.html -macro_rules! another_macro { - (a: tt) => {} -} diff --git a/tests/rustdoc/macro-private-not-documented.rs b/tests/rustdoc/macro-private-not-documented.rs deleted file mode 100644 index bd97be5d366..00000000000 --- a/tests/rustdoc/macro-private-not-documented.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Checks that private macros aren't documented by default. They -// should be still be documented in `--document-private-items` mode, -// but that's tested in `macro-document-private.rs`. -// -// -// This is a regression text for issue #88453. -#![feature(decl_macro)] - -//@ !hasraw macro_private_not_documented/index.html 'a_macro' -//@ !has macro_private_not_documented/macro.a_macro.html -macro_rules! a_macro { - () => () -} - -//@ !hasraw macro_private_not_documented/index.html 'another_macro' -//@ !has macro_private_not_documented/macro.another_macro.html -macro another_macro { - () => () -} diff --git a/tests/rustdoc/missing-private-inlining-109258.rs b/tests/rustdoc/missing-private-inlining-109258.rs deleted file mode 100644 index 7f010f160c4..00000000000 --- a/tests/rustdoc/missing-private-inlining-109258.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Regression test for . - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// We should only have a "Re-exports" and a "Modules" headers. -//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Re-exports' -//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Modules' - -//@ has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;' -//@ has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo' -//@ !has 'foo/struct.Foo.html' -pub use crate::issue_109258::Foo; - -//@ has 'foo/issue_109258/index.html' -// We should only have a "Structs" header. -//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 1 -//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Structs' -//@ has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo' -//@ has 'foo/issue_109258/struct.Foo.html' -pub mod issue_109258 { - mod priv_mod { - pub struct Foo; - } - pub use self::priv_mod::Foo; -} diff --git a/tests/rustdoc/private-fields-tuple-struct.rs b/tests/rustdoc/private-fields-tuple-struct.rs deleted file mode 100644 index 51141923cd8..00000000000 --- a/tests/rustdoc/private-fields-tuple-struct.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This test checks the diplay of "/* private fields */" sentence in tuple structs. -#![crate_name = "foo"] - -//@ has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);' -pub struct A(pub u8, u8); -//@ has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);' -pub struct B(u8, pub u8); -//@ has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);' -pub struct C(u8, pub u8, u8); -//@ has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);' -pub struct D(pub u8, u8, pub u8); -//@ has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);' -pub struct E(u8); -//@ has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);' -pub struct F(u8, u8); diff --git a/tests/rustdoc/private-non-local-fields-2.rs b/tests/rustdoc/private-non-local-fields-2.rs deleted file mode 100644 index f2d3530c088..00000000000 --- a/tests/rustdoc/private-non-local-fields-2.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This test makes sure that with never show the inner fields in the -//! aliased type view of type alias. - -//@ compile-flags: -Z unstable-options --document-private-items - -#![crate_name = "foo"] - -use std::collections::BTreeMap; - -//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' -pub type FooBar = BTreeMap; diff --git a/tests/rustdoc/private-non-local-fields.rs b/tests/rustdoc/private-non-local-fields.rs deleted file mode 100644 index aa7f01a58c6..00000000000 --- a/tests/rustdoc/private-non-local-fields.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! This test makes sure that with never show the inner fields in the -//! aliased type view of type alias. - -#![crate_name = "foo"] - -use std::collections::BTreeMap; - -//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' -pub type FooBar = BTreeMap; diff --git a/tests/rustdoc/private-type-alias.rs b/tests/rustdoc/private-type-alias.rs deleted file mode 100644 index 5b5f52728a9..00000000000 --- a/tests/rustdoc/private-type-alias.rs +++ /dev/null @@ -1,31 +0,0 @@ -type MyResultPriv = Result; -pub type MyResultPub = Result; - -//@ has private_type_alias/fn.get_result_priv.html '//pre' 'Result' -pub fn get_result_priv() -> MyResultPriv { - panic!(); -} - -//@ has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub' -pub fn get_result_pub() -> MyResultPub { - panic!(); -} - -pub type PubRecursive = u16; -type PrivRecursive3 = u8; -type PrivRecursive2 = PubRecursive; -type PrivRecursive1 = PrivRecursive3; - -// PrivRecursive1 is expanded twice and stops at u8 -// PrivRecursive2 is expanded once and stops at public type alias PubRecursive -//@ has private_type_alias/fn.get_result_recursive.html '//pre' '(u8, PubRecursive)' -pub fn get_result_recursive() -> (PrivRecursive1, PrivRecursive2) { - panic!(); -} - -type MyLifetimePriv<'a> = &'a isize; - -//@ has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize" -pub fn get_lifetime_priv() -> MyLifetimePriv<'static> { - panic!(); -} diff --git a/tests/rustdoc/private-type-cycle-110629.rs b/tests/rustdoc/private-type-cycle-110629.rs deleted file mode 100644 index e2376809697..00000000000 --- a/tests/rustdoc/private-type-cycle-110629.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ compile-flags: --document-private-items - -// https://github.com/rust-lang/rust/issues/110629 -#![crate_name="foo"] -#![feature(type_alias_impl_trait)] - -type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; - -//@ has foo/type.Bar.html -//@ has - '//pre[@class="rust item-decl"]' \ -// "pub(crate) type Bar<'a, 'b> = impl PartialEq> + Debug;" - -fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i -} - -fn main() { - let meh = 42; - let muh = 42; - assert_eq!(bar(&meh), bar(&muh)); -} diff --git a/tests/rustdoc/private-use-decl-macro-47038.rs b/tests/rustdoc/private-use-decl-macro-47038.rs deleted file mode 100644 index b72fca06d3b..00000000000 --- a/tests/rustdoc/private-use-decl-macro-47038.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(decl_macro)] - -#![crate_name = "foo"] - -// https://github.com/rust-lang/rust/issues/47038 - -use std::vec; - -//@ has 'foo/index.html' -//@ !has - '//*[@id="macros"]' 'Macros' -//@ !has - '//a/@href' 'macro.vec.html' -//@ !has 'foo/macro.vec.html' diff --git a/tests/rustdoc/private-use.rs b/tests/rustdoc/private-use.rs deleted file mode 100644 index 689ed73140d..00000000000 --- a/tests/rustdoc/private-use.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Regression test for to -// ensure it doesn't panic. - -mod generics { - pub enum WherePredicate { - EqPredicate, - } -} -pub mod visit { - use *; - pub fn visit_where_predicate(_visitor: &mut V, _i: &WherePredicate) {} -} -pub use generics::*; diff --git a/tests/rustdoc/private/doc-hidden-private-67851-both.rs b/tests/rustdoc/private/doc-hidden-private-67851-both.rs new file mode 100644 index 00000000000..2e2190d8755 --- /dev/null +++ b/tests/rustdoc/private/doc-hidden-private-67851-both.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -Zunstable-options --document-private-items --document-hidden-items +// https://github.com/rust-lang/rust/issues/67851 +#![crate_name="foo"] + +//@ has foo/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +//@ has foo/struct.Private.html +struct Private; diff --git a/tests/rustdoc/private/doc-hidden-private-67851-hidden.rs b/tests/rustdoc/private/doc-hidden-private-67851-hidden.rs new file mode 100644 index 00000000000..a811a04a668 --- /dev/null +++ b/tests/rustdoc/private/doc-hidden-private-67851-hidden.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -Zunstable-options --document-hidden-items +// https://github.com/rust-lang/rust/issues/67851 +#![crate_name="foo"] + +//@ has foo/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +//@ !has foo/struct.Private.html +struct Private; diff --git a/tests/rustdoc/private/doc-hidden-private-67851-neither.rs b/tests/rustdoc/private/doc-hidden-private-67851-neither.rs new file mode 100644 index 00000000000..1f70ceefe44 --- /dev/null +++ b/tests/rustdoc/private/doc-hidden-private-67851-neither.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/67851 +#![crate_name="foo"] + +//@ !has foo/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +//@ !has foo/struct.Private.html +struct Private; diff --git a/tests/rustdoc/private/doc-hidden-private-67851-private.rs b/tests/rustdoc/private/doc-hidden-private-67851-private.rs new file mode 100644 index 00000000000..f6f546ad5ea --- /dev/null +++ b/tests/rustdoc/private/doc-hidden-private-67851-private.rs @@ -0,0 +1,10 @@ +//@ compile-flags: --document-private-items +// https://github.com/rust-lang/rust/issues/67851 +#![crate_name="foo"] + +//@ !has foo/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +//@ has foo/struct.Private.html +struct Private; diff --git a/tests/rustdoc/private/empty-impl-block-private-with-doc.rs b/tests/rustdoc/private/empty-impl-block-private-with-doc.rs new file mode 100644 index 00000000000..5dc7e1aed7a --- /dev/null +++ b/tests/rustdoc/private/empty-impl-block-private-with-doc.rs @@ -0,0 +1,44 @@ +//@ compile-flags: --document-private-items + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +pub struct Foo; + +// There are 3 impl blocks with public item and one that should not be displayed +// by default because it only contains private items (but not in this case because +// we used `--document-private-items`). +//@ count - '//*[@class="impl"]' 'impl Foo' 4 + +// Impl block only containing private items should not be displayed unless the +// `--document-private-items` flag is used. +/// Private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +// But if any element of the impl block is public, it should be displayed. +/// Not private +impl Foo { + pub const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + pub type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + pub fn hello() {} +} diff --git a/tests/rustdoc/private/empty-impl-block-private.rs b/tests/rustdoc/private/empty-impl-block-private.rs new file mode 100644 index 00000000000..2ee65d1a969 --- /dev/null +++ b/tests/rustdoc/private/empty-impl-block-private.rs @@ -0,0 +1,40 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +pub struct Foo; + +// There are 3 impl blocks with public item and one that should not be displayed +// because it only contains private items. +//@ count - '//*[@class="impl"]' 'impl Foo' 3 + +// Impl block only containing private items should not be displayed. +/// Private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +// But if any element of the impl block is public, it should be displayed. +/// Not private +impl Foo { + pub const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + pub type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + pub fn hello() {} +} diff --git a/tests/rustdoc/private/empty-mod-private.rs b/tests/rustdoc/private/empty-mod-private.rs new file mode 100644 index 00000000000..5a8638cd5f5 --- /dev/null +++ b/tests/rustdoc/private/empty-mod-private.rs @@ -0,0 +1,19 @@ +//@ compile-flags: --document-private-items + +//@ has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' +//@ hasraw 'empty_mod_private/sidebar-items.js' 'foo' +//@ matches 'empty_mod_private/foo/index.html' '//h1' 'Module foo' +//@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private' +mod foo {} + +//@ has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar' +//@ hasraw 'empty_mod_private/sidebar-items.js' 'bar' +//@ matches 'empty_mod_private/bar/index.html' '//h1' 'Module bar' +//@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private' +mod bar { + //@ has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz' + //@ hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz' + //@ matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module baz' + //@ matches - '//*[@class="rustdoc-breadcrumbs"]' 'empty_mod_private::bar' + mod baz {} +} diff --git a/tests/rustdoc/private/enum-variant-private-46767.rs b/tests/rustdoc/private/enum-variant-private-46767.rs new file mode 100644 index 00000000000..cc93684e723 --- /dev/null +++ b/tests/rustdoc/private/enum-variant-private-46767.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/46767 +#![crate_name = "foo"] + +mod private { + pub enum Enum{Variant} +} +pub use self::private::Enum::*; + +//@ !has-dir foo/private +//@ !has foo/index.html '//a/@href' 'private/index.html' diff --git a/tests/rustdoc/private/files-creation-private.rs b/tests/rustdoc/private/files-creation-private.rs new file mode 100644 index 00000000000..54579380f0b --- /dev/null +++ b/tests/rustdoc/private/files-creation-private.rs @@ -0,0 +1,22 @@ +#![crate_name="foo"] + +//@ files "foo" \ +// '["index.html", "all.html", "sidebar-items.js", "foo", "bar", "private", "struct.Bar.html"]' +//@ files "foo/bar" '["index.html", "sidebar-items.js"]' + +//@ !has "foo/priv/index.html" +//@ !has "foo/priv/struct.Foo.html" +mod private { + pub struct Foo; +} + +//@ has "foo/struct.Bar.html" +pub use crate::private::Foo as Bar; + +//@ !has "foo/foo/index.html" +mod foo { + pub mod subfoo {} +} + +//@ has "foo/bar/index.html" +pub use crate::foo::subfoo as bar; diff --git a/tests/rustdoc/private/hidden-private.rs b/tests/rustdoc/private/hidden-private.rs new file mode 100644 index 00000000000..658e093cc23 --- /dev/null +++ b/tests/rustdoc/private/hidden-private.rs @@ -0,0 +1,50 @@ +// This is a regression test for . +// It ensures that the items in the `doc(hidden)` const block don't show up in the +// generated docs. + +//@ compile-flags: --document-private-items + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ count - '//*[@class="item-table"]//a[@class="struct"]' 2 +//@ count - '//*[@class="item-table"]//a[@class="trait"]' 1 +//@ count - '//*[@class="item-table"]//a[@class="macro"]' 0 +#[doc(hidden)] +const _: () = { + macro_rules! stry { + () => {}; + } + + struct ShouldBeHidden; + + //@ has 'foo/struct.Foo.html' + //@ !has - '//*[@class="code-header"]' 'impl Bar for Foo' + #[doc(hidden)] + impl Bar for Foo { + fn bar(&self) { + struct SHouldAlsoBeHidden; + } + } + + //@ has 'foo/struct.Private.html' + //@ has - '//*[@id="impl-Bar-for-Private"]/*[@class="code-header"]' 'impl Bar for Private' + //@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar(&self)' + impl Bar for Private { + fn bar(&self) {} + } + + //@ has - '//*[@id="impl-Private"]/*[@class="code-header"]' 'impl Private' + //@ has - '//*[@id="method.tralala"]/*[@class="code-header"]' 'fn tralala()' + impl Private { + fn tralala() {} + } +}; + + +struct Private; +pub struct Foo; + +pub trait Bar { + fn bar(&self); +} diff --git a/tests/rustdoc/private/inline-private-with-intermediate-doc-hidden.rs b/tests/rustdoc/private/inline-private-with-intermediate-doc-hidden.rs new file mode 100644 index 00000000000..d27ecbad169 --- /dev/null +++ b/tests/rustdoc/private/inline-private-with-intermediate-doc-hidden.rs @@ -0,0 +1,23 @@ +// This test ensures that if a private item is re-exported with an intermediate +// `#[doc(hidden)]` re-export, it'll still be inlined (and not include any attribute +// from the doc hidden re-export. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// There should only be one struct displayed. +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]//a[@href="struct.Reexport.html"]' 'Reexport' +//@ has - '//*[@id="main-content"]//dd' 'Visible. Original.' + +mod private { + /// Original. + pub struct Bar3; +} + +/// Hidden. +#[doc(hidden)] +pub use crate::private::Bar3; +/// Visible. +pub use self::Bar3 as Reexport; diff --git a/tests/rustdoc/private/inner-private-110422.rs b/tests/rustdoc/private/inner-private-110422.rs new file mode 100644 index 00000000000..31e28676879 --- /dev/null +++ b/tests/rustdoc/private/inner-private-110422.rs @@ -0,0 +1,64 @@ +// Regression test for . +// This test ensures that inner items (except for implementations and macros) +// don't appear in documentation. + +//@ compile-flags: --document-private-items + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// Checking there is no "trait" entry. +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 4 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Macros' + +//@ has - '//a[@href="fn.foo.html"]' 'foo' +fn foo() { + fn bar() {} + + //@ has - '//a[@class="macro"]' 'visible_macro' + //@ !has - '//a[@class="macro"]' 'non_visible_macro' + //@ has 'foo/macro.visible_macro.html' + //@ !has 'foo/macro.non_visible_macro.html' + #[macro_export] + macro_rules! visible_macro { + () => {} + } + + macro_rules! non_visible_macro { + () => {} + } +} + +//@ has 'foo/index.html' +//@ has - '//a[@href="struct.Bar.html"]' 'Bar' +struct Bar; + +const BAR: i32 = { + //@ !has - '//a[@href="fn.yo.html"]' 'yo' + //@ !has 'foo/fn.yo.html' + fn yo() {} + + //@ !has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' + //@ !has 'foo/trait.Foo.html' + trait Foo { + fn babar() {} + } + impl Foo for Bar {} + + //@ has 'foo/struct.Bar.html' + //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 + // We now check that the `Foo` trait is not documented nor visible on `Bar` page. + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Implementations' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Auto Trait Implementations' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Blanket Implementations' + //@ !has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' + impl Bar { + fn foo() {} + } + + 1 +}; diff --git a/tests/rustdoc/private/macro-document-private-duplicate.rs b/tests/rustdoc/private/macro-document-private-duplicate.rs new file mode 100644 index 00000000000..35cdc60dfdc --- /dev/null +++ b/tests/rustdoc/private/macro-document-private-duplicate.rs @@ -0,0 +1,25 @@ +//@ ignore-test (fails spuriously, see issue #89228) + +// FIXME: If two macros in the same module have the same name +// (yes, that's a thing), rustdoc lists both of them on the index page, +// but only documents the first one on the page for the macro. +// Fortunately, this can only happen in document private items mode, +// but it still isn't ideal behavior. +// +// See https://github.com/rust-lang/rust/pull/88019#discussion_r693920453 +// +//@ compile-flags: --document-private-items + +//@ hasraw macro_document_private_duplicate/index.html 'Doc 1.' +//@ hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' +/// Doc 1. +macro_rules! a_macro { + () => () +} + +//@ hasraw macro_document_private_duplicate/index.html 'Doc 2.' +//@ !hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' +/// Doc 2. +macro_rules! a_macro { + () => () +} diff --git a/tests/rustdoc/private/macro-document-private.rs b/tests/rustdoc/private/macro-document-private.rs new file mode 100644 index 00000000000..224e31f8312 --- /dev/null +++ b/tests/rustdoc/private/macro-document-private.rs @@ -0,0 +1,19 @@ +// Checks that private macros are documented when `--document-private-items` +// is present. +// +// This is a regression test for issue #73754. +// +//@ compile-flags: --document-private-items + +#![feature(decl_macro)] + + +//@ has macro_document_private/macro.some_macro.html +macro some_macro { + (a: tt) => {} +} + +//@ has macro_document_private/macro.another_macro.html +macro_rules! another_macro { + (a: tt) => {} +} diff --git a/tests/rustdoc/private/macro-private-not-documented.rs b/tests/rustdoc/private/macro-private-not-documented.rs new file mode 100644 index 00000000000..bd97be5d366 --- /dev/null +++ b/tests/rustdoc/private/macro-private-not-documented.rs @@ -0,0 +1,19 @@ +// Checks that private macros aren't documented by default. They +// should be still be documented in `--document-private-items` mode, +// but that's tested in `macro-document-private.rs`. +// +// +// This is a regression text for issue #88453. +#![feature(decl_macro)] + +//@ !hasraw macro_private_not_documented/index.html 'a_macro' +//@ !has macro_private_not_documented/macro.a_macro.html +macro_rules! a_macro { + () => () +} + +//@ !hasraw macro_private_not_documented/index.html 'another_macro' +//@ !has macro_private_not_documented/macro.another_macro.html +macro another_macro { + () => () +} diff --git a/tests/rustdoc/private/missing-private-inlining-109258.rs b/tests/rustdoc/private/missing-private-inlining-109258.rs new file mode 100644 index 00000000000..7f010f160c4 --- /dev/null +++ b/tests/rustdoc/private/missing-private-inlining-109258.rs @@ -0,0 +1,27 @@ +// Regression test for . + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// We should only have a "Re-exports" and a "Modules" headers. +//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Re-exports' +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Modules' + +//@ has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;' +//@ has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo' +//@ !has 'foo/struct.Foo.html' +pub use crate::issue_109258::Foo; + +//@ has 'foo/issue_109258/index.html' +// We should only have a "Structs" header. +//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo' +//@ has 'foo/issue_109258/struct.Foo.html' +pub mod issue_109258 { + mod priv_mod { + pub struct Foo; + } + pub use self::priv_mod::Foo; +} diff --git a/tests/rustdoc/private/private-fields-tuple-struct.rs b/tests/rustdoc/private/private-fields-tuple-struct.rs new file mode 100644 index 00000000000..51141923cd8 --- /dev/null +++ b/tests/rustdoc/private/private-fields-tuple-struct.rs @@ -0,0 +1,15 @@ +// This test checks the diplay of "/* private fields */" sentence in tuple structs. +#![crate_name = "foo"] + +//@ has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);' +pub struct A(pub u8, u8); +//@ has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);' +pub struct B(u8, pub u8); +//@ has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);' +pub struct C(u8, pub u8, u8); +//@ has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);' +pub struct D(pub u8, u8, pub u8); +//@ has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);' +pub struct E(u8); +//@ has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);' +pub struct F(u8, u8); diff --git a/tests/rustdoc/private/private-non-local-fields-2.rs b/tests/rustdoc/private/private-non-local-fields-2.rs new file mode 100644 index 00000000000..f2d3530c088 --- /dev/null +++ b/tests/rustdoc/private/private-non-local-fields-2.rs @@ -0,0 +1,11 @@ +//! This test makes sure that with never show the inner fields in the +//! aliased type view of type alias. + +//@ compile-flags: -Z unstable-options --document-private-items + +#![crate_name = "foo"] + +use std::collections::BTreeMap; + +//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' +pub type FooBar = BTreeMap; diff --git a/tests/rustdoc/private/private-non-local-fields.rs b/tests/rustdoc/private/private-non-local-fields.rs new file mode 100644 index 00000000000..aa7f01a58c6 --- /dev/null +++ b/tests/rustdoc/private/private-non-local-fields.rs @@ -0,0 +1,9 @@ +//! This test makes sure that with never show the inner fields in the +//! aliased type view of type alias. + +#![crate_name = "foo"] + +use std::collections::BTreeMap; + +//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' +pub type FooBar = BTreeMap; diff --git a/tests/rustdoc/private/private-type-alias.rs b/tests/rustdoc/private/private-type-alias.rs new file mode 100644 index 00000000000..5b5f52728a9 --- /dev/null +++ b/tests/rustdoc/private/private-type-alias.rs @@ -0,0 +1,31 @@ +type MyResultPriv = Result; +pub type MyResultPub = Result; + +//@ has private_type_alias/fn.get_result_priv.html '//pre' 'Result' +pub fn get_result_priv() -> MyResultPriv { + panic!(); +} + +//@ has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub' +pub fn get_result_pub() -> MyResultPub { + panic!(); +} + +pub type PubRecursive = u16; +type PrivRecursive3 = u8; +type PrivRecursive2 = PubRecursive; +type PrivRecursive1 = PrivRecursive3; + +// PrivRecursive1 is expanded twice and stops at u8 +// PrivRecursive2 is expanded once and stops at public type alias PubRecursive +//@ has private_type_alias/fn.get_result_recursive.html '//pre' '(u8, PubRecursive)' +pub fn get_result_recursive() -> (PrivRecursive1, PrivRecursive2) { + panic!(); +} + +type MyLifetimePriv<'a> = &'a isize; + +//@ has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize" +pub fn get_lifetime_priv() -> MyLifetimePriv<'static> { + panic!(); +} diff --git a/tests/rustdoc/private/private-type-cycle-110629.rs b/tests/rustdoc/private/private-type-cycle-110629.rs new file mode 100644 index 00000000000..e2376809697 --- /dev/null +++ b/tests/rustdoc/private/private-type-cycle-110629.rs @@ -0,0 +1,21 @@ +//@ compile-flags: --document-private-items + +// https://github.com/rust-lang/rust/issues/110629 +#![crate_name="foo"] +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; + +//@ has foo/type.Bar.html +//@ has - '//pre[@class="rust item-decl"]' \ +// "pub(crate) type Bar<'a, 'b> = impl PartialEq> + Debug;" + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} diff --git a/tests/rustdoc/private/private-use-decl-macro-47038.rs b/tests/rustdoc/private/private-use-decl-macro-47038.rs new file mode 100644 index 00000000000..b72fca06d3b --- /dev/null +++ b/tests/rustdoc/private/private-use-decl-macro-47038.rs @@ -0,0 +1,12 @@ +#![feature(decl_macro)] + +#![crate_name = "foo"] + +// https://github.com/rust-lang/rust/issues/47038 + +use std::vec; + +//@ has 'foo/index.html' +//@ !has - '//*[@id="macros"]' 'Macros' +//@ !has - '//a/@href' 'macro.vec.html' +//@ !has 'foo/macro.vec.html' diff --git a/tests/rustdoc/private/private-use.rs b/tests/rustdoc/private/private-use.rs new file mode 100644 index 00000000000..689ed73140d --- /dev/null +++ b/tests/rustdoc/private/private-use.rs @@ -0,0 +1,13 @@ +// Regression test for to +// ensure it doesn't panic. + +mod generics { + pub enum WherePredicate { + EqPredicate, + } +} +pub mod visit { + use *; + pub fn visit_where_predicate(_visitor: &mut V, _i: &WherePredicate) {} +} +pub use generics::*; diff --git a/tests/rustdoc/private/public-impl-mention-private-generic-46380-2.rs b/tests/rustdoc/private/public-impl-mention-private-generic-46380-2.rs new file mode 100644 index 00000000000..0445ae75e85 --- /dev/null +++ b/tests/rustdoc/private/public-impl-mention-private-generic-46380-2.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/46380 +#![crate_name="foo"] + +pub trait PublicTrait {} + +//@ has foo/struct.PublicStruct.html +pub struct PublicStruct; + +//@ !has - '//*[@class="impl"]' 'impl PublicTrait for PublicStruct' +impl PublicTrait for PublicStruct {} + +struct PrivateStruct; diff --git a/tests/rustdoc/private/traits-in-bodies-private.rs b/tests/rustdoc/private/traits-in-bodies-private.rs new file mode 100644 index 00000000000..a3455b3255b --- /dev/null +++ b/tests/rustdoc/private/traits-in-bodies-private.rs @@ -0,0 +1,13 @@ +// when implementing the fix for traits-in-bodies, there was an ICE when documenting private items +// and a trait was defined in non-module scope + +//@ compile-flags:--document-private-items + +//@ has traits_in_bodies_private/struct.SomeStruct.html +//@ !has - '//code' 'impl HiddenTrait for SomeStruct' +pub struct SomeStruct; + +fn __implementation_details() { + trait HiddenTrait {} + impl HiddenTrait for SomeStruct {} +} diff --git a/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs b/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs deleted file mode 100644 index 0445ae75e85..00000000000 --- a/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// https://github.com/rust-lang/rust/issues/46380 -#![crate_name="foo"] - -pub trait PublicTrait {} - -//@ has foo/struct.PublicStruct.html -pub struct PublicStruct; - -//@ !has - '//*[@class="impl"]' 'impl PublicTrait for PublicStruct' -impl PublicTrait for PublicStruct {} - -struct PrivateStruct; diff --git a/tests/rustdoc/traits-in-bodies-private.rs b/tests/rustdoc/traits-in-bodies-private.rs deleted file mode 100644 index a3455b3255b..00000000000 --- a/tests/rustdoc/traits-in-bodies-private.rs +++ /dev/null @@ -1,13 +0,0 @@ -// when implementing the fix for traits-in-bodies, there was an ICE when documenting private items -// and a trait was defined in non-module scope - -//@ compile-flags:--document-private-items - -//@ has traits_in_bodies_private/struct.SomeStruct.html -//@ !has - '//code' 'impl HiddenTrait for SomeStruct' -pub struct SomeStruct; - -fn __implementation_details() { - trait HiddenTrait {} - impl HiddenTrait for SomeStruct {} -} -- cgit 1.4.1-3-g733a5 From d1f4a0bcb60ab868c496ca72a28b48ac0a4128af Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:40:02 +0200 Subject: Created `tests/rustdoc/macro` subfolder to limit number of files at the top level --- tests/rustdoc/auxiliary/external-macro-src.rs | 15 ---- tests/rustdoc/auxiliary/macro_pub_in_module.rs | 13 ---- tests/rustdoc/auxiliary/pub-use-extern-macros.rs | 21 ------ tests/rustdoc/compiler-derive-proc-macro.rs | 15 ---- tests/rustdoc/const-rendering-macros-33302.rs | 54 -------------- tests/rustdoc/decl_macro.rs | 58 --------------- tests/rustdoc/decl_macro_priv.rs | 14 ---- tests/rustdoc/doc-proc-macro.rs | 8 -- tests/rustdoc/external-macro-src.rs | 12 --- tests/rustdoc/macro-const-display-115295.rs | 41 ----------- tests/rustdoc/macro-doc-comment-23812.rs | 39 ---------- tests/rustdoc/macro-export-crate-root-108231.rs | 23 ------ .../macro-generated-macro.macro_linebreak_pre.html | 6 -- .../macro-generated-macro.macro_morestuff_pre.html | 15 ---- tests/rustdoc/macro-generated-macro.rs | 39 ---------- tests/rustdoc/macro-higher-kinded-function.rs | 21 ------ tests/rustdoc/macro-ice-16019.rs | 11 --- tests/rustdoc/macro-in-async-block.rs | 9 --- tests/rustdoc/macro-in-closure.rs | 16 ---- tests/rustdoc/macro-indirect-use.rs | 16 ---- .../rustdoc/macro/auxiliary/external-macro-src.rs | 15 ++++ tests/rustdoc/macro/auxiliary/issue-99221-aux.rs | 20 +++++ .../rustdoc/macro/auxiliary/macro_pub_in_module.rs | 13 ++++ .../macro/auxiliary/pub-use-extern-macros.rs | 21 ++++++ tests/rustdoc/macro/compiler-derive-proc-macro.rs | 15 ++++ .../rustdoc/macro/const-rendering-macros-33302.rs | 54 ++++++++++++++ tests/rustdoc/macro/decl_macro.rs | 58 +++++++++++++++ tests/rustdoc/macro/decl_macro_priv.rs | 14 ++++ tests/rustdoc/macro/doc-proc-macro.rs | 8 ++ tests/rustdoc/macro/external-macro-src.rs | 12 +++ tests/rustdoc/macro/macro-const-display-115295.rs | 41 +++++++++++ tests/rustdoc/macro/macro-doc-comment-23812.rs | 39 ++++++++++ .../macro/macro-export-crate-root-108231.rs | 23 ++++++ .../macro-generated-macro.macro_linebreak_pre.html | 6 ++ .../macro-generated-macro.macro_morestuff_pre.html | 15 ++++ tests/rustdoc/macro/macro-generated-macro.rs | 39 ++++++++++ .../rustdoc/macro/macro-higher-kinded-function.rs | 21 ++++++ tests/rustdoc/macro/macro-ice-16019.rs | 11 +++ tests/rustdoc/macro/macro-in-async-block.rs | 9 +++ tests/rustdoc/macro/macro-in-closure.rs | 16 ++++ tests/rustdoc/macro/macro-indirect-use.rs | 16 ++++ tests/rustdoc/macro/macro_pub_in_module.rs | 86 ++++++++++++++++++++++ tests/rustdoc/macro/macro_rules-matchers.rs | 22 ++++++ tests/rustdoc/macro/macros.rs | 24 ++++++ .../multiple-macro-rules-w-same-name-99221.rs | 18 +++++ ...iple-macro-rules-w-same-name-submodule-99221.rs | 20 +++++ tests/rustdoc/macro/proc-macro.rs | 72 ++++++++++++++++++ tests/rustdoc/macro/pub-use-extern-macros.rs | 17 +++++ tests/rustdoc/macro/rustc-macro-crate.rs | 14 ++++ tests/rustdoc/macro_pub_in_module.rs | 86 ---------------------- tests/rustdoc/macro_rules-matchers.rs | 22 ------ tests/rustdoc/macros.rs | 24 ------ .../multiple-macro-rules-w-same-name-99221.rs | 18 ----- ...iple-macro-rules-w-same-name-submodule-99221.rs | 20 ----- tests/rustdoc/proc-macro.rs | 72 ------------------ tests/rustdoc/pub-use-extern-macros.rs | 17 ----- tests/rustdoc/rustc-macro-crate.rs | 14 ---- 57 files changed, 739 insertions(+), 719 deletions(-) delete mode 100644 tests/rustdoc/auxiliary/external-macro-src.rs delete mode 100644 tests/rustdoc/auxiliary/macro_pub_in_module.rs delete mode 100644 tests/rustdoc/auxiliary/pub-use-extern-macros.rs delete mode 100644 tests/rustdoc/compiler-derive-proc-macro.rs delete mode 100644 tests/rustdoc/const-rendering-macros-33302.rs delete mode 100644 tests/rustdoc/decl_macro.rs delete mode 100644 tests/rustdoc/decl_macro_priv.rs delete mode 100644 tests/rustdoc/doc-proc-macro.rs delete mode 100644 tests/rustdoc/external-macro-src.rs delete mode 100644 tests/rustdoc/macro-const-display-115295.rs delete mode 100644 tests/rustdoc/macro-doc-comment-23812.rs delete mode 100644 tests/rustdoc/macro-export-crate-root-108231.rs delete mode 100644 tests/rustdoc/macro-generated-macro.macro_linebreak_pre.html delete mode 100644 tests/rustdoc/macro-generated-macro.macro_morestuff_pre.html delete mode 100644 tests/rustdoc/macro-generated-macro.rs delete mode 100644 tests/rustdoc/macro-higher-kinded-function.rs delete mode 100644 tests/rustdoc/macro-ice-16019.rs delete mode 100644 tests/rustdoc/macro-in-async-block.rs delete mode 100644 tests/rustdoc/macro-in-closure.rs delete mode 100644 tests/rustdoc/macro-indirect-use.rs create mode 100644 tests/rustdoc/macro/auxiliary/external-macro-src.rs create mode 100644 tests/rustdoc/macro/auxiliary/issue-99221-aux.rs create mode 100644 tests/rustdoc/macro/auxiliary/macro_pub_in_module.rs create mode 100644 tests/rustdoc/macro/auxiliary/pub-use-extern-macros.rs create mode 100644 tests/rustdoc/macro/compiler-derive-proc-macro.rs create mode 100644 tests/rustdoc/macro/const-rendering-macros-33302.rs create mode 100644 tests/rustdoc/macro/decl_macro.rs create mode 100644 tests/rustdoc/macro/decl_macro_priv.rs create mode 100644 tests/rustdoc/macro/doc-proc-macro.rs create mode 100644 tests/rustdoc/macro/external-macro-src.rs create mode 100644 tests/rustdoc/macro/macro-const-display-115295.rs create mode 100644 tests/rustdoc/macro/macro-doc-comment-23812.rs create mode 100644 tests/rustdoc/macro/macro-export-crate-root-108231.rs create mode 100644 tests/rustdoc/macro/macro-generated-macro.macro_linebreak_pre.html create mode 100644 tests/rustdoc/macro/macro-generated-macro.macro_morestuff_pre.html create mode 100644 tests/rustdoc/macro/macro-generated-macro.rs create mode 100644 tests/rustdoc/macro/macro-higher-kinded-function.rs create mode 100644 tests/rustdoc/macro/macro-ice-16019.rs create mode 100644 tests/rustdoc/macro/macro-in-async-block.rs create mode 100644 tests/rustdoc/macro/macro-in-closure.rs create mode 100644 tests/rustdoc/macro/macro-indirect-use.rs create mode 100644 tests/rustdoc/macro/macro_pub_in_module.rs create mode 100644 tests/rustdoc/macro/macro_rules-matchers.rs create mode 100644 tests/rustdoc/macro/macros.rs create mode 100644 tests/rustdoc/macro/multiple-macro-rules-w-same-name-99221.rs create mode 100644 tests/rustdoc/macro/multiple-macro-rules-w-same-name-submodule-99221.rs create mode 100644 tests/rustdoc/macro/proc-macro.rs create mode 100644 tests/rustdoc/macro/pub-use-extern-macros.rs create mode 100644 tests/rustdoc/macro/rustc-macro-crate.rs delete mode 100644 tests/rustdoc/macro_pub_in_module.rs delete mode 100644 tests/rustdoc/macro_rules-matchers.rs delete mode 100644 tests/rustdoc/macros.rs delete mode 100644 tests/rustdoc/multiple-macro-rules-w-same-name-99221.rs delete mode 100644 tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs delete mode 100644 tests/rustdoc/proc-macro.rs delete mode 100644 tests/rustdoc/pub-use-extern-macros.rs delete mode 100644 tests/rustdoc/rustc-macro-crate.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/auxiliary/external-macro-src.rs b/tests/rustdoc/auxiliary/external-macro-src.rs deleted file mode 100644 index 79df5dc98eb..00000000000 --- a/tests/rustdoc/auxiliary/external-macro-src.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist - -#![doc(html_root_url = "https://example.com/")] - -#[macro_export] -macro_rules! make_foo { - () => { - pub struct Foo; - impl Foo { - pub fn new() -> Foo { - Foo - } - } - } -} diff --git a/tests/rustdoc/auxiliary/macro_pub_in_module.rs b/tests/rustdoc/auxiliary/macro_pub_in_module.rs deleted file mode 100644 index 81efa1db536..00000000000 --- a/tests/rustdoc/auxiliary/macro_pub_in_module.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ edition:2018 - -#![feature(decl_macro)] -#![crate_name = "external_crate"] - -pub mod some_module { - /* == Make sure the logic is not affected by a re-export == */ - mod private { - pub macro external_macro() {} - } - - pub use private::external_macro; -} diff --git a/tests/rustdoc/auxiliary/pub-use-extern-macros.rs b/tests/rustdoc/auxiliary/pub-use-extern-macros.rs deleted file mode 100644 index 7934e07339a..00000000000 --- a/tests/rustdoc/auxiliary/pub-use-extern-macros.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![crate_name="macros"] - -#[macro_export] -macro_rules! foo { - () => {}; -} - -#[macro_export] -macro_rules! bar { - () => {}; -} - -#[macro_export] -macro_rules! baz { - () => {}; -} - -#[macro_export] -macro_rules! quux { - () => {}; -} diff --git a/tests/rustdoc/compiler-derive-proc-macro.rs b/tests/rustdoc/compiler-derive-proc-macro.rs deleted file mode 100644 index e8dc5d7c6b7..00000000000 --- a/tests/rustdoc/compiler-derive-proc-macro.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This test ensures that compiler builtin proc-macros are considered as such. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// Each compiler builtin proc-macro has a trait equivalent so we should have -// a trait section as well. -//@ count - '//*[@id="main-content"]//*[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Traits' -//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Derive Macros' - -// Now checking the correct file is generated as well. -//@ has 'foo/derive.Clone.html' -//@ !has 'foo/macro.Clone.html' -pub use std::clone::Clone; diff --git a/tests/rustdoc/const-rendering-macros-33302.rs b/tests/rustdoc/const-rendering-macros-33302.rs deleted file mode 100644 index 9fd45df08be..00000000000 --- a/tests/rustdoc/const-rendering-macros-33302.rs +++ /dev/null @@ -1,54 +0,0 @@ -// https://github.com/rust-lang/rust/issues/33302 -#![crate_name="issue_33302"] - -// Ensure constant and array length values are not taken from source -// code, which wreaks havoc with macros. - -macro_rules! make { - ($n:expr) => { - pub struct S; - - //@ has issue_33302/constant.CST.html \ - // '//pre[@class="rust item-decl"]' 'pub const CST: i32' - pub const CST: i32 = ($n * $n); - //@ has issue_33302/static.ST.html \ - // '//pre[@class="rust item-decl"]' 'pub static ST: i32' - pub static ST: i32 = ($n * $n); - - pub trait T { - fn ignore(_: &X) {} - const C: X; - //@ has issue_33302/trait.T.html \ - // '//pre[@class="rust item-decl"]' 'const D: i32' - //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' - const D: i32 = ($n * $n); - } - - //@ has issue_33302/struct.S.html \ - // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' - //@ has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]' - //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' - impl T<[i32; ($n * $n)]> for S { - const C: [i32; ($n * $n)] = [0; ($n * $n)]; - } - - //@ has issue_33302/struct.S.html \ - // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' - //@ has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)' - //@ has - '//*[@id="associatedconstant.D-1"]' 'const D: i32' - impl T<(i32,)> for S { - const C: (i32,) = ($n,); - } - - //@ has issue_33302/struct.S.html \ - // '//*[@class="impl"]' 'impl T<(i32, i32)> for S' - //@ has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)' - //@ has - '//*[@id="associatedconstant.D-2"]' 'const D: i32' - impl T<(i32, i32)> for S { - const C: (i32, i32) = ($n, $n); - const D: i32 = ($n / $n); - } - }; -} - -make!(4); diff --git a/tests/rustdoc/decl_macro.rs b/tests/rustdoc/decl_macro.rs deleted file mode 100644 index 040859baffb..00000000000 --- a/tests/rustdoc/decl_macro.rs +++ /dev/null @@ -1,58 +0,0 @@ -//@ compile-flags: --document-private-items - -#![feature(decl_macro)] - -//@ has decl_macro/macro.my_macro.html //pre 'pub macro my_macro() {' -//@ has - //pre '...' -//@ has - //pre '}' -pub macro my_macro() { - -} - -//@ has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {' -//@ has - //pre '...' -//@ has - //pre '}' -pub macro my_macro_2($($tok:tt)*) { - -} - -//@ has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {' -//@ has - //pre '(_) => { ... },' -//@ has - //pre '($foo:ident . $bar:expr) => { ... },' -//@ has - //pre '($($foo:literal),+) => { ... },' -//@ has - //pre '}' -pub macro my_macro_multi { - (_) => { - - }, - ($foo:ident . $bar:expr) => { - - }, - ($($foo:literal),+) => { - - } -} - -//@ has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($foo:expr) {' -//@ has - //pre '...' -//@ has - //pre '}' -pub macro by_example_single { - ($foo:expr) => {} -} - -mod a { - mod b { - //@ has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($foo:expr) {' - pub(in super) macro by_example_vis { - ($foo:expr) => {} - } - mod c { - //@ has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($foo:expr) {' - // Regression test for : - //@ has - '//pre[@class="rust item-decl"]//a[@class="mod"]/@href' '../../index.html' - pub(in a) macro by_example_vis_named { - ($foo:expr) => {} - } - } - } -} diff --git a/tests/rustdoc/decl_macro_priv.rs b/tests/rustdoc/decl_macro_priv.rs deleted file mode 100644 index d87c8d22f2d..00000000000 --- a/tests/rustdoc/decl_macro_priv.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ compile-flags: --document-private-items - -#![feature(decl_macro)] - -//@ has decl_macro_priv/macro.crate_macro.html //pre 'pub(crate) macro crate_macro() {' -//@ has - //pre '...' -//@ has - //pre '}' -pub(crate) macro crate_macro() {} - -//@ has decl_macro_priv/macro.priv_macro.html //pre 'macro priv_macro() {' -//@ !has - //pre 'pub macro priv_macro() {' -//@ has - //pre '...' -//@ has - //pre '}' -macro priv_macro() {} diff --git a/tests/rustdoc/doc-proc-macro.rs b/tests/rustdoc/doc-proc-macro.rs deleted file mode 100644 index 19172ffa41d..00000000000 --- a/tests/rustdoc/doc-proc-macro.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro - -// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't -// crash when we try. - -extern crate proc_macro; - -pub use proc_macro::*; diff --git a/tests/rustdoc/external-macro-src.rs b/tests/rustdoc/external-macro-src.rs deleted file mode 100644 index 998687d93bd..00000000000 --- a/tests/rustdoc/external-macro-src.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ aux-build:external-macro-src.rs - -#![crate_name = "foo"] - -#[macro_use] -extern crate external_macro_src; - -//@ has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#3-12"]' 'Source' - -//@ has foo/struct.Foo.html -//@ has - '//a[@href="../src/foo/external-macro-src.rs.html#12"]' 'Source' -make_foo!(); diff --git a/tests/rustdoc/macro-const-display-115295.rs b/tests/rustdoc/macro-const-display-115295.rs deleted file mode 100644 index 445b47e0b24..00000000000 --- a/tests/rustdoc/macro-const-display-115295.rs +++ /dev/null @@ -1,41 +0,0 @@ -// https://github.com/rust-lang/rust/issues/115295 -#![crate_name = "foo"] - -//@ has foo/trait.Trait.html -pub trait Trait {} - -//@ has foo/struct.WithConst.html -pub struct WithConst; - -macro_rules! spans_from_macro { - () => { - impl WithConst<42> { - pub fn new() -> Self { - Self - } - } - impl Trait> for WithConst<42> {} - impl Trait> for WithConst<{ 43 }> {} - impl Trait> for WithConst<44> {} - pub struct Other { - pub field: WithConst<42>, - } - }; -} - -//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Trait> for WithConst<41>" -impl Trait> for WithConst<41> {} - -//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl WithConst<42>" -//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Trait> for WithConst<42>" -//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Trait> for WithConst<{ 43 }>" -//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Trait> for WithConst<44>" - -//@ has foo/struct.Other.html -//@ has - //pre "pub field: WithConst<42>" -spans_from_macro!(); diff --git a/tests/rustdoc/macro-doc-comment-23812.rs b/tests/rustdoc/macro-doc-comment-23812.rs deleted file mode 100644 index 03fda4a25b9..00000000000 --- a/tests/rustdoc/macro-doc-comment-23812.rs +++ /dev/null @@ -1,39 +0,0 @@ -// https://github.com/rust-lang/rust/issues/23812 -#![crate_name="issue_23812"] - -macro_rules! doc { - (#[$outer:meta] mod $i:ident { #![$inner:meta] }) => - ( - #[$outer] - pub mod $i { - #![$inner] - } - ) -} - -doc! { - /// Outer comment - mod Foo { - //! Inner comment - } -} - -//@ has issue_23812/Foo/index.html -//@ hasraw - 'Outer comment' -//@ !hasraw - '/// Outer comment' -//@ hasraw - 'Inner comment' -//@ !hasraw - '//! Inner comment' - - -doc! { - /** Outer block comment */ - mod Bar { - /*! Inner block comment */ - } -} - -//@ has issue_23812/Bar/index.html -//@ hasraw - 'Outer block comment' -//@ !hasraw - '/** Outer block comment */' -//@ hasraw - 'Inner block comment' -//@ !hasraw - '/*! Inner block comment */' diff --git a/tests/rustdoc/macro-export-crate-root-108231.rs b/tests/rustdoc/macro-export-crate-root-108231.rs deleted file mode 100644 index 0d3ad1b0571..00000000000 --- a/tests/rustdoc/macro-export-crate-root-108231.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test for . -// Macros with `#[macro_export]` attribute should be visible at the top level -// even if they are inside a doc hidden item. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' -//@ count - '//*[@id="main-content"]//a[@class="macro"]' 1 -//@ has - '//*[@id="main-content"]//a[@class="macro"]' 'foo' - -#[doc(hidden)] -pub mod __internal { - /// This one should be visible. - #[macro_export] - macro_rules! foo { - () => {}; - } - - /// This one should be hidden. - macro_rules! bar { - () => {}; - } -} diff --git a/tests/rustdoc/macro-generated-macro.macro_linebreak_pre.html b/tests/rustdoc/macro-generated-macro.macro_linebreak_pre.html deleted file mode 100644 index ce5d3a8461b..00000000000 --- a/tests/rustdoc/macro-generated-macro.macro_linebreak_pre.html +++ /dev/null @@ -1,6 +0,0 @@ -macro_rules! linebreak { - ( - <= 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - 26 27 28 => - ) => { ... }; -} \ No newline at end of file diff --git a/tests/rustdoc/macro-generated-macro.macro_morestuff_pre.html b/tests/rustdoc/macro-generated-macro.macro_morestuff_pre.html deleted file mode 100644 index 28f15522a82..00000000000 --- a/tests/rustdoc/macro-generated-macro.macro_morestuff_pre.html +++ /dev/null @@ -1,15 +0,0 @@ -macro_rules! morestuff { - ( - <= "space between most kinds of tokens" : 1 $x + @ :: >>= 'static - "no space inside paren or bracket" : (2 a) [2 a] $(2 $a:tt)* - "space inside curly brace" : { 2 a } - "no space inside empty delimiters" : () [] {} - "no space before comma or semicolon" : a, (a), { a }, a; [T; 0]; - "the three repetition specifiers" : $(@)*, $(@)+, $(@)? - "repetition separators" : $(@)|*, $(@)|+, $(@)==*, $(@)static* - "plus or star cannot be a repetition separator" : $(@)+ * $(@)* + - "no space between ident and paren" : let _ = f(0) + f[0] + Struct {}; - "space between keyword and paren" : return (a,) & for x in (..) - "some special case keywords" : pub(crate), fn() -> u8, Self(0, 0) => - ) => { ... }; -} \ No newline at end of file diff --git a/tests/rustdoc/macro-generated-macro.rs b/tests/rustdoc/macro-generated-macro.rs deleted file mode 100644 index e77d0cf89e7..00000000000 --- a/tests/rustdoc/macro-generated-macro.rs +++ /dev/null @@ -1,39 +0,0 @@ -macro_rules! make_macro { - ($macro_name:ident $($matcher:tt)*) => { - #[macro_export] - macro_rules! $macro_name { - (<= $($matcher)* =>) => {}; - } - } -} - -//@ has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {' -//@ has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };' -make_macro!(interpolations type $($i:ident)::* + $e:expr); -interpolations!(<= type foo::bar + x.sort() =>); - -//@ has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {' -//@ has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };' -make_macro!(attributes #![no_std] #[cfg(feature = "alloc")]); - -//@ has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {' -//@ has - //pre '(<= fn {} () { foo[0] } =>) => { ... };' -make_macro!(groups fn {}() {foo[0]}); - -//@ snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text() -make_macro!(linebreak 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28); - -//@ snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text() -make_macro!(morestuff - "space between most kinds of tokens": 1 $x + @ :: >>= 'static - "no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)* - "space inside curly brace": { 2 a } - "no space inside empty delimiters": () [] {} - "no space before comma or semicolon": a, (a), { a }, a; [T; 0]; - "the three repetition specifiers": $(@)*, $(@)+, $(@)? - "repetition separators": $(@)|*, $(@)|+, $(@)==*, $(@)static* - "plus or star cannot be a repetition separator": $(@)+ * $(@)* + - "no space between ident and paren": let _ = f(0) + f[0] + Struct {}; - "space between keyword and paren": return (a,) & for x in (..) - "some special case keywords": pub(crate), fn() -> u8, Self(0, 0) -); diff --git a/tests/rustdoc/macro-higher-kinded-function.rs b/tests/rustdoc/macro-higher-kinded-function.rs deleted file mode 100644 index 738ea8fb3f1..00000000000 --- a/tests/rustdoc/macro-higher-kinded-function.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![crate_name = "foo"] - -pub struct TyCtxt<'tcx>(&'tcx u8); - -macro_rules! gen { - ($(($name:ident, $tcx:lifetime, [$k:ty], [$r:ty]))*) => { - pub struct Providers { - $(pub $name: for<$tcx> fn(TyCtxt<$tcx>, $k) -> $r,)* - } - } -} - -//@ has 'foo/struct.Providers.html' -//@ has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8," -//@ has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16," -//@ has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8" -//@ has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16" -gen! { - (a, 'tcx, [u8], [i8]) - (b, 'tcx, [u16], [i16]) -} diff --git a/tests/rustdoc/macro-ice-16019.rs b/tests/rustdoc/macro-ice-16019.rs deleted file mode 100644 index d0f82e0a314..00000000000 --- a/tests/rustdoc/macro-ice-16019.rs +++ /dev/null @@ -1,11 +0,0 @@ -// https://github.com/rust-lang/rust/issues/16019 - -macro_rules! define_struct { - ($rounds:expr) => ( - struct Struct { - sk: [u32; $rounds + 1] - } - ) -} - -define_struct!(2); diff --git a/tests/rustdoc/macro-in-async-block.rs b/tests/rustdoc/macro-in-async-block.rs deleted file mode 100644 index 43822fb9c52..00000000000 --- a/tests/rustdoc/macro-in-async-block.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Regression issue for rustdoc ICE encountered in PR #72088. -//@ edition:2018 -#![feature(decl_macro)] - -fn main() { - async { - macro m() {} - }; -} diff --git a/tests/rustdoc/macro-in-closure.rs b/tests/rustdoc/macro-in-closure.rs deleted file mode 100644 index b4411d927e2..00000000000 --- a/tests/rustdoc/macro-in-closure.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Regression issue for rustdoc ICE encountered in PR #65252. - -#![feature(decl_macro)] - -fn main() { - || { - macro m() {} - }; - - let _ = || { - macro n() {} - }; - - let cond = true; - let _ = || if cond { macro n() {} } else { panic!() }; -} diff --git a/tests/rustdoc/macro-indirect-use.rs b/tests/rustdoc/macro-indirect-use.rs deleted file mode 100644 index e410e96ae6a..00000000000 --- a/tests/rustdoc/macro-indirect-use.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Checks that it is possible to make a macro public through a `pub use` of its -// parent module. -// -// This is a regression test for issue #87257. - -#![feature(decl_macro)] - -mod outer { - pub mod inner { - pub macro some_macro() {} - } -} - -//@ has macro_indirect_use/inner/index.html -//@ has macro_indirect_use/inner/macro.some_macro.html -pub use outer::inner; diff --git a/tests/rustdoc/macro/auxiliary/external-macro-src.rs b/tests/rustdoc/macro/auxiliary/external-macro-src.rs new file mode 100644 index 00000000000..79df5dc98eb --- /dev/null +++ b/tests/rustdoc/macro/auxiliary/external-macro-src.rs @@ -0,0 +1,15 @@ +//@ compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist + +#![doc(html_root_url = "https://example.com/")] + +#[macro_export] +macro_rules! make_foo { + () => { + pub struct Foo; + impl Foo { + pub fn new() -> Foo { + Foo + } + } + } +} diff --git a/tests/rustdoc/macro/auxiliary/issue-99221-aux.rs b/tests/rustdoc/macro/auxiliary/issue-99221-aux.rs new file mode 100644 index 00000000000..e061e42b29d --- /dev/null +++ b/tests/rustdoc/macro/auxiliary/issue-99221-aux.rs @@ -0,0 +1,20 @@ +pub struct Option; +impl Option { + pub fn unwrap(self) {} +} + +mod macros { + use crate::Option; + /// [`Option::unwrap`] + #[macro_export] + macro_rules! print { + () => () + } +} + +mod structs { + use crate::Option; + /// [`Option::unwrap`] + pub struct Print; +} +pub use structs::Print; diff --git a/tests/rustdoc/macro/auxiliary/macro_pub_in_module.rs b/tests/rustdoc/macro/auxiliary/macro_pub_in_module.rs new file mode 100644 index 00000000000..81efa1db536 --- /dev/null +++ b/tests/rustdoc/macro/auxiliary/macro_pub_in_module.rs @@ -0,0 +1,13 @@ +//@ edition:2018 + +#![feature(decl_macro)] +#![crate_name = "external_crate"] + +pub mod some_module { + /* == Make sure the logic is not affected by a re-export == */ + mod private { + pub macro external_macro() {} + } + + pub use private::external_macro; +} diff --git a/tests/rustdoc/macro/auxiliary/pub-use-extern-macros.rs b/tests/rustdoc/macro/auxiliary/pub-use-extern-macros.rs new file mode 100644 index 00000000000..7934e07339a --- /dev/null +++ b/tests/rustdoc/macro/auxiliary/pub-use-extern-macros.rs @@ -0,0 +1,21 @@ +#![crate_name="macros"] + +#[macro_export] +macro_rules! foo { + () => {}; +} + +#[macro_export] +macro_rules! bar { + () => {}; +} + +#[macro_export] +macro_rules! baz { + () => {}; +} + +#[macro_export] +macro_rules! quux { + () => {}; +} diff --git a/tests/rustdoc/macro/compiler-derive-proc-macro.rs b/tests/rustdoc/macro/compiler-derive-proc-macro.rs new file mode 100644 index 00000000000..e8dc5d7c6b7 --- /dev/null +++ b/tests/rustdoc/macro/compiler-derive-proc-macro.rs @@ -0,0 +1,15 @@ +// This test ensures that compiler builtin proc-macros are considered as such. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// Each compiler builtin proc-macro has a trait equivalent so we should have +// a trait section as well. +//@ count - '//*[@id="main-content"]//*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Traits' +//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Derive Macros' + +// Now checking the correct file is generated as well. +//@ has 'foo/derive.Clone.html' +//@ !has 'foo/macro.Clone.html' +pub use std::clone::Clone; diff --git a/tests/rustdoc/macro/const-rendering-macros-33302.rs b/tests/rustdoc/macro/const-rendering-macros-33302.rs new file mode 100644 index 00000000000..9fd45df08be --- /dev/null +++ b/tests/rustdoc/macro/const-rendering-macros-33302.rs @@ -0,0 +1,54 @@ +// https://github.com/rust-lang/rust/issues/33302 +#![crate_name="issue_33302"] + +// Ensure constant and array length values are not taken from source +// code, which wreaks havoc with macros. + +macro_rules! make { + ($n:expr) => { + pub struct S; + + //@ has issue_33302/constant.CST.html \ + // '//pre[@class="rust item-decl"]' 'pub const CST: i32' + pub const CST: i32 = ($n * $n); + //@ has issue_33302/static.ST.html \ + // '//pre[@class="rust item-decl"]' 'pub static ST: i32' + pub static ST: i32 = ($n * $n); + + pub trait T { + fn ignore(_: &X) {} + const C: X; + //@ has issue_33302/trait.T.html \ + // '//pre[@class="rust item-decl"]' 'const D: i32' + //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' + const D: i32 = ($n * $n); + } + + //@ has issue_33302/struct.S.html \ + // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' + //@ has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]' + //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' + impl T<[i32; ($n * $n)]> for S { + const C: [i32; ($n * $n)] = [0; ($n * $n)]; + } + + //@ has issue_33302/struct.S.html \ + // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' + //@ has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)' + //@ has - '//*[@id="associatedconstant.D-1"]' 'const D: i32' + impl T<(i32,)> for S { + const C: (i32,) = ($n,); + } + + //@ has issue_33302/struct.S.html \ + // '//*[@class="impl"]' 'impl T<(i32, i32)> for S' + //@ has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)' + //@ has - '//*[@id="associatedconstant.D-2"]' 'const D: i32' + impl T<(i32, i32)> for S { + const C: (i32, i32) = ($n, $n); + const D: i32 = ($n / $n); + } + }; +} + +make!(4); diff --git a/tests/rustdoc/macro/decl_macro.rs b/tests/rustdoc/macro/decl_macro.rs new file mode 100644 index 00000000000..040859baffb --- /dev/null +++ b/tests/rustdoc/macro/decl_macro.rs @@ -0,0 +1,58 @@ +//@ compile-flags: --document-private-items + +#![feature(decl_macro)] + +//@ has decl_macro/macro.my_macro.html //pre 'pub macro my_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' +pub macro my_macro() { + +} + +//@ has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {' +//@ has - //pre '...' +//@ has - //pre '}' +pub macro my_macro_2($($tok:tt)*) { + +} + +//@ has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {' +//@ has - //pre '(_) => { ... },' +//@ has - //pre '($foo:ident . $bar:expr) => { ... },' +//@ has - //pre '($($foo:literal),+) => { ... },' +//@ has - //pre '}' +pub macro my_macro_multi { + (_) => { + + }, + ($foo:ident . $bar:expr) => { + + }, + ($($foo:literal),+) => { + + } +} + +//@ has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($foo:expr) {' +//@ has - //pre '...' +//@ has - //pre '}' +pub macro by_example_single { + ($foo:expr) => {} +} + +mod a { + mod b { + //@ has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($foo:expr) {' + pub(in super) macro by_example_vis { + ($foo:expr) => {} + } + mod c { + //@ has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($foo:expr) {' + // Regression test for : + //@ has - '//pre[@class="rust item-decl"]//a[@class="mod"]/@href' '../../index.html' + pub(in a) macro by_example_vis_named { + ($foo:expr) => {} + } + } + } +} diff --git a/tests/rustdoc/macro/decl_macro_priv.rs b/tests/rustdoc/macro/decl_macro_priv.rs new file mode 100644 index 00000000000..d87c8d22f2d --- /dev/null +++ b/tests/rustdoc/macro/decl_macro_priv.rs @@ -0,0 +1,14 @@ +//@ compile-flags: --document-private-items + +#![feature(decl_macro)] + +//@ has decl_macro_priv/macro.crate_macro.html //pre 'pub(crate) macro crate_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' +pub(crate) macro crate_macro() {} + +//@ has decl_macro_priv/macro.priv_macro.html //pre 'macro priv_macro() {' +//@ !has - //pre 'pub macro priv_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' +macro priv_macro() {} diff --git a/tests/rustdoc/macro/doc-proc-macro.rs b/tests/rustdoc/macro/doc-proc-macro.rs new file mode 100644 index 00000000000..19172ffa41d --- /dev/null +++ b/tests/rustdoc/macro/doc-proc-macro.rs @@ -0,0 +1,8 @@ +// Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro + +// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't +// crash when we try. + +extern crate proc_macro; + +pub use proc_macro::*; diff --git a/tests/rustdoc/macro/external-macro-src.rs b/tests/rustdoc/macro/external-macro-src.rs new file mode 100644 index 00000000000..998687d93bd --- /dev/null +++ b/tests/rustdoc/macro/external-macro-src.rs @@ -0,0 +1,12 @@ +//@ aux-build:external-macro-src.rs + +#![crate_name = "foo"] + +#[macro_use] +extern crate external_macro_src; + +//@ has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#3-12"]' 'Source' + +//@ has foo/struct.Foo.html +//@ has - '//a[@href="../src/foo/external-macro-src.rs.html#12"]' 'Source' +make_foo!(); diff --git a/tests/rustdoc/macro/macro-const-display-115295.rs b/tests/rustdoc/macro/macro-const-display-115295.rs new file mode 100644 index 00000000000..445b47e0b24 --- /dev/null +++ b/tests/rustdoc/macro/macro-const-display-115295.rs @@ -0,0 +1,41 @@ +// https://github.com/rust-lang/rust/issues/115295 +#![crate_name = "foo"] + +//@ has foo/trait.Trait.html +pub trait Trait {} + +//@ has foo/struct.WithConst.html +pub struct WithConst; + +macro_rules! spans_from_macro { + () => { + impl WithConst<42> { + pub fn new() -> Self { + Self + } + } + impl Trait> for WithConst<42> {} + impl Trait> for WithConst<{ 43 }> {} + impl Trait> for WithConst<44> {} + pub struct Other { + pub field: WithConst<42>, + } + }; +} + +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Trait> for WithConst<41>" +impl Trait> for WithConst<41> {} + +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl WithConst<42>" +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Trait> for WithConst<42>" +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Trait> for WithConst<{ 43 }>" +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Trait> for WithConst<44>" + +//@ has foo/struct.Other.html +//@ has - //pre "pub field: WithConst<42>" +spans_from_macro!(); diff --git a/tests/rustdoc/macro/macro-doc-comment-23812.rs b/tests/rustdoc/macro/macro-doc-comment-23812.rs new file mode 100644 index 00000000000..03fda4a25b9 --- /dev/null +++ b/tests/rustdoc/macro/macro-doc-comment-23812.rs @@ -0,0 +1,39 @@ +// https://github.com/rust-lang/rust/issues/23812 +#![crate_name="issue_23812"] + +macro_rules! doc { + (#[$outer:meta] mod $i:ident { #![$inner:meta] }) => + ( + #[$outer] + pub mod $i { + #![$inner] + } + ) +} + +doc! { + /// Outer comment + mod Foo { + //! Inner comment + } +} + +//@ has issue_23812/Foo/index.html +//@ hasraw - 'Outer comment' +//@ !hasraw - '/// Outer comment' +//@ hasraw - 'Inner comment' +//@ !hasraw - '//! Inner comment' + + +doc! { + /** Outer block comment */ + mod Bar { + /*! Inner block comment */ + } +} + +//@ has issue_23812/Bar/index.html +//@ hasraw - 'Outer block comment' +//@ !hasraw - '/** Outer block comment */' +//@ hasraw - 'Inner block comment' +//@ !hasraw - '/*! Inner block comment */' diff --git a/tests/rustdoc/macro/macro-export-crate-root-108231.rs b/tests/rustdoc/macro/macro-export-crate-root-108231.rs new file mode 100644 index 00000000000..0d3ad1b0571 --- /dev/null +++ b/tests/rustdoc/macro/macro-export-crate-root-108231.rs @@ -0,0 +1,23 @@ +// Regression test for . +// Macros with `#[macro_export]` attribute should be visible at the top level +// even if they are inside a doc hidden item. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ count - '//*[@id="main-content"]//a[@class="macro"]' 1 +//@ has - '//*[@id="main-content"]//a[@class="macro"]' 'foo' + +#[doc(hidden)] +pub mod __internal { + /// This one should be visible. + #[macro_export] + macro_rules! foo { + () => {}; + } + + /// This one should be hidden. + macro_rules! bar { + () => {}; + } +} diff --git a/tests/rustdoc/macro/macro-generated-macro.macro_linebreak_pre.html b/tests/rustdoc/macro/macro-generated-macro.macro_linebreak_pre.html new file mode 100644 index 00000000000..ce5d3a8461b --- /dev/null +++ b/tests/rustdoc/macro/macro-generated-macro.macro_linebreak_pre.html @@ -0,0 +1,6 @@ +macro_rules! linebreak { + ( + <= 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 + 26 27 28 => + ) => { ... }; +} \ No newline at end of file diff --git a/tests/rustdoc/macro/macro-generated-macro.macro_morestuff_pre.html b/tests/rustdoc/macro/macro-generated-macro.macro_morestuff_pre.html new file mode 100644 index 00000000000..28f15522a82 --- /dev/null +++ b/tests/rustdoc/macro/macro-generated-macro.macro_morestuff_pre.html @@ -0,0 +1,15 @@ +macro_rules! morestuff { + ( + <= "space between most kinds of tokens" : 1 $x + @ :: >>= 'static + "no space inside paren or bracket" : (2 a) [2 a] $(2 $a:tt)* + "space inside curly brace" : { 2 a } + "no space inside empty delimiters" : () [] {} + "no space before comma or semicolon" : a, (a), { a }, a; [T; 0]; + "the three repetition specifiers" : $(@)*, $(@)+, $(@)? + "repetition separators" : $(@)|*, $(@)|+, $(@)==*, $(@)static* + "plus or star cannot be a repetition separator" : $(@)+ * $(@)* + + "no space between ident and paren" : let _ = f(0) + f[0] + Struct {}; + "space between keyword and paren" : return (a,) & for x in (..) + "some special case keywords" : pub(crate), fn() -> u8, Self(0, 0) => + ) => { ... }; +} \ No newline at end of file diff --git a/tests/rustdoc/macro/macro-generated-macro.rs b/tests/rustdoc/macro/macro-generated-macro.rs new file mode 100644 index 00000000000..e77d0cf89e7 --- /dev/null +++ b/tests/rustdoc/macro/macro-generated-macro.rs @@ -0,0 +1,39 @@ +macro_rules! make_macro { + ($macro_name:ident $($matcher:tt)*) => { + #[macro_export] + macro_rules! $macro_name { + (<= $($matcher)* =>) => {}; + } + } +} + +//@ has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {' +//@ has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };' +make_macro!(interpolations type $($i:ident)::* + $e:expr); +interpolations!(<= type foo::bar + x.sort() =>); + +//@ has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {' +//@ has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };' +make_macro!(attributes #![no_std] #[cfg(feature = "alloc")]); + +//@ has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {' +//@ has - //pre '(<= fn {} () { foo[0] } =>) => { ... };' +make_macro!(groups fn {}() {foo[0]}); + +//@ snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text() +make_macro!(linebreak 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28); + +//@ snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text() +make_macro!(morestuff + "space between most kinds of tokens": 1 $x + @ :: >>= 'static + "no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)* + "space inside curly brace": { 2 a } + "no space inside empty delimiters": () [] {} + "no space before comma or semicolon": a, (a), { a }, a; [T; 0]; + "the three repetition specifiers": $(@)*, $(@)+, $(@)? + "repetition separators": $(@)|*, $(@)|+, $(@)==*, $(@)static* + "plus or star cannot be a repetition separator": $(@)+ * $(@)* + + "no space between ident and paren": let _ = f(0) + f[0] + Struct {}; + "space between keyword and paren": return (a,) & for x in (..) + "some special case keywords": pub(crate), fn() -> u8, Self(0, 0) +); diff --git a/tests/rustdoc/macro/macro-higher-kinded-function.rs b/tests/rustdoc/macro/macro-higher-kinded-function.rs new file mode 100644 index 00000000000..738ea8fb3f1 --- /dev/null +++ b/tests/rustdoc/macro/macro-higher-kinded-function.rs @@ -0,0 +1,21 @@ +#![crate_name = "foo"] + +pub struct TyCtxt<'tcx>(&'tcx u8); + +macro_rules! gen { + ($(($name:ident, $tcx:lifetime, [$k:ty], [$r:ty]))*) => { + pub struct Providers { + $(pub $name: for<$tcx> fn(TyCtxt<$tcx>, $k) -> $r,)* + } + } +} + +//@ has 'foo/struct.Providers.html' +//@ has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8," +//@ has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16," +//@ has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8" +//@ has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16" +gen! { + (a, 'tcx, [u8], [i8]) + (b, 'tcx, [u16], [i16]) +} diff --git a/tests/rustdoc/macro/macro-ice-16019.rs b/tests/rustdoc/macro/macro-ice-16019.rs new file mode 100644 index 00000000000..d0f82e0a314 --- /dev/null +++ b/tests/rustdoc/macro/macro-ice-16019.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/16019 + +macro_rules! define_struct { + ($rounds:expr) => ( + struct Struct { + sk: [u32; $rounds + 1] + } + ) +} + +define_struct!(2); diff --git a/tests/rustdoc/macro/macro-in-async-block.rs b/tests/rustdoc/macro/macro-in-async-block.rs new file mode 100644 index 00000000000..43822fb9c52 --- /dev/null +++ b/tests/rustdoc/macro/macro-in-async-block.rs @@ -0,0 +1,9 @@ +// Regression issue for rustdoc ICE encountered in PR #72088. +//@ edition:2018 +#![feature(decl_macro)] + +fn main() { + async { + macro m() {} + }; +} diff --git a/tests/rustdoc/macro/macro-in-closure.rs b/tests/rustdoc/macro/macro-in-closure.rs new file mode 100644 index 00000000000..b4411d927e2 --- /dev/null +++ b/tests/rustdoc/macro/macro-in-closure.rs @@ -0,0 +1,16 @@ +// Regression issue for rustdoc ICE encountered in PR #65252. + +#![feature(decl_macro)] + +fn main() { + || { + macro m() {} + }; + + let _ = || { + macro n() {} + }; + + let cond = true; + let _ = || if cond { macro n() {} } else { panic!() }; +} diff --git a/tests/rustdoc/macro/macro-indirect-use.rs b/tests/rustdoc/macro/macro-indirect-use.rs new file mode 100644 index 00000000000..e410e96ae6a --- /dev/null +++ b/tests/rustdoc/macro/macro-indirect-use.rs @@ -0,0 +1,16 @@ +// Checks that it is possible to make a macro public through a `pub use` of its +// parent module. +// +// This is a regression test for issue #87257. + +#![feature(decl_macro)] + +mod outer { + pub mod inner { + pub macro some_macro() {} + } +} + +//@ has macro_indirect_use/inner/index.html +//@ has macro_indirect_use/inner/macro.some_macro.html +pub use outer::inner; diff --git a/tests/rustdoc/macro/macro_pub_in_module.rs b/tests/rustdoc/macro/macro_pub_in_module.rs new file mode 100644 index 00000000000..2dce73c2cf2 --- /dev/null +++ b/tests/rustdoc/macro/macro_pub_in_module.rs @@ -0,0 +1,86 @@ +//@ aux-build:macro_pub_in_module.rs +//@ edition:2018 +//@ build-aux-docs + +//! See issue #74355 +#![feature(decl_macro, no_core, rustc_attrs)] +#![crate_name = "krate"] +#![no_core] + +//@ has external_crate/some_module/macro.external_macro.html +//@ !has external_crate/macro.external_macro.html +extern crate external_crate; + +pub mod inner { + //@ has krate/inner/macro.raw_const.html + //@ !has krate/macro.raw_const.html + pub macro raw_const() {} + + //@ has krate/inner/attr.test.html + //@ !has krate/macro.test.html + //@ !has krate/inner/macro.test.html + //@ !has krate/attr.test.html + #[rustc_builtin_macro] + pub macro test($item:item) {} + + //@ has krate/inner/derive.Clone.html + //@ !has krate/inner/macro.Clone.html + //@ !has krate/macro.Clone.html + //@ !has krate/derive.Clone.html + #[rustc_builtin_macro] + pub macro Clone($item:item) {} + + // Make sure the logic is not affected by re-exports. + mod unrenamed { + //@ !has krate/macro.unrenamed.html + #[rustc_macro_transparency = "semitransparent"] + pub macro unrenamed() {} + } + //@ has krate/inner/macro.unrenamed.html + pub use unrenamed::unrenamed; + + mod private { + //@ !has krate/macro.m.html + pub macro m() {} + } + //@ has krate/inner/macro.renamed.html + //@ !has krate/macro.renamed.html + pub use private::m as renamed; + + mod private2 { + //@ !has krate/macro.m2.html + pub macro m2() {} + } + use private2 as renamed_mod; + //@ has krate/inner/macro.m2.html + pub use renamed_mod::m2; + + //@ has krate/inner/macro.external_macro.html + //@ !has krate/macro.external_macro.html + pub use ::external_crate::some_module::external_macro; +} + +// Namespaces: Make sure the logic does not mix up a function name with a module name… +fn both_fn_and_mod() { + //@ !has krate/macro.in_both_fn_and_mod.html + pub macro in_both_fn_and_mod() {} +} +pub mod both_fn_and_mod { + //@ !has krate/both_fn_and_mod/macro.in_both_fn_and_mod.html +} + +const __: () = { + //@ !has krate/macro.in_both_const_and_mod.html + pub macro in_both_const_and_mod() {} +}; +pub mod __ { + //@ !has krate/__/macro.in_both_const_and_mod.html +} + +enum Enum { + Crazy = { + //@ !has krate/macro.this_is_getting_weird.html; + pub macro this_is_getting_weird() {} + 42 + }, +} diff --git a/tests/rustdoc/macro/macro_rules-matchers.rs b/tests/rustdoc/macro/macro_rules-matchers.rs new file mode 100644 index 00000000000..2c9fb50539a --- /dev/null +++ b/tests/rustdoc/macro/macro_rules-matchers.rs @@ -0,0 +1,22 @@ +// This is a regression test for issue #86208. +// It is also a general test of macro_rules! display. + +#![crate_name = "foo"] + +//@ has 'foo/macro.todo.html' '//pre' 'macro_rules! todo { \ +// () => { ... }; \ +// ($($arg:tt)+) => { ... }; \ +// }' +pub use std::todo; + +mod mod1 { + //@ has 'foo/macro.macro1.html' '//pre' 'macro_rules! macro1 { \ + // () => { ... }; \ + // ($($arg:expr),+) => { ... }; \ + // }' + #[macro_export] + macro_rules! macro1 { + () => {}; + ($($arg:expr),+) => { stringify!($($arg),+) }; + } +} diff --git a/tests/rustdoc/macro/macros.rs b/tests/rustdoc/macro/macros.rs new file mode 100644 index 00000000000..d08babc25f8 --- /dev/null +++ b/tests/rustdoc/macro/macros.rs @@ -0,0 +1,24 @@ +//@ has macros/macro.my_macro.html //pre 'macro_rules! my_macro {' +//@ has - //pre '() => { ... };' +//@ has - //pre '($a:tt) => { ... };' +//@ has - //pre '($e:expr) => { ... };' +#[macro_export] +macro_rules! my_macro { + () => []; + ($a:tt) => (); + ($e:expr) => {}; +} + +// Check that exported macro defined in a module are shown at crate root. +//@ has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {' +//@ has - //pre '() => { ... };' +//@ has - //pre '($a:tt) => { ... };' +//@ has - //pre '($e:expr) => { ... };' +mod sub { + #[macro_export] + macro_rules! my_sub_macro { + () => {}; + ($a:tt) => {}; + ($e:expr) => {}; + } +} diff --git a/tests/rustdoc/macro/multiple-macro-rules-w-same-name-99221.rs b/tests/rustdoc/macro/multiple-macro-rules-w-same-name-99221.rs new file mode 100644 index 00000000000..4a1798a8496 --- /dev/null +++ b/tests/rustdoc/macro/multiple-macro-rules-w-same-name-99221.rs @@ -0,0 +1,18 @@ +//@ aux-build:issue-99221-aux.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/99221 +#![crate_name = "foo"] + +#[macro_use] +extern crate issue_99221_aux; + +pub use issue_99221_aux::*; + +//@ count foo/index.html '//a[@class="macro"]' 1 + +#[macro_export] +macro_rules! print { + () => () +} diff --git a/tests/rustdoc/macro/multiple-macro-rules-w-same-name-submodule-99221.rs b/tests/rustdoc/macro/multiple-macro-rules-w-same-name-submodule-99221.rs new file mode 100644 index 00000000000..bf59788073e --- /dev/null +++ b/tests/rustdoc/macro/multiple-macro-rules-w-same-name-submodule-99221.rs @@ -0,0 +1,20 @@ +//@ aux-build:issue-99221-aux.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/99221 +#![crate_name = "foo"] + +#[macro_use] +extern crate issue_99221_aux; + +pub use issue_99221_aux::*; + +//@ count foo/index.html '//a[@class="macro"]' 1 + +mod inner { + #[macro_export] + macro_rules! print { + () => () + } +} diff --git a/tests/rustdoc/macro/proc-macro.rs b/tests/rustdoc/macro/proc-macro.rs new file mode 100644 index 00000000000..a821f68ab93 --- /dev/null +++ b/tests/rustdoc/macro/proc-macro.rs @@ -0,0 +1,72 @@ +//@ force-host +//@ no-prefer-dynamic +//@ compile-flags: --crate-type proc-macro --document-private-items + +#![crate_type="proc-macro"] +#![crate_name="some_macros"] + +//@ has some_macros/index.html +//@ has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr' + +//! include a link to [some_proc_macro!] to make sure it works. + +extern crate proc_macro; + +use proc_macro::TokenStream; + +//@ has some_macros/index.html +//@ has - '//h2' 'Macros' +//@ has - '//h2' 'Attribute Macros' +//@ has - '//h2' 'Derive Macros' +//@ !has - '//h2' 'Functions' + +//@ has some_macros/all.html +//@ has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro' +//@ has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr' +//@ has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive' +//@ !has - '//a/@href' 'fn.some_proc_macro.html' +//@ !has - '//a/@href' 'fn.some_proc_attr.html' +//@ !has - '//a/@href' 'fn.some_derive.html' + +//@ has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html' +//@ !has - '//a/@href' 'fn.some_proc_macro.html' +//@ has some_macros/macro.some_proc_macro.html +//@ !has some_macros/fn.some_proc_macro.html +/// a proc-macro that swallows its input and does nothing. +#[proc_macro] +pub fn some_proc_macro(_input: TokenStream) -> TokenStream { + TokenStream::new() +} + +//@ has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html' +//@ !has - '//a/@href' 'fn.some_proc_attr.html' +//@ has some_macros/attr.some_proc_attr.html +//@ !has some_macros/fn.some_proc_attr.html +/// a proc-macro attribute that passes its item through verbatim. +#[proc_macro_attribute] +pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { + item +} + +//@ has some_macros/index.html '//a/@href' 'derive.SomeDerive.html' +//@ !has - '//a/@href' 'fn.some_derive.html' +//@ has some_macros/derive.SomeDerive.html +//@ !has some_macros/fn.some_derive.html +/// a derive attribute that adds nothing to its input. +#[proc_macro_derive(SomeDerive)] +pub fn some_derive(_item: TokenStream) -> TokenStream { + TokenStream::new() +} + +//@ has some_macros/foo/index.html +mod foo { + //@ has - '//code' 'pub use some_proc_macro;' + //@ has - '//a/@href' '../macro.some_proc_macro.html' + pub use some_proc_macro; + //@ has - '//code' 'pub use some_proc_attr;' + //@ has - '//a/@href' '../attr.some_proc_attr.html' + pub use some_proc_attr; + //@ has - '//code' 'pub use some_derive;' + //@ has - '//a/@href' '../derive.SomeDerive.html' + pub use some_derive; +} diff --git a/tests/rustdoc/macro/pub-use-extern-macros.rs b/tests/rustdoc/macro/pub-use-extern-macros.rs new file mode 100644 index 00000000000..2316e620343 --- /dev/null +++ b/tests/rustdoc/macro/pub-use-extern-macros.rs @@ -0,0 +1,17 @@ +//@ aux-build:pub-use-extern-macros.rs + +extern crate macros; + +//@ has pub_use_extern_macros/macro.bar.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;' +pub use macros::bar; + +//@ has pub_use_extern_macros/macro.baz.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;' +#[doc(inline)] +pub use macros::baz; + +//@ !has pub_use_extern_macros/macro.quux.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;' +#[doc(hidden)] +pub use macros::quux; diff --git a/tests/rustdoc/macro/rustc-macro-crate.rs b/tests/rustdoc/macro/rustc-macro-crate.rs new file mode 100644 index 00000000000..f0443364bb2 --- /dev/null +++ b/tests/rustdoc/macro/rustc-macro-crate.rs @@ -0,0 +1,14 @@ +//@ force-host +//@ no-prefer-dynamic +//@ compile-flags: --crate-type proc-macro + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Foo)] +pub fn foo(input: TokenStream) -> TokenStream { + input +} diff --git a/tests/rustdoc/macro_pub_in_module.rs b/tests/rustdoc/macro_pub_in_module.rs deleted file mode 100644 index 2dce73c2cf2..00000000000 --- a/tests/rustdoc/macro_pub_in_module.rs +++ /dev/null @@ -1,86 +0,0 @@ -//@ aux-build:macro_pub_in_module.rs -//@ edition:2018 -//@ build-aux-docs - -//! See issue #74355 -#![feature(decl_macro, no_core, rustc_attrs)] -#![crate_name = "krate"] -#![no_core] - -//@ has external_crate/some_module/macro.external_macro.html -//@ !has external_crate/macro.external_macro.html -extern crate external_crate; - -pub mod inner { - //@ has krate/inner/macro.raw_const.html - //@ !has krate/macro.raw_const.html - pub macro raw_const() {} - - //@ has krate/inner/attr.test.html - //@ !has krate/macro.test.html - //@ !has krate/inner/macro.test.html - //@ !has krate/attr.test.html - #[rustc_builtin_macro] - pub macro test($item:item) {} - - //@ has krate/inner/derive.Clone.html - //@ !has krate/inner/macro.Clone.html - //@ !has krate/macro.Clone.html - //@ !has krate/derive.Clone.html - #[rustc_builtin_macro] - pub macro Clone($item:item) {} - - // Make sure the logic is not affected by re-exports. - mod unrenamed { - //@ !has krate/macro.unrenamed.html - #[rustc_macro_transparency = "semitransparent"] - pub macro unrenamed() {} - } - //@ has krate/inner/macro.unrenamed.html - pub use unrenamed::unrenamed; - - mod private { - //@ !has krate/macro.m.html - pub macro m() {} - } - //@ has krate/inner/macro.renamed.html - //@ !has krate/macro.renamed.html - pub use private::m as renamed; - - mod private2 { - //@ !has krate/macro.m2.html - pub macro m2() {} - } - use private2 as renamed_mod; - //@ has krate/inner/macro.m2.html - pub use renamed_mod::m2; - - //@ has krate/inner/macro.external_macro.html - //@ !has krate/macro.external_macro.html - pub use ::external_crate::some_module::external_macro; -} - -// Namespaces: Make sure the logic does not mix up a function name with a module name… -fn both_fn_and_mod() { - //@ !has krate/macro.in_both_fn_and_mod.html - pub macro in_both_fn_and_mod() {} -} -pub mod both_fn_and_mod { - //@ !has krate/both_fn_and_mod/macro.in_both_fn_and_mod.html -} - -const __: () = { - //@ !has krate/macro.in_both_const_and_mod.html - pub macro in_both_const_and_mod() {} -}; -pub mod __ { - //@ !has krate/__/macro.in_both_const_and_mod.html -} - -enum Enum { - Crazy = { - //@ !has krate/macro.this_is_getting_weird.html; - pub macro this_is_getting_weird() {} - 42 - }, -} diff --git a/tests/rustdoc/macro_rules-matchers.rs b/tests/rustdoc/macro_rules-matchers.rs deleted file mode 100644 index 2c9fb50539a..00000000000 --- a/tests/rustdoc/macro_rules-matchers.rs +++ /dev/null @@ -1,22 +0,0 @@ -// This is a regression test for issue #86208. -// It is also a general test of macro_rules! display. - -#![crate_name = "foo"] - -//@ has 'foo/macro.todo.html' '//pre' 'macro_rules! todo { \ -// () => { ... }; \ -// ($($arg:tt)+) => { ... }; \ -// }' -pub use std::todo; - -mod mod1 { - //@ has 'foo/macro.macro1.html' '//pre' 'macro_rules! macro1 { \ - // () => { ... }; \ - // ($($arg:expr),+) => { ... }; \ - // }' - #[macro_export] - macro_rules! macro1 { - () => {}; - ($($arg:expr),+) => { stringify!($($arg),+) }; - } -} diff --git a/tests/rustdoc/macros.rs b/tests/rustdoc/macros.rs deleted file mode 100644 index d08babc25f8..00000000000 --- a/tests/rustdoc/macros.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ has macros/macro.my_macro.html //pre 'macro_rules! my_macro {' -//@ has - //pre '() => { ... };' -//@ has - //pre '($a:tt) => { ... };' -//@ has - //pre '($e:expr) => { ... };' -#[macro_export] -macro_rules! my_macro { - () => []; - ($a:tt) => (); - ($e:expr) => {}; -} - -// Check that exported macro defined in a module are shown at crate root. -//@ has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {' -//@ has - //pre '() => { ... };' -//@ has - //pre '($a:tt) => { ... };' -//@ has - //pre '($e:expr) => { ... };' -mod sub { - #[macro_export] - macro_rules! my_sub_macro { - () => {}; - ($a:tt) => {}; - ($e:expr) => {}; - } -} diff --git a/tests/rustdoc/multiple-macro-rules-w-same-name-99221.rs b/tests/rustdoc/multiple-macro-rules-w-same-name-99221.rs deleted file mode 100644 index 4a1798a8496..00000000000 --- a/tests/rustdoc/multiple-macro-rules-w-same-name-99221.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ aux-build:issue-99221-aux.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/99221 -#![crate_name = "foo"] - -#[macro_use] -extern crate issue_99221_aux; - -pub use issue_99221_aux::*; - -//@ count foo/index.html '//a[@class="macro"]' 1 - -#[macro_export] -macro_rules! print { - () => () -} diff --git a/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs b/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs deleted file mode 100644 index bf59788073e..00000000000 --- a/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build:issue-99221-aux.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/99221 -#![crate_name = "foo"] - -#[macro_use] -extern crate issue_99221_aux; - -pub use issue_99221_aux::*; - -//@ count foo/index.html '//a[@class="macro"]' 1 - -mod inner { - #[macro_export] - macro_rules! print { - () => () - } -} diff --git a/tests/rustdoc/proc-macro.rs b/tests/rustdoc/proc-macro.rs deleted file mode 100644 index a821f68ab93..00000000000 --- a/tests/rustdoc/proc-macro.rs +++ /dev/null @@ -1,72 +0,0 @@ -//@ force-host -//@ no-prefer-dynamic -//@ compile-flags: --crate-type proc-macro --document-private-items - -#![crate_type="proc-macro"] -#![crate_name="some_macros"] - -//@ has some_macros/index.html -//@ has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr' - -//! include a link to [some_proc_macro!] to make sure it works. - -extern crate proc_macro; - -use proc_macro::TokenStream; - -//@ has some_macros/index.html -//@ has - '//h2' 'Macros' -//@ has - '//h2' 'Attribute Macros' -//@ has - '//h2' 'Derive Macros' -//@ !has - '//h2' 'Functions' - -//@ has some_macros/all.html -//@ has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro' -//@ has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr' -//@ has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive' -//@ !has - '//a/@href' 'fn.some_proc_macro.html' -//@ !has - '//a/@href' 'fn.some_proc_attr.html' -//@ !has - '//a/@href' 'fn.some_derive.html' - -//@ has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html' -//@ !has - '//a/@href' 'fn.some_proc_macro.html' -//@ has some_macros/macro.some_proc_macro.html -//@ !has some_macros/fn.some_proc_macro.html -/// a proc-macro that swallows its input and does nothing. -#[proc_macro] -pub fn some_proc_macro(_input: TokenStream) -> TokenStream { - TokenStream::new() -} - -//@ has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html' -//@ !has - '//a/@href' 'fn.some_proc_attr.html' -//@ has some_macros/attr.some_proc_attr.html -//@ !has some_macros/fn.some_proc_attr.html -/// a proc-macro attribute that passes its item through verbatim. -#[proc_macro_attribute] -pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { - item -} - -//@ has some_macros/index.html '//a/@href' 'derive.SomeDerive.html' -//@ !has - '//a/@href' 'fn.some_derive.html' -//@ has some_macros/derive.SomeDerive.html -//@ !has some_macros/fn.some_derive.html -/// a derive attribute that adds nothing to its input. -#[proc_macro_derive(SomeDerive)] -pub fn some_derive(_item: TokenStream) -> TokenStream { - TokenStream::new() -} - -//@ has some_macros/foo/index.html -mod foo { - //@ has - '//code' 'pub use some_proc_macro;' - //@ has - '//a/@href' '../macro.some_proc_macro.html' - pub use some_proc_macro; - //@ has - '//code' 'pub use some_proc_attr;' - //@ has - '//a/@href' '../attr.some_proc_attr.html' - pub use some_proc_attr; - //@ has - '//code' 'pub use some_derive;' - //@ has - '//a/@href' '../derive.SomeDerive.html' - pub use some_derive; -} diff --git a/tests/rustdoc/pub-use-extern-macros.rs b/tests/rustdoc/pub-use-extern-macros.rs deleted file mode 100644 index 2316e620343..00000000000 --- a/tests/rustdoc/pub-use-extern-macros.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ aux-build:pub-use-extern-macros.rs - -extern crate macros; - -//@ has pub_use_extern_macros/macro.bar.html -//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;' -pub use macros::bar; - -//@ has pub_use_extern_macros/macro.baz.html -//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;' -#[doc(inline)] -pub use macros::baz; - -//@ !has pub_use_extern_macros/macro.quux.html -//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;' -#[doc(hidden)] -pub use macros::quux; diff --git a/tests/rustdoc/rustc-macro-crate.rs b/tests/rustdoc/rustc-macro-crate.rs deleted file mode 100644 index f0443364bb2..00000000000 --- a/tests/rustdoc/rustc-macro-crate.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ force-host -//@ no-prefer-dynamic -//@ compile-flags: --crate-type proc-macro - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Foo)] -pub fn foo(input: TokenStream) -> TokenStream { - input -} -- cgit 1.4.1-3-g733a5 From be71d8b24f1aebe9c45279d95a76db8fa6a62574 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 16:42:18 +0200 Subject: Created `tests/rustdoc/doc-cfg` subfolder to limit number of files at the top level --- tests/rustdoc/doc-cfg-hide.rs | 32 ---- tests/rustdoc/doc-cfg-implicit-gate.rs | 7 - tests/rustdoc/doc-cfg-implicit.rs | 31 ---- tests/rustdoc/doc-cfg-inherit-from-module-79201.rs | 44 ----- tests/rustdoc/doc-cfg-simplification.rs | 182 --------------------- tests/rustdoc/doc-cfg-target-feature.rs | 20 --- tests/rustdoc/doc-cfg-traits.rs | 124 -------------- tests/rustdoc/doc-cfg.rs | 101 ------------ tests/rustdoc/doc-cfg/doc-cfg-hide.rs | 32 ++++ tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs | 7 + tests/rustdoc/doc-cfg/doc-cfg-implicit.rs | 31 ++++ .../doc-cfg/doc-cfg-inherit-from-module-79201.rs | 44 +++++ tests/rustdoc/doc-cfg/doc-cfg-simplification.rs | 182 +++++++++++++++++++++ tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs | 20 +++ tests/rustdoc/doc-cfg/doc-cfg-traits.rs | 124 ++++++++++++++ tests/rustdoc/doc-cfg/doc-cfg.rs | 101 ++++++++++++ 16 files changed, 541 insertions(+), 541 deletions(-) delete mode 100644 tests/rustdoc/doc-cfg-hide.rs delete mode 100644 tests/rustdoc/doc-cfg-implicit-gate.rs delete mode 100644 tests/rustdoc/doc-cfg-implicit.rs delete mode 100644 tests/rustdoc/doc-cfg-inherit-from-module-79201.rs delete mode 100644 tests/rustdoc/doc-cfg-simplification.rs delete mode 100644 tests/rustdoc/doc-cfg-target-feature.rs delete mode 100644 tests/rustdoc/doc-cfg-traits.rs delete mode 100644 tests/rustdoc/doc-cfg.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-hide.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-implicit.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-simplification.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg-traits.rs create mode 100644 tests/rustdoc/doc-cfg/doc-cfg.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg-hide.rs deleted file mode 100644 index ceb1f99fae0..00000000000 --- a/tests/rustdoc/doc-cfg-hide.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![crate_name = "oud"] -#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)] - -#![doc(cfg_hide(feature = "solecism"))] - -//@ has 'oud/struct.Solecism.html' -//@ count - '//*[@class="stab portability"]' 0 -//@ compile-flags:--cfg feature="solecism" -#[cfg(feature = "solecism")] -pub struct Solecism; - -//@ has 'oud/struct.Scribacious.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature solecism' -#[cfg(feature = "solecism")] -#[doc(cfg(feature = "solecism"))] -pub struct Scribacious; - -//@ has 'oud/struct.Hyperdulia.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia' -//@ compile-flags:--cfg feature="hyperdulia" -#[cfg(feature = "solecism")] -#[cfg(feature = "hyperdulia")] -pub struct Hyperdulia; - -//@ has 'oud/struct.Oystercatcher.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only' -//@ compile-flags:--cfg feature="oystercatcher" -#[cfg(all(feature = "solecism", feature = "oystercatcher"))] -pub struct Oystercatcher; diff --git a/tests/rustdoc/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg-implicit-gate.rs deleted file mode 100644 index b5b8d0f427b..00000000000 --- a/tests/rustdoc/doc-cfg-implicit-gate.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags:--cfg feature="worricow" -#![crate_name = "xenogenous"] - -//@ has 'xenogenous/struct.Worricow.html' -//@ count - '//*[@class="stab portability"]' 0 -#[cfg(feature = "worricow")] -pub struct Worricow; diff --git a/tests/rustdoc/doc-cfg-implicit.rs b/tests/rustdoc/doc-cfg-implicit.rs deleted file mode 100644 index 69b10867ee3..00000000000 --- a/tests/rustdoc/doc-cfg-implicit.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![crate_name = "funambulism"] -#![feature(doc_auto_cfg, doc_cfg)] - -//@ has 'funambulism/struct.Disorbed.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature disorbed' -//@ compile-flags:--cfg feature="disorbed" -#[cfg(feature = "disorbed")] -pub struct Disorbed; - -//@ has 'funambulism/struct.Aesthesia.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature aesthesia' -//@ compile-flags:--cfg feature="aesthesia" -#[doc(cfg(feature = "aesthesia"))] -pub struct Aesthesia; - -//@ has 'funambulism/struct.Pliothermic.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' 'crate feature pliothermic' -//@ compile-flags:--cfg feature="epopoeist" -#[cfg(feature = "epopoeist")] -#[doc(cfg(feature = "pliothermic"))] -pub struct Pliothermic; - -//@ has 'funambulism/struct.Simillimum.html' -//@ count - '//*[@class="stab portability"]' 0 -//@ compile-flags:--cfg feature="simillimum" -#[cfg(feature = "simillimum")] -#[doc(cfg(all()))] -pub struct Simillimum; diff --git a/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs b/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs deleted file mode 100644 index 256e3b0015c..00000000000 --- a/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs +++ /dev/null @@ -1,44 +0,0 @@ -// https://github.com/rust-lang/rust/issues/79201 -#![crate_name="foo"] - -#![feature(doc_cfg)] - -//@ has 'foo/trait.Foo.html' -//@ count - '//*[@class="stab portability"]' 6 -//@ matches - '//*[@class="stab portability"]' 'crate feature foo-root' -//@ matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod' -//@ matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod' -//@ matches - '//*[@class="stab portability"]' 'crate feature foo-fn' -//@ matches - '//*[@class="stab portability"]' 'crate feature foo-method' - -pub trait Foo {} - -#[doc(cfg(feature = "foo-root"))] -impl crate::Foo for usize {} - -#[doc(cfg(feature = "foo-public-mod"))] -pub mod public { - impl crate::Foo for u8 {} -} - -#[doc(cfg(feature = "foo-private-mod"))] -mod private { - impl crate::Foo for u16 {} -} - -#[doc(cfg(feature = "foo-const"))] -const _: () = { - impl crate::Foo for u32 {} -}; - -#[doc(cfg(feature = "foo-fn"))] -fn __() { - impl crate::Foo for u64 {} -} - -#[doc(cfg(feature = "foo-method"))] -impl dyn Foo { - fn __() { - impl crate::Foo for u128 {} - } -} diff --git a/tests/rustdoc/doc-cfg-simplification.rs b/tests/rustdoc/doc-cfg-simplification.rs deleted file mode 100644 index ce70de289c6..00000000000 --- a/tests/rustdoc/doc-cfg-simplification.rs +++ /dev/null @@ -1,182 +0,0 @@ -#![crate_name = "globuliferous"] -#![feature(doc_cfg)] - -//@ has 'globuliferous/index.html' -//@ count - '//*[@class="stab portability"]' 1 -//@ matches - '//*[@class="stab portability"]' '^ratel$' - -//@ has 'globuliferous/ratel/index.html' -//@ count - '//*[@class="stab portability"]' 8 -//@ matches - '//*[@class="stab portability"]' 'crate feature ratel' -//@ matches - '//*[@class="stab portability"]' '^zoonosology$' -//@ matches - '//*[@class="stab portability"]' '^yusho$' -//@ matches - '//*[@class="stab portability"]' '^nunciative$' -//@ matches - '//*[@class="stab portability"]' '^thionic$' -//@ matches - '//*[@class="stab portability"]' '^zincic$' -//@ matches - '//*[@class="stab portability"]' '^cosmotellurian$' -//@ matches - '//*[@class="stab portability"]' '^aposiopesis$' -#[doc(cfg(feature = "ratel"))] -pub mod ratel { - //@ has 'globuliferous/ratel/fn.ovicide.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - pub fn ovicide() {} - - //@ has 'globuliferous/ratel/fn.zoonosology.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zoonosology' - #[doc(cfg(feature = "zoonosology"))] - pub fn zoonosology() {} - - //@ has 'globuliferous/ratel/constant.DIAGRAPHICS.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - pub const DIAGRAPHICS: () = (); - - //@ has 'globuliferous/ratel/constant.YUSHO.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and yusho' - #[doc(cfg(feature = "yusho"))] - pub const YUSHO: () = (); - - //@ has 'globuliferous/ratel/static.KEYBUGLE.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - pub static KEYBUGLE: () = (); - - //@ has 'globuliferous/ratel/static.NUNCIATIVE.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and nunciative' - #[doc(cfg(feature = "nunciative"))] - pub static NUNCIATIVE: () = (); - - //@ has 'globuliferous/ratel/type.Wrick.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - pub type Wrick = (); - - //@ has 'globuliferous/ratel/type.Thionic.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and thionic' - #[doc(cfg(feature = "thionic"))] - pub type Thionic = (); - - //@ has 'globuliferous/ratel/struct.Eventration.html' - //@ count - '//*[@class="stab portability"]' 1 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - pub struct Eventration; - - //@ has 'globuliferous/ratel/struct.Zincic.html' - //@ count - '//*[@class="stab portability"]' 2 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zincic' - //@ matches - '//*[@class="stab portability"]' 'crate feature rutherford' - #[doc(cfg(feature = "zincic"))] - pub struct Zincic { - pub rectigrade: (), - - #[doc(cfg(feature = "rutherford"))] - pub rutherford: (), - } - - //@ has 'globuliferous/ratel/enum.Cosmotellurian.html' - //@ count - '//*[@class="stab portability"]' 10 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and cosmotellurian' - //@ matches - '//*[@class="stab portability"]' 'crate feature biotaxy' - //@ matches - '//*[@class="stab portability"]' 'crate feature xiphopagus' - //@ matches - '//*[@class="stab portability"]' 'crate feature juxtapositive' - //@ matches - '//*[@class="stab portability"]' 'crate feature fuero' - //@ matches - '//*[@class="stab portability"]' 'crate feature palaeophile' - //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' - //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and xanthocomic' - //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' - //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and whosoever' - #[doc(cfg(feature = "cosmotellurian"))] - pub enum Cosmotellurian { - Groundsel { - jagger: (), - - #[doc(cfg(feature = "xiphopagus"))] - xiphopagus: (), - }, - - #[doc(cfg(feature = "biotaxy"))] - Biotaxy { - glossography: (), - - #[doc(cfg(feature = "juxtapositive"))] - juxtapositive: (), - }, - } - - impl Cosmotellurian { - pub fn uxoricide() {} - - #[doc(cfg(feature = "fuero"))] - pub fn fuero() {} - - pub const MAMELLE: () = (); - - #[doc(cfg(feature = "palaeophile"))] - pub const PALAEOPHILE: () = (); - } - - #[doc(cfg(feature = "broadcloth"))] - impl Cosmotellurian { - pub fn trabeculated() {} - - #[doc(cfg(feature = "xanthocomic"))] - pub fn xanthocomic() {} - - pub const BRACHIFEROUS: () = (); - - #[doc(cfg(feature = "whosoever"))] - pub const WHOSOEVER: () = (); - } - - //@ has 'globuliferous/ratel/trait.Gnotobiology.html' - //@ count - '//*[@class="stab portability"]' 4 - //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' - //@ matches - '//*[@class="stab portability"]' 'crate feature unzymotic' - //@ matches - '//*[@class="stab portability"]' 'crate feature summate' - //@ matches - '//*[@class="stab portability"]' 'crate feature unctuous' - pub trait Gnotobiology { - const XYLOTHERAPY: (); - - #[doc(cfg(feature = "unzymotic"))] - const UNZYMOTIC: (); - - type Lepadoid; - - #[doc(cfg(feature = "summate"))] - type Summate; - - fn decalcomania(); - - #[doc(cfg(feature = "unctuous"))] - fn unctuous(); - } - - //@ has 'globuliferous/ratel/trait.Aposiopesis.html' - //@ count - '//*[@class="stab portability"]' 4 - //@ matches - '//*[@class="stab portability"]' 'crate features ratel and aposiopesis' - //@ matches - '//*[@class="stab portability"]' 'crate feature umbracious' - //@ matches - '//*[@class="stab portability"]' 'crate feature uakari' - //@ matches - '//*[@class="stab portability"]' 'crate feature rotograph' - #[doc(cfg(feature = "aposiopesis"))] - pub trait Aposiopesis { - const REDHIBITION: (); - - #[doc(cfg(feature = "umbracious"))] - const UMBRACIOUS: (); - - type Ophthalmoscope; - - #[doc(cfg(feature = "uakari"))] - type Uakari; - - fn meseems(); - - #[doc(cfg(feature = "rotograph"))] - fn rotograph(); - } -} diff --git a/tests/rustdoc/doc-cfg-target-feature.rs b/tests/rustdoc/doc-cfg-target-feature.rs deleted file mode 100644 index b66e86e36af..00000000000 --- a/tests/rustdoc/doc-cfg-target-feature.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ only-x86_64 -//@ compile-flags:--test -//@ should-fail - -// #49723: rustdoc didn't add target features when extracting or running doctests - -#![feature(doc_cfg)] - -/// Foo -/// -/// # Examples -/// -/// ``` -/// #![feature(cfg_target_feature)] -/// -/// #[cfg(target_feature = "sse")] -/// assert!(false); -/// ``` -#[doc(cfg(target_feature = "sse"))] -pub unsafe fn foo() {} diff --git a/tests/rustdoc/doc-cfg-traits.rs b/tests/rustdoc/doc-cfg-traits.rs deleted file mode 100644 index 1256a7ae2c1..00000000000 --- a/tests/rustdoc/doc-cfg-traits.rs +++ /dev/null @@ -1,124 +0,0 @@ -#![crate_name = "myrmecophagous"] -#![feature(doc_cfg, associated_type_defaults)] - -//@ has 'myrmecophagous/index.html' -//@ count - '//*[@class="stab portability"]' 2 -//@ matches - '//*[@class="stab portability"]' '^jurisconsult$' -//@ matches - '//*[@class="stab portability"]' '^quarter$' - -pub trait Lea {} - -//@ has 'myrmecophagous/trait.Vortoscope.html' -//@ count - '//*[@class="stab portability"]' 6 -//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' -//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' -//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' -//@ matches - '//*[@class="stab portability"]' 'crate feature lea' -//@ matches - '//*[@class="stab portability"]' 'crate feature unit' -//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' -pub trait Vortoscope { - type Batology = (); - - #[doc(cfg(feature = "zibib"))] - type Zibib = (); - - const YAHRZEIT: () = (); - - #[doc(cfg(feature = "poriform"))] - const PORIFORM: () = (); - - fn javanais() {} - - #[doc(cfg(feature = "ethopoeia"))] - fn ethopoeia() {} -} - -#[doc(cfg(feature = "lea"))] -impl Vortoscope for T {} - -#[doc(cfg(feature = "unit"))] -impl Vortoscope for () {} - -//@ has 'myrmecophagous/trait.Jurisconsult.html' -//@ count - '//*[@class="stab portability"]' 7 -//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' -//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' -//@ matches - '//*[@class="stab portability"]' 'crate feature lea' -//@ matches - '//*[@class="stab portability"]' 'crate feature unit' -//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' -#[doc(cfg(feature = "jurisconsult"))] -pub trait Jurisconsult { - type Urbanist = (); - - #[doc(cfg(feature = "lithomancy"))] - type Lithomancy = (); - - const UNIFILAR: () = (); - - #[doc(cfg(feature = "boodle"))] - const BOODLE: () = (); - - fn mersion() {} - - #[doc(cfg(feature = "mistetch"))] - fn mistetch() {} -} - -#[doc(cfg(feature = "lea"))] -impl Jurisconsult for T {} - -#[doc(cfg(feature = "unit"))] -impl Jurisconsult for () {} - -//@ has 'myrmecophagous/struct.Ultimogeniture.html' -//@ count - '//*[@class="stab portability"]' 8 -// -//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' -//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' -//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' -// -//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' -//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' -// -//@ matches - '//*[@class="stab portability"]' 'crate feature copy' -#[derive(Clone)] -pub struct Ultimogeniture; - -impl Vortoscope for Ultimogeniture {} - -#[doc(cfg(feature = "jurisconsult"))] -impl Jurisconsult for Ultimogeniture {} - -#[doc(cfg(feature = "copy"))] -impl Copy for Ultimogeniture {} - -//@ has 'myrmecophagous/struct.Quarter.html' -//@ count - '//*[@class="stab portability"]' 9 -//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' -// -//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' -//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' -//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' -// -//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' -//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' -// -//@ matches - '//*[@class="stab portability"]' 'crate feature copy' -#[doc(cfg(feature = "quarter"))] -#[derive(Clone)] -pub struct Quarter; - -#[doc(cfg(feature = "quarter"))] -impl Vortoscope for Quarter {} - -#[doc(cfg(all(feature = "jurisconsult", feature = "quarter")))] -impl Jurisconsult for Quarter {} - -#[doc(cfg(all(feature = "copy", feature = "quarter")))] -impl Copy for Quarter {} diff --git a/tests/rustdoc/doc-cfg.rs b/tests/rustdoc/doc-cfg.rs deleted file mode 100644 index 652c8419b4f..00000000000 --- a/tests/rustdoc/doc-cfg.rs +++ /dev/null @@ -1,101 +0,0 @@ -#![feature(doc_cfg)] -#![feature(target_feature, cfg_target_feature)] - -//@ has doc_cfg/struct.Portable.html -//@ !has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' '' -//@ has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()' -//@ has - '//*[@class="stab portability"]' 'Available on Unix and ARM only.' -//@ has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()' -//@ has - '//*[@class="stab portability"]' 'Available on WASI and WebAssembly only.' -pub struct Portable; - -//@ has doc_cfg/unix_only/index.html \ -// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ -// 'Available on Unix only.' -//@ matches - '//dt//*[@class="stab portability"]' '\AARM\Z' -//@ count - '//*[@class="stab portability"]' 2 -#[doc(cfg(unix))] -pub mod unix_only { - //@ has doc_cfg/unix_only/fn.unix_only_function.html \ - // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on Unix only.' - //@ count - '//*[@class="stab portability"]' 1 - pub fn unix_only_function() { - content::should::be::irrelevant(); - } - - //@ has doc_cfg/unix_only/trait.ArmOnly.html \ - // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on Unix and ARM only.' - //@ count - '//*[@class="stab portability"]' 1 - #[doc(cfg(target_arch = "arm"))] - pub trait ArmOnly { - fn unix_and_arm_only_function(); - } - - #[doc(cfg(target_arch = "arm"))] - impl ArmOnly for super::Portable { - fn unix_and_arm_only_function() {} - } -} - -//@ has doc_cfg/wasi_only/index.html \ -// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ -// 'Available on WASI only.' -//@ matches - '//dt//*[@class="stab portability"]' '\AWebAssembly\Z' -//@ count - '//*[@class="stab portability"]' 2 -#[doc(cfg(target_os = "wasi"))] -pub mod wasi_only { - //@ has doc_cfg/wasi_only/fn.wasi_only_function.html \ - // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on WASI only.' - //@ count - '//*[@class="stab portability"]' 1 - pub fn wasi_only_function() { - content::should::be::irrelevant(); - } - - //@ has doc_cfg/wasi_only/trait.Wasm32Only.html \ - // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ - // 'Available on WASI and WebAssembly only.' - //@ count - '//*[@class="stab portability"]' 1 - #[doc(cfg(target_arch = "wasm32"))] - pub trait Wasm32Only { - fn wasi_and_wasm32_only_function(); - } - - #[doc(cfg(target_arch = "wasm32"))] - impl Wasm32Only for super::Portable { - fn wasi_and_wasm32_only_function() {} - } -} - -// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that -// item as well - -// the portability header is different on the module view versus the full view -//@ has doc_cfg/index.html -//@ matches - '//dt//*[@class="stab portability"]' '\Aavx\Z' - -//@ has doc_cfg/fn.uses_target_feature.html -//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ -// 'Available with target feature avx only.' -#[target_feature(enable = "avx")] -pub unsafe fn uses_target_feature() { - content::should::be::irrelevant(); -} - -//@ has doc_cfg/fn.uses_cfg_target_feature.html -//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ -// 'Available with target feature avx only.' -#[doc(cfg(target_feature = "avx"))] -pub fn uses_cfg_target_feature() { - uses_target_feature(); -} - -// multiple attributes should be allowed -//@ has doc_cfg/fn.multiple_attrs.html \ -// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ -// 'Available on x and y and z only.' -#[doc(cfg(x))] -#[doc(cfg(y), cfg(z))] -pub fn multiple_attrs() {} diff --git a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs new file mode 100644 index 00000000000..ceb1f99fae0 --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs @@ -0,0 +1,32 @@ +#![crate_name = "oud"] +#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)] + +#![doc(cfg_hide(feature = "solecism"))] + +//@ has 'oud/struct.Solecism.html' +//@ count - '//*[@class="stab portability"]' 0 +//@ compile-flags:--cfg feature="solecism" +#[cfg(feature = "solecism")] +pub struct Solecism; + +//@ has 'oud/struct.Scribacious.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature solecism' +#[cfg(feature = "solecism")] +#[doc(cfg(feature = "solecism"))] +pub struct Scribacious; + +//@ has 'oud/struct.Hyperdulia.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia' +//@ compile-flags:--cfg feature="hyperdulia" +#[cfg(feature = "solecism")] +#[cfg(feature = "hyperdulia")] +pub struct Hyperdulia; + +//@ has 'oud/struct.Oystercatcher.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only' +//@ compile-flags:--cfg feature="oystercatcher" +#[cfg(all(feature = "solecism", feature = "oystercatcher"))] +pub struct Oystercatcher; diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs new file mode 100644 index 00000000000..b5b8d0f427b --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs @@ -0,0 +1,7 @@ +//@ compile-flags:--cfg feature="worricow" +#![crate_name = "xenogenous"] + +//@ has 'xenogenous/struct.Worricow.html' +//@ count - '//*[@class="stab portability"]' 0 +#[cfg(feature = "worricow")] +pub struct Worricow; diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs new file mode 100644 index 00000000000..69b10867ee3 --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs @@ -0,0 +1,31 @@ +#![crate_name = "funambulism"] +#![feature(doc_auto_cfg, doc_cfg)] + +//@ has 'funambulism/struct.Disorbed.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature disorbed' +//@ compile-flags:--cfg feature="disorbed" +#[cfg(feature = "disorbed")] +pub struct Disorbed; + +//@ has 'funambulism/struct.Aesthesia.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature aesthesia' +//@ compile-flags:--cfg feature="aesthesia" +#[doc(cfg(feature = "aesthesia"))] +pub struct Aesthesia; + +//@ has 'funambulism/struct.Pliothermic.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature pliothermic' +//@ compile-flags:--cfg feature="epopoeist" +#[cfg(feature = "epopoeist")] +#[doc(cfg(feature = "pliothermic"))] +pub struct Pliothermic; + +//@ has 'funambulism/struct.Simillimum.html' +//@ count - '//*[@class="stab portability"]' 0 +//@ compile-flags:--cfg feature="simillimum" +#[cfg(feature = "simillimum")] +#[doc(cfg(all()))] +pub struct Simillimum; diff --git a/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs new file mode 100644 index 00000000000..256e3b0015c --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs @@ -0,0 +1,44 @@ +// https://github.com/rust-lang/rust/issues/79201 +#![crate_name="foo"] + +#![feature(doc_cfg)] + +//@ has 'foo/trait.Foo.html' +//@ count - '//*[@class="stab portability"]' 6 +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-root' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-fn' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-method' + +pub trait Foo {} + +#[doc(cfg(feature = "foo-root"))] +impl crate::Foo for usize {} + +#[doc(cfg(feature = "foo-public-mod"))] +pub mod public { + impl crate::Foo for u8 {} +} + +#[doc(cfg(feature = "foo-private-mod"))] +mod private { + impl crate::Foo for u16 {} +} + +#[doc(cfg(feature = "foo-const"))] +const _: () = { + impl crate::Foo for u32 {} +}; + +#[doc(cfg(feature = "foo-fn"))] +fn __() { + impl crate::Foo for u64 {} +} + +#[doc(cfg(feature = "foo-method"))] +impl dyn Foo { + fn __() { + impl crate::Foo for u128 {} + } +} diff --git a/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs new file mode 100644 index 00000000000..ce70de289c6 --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs @@ -0,0 +1,182 @@ +#![crate_name = "globuliferous"] +#![feature(doc_cfg)] + +//@ has 'globuliferous/index.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' '^ratel$' + +//@ has 'globuliferous/ratel/index.html' +//@ count - '//*[@class="stab portability"]' 8 +//@ matches - '//*[@class="stab portability"]' 'crate feature ratel' +//@ matches - '//*[@class="stab portability"]' '^zoonosology$' +//@ matches - '//*[@class="stab portability"]' '^yusho$' +//@ matches - '//*[@class="stab portability"]' '^nunciative$' +//@ matches - '//*[@class="stab portability"]' '^thionic$' +//@ matches - '//*[@class="stab portability"]' '^zincic$' +//@ matches - '//*[@class="stab portability"]' '^cosmotellurian$' +//@ matches - '//*[@class="stab portability"]' '^aposiopesis$' +#[doc(cfg(feature = "ratel"))] +pub mod ratel { + //@ has 'globuliferous/ratel/fn.ovicide.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + pub fn ovicide() {} + + //@ has 'globuliferous/ratel/fn.zoonosology.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zoonosology' + #[doc(cfg(feature = "zoonosology"))] + pub fn zoonosology() {} + + //@ has 'globuliferous/ratel/constant.DIAGRAPHICS.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + pub const DIAGRAPHICS: () = (); + + //@ has 'globuliferous/ratel/constant.YUSHO.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and yusho' + #[doc(cfg(feature = "yusho"))] + pub const YUSHO: () = (); + + //@ has 'globuliferous/ratel/static.KEYBUGLE.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + pub static KEYBUGLE: () = (); + + //@ has 'globuliferous/ratel/static.NUNCIATIVE.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and nunciative' + #[doc(cfg(feature = "nunciative"))] + pub static NUNCIATIVE: () = (); + + //@ has 'globuliferous/ratel/type.Wrick.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + pub type Wrick = (); + + //@ has 'globuliferous/ratel/type.Thionic.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and thionic' + #[doc(cfg(feature = "thionic"))] + pub type Thionic = (); + + //@ has 'globuliferous/ratel/struct.Eventration.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + pub struct Eventration; + + //@ has 'globuliferous/ratel/struct.Zincic.html' + //@ count - '//*[@class="stab portability"]' 2 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zincic' + //@ matches - '//*[@class="stab portability"]' 'crate feature rutherford' + #[doc(cfg(feature = "zincic"))] + pub struct Zincic { + pub rectigrade: (), + + #[doc(cfg(feature = "rutherford"))] + pub rutherford: (), + } + + //@ has 'globuliferous/ratel/enum.Cosmotellurian.html' + //@ count - '//*[@class="stab portability"]' 10 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and cosmotellurian' + //@ matches - '//*[@class="stab portability"]' 'crate feature biotaxy' + //@ matches - '//*[@class="stab portability"]' 'crate feature xiphopagus' + //@ matches - '//*[@class="stab portability"]' 'crate feature juxtapositive' + //@ matches - '//*[@class="stab portability"]' 'crate feature fuero' + //@ matches - '//*[@class="stab portability"]' 'crate feature palaeophile' + //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' + //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and xanthocomic' + //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' + //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and whosoever' + #[doc(cfg(feature = "cosmotellurian"))] + pub enum Cosmotellurian { + Groundsel { + jagger: (), + + #[doc(cfg(feature = "xiphopagus"))] + xiphopagus: (), + }, + + #[doc(cfg(feature = "biotaxy"))] + Biotaxy { + glossography: (), + + #[doc(cfg(feature = "juxtapositive"))] + juxtapositive: (), + }, + } + + impl Cosmotellurian { + pub fn uxoricide() {} + + #[doc(cfg(feature = "fuero"))] + pub fn fuero() {} + + pub const MAMELLE: () = (); + + #[doc(cfg(feature = "palaeophile"))] + pub const PALAEOPHILE: () = (); + } + + #[doc(cfg(feature = "broadcloth"))] + impl Cosmotellurian { + pub fn trabeculated() {} + + #[doc(cfg(feature = "xanthocomic"))] + pub fn xanthocomic() {} + + pub const BRACHIFEROUS: () = (); + + #[doc(cfg(feature = "whosoever"))] + pub const WHOSOEVER: () = (); + } + + //@ has 'globuliferous/ratel/trait.Gnotobiology.html' + //@ count - '//*[@class="stab portability"]' 4 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ matches - '//*[@class="stab portability"]' 'crate feature unzymotic' + //@ matches - '//*[@class="stab portability"]' 'crate feature summate' + //@ matches - '//*[@class="stab portability"]' 'crate feature unctuous' + pub trait Gnotobiology { + const XYLOTHERAPY: (); + + #[doc(cfg(feature = "unzymotic"))] + const UNZYMOTIC: (); + + type Lepadoid; + + #[doc(cfg(feature = "summate"))] + type Summate; + + fn decalcomania(); + + #[doc(cfg(feature = "unctuous"))] + fn unctuous(); + } + + //@ has 'globuliferous/ratel/trait.Aposiopesis.html' + //@ count - '//*[@class="stab portability"]' 4 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and aposiopesis' + //@ matches - '//*[@class="stab portability"]' 'crate feature umbracious' + //@ matches - '//*[@class="stab portability"]' 'crate feature uakari' + //@ matches - '//*[@class="stab portability"]' 'crate feature rotograph' + #[doc(cfg(feature = "aposiopesis"))] + pub trait Aposiopesis { + const REDHIBITION: (); + + #[doc(cfg(feature = "umbracious"))] + const UMBRACIOUS: (); + + type Ophthalmoscope; + + #[doc(cfg(feature = "uakari"))] + type Uakari; + + fn meseems(); + + #[doc(cfg(feature = "rotograph"))] + fn rotograph(); + } +} diff --git a/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs new file mode 100644 index 00000000000..b66e86e36af --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs @@ -0,0 +1,20 @@ +//@ only-x86_64 +//@ compile-flags:--test +//@ should-fail + +// #49723: rustdoc didn't add target features when extracting or running doctests + +#![feature(doc_cfg)] + +/// Foo +/// +/// # Examples +/// +/// ``` +/// #![feature(cfg_target_feature)] +/// +/// #[cfg(target_feature = "sse")] +/// assert!(false); +/// ``` +#[doc(cfg(target_feature = "sse"))] +pub unsafe fn foo() {} diff --git a/tests/rustdoc/doc-cfg/doc-cfg-traits.rs b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs new file mode 100644 index 00000000000..1256a7ae2c1 --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs @@ -0,0 +1,124 @@ +#![crate_name = "myrmecophagous"] +#![feature(doc_cfg, associated_type_defaults)] + +//@ has 'myrmecophagous/index.html' +//@ count - '//*[@class="stab portability"]' 2 +//@ matches - '//*[@class="stab portability"]' '^jurisconsult$' +//@ matches - '//*[@class="stab portability"]' '^quarter$' + +pub trait Lea {} + +//@ has 'myrmecophagous/trait.Vortoscope.html' +//@ count - '//*[@class="stab portability"]' 6 +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +//@ matches - '//*[@class="stab portability"]' 'crate feature lea' +//@ matches - '//*[@class="stab portability"]' 'crate feature unit' +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' +pub trait Vortoscope { + type Batology = (); + + #[doc(cfg(feature = "zibib"))] + type Zibib = (); + + const YAHRZEIT: () = (); + + #[doc(cfg(feature = "poriform"))] + const PORIFORM: () = (); + + fn javanais() {} + + #[doc(cfg(feature = "ethopoeia"))] + fn ethopoeia() {} +} + +#[doc(cfg(feature = "lea"))] +impl Vortoscope for T {} + +#[doc(cfg(feature = "unit"))] +impl Vortoscope for () {} + +//@ has 'myrmecophagous/trait.Jurisconsult.html' +//@ count - '//*[@class="stab portability"]' 7 +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' +//@ matches - '//*[@class="stab portability"]' 'crate feature lea' +//@ matches - '//*[@class="stab portability"]' 'crate feature unit' +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' +#[doc(cfg(feature = "jurisconsult"))] +pub trait Jurisconsult { + type Urbanist = (); + + #[doc(cfg(feature = "lithomancy"))] + type Lithomancy = (); + + const UNIFILAR: () = (); + + #[doc(cfg(feature = "boodle"))] + const BOODLE: () = (); + + fn mersion() {} + + #[doc(cfg(feature = "mistetch"))] + fn mistetch() {} +} + +#[doc(cfg(feature = "lea"))] +impl Jurisconsult for T {} + +#[doc(cfg(feature = "unit"))] +impl Jurisconsult for () {} + +//@ has 'myrmecophagous/struct.Ultimogeniture.html' +//@ count - '//*[@class="stab portability"]' 8 +// +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +// +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' +// +//@ matches - '//*[@class="stab portability"]' 'crate feature copy' +#[derive(Clone)] +pub struct Ultimogeniture; + +impl Vortoscope for Ultimogeniture {} + +#[doc(cfg(feature = "jurisconsult"))] +impl Jurisconsult for Ultimogeniture {} + +#[doc(cfg(feature = "copy"))] +impl Copy for Ultimogeniture {} + +//@ has 'myrmecophagous/struct.Quarter.html' +//@ count - '//*[@class="stab portability"]' 9 +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' +// +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +// +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' +// +//@ matches - '//*[@class="stab portability"]' 'crate feature copy' +#[doc(cfg(feature = "quarter"))] +#[derive(Clone)] +pub struct Quarter; + +#[doc(cfg(feature = "quarter"))] +impl Vortoscope for Quarter {} + +#[doc(cfg(all(feature = "jurisconsult", feature = "quarter")))] +impl Jurisconsult for Quarter {} + +#[doc(cfg(all(feature = "copy", feature = "quarter")))] +impl Copy for Quarter {} diff --git a/tests/rustdoc/doc-cfg/doc-cfg.rs b/tests/rustdoc/doc-cfg/doc-cfg.rs new file mode 100644 index 00000000000..652c8419b4f --- /dev/null +++ b/tests/rustdoc/doc-cfg/doc-cfg.rs @@ -0,0 +1,101 @@ +#![feature(doc_cfg)] +#![feature(target_feature, cfg_target_feature)] + +//@ has doc_cfg/struct.Portable.html +//@ !has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' '' +//@ has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()' +//@ has - '//*[@class="stab portability"]' 'Available on Unix and ARM only.' +//@ has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()' +//@ has - '//*[@class="stab portability"]' 'Available on WASI and WebAssembly only.' +pub struct Portable; + +//@ has doc_cfg/unix_only/index.html \ +// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available on Unix only.' +//@ matches - '//dt//*[@class="stab portability"]' '\AARM\Z' +//@ count - '//*[@class="stab portability"]' 2 +#[doc(cfg(unix))] +pub mod unix_only { + //@ has doc_cfg/unix_only/fn.unix_only_function.html \ + // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on Unix only.' + //@ count - '//*[@class="stab portability"]' 1 + pub fn unix_only_function() { + content::should::be::irrelevant(); + } + + //@ has doc_cfg/unix_only/trait.ArmOnly.html \ + // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on Unix and ARM only.' + //@ count - '//*[@class="stab portability"]' 1 + #[doc(cfg(target_arch = "arm"))] + pub trait ArmOnly { + fn unix_and_arm_only_function(); + } + + #[doc(cfg(target_arch = "arm"))] + impl ArmOnly for super::Portable { + fn unix_and_arm_only_function() {} + } +} + +//@ has doc_cfg/wasi_only/index.html \ +// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available on WASI only.' +//@ matches - '//dt//*[@class="stab portability"]' '\AWebAssembly\Z' +//@ count - '//*[@class="stab portability"]' 2 +#[doc(cfg(target_os = "wasi"))] +pub mod wasi_only { + //@ has doc_cfg/wasi_only/fn.wasi_only_function.html \ + // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on WASI only.' + //@ count - '//*[@class="stab portability"]' 1 + pub fn wasi_only_function() { + content::should::be::irrelevant(); + } + + //@ has doc_cfg/wasi_only/trait.Wasm32Only.html \ + // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on WASI and WebAssembly only.' + //@ count - '//*[@class="stab portability"]' 1 + #[doc(cfg(target_arch = "wasm32"))] + pub trait Wasm32Only { + fn wasi_and_wasm32_only_function(); + } + + #[doc(cfg(target_arch = "wasm32"))] + impl Wasm32Only for super::Portable { + fn wasi_and_wasm32_only_function() {} + } +} + +// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that +// item as well + +// the portability header is different on the module view versus the full view +//@ has doc_cfg/index.html +//@ matches - '//dt//*[@class="stab portability"]' '\Aavx\Z' + +//@ has doc_cfg/fn.uses_target_feature.html +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available with target feature avx only.' +#[target_feature(enable = "avx")] +pub unsafe fn uses_target_feature() { + content::should::be::irrelevant(); +} + +//@ has doc_cfg/fn.uses_cfg_target_feature.html +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available with target feature avx only.' +#[doc(cfg(target_feature = "avx"))] +pub fn uses_cfg_target_feature() { + uses_target_feature(); +} + +// multiple attributes should be allowed +//@ has doc_cfg/fn.multiple_attrs.html \ +// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available on x and y and z only.' +#[doc(cfg(x))] +#[doc(cfg(y), cfg(z))] +pub fn multiple_attrs() {} -- cgit 1.4.1-3-g733a5 From b84f4cc39e99f801dcd37125dffa67eb796c85b8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:01:08 +0200 Subject: Created `tests/rustdoc/impl` subfolder to limit number of files at the top level --- tests/rustdoc/assoc-consts-underscore.rs | 30 ------ tests/rustdoc/assoc-consts-version.rs | 15 --- tests/rustdoc/assoc-consts.rs | 103 ------------------ tests/rustdoc/associated-consts.rs | 51 --------- .../auxiliary/cross-crate-hidden-impl-parameter.rs | 5 - tests/rustdoc/auxiliary/extern-impl-trait.rs | 27 ----- tests/rustdoc/auxiliary/incoherent-impl-types.rs | 7 -- tests/rustdoc/auxiliary/issue-100204-aux.rs | 13 --- tests/rustdoc/auxiliary/issue-17476.rs | 7 -- tests/rustdoc/auxiliary/issue-21092.rs | 12 --- tests/rustdoc/auxiliary/issue-22025.rs | 10 -- tests/rustdoc/auxiliary/issue-53689.rs | 1 - tests/rustdoc/auxiliary/precise-capturing.rs | 7 -- tests/rustdoc/auxiliary/real_gimli.rs | 13 --- tests/rustdoc/auxiliary/realcore.rs | 15 --- tests/rustdoc/auxiliary/rustdoc-default-impl.rs | 23 ---- .../auxiliary/rustdoc-impl-parts-crosscrate.rs | 3 - tests/rustdoc/blanket-impl-29503.rs | 21 ---- tests/rustdoc/blanket-impl-78673.rs | 25 ----- tests/rustdoc/const-display.rs | 92 ---------------- tests/rustdoc/const-doc.rs | 19 ---- tests/rustdoc/const-effect-param.rs | 14 --- tests/rustdoc/const-underscore.rs | 7 -- tests/rustdoc/const-value-display.rs | 9 -- tests/rustdoc/const.rs | 10 -- tests/rustdoc/constant/assoc-consts-underscore.rs | 30 ++++++ tests/rustdoc/constant/assoc-consts-version.rs | 15 +++ tests/rustdoc/constant/assoc-consts.rs | 103 ++++++++++++++++++ tests/rustdoc/constant/associated-consts.rs | 51 +++++++++ tests/rustdoc/constant/const-display.rs | 92 ++++++++++++++++ tests/rustdoc/constant/const-doc.rs | 19 ++++ tests/rustdoc/constant/const-effect-param.rs | 14 +++ tests/rustdoc/constant/const-underscore.rs | 7 ++ tests/rustdoc/constant/const-value-display.rs | 9 ++ tests/rustdoc/constant/const.rs | 10 ++ ...t-item-with-associated-const-in-where-clause.rs | 17 +++ tests/rustdoc/constant/generic-const-items.rs | 38 +++++++ tests/rustdoc/constant/generic_const_exprs.rs | 24 +++++ tests/rustdoc/constant/glob-shadowing-const.rs | 20 ++++ .../hide-complex-unevaluated-const-arguments.rs | 91 ++++++++++++++++ .../constant/hide-complex-unevaluated-consts.rs | 71 +++++++++++++ .../ice-associated-const-equality-105952.rs | 15 +++ tests/rustdoc/constant/legacy-const-generic.rs | 16 +++ tests/rustdoc/constant/link-assoc-const.rs | 16 +++ tests/rustdoc/constant/redirect-const.rs | 13 +++ .../rustdoc/constant/rfc-2632-const-trait-impl.rs | 73 +++++++++++++ tests/rustdoc/constant/show-const-contents.rs | 68 ++++++++++++ tests/rustdoc/cross-crate-hidden-impl-parameter.rs | 35 ------ .../rustdoc/deduplicate-glob-import-impl-21474.rs | 14 --- tests/rustdoc/deduplicate-trait-impl-22025.rs | 9 -- tests/rustdoc/default-impl.rs | 9 -- tests/rustdoc/deprecated-impls.rs | 118 --------------------- .../rustdoc/doc-hidden-trait-implementors-33069.rs | 13 --- tests/rustdoc/doc_auto_cfg_nested_impl.rs | 24 ----- ...t-item-with-associated-const-in-where-clause.rs | 17 --- tests/rustdoc/duplicated_impl.rs | 14 --- tests/rustdoc/empty-impl-block.rs | 20 ---- tests/rustdoc/empty-impls.rs | 19 ---- tests/rustdoc/extern-impl-trait.rs | 11 -- tests/rustdoc/extern-impl.rs | 27 ----- tests/rustdoc/foreign-implementors-js-43701.rs | 6 -- tests/rustdoc/generic-const-items.rs | 38 ------- tests/rustdoc/generic-impl.rs | 16 --- tests/rustdoc/generic_const_exprs.rs | 24 ----- tests/rustdoc/glob-shadowing-const.rs | 20 ---- tests/rustdoc/hidden-implementors-90781.rs | 78 -------------- tests/rustdoc/hidden-impls.rs | 17 --- tests/rustdoc/hidden-trait-struct-impls.rs | 22 ---- .../hide-complex-unevaluated-const-arguments.rs | 91 ---------------- tests/rustdoc/hide-complex-unevaluated-consts.rs | 71 ------------- .../hide-mut-methods-if-no-derefmut-impl-74083.rs | 24 ----- .../ice-associated-const-equality-105952.rs | 15 --- tests/rustdoc/impl-alias-substituted.rs | 9 -- tests/rustdoc/impl-assoc-type-21092.rs | 11 -- tests/rustdoc/impl-associated-items-order.rs | 42 -------- tests/rustdoc/impl-associated-items-sidebar.rs | 42 -------- tests/rustdoc/impl-blanket-53689.rs | 17 --- tests/rustdoc/impl-box.rs | 16 --- tests/rustdoc/impl-disambiguation.rs | 30 ------ tests/rustdoc/impl-everywhere.rs | 30 ------ tests/rustdoc/impl-in-const-block.rs | 43 -------- tests/rustdoc/impl-on-ty-alias-issue-119015.rs | 27 ----- tests/rustdoc/impl-parts-crosscrate.rs | 20 ---- tests/rustdoc/impl-parts.rs | 12 --- tests/rustdoc/impl-ref-20175.rs | 14 --- tests/rustdoc/impl-trait-43869.rs | 75 ------------- tests/rustdoc/impl-trait-alias.rs | 14 --- tests/rustdoc/impl-trait-precise-capturing.rs | 26 ----- tests/rustdoc/impl-type-parameter-33592.rs | 14 --- .../auxiliary/cross-crate-hidden-impl-parameter.rs | 5 + tests/rustdoc/impl/auxiliary/extern-impl-trait.rs | 27 +++++ .../impl/auxiliary/incoherent-impl-types.rs | 7 ++ tests/rustdoc/impl/auxiliary/issue-100204-aux.rs | 13 +++ tests/rustdoc/impl/auxiliary/issue-17476.rs | 7 ++ tests/rustdoc/impl/auxiliary/issue-21092.rs | 12 +++ tests/rustdoc/impl/auxiliary/issue-22025.rs | 10 ++ tests/rustdoc/impl/auxiliary/issue-53689.rs | 1 + tests/rustdoc/impl/auxiliary/precise-capturing.rs | 7 ++ tests/rustdoc/impl/auxiliary/real_gimli.rs | 13 +++ tests/rustdoc/impl/auxiliary/realcore.rs | 15 +++ .../rustdoc/impl/auxiliary/rustdoc-default-impl.rs | 23 ++++ .../auxiliary/rustdoc-impl-parts-crosscrate.rs | 3 + tests/rustdoc/impl/blanket-impl-29503.rs | 21 ++++ tests/rustdoc/impl/blanket-impl-78673.rs | 25 +++++ .../impl/cross-crate-hidden-impl-parameter.rs | 35 ++++++ .../impl/deduplicate-glob-import-impl-21474.rs | 14 +++ tests/rustdoc/impl/deduplicate-trait-impl-22025.rs | 9 ++ tests/rustdoc/impl/default-impl.rs | 9 ++ tests/rustdoc/impl/deprecated-impls.rs | 118 +++++++++++++++++++++ .../impl/doc-hidden-trait-implementors-33069.rs | 13 +++ tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs | 24 +++++ tests/rustdoc/impl/duplicated_impl.rs | 14 +++ tests/rustdoc/impl/empty-impl-block.rs | 20 ++++ tests/rustdoc/impl/empty-impls.rs | 19 ++++ tests/rustdoc/impl/extern-impl-trait.rs | 11 ++ tests/rustdoc/impl/extern-impl.rs | 27 +++++ .../rustdoc/impl/foreign-implementors-js-43701.rs | 6 ++ tests/rustdoc/impl/generic-impl.rs | 16 +++ tests/rustdoc/impl/hidden-implementors-90781.rs | 78 ++++++++++++++ tests/rustdoc/impl/hidden-impls.rs | 17 +++ tests/rustdoc/impl/hidden-trait-struct-impls.rs | 22 ++++ .../hide-mut-methods-if-no-derefmut-impl-74083.rs | 24 +++++ tests/rustdoc/impl/impl-alias-substituted.rs | 9 ++ tests/rustdoc/impl/impl-assoc-type-21092.rs | 11 ++ tests/rustdoc/impl/impl-associated-items-order.rs | 42 ++++++++ .../rustdoc/impl/impl-associated-items-sidebar.rs | 42 ++++++++ tests/rustdoc/impl/impl-blanket-53689.rs | 17 +++ tests/rustdoc/impl/impl-box.rs | 16 +++ tests/rustdoc/impl/impl-disambiguation.rs | 30 ++++++ tests/rustdoc/impl/impl-everywhere.rs | 30 ++++++ tests/rustdoc/impl/impl-in-const-block.rs | 43 ++++++++ .../rustdoc/impl/impl-on-ty-alias-issue-119015.rs | 27 +++++ tests/rustdoc/impl/impl-parts-crosscrate.rs | 20 ++++ tests/rustdoc/impl/impl-parts.rs | 12 +++ tests/rustdoc/impl/impl-ref-20175.rs | 14 +++ tests/rustdoc/impl/impl-trait-43869.rs | 75 +++++++++++++ tests/rustdoc/impl/impl-trait-alias.rs | 14 +++ tests/rustdoc/impl/impl-trait-precise-capturing.rs | 26 +++++ tests/rustdoc/impl/impl-type-parameter-33592.rs | 14 +++ tests/rustdoc/impl/implementor-stable-version.rs | 21 ++++ tests/rustdoc/impl/implementors-unstable-75588.rs | 18 ++++ .../impl/inline-impl-through-glob-import-100204.rs | 15 +++ tests/rustdoc/impl/manual_impl.rs | 77 ++++++++++++++ .../impl/method-link-foreign-trait-impl-17476.rs | 14 +++ tests/rustdoc/impl/module-impls.rs | 5 + tests/rustdoc/impl/must_implement_one_of.rs | 10 ++ tests/rustdoc/impl/negative-impl-no-items.rs | 26 +++++ tests/rustdoc/impl/negative-impl-sidebar.rs | 9 ++ tests/rustdoc/impl/negative-impl.rs | 14 +++ tests/rustdoc/impl/return-impl-trait.rs | 15 +++ tests/rustdoc/impl/rustc-incoherent-impls.rs | 28 +++++ .../impl/same-crate-hidden-impl-parameter.rs | 36 +++++++ .../impl/sidebar-trait-impl-disambiguate-78701.rs | 21 ++++ tests/rustdoc/impl/struct-implementations-title.rs | 9 ++ tests/rustdoc/impl/trait-impl.rs | 45 ++++++++ .../trait-implementations-duplicate-self-45584.rs | 17 +++ .../impl/underscore-type-in-trait-impl-96381.rs | 17 +++ tests/rustdoc/impl/universal-impl-trait.rs | 55 ++++++++++ .../impl/unneeded-trait-implementations-title.rs | 5 + tests/rustdoc/implementor-stable-version.rs | 21 ---- tests/rustdoc/implementors-unstable-75588.rs | 18 ---- .../inline-impl-through-glob-import-100204.rs | 15 --- tests/rustdoc/legacy-const-generic.rs | 16 --- tests/rustdoc/link-assoc-const.rs | 16 --- tests/rustdoc/manual_impl.rs | 77 -------------- .../method-link-foreign-trait-impl-17476.rs | 14 --- tests/rustdoc/module-impls.rs | 5 - tests/rustdoc/must_implement_one_of.rs | 10 -- tests/rustdoc/negative-impl-no-items.rs | 26 ----- tests/rustdoc/negative-impl-sidebar.rs | 9 -- tests/rustdoc/negative-impl.rs | 14 --- tests/rustdoc/redirect-const.rs | 13 --- tests/rustdoc/return-impl-trait.rs | 15 --- tests/rustdoc/rfc-2632-const-trait-impl.rs | 73 ------------- tests/rustdoc/rustc-incoherent-impls.rs | 28 ----- tests/rustdoc/same-crate-hidden-impl-parameter.rs | 36 ------- tests/rustdoc/show-const-contents.rs | 68 ------------ .../sidebar-trait-impl-disambiguate-78701.rs | 21 ---- tests/rustdoc/struct-implementations-title.rs | 9 -- tests/rustdoc/trait-impl.rs | 45 -------- .../trait-implementations-duplicate-self-45584.rs | 17 --- .../rustdoc/underscore-type-in-trait-impl-96381.rs | 17 --- tests/rustdoc/universal-impl-trait.rs | 55 ---------- .../unneeded-trait-implementations-title.rs | 5 - 184 files changed, 2376 insertions(+), 2376 deletions(-) delete mode 100644 tests/rustdoc/assoc-consts-underscore.rs delete mode 100644 tests/rustdoc/assoc-consts-version.rs delete mode 100644 tests/rustdoc/assoc-consts.rs delete mode 100644 tests/rustdoc/associated-consts.rs delete mode 100644 tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/auxiliary/extern-impl-trait.rs delete mode 100644 tests/rustdoc/auxiliary/incoherent-impl-types.rs delete mode 100644 tests/rustdoc/auxiliary/issue-100204-aux.rs delete mode 100644 tests/rustdoc/auxiliary/issue-17476.rs delete mode 100644 tests/rustdoc/auxiliary/issue-21092.rs delete mode 100644 tests/rustdoc/auxiliary/issue-22025.rs delete mode 100644 tests/rustdoc/auxiliary/issue-53689.rs delete mode 100644 tests/rustdoc/auxiliary/precise-capturing.rs delete mode 100644 tests/rustdoc/auxiliary/real_gimli.rs delete mode 100644 tests/rustdoc/auxiliary/realcore.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-default-impl.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs delete mode 100644 tests/rustdoc/blanket-impl-29503.rs delete mode 100644 tests/rustdoc/blanket-impl-78673.rs delete mode 100644 tests/rustdoc/const-display.rs delete mode 100644 tests/rustdoc/const-doc.rs delete mode 100644 tests/rustdoc/const-effect-param.rs delete mode 100644 tests/rustdoc/const-underscore.rs delete mode 100644 tests/rustdoc/const-value-display.rs delete mode 100644 tests/rustdoc/const.rs create mode 100644 tests/rustdoc/constant/assoc-consts-underscore.rs create mode 100644 tests/rustdoc/constant/assoc-consts-version.rs create mode 100644 tests/rustdoc/constant/assoc-consts.rs create mode 100644 tests/rustdoc/constant/associated-consts.rs create mode 100644 tests/rustdoc/constant/const-display.rs create mode 100644 tests/rustdoc/constant/const-doc.rs create mode 100644 tests/rustdoc/constant/const-effect-param.rs create mode 100644 tests/rustdoc/constant/const-underscore.rs create mode 100644 tests/rustdoc/constant/const-value-display.rs create mode 100644 tests/rustdoc/constant/const.rs create mode 100644 tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs create mode 100644 tests/rustdoc/constant/generic-const-items.rs create mode 100644 tests/rustdoc/constant/generic_const_exprs.rs create mode 100644 tests/rustdoc/constant/glob-shadowing-const.rs create mode 100644 tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs create mode 100644 tests/rustdoc/constant/hide-complex-unevaluated-consts.rs create mode 100644 tests/rustdoc/constant/ice-associated-const-equality-105952.rs create mode 100644 tests/rustdoc/constant/legacy-const-generic.rs create mode 100644 tests/rustdoc/constant/link-assoc-const.rs create mode 100644 tests/rustdoc/constant/redirect-const.rs create mode 100644 tests/rustdoc/constant/rfc-2632-const-trait-impl.rs create mode 100644 tests/rustdoc/constant/show-const-contents.rs delete mode 100644 tests/rustdoc/cross-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/deduplicate-glob-import-impl-21474.rs delete mode 100644 tests/rustdoc/deduplicate-trait-impl-22025.rs delete mode 100644 tests/rustdoc/default-impl.rs delete mode 100644 tests/rustdoc/deprecated-impls.rs delete mode 100644 tests/rustdoc/doc-hidden-trait-implementors-33069.rs delete mode 100644 tests/rustdoc/doc_auto_cfg_nested_impl.rs delete mode 100644 tests/rustdoc/document-item-with-associated-const-in-where-clause.rs delete mode 100644 tests/rustdoc/duplicated_impl.rs delete mode 100644 tests/rustdoc/empty-impl-block.rs delete mode 100644 tests/rustdoc/empty-impls.rs delete mode 100644 tests/rustdoc/extern-impl-trait.rs delete mode 100644 tests/rustdoc/extern-impl.rs delete mode 100644 tests/rustdoc/foreign-implementors-js-43701.rs delete mode 100644 tests/rustdoc/generic-const-items.rs delete mode 100644 tests/rustdoc/generic-impl.rs delete mode 100644 tests/rustdoc/generic_const_exprs.rs delete mode 100644 tests/rustdoc/glob-shadowing-const.rs delete mode 100644 tests/rustdoc/hidden-implementors-90781.rs delete mode 100644 tests/rustdoc/hidden-impls.rs delete mode 100644 tests/rustdoc/hidden-trait-struct-impls.rs delete mode 100644 tests/rustdoc/hide-complex-unevaluated-const-arguments.rs delete mode 100644 tests/rustdoc/hide-complex-unevaluated-consts.rs delete mode 100644 tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs delete mode 100644 tests/rustdoc/ice-associated-const-equality-105952.rs delete mode 100644 tests/rustdoc/impl-alias-substituted.rs delete mode 100644 tests/rustdoc/impl-assoc-type-21092.rs delete mode 100644 tests/rustdoc/impl-associated-items-order.rs delete mode 100644 tests/rustdoc/impl-associated-items-sidebar.rs delete mode 100644 tests/rustdoc/impl-blanket-53689.rs delete mode 100644 tests/rustdoc/impl-box.rs delete mode 100644 tests/rustdoc/impl-disambiguation.rs delete mode 100644 tests/rustdoc/impl-everywhere.rs delete mode 100644 tests/rustdoc/impl-in-const-block.rs delete mode 100644 tests/rustdoc/impl-on-ty-alias-issue-119015.rs delete mode 100644 tests/rustdoc/impl-parts-crosscrate.rs delete mode 100644 tests/rustdoc/impl-parts.rs delete mode 100644 tests/rustdoc/impl-ref-20175.rs delete mode 100644 tests/rustdoc/impl-trait-43869.rs delete mode 100644 tests/rustdoc/impl-trait-alias.rs delete mode 100644 tests/rustdoc/impl-trait-precise-capturing.rs delete mode 100644 tests/rustdoc/impl-type-parameter-33592.rs create mode 100644 tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/auxiliary/extern-impl-trait.rs create mode 100644 tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-100204-aux.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-17476.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-21092.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-22025.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-53689.rs create mode 100644 tests/rustdoc/impl/auxiliary/precise-capturing.rs create mode 100644 tests/rustdoc/impl/auxiliary/real_gimli.rs create mode 100644 tests/rustdoc/impl/auxiliary/realcore.rs create mode 100644 tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs create mode 100644 tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs create mode 100644 tests/rustdoc/impl/blanket-impl-29503.rs create mode 100644 tests/rustdoc/impl/blanket-impl-78673.rs create mode 100644 tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs create mode 100644 tests/rustdoc/impl/deduplicate-trait-impl-22025.rs create mode 100644 tests/rustdoc/impl/default-impl.rs create mode 100644 tests/rustdoc/impl/deprecated-impls.rs create mode 100644 tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs create mode 100644 tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs create mode 100644 tests/rustdoc/impl/duplicated_impl.rs create mode 100644 tests/rustdoc/impl/empty-impl-block.rs create mode 100644 tests/rustdoc/impl/empty-impls.rs create mode 100644 tests/rustdoc/impl/extern-impl-trait.rs create mode 100644 tests/rustdoc/impl/extern-impl.rs create mode 100644 tests/rustdoc/impl/foreign-implementors-js-43701.rs create mode 100644 tests/rustdoc/impl/generic-impl.rs create mode 100644 tests/rustdoc/impl/hidden-implementors-90781.rs create mode 100644 tests/rustdoc/impl/hidden-impls.rs create mode 100644 tests/rustdoc/impl/hidden-trait-struct-impls.rs create mode 100644 tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs create mode 100644 tests/rustdoc/impl/impl-alias-substituted.rs create mode 100644 tests/rustdoc/impl/impl-assoc-type-21092.rs create mode 100644 tests/rustdoc/impl/impl-associated-items-order.rs create mode 100644 tests/rustdoc/impl/impl-associated-items-sidebar.rs create mode 100644 tests/rustdoc/impl/impl-blanket-53689.rs create mode 100644 tests/rustdoc/impl/impl-box.rs create mode 100644 tests/rustdoc/impl/impl-disambiguation.rs create mode 100644 tests/rustdoc/impl/impl-everywhere.rs create mode 100644 tests/rustdoc/impl/impl-in-const-block.rs create mode 100644 tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs create mode 100644 tests/rustdoc/impl/impl-parts-crosscrate.rs create mode 100644 tests/rustdoc/impl/impl-parts.rs create mode 100644 tests/rustdoc/impl/impl-ref-20175.rs create mode 100644 tests/rustdoc/impl/impl-trait-43869.rs create mode 100644 tests/rustdoc/impl/impl-trait-alias.rs create mode 100644 tests/rustdoc/impl/impl-trait-precise-capturing.rs create mode 100644 tests/rustdoc/impl/impl-type-parameter-33592.rs create mode 100644 tests/rustdoc/impl/implementor-stable-version.rs create mode 100644 tests/rustdoc/impl/implementors-unstable-75588.rs create mode 100644 tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs create mode 100644 tests/rustdoc/impl/manual_impl.rs create mode 100644 tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs create mode 100644 tests/rustdoc/impl/module-impls.rs create mode 100644 tests/rustdoc/impl/must_implement_one_of.rs create mode 100644 tests/rustdoc/impl/negative-impl-no-items.rs create mode 100644 tests/rustdoc/impl/negative-impl-sidebar.rs create mode 100644 tests/rustdoc/impl/negative-impl.rs create mode 100644 tests/rustdoc/impl/return-impl-trait.rs create mode 100644 tests/rustdoc/impl/rustc-incoherent-impls.rs create mode 100644 tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs create mode 100644 tests/rustdoc/impl/struct-implementations-title.rs create mode 100644 tests/rustdoc/impl/trait-impl.rs create mode 100644 tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs create mode 100644 tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs create mode 100644 tests/rustdoc/impl/universal-impl-trait.rs create mode 100644 tests/rustdoc/impl/unneeded-trait-implementations-title.rs delete mode 100644 tests/rustdoc/implementor-stable-version.rs delete mode 100644 tests/rustdoc/implementors-unstable-75588.rs delete mode 100644 tests/rustdoc/inline-impl-through-glob-import-100204.rs delete mode 100644 tests/rustdoc/legacy-const-generic.rs delete mode 100644 tests/rustdoc/link-assoc-const.rs delete mode 100644 tests/rustdoc/manual_impl.rs delete mode 100644 tests/rustdoc/method-link-foreign-trait-impl-17476.rs delete mode 100644 tests/rustdoc/module-impls.rs delete mode 100644 tests/rustdoc/must_implement_one_of.rs delete mode 100644 tests/rustdoc/negative-impl-no-items.rs delete mode 100644 tests/rustdoc/negative-impl-sidebar.rs delete mode 100644 tests/rustdoc/negative-impl.rs delete mode 100644 tests/rustdoc/redirect-const.rs delete mode 100644 tests/rustdoc/return-impl-trait.rs delete mode 100644 tests/rustdoc/rfc-2632-const-trait-impl.rs delete mode 100644 tests/rustdoc/rustc-incoherent-impls.rs delete mode 100644 tests/rustdoc/same-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/show-const-contents.rs delete mode 100644 tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs delete mode 100644 tests/rustdoc/struct-implementations-title.rs delete mode 100644 tests/rustdoc/trait-impl.rs delete mode 100644 tests/rustdoc/trait-implementations-duplicate-self-45584.rs delete mode 100644 tests/rustdoc/underscore-type-in-trait-impl-96381.rs delete mode 100644 tests/rustdoc/universal-impl-trait.rs delete mode 100644 tests/rustdoc/unneeded-trait-implementations-title.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/assoc-consts-underscore.rs b/tests/rustdoc/assoc-consts-underscore.rs deleted file mode 100644 index f48098094db..00000000000 --- a/tests/rustdoc/assoc-consts-underscore.rs +++ /dev/null @@ -1,30 +0,0 @@ -pub struct Struct { - _private: (), -} - -pub trait Trait { - //@ has assoc_consts_underscore/trait.Trait.html '//pre[@class="rust item-decl"]' \ - // 'const REQUIRED: Struct;' - //@ !has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct = _' - //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' - const REQUIRED: Struct; - //@ has - '//pre[@class="rust item-decl"]' 'const OPTIONAL: Struct = _;' - //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' - const OPTIONAL: Struct = Struct { _private: () }; -} - -impl Trait for Struct { - //@ !has assoc_consts_underscore/struct.Struct.html '//*[@id="associatedconstant.REQUIRED"]' \ - // 'const REQUIRED: Struct = _' - //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' - const REQUIRED: Struct = Struct { _private: () }; - //@ !has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' - //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct' - const OPTIONAL: Struct = Struct { _private: () }; -} - -impl Struct { - //@ !has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct = _' - //@ has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct' - pub const INHERENT: Struct = Struct { _private: () }; -} diff --git a/tests/rustdoc/assoc-consts-version.rs b/tests/rustdoc/assoc-consts-version.rs deleted file mode 100644 index db4d759acab..00000000000 --- a/tests/rustdoc/assoc-consts-version.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![crate_name = "foo"] - -#![feature(staged_api)] - -#![stable(since="1.1.1", feature="rust1")] - -#[stable(since="1.1.1", feature="rust1")] -pub struct SomeStruct; - -impl SomeStruct { - //@ has 'foo/struct.SomeStruct.html' \ - // '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2' - #[stable(since="1.1.2", feature="rust2")] - pub const SOME_CONST: usize = 0; -} diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs deleted file mode 100644 index 247b5b180a8..00000000000 --- a/tests/rustdoc/assoc-consts.rs +++ /dev/null @@ -1,103 +0,0 @@ -pub trait Foo { - //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ - // 'const FOO: usize = 13usize;' - //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' - const FOO: usize = 12 + 1; - //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' - const FOO_NO_DEFAULT: bool; - //@ !hasraw - FOO_HIDDEN - #[doc(hidden)] - const FOO_HIDDEN: u8 = 0; -} - -pub struct Bar; - -impl Foo for Bar { - //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' - //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' - const FOO: usize = 12; - //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' - const FOO_NO_DEFAULT: bool = false; - //@ !hasraw - FOO_HIDDEN - #[doc(hidden)] - const FOO_HIDDEN: u8 = 0; -} - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ - // 'const BAR: usize' - pub const BAR: usize = 3; - - //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ - // "const BAR_ESCAPED: &'static str = \"markup\"" - pub const BAR_ESCAPED: &'static str = "markup"; -} - -pub struct Baz<'a, U: 'a, T>(T, &'a [U]); - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ - // "const BAZ: Baz<'static, u8, u32>" - pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]); -} - -pub fn f(_: &(ToString + 'static)) {} - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ - // "const F: fn(&(dyn ToString + 'static))" - pub const F: fn(_: &(ToString + 'static)) = f; -} - -impl Bar { - //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' - const BAR_PRIVATE: char = 'a'; - //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' - #[doc(hidden)] - pub const BAR_HIDDEN: &'static str = "a"; -} - -//@ has assoc_consts/trait.Qux.html -pub trait Qux { - //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." - /// Docs for QUX0 in trait. - const QUX0: u8; - //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait." - /// Docs for QUX1 in trait. - const QUX1: i8; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." - /// Docs for QUX_DEFAULT12 in trait. - const QUX_DEFAULT0: u16 = 1; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." - /// Docs for QUX_DEFAULT1 in trait. - const QUX_DEFAULT1: i16 = 2; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." - /// Docs for QUX_DEFAULT2 in trait. - const QUX_DEFAULT2: u32 = 3; -} - -//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' -impl Qux for Bar { - //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." - /// Docs for QUX0 in trait. - const QUX0: u8 = 4; - //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl." - /// Docs for QUX1 in impl. - const QUX1: i8 = 5; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." - const QUX_DEFAULT0: u16 = 6; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." - /// Docs for QUX_DEFAULT1 in impl. - const QUX_DEFAULT1: i16 = 7; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." -} diff --git a/tests/rustdoc/associated-consts.rs b/tests/rustdoc/associated-consts.rs deleted file mode 100644 index 2a7269a89be..00000000000 --- a/tests/rustdoc/associated-consts.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![crate_name = "foo"] - -pub trait Trait { - const FOO: u32 = 12; - - fn foo(); -} - -pub struct Bar; - -//@ has 'foo/struct.Bar.html' -//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Trait for Bar { - const FOO: u32 = 1; - - fn foo() {} -} - -pub enum Foo { - A, -} - -//@ has 'foo/enum.Foo.html' -//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Trait for Foo { - const FOO: u32 = 1; - - fn foo() {} -} - -pub struct Baz; - -//@ has 'foo/struct.Baz.html' -//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Baz { - pub const FOO: u32 = 42; -} - -pub enum Quux { - B, -} - -//@ has 'foo/enum.Quux.html' -//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Quux { - pub const FOO: u32 = 42; -} diff --git a/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs deleted file mode 100644 index 15953122280..00000000000 --- a/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[doc(hidden)] -pub enum HiddenType {} - -#[doc(hidden)] -pub trait HiddenTrait {} diff --git a/tests/rustdoc/auxiliary/extern-impl-trait.rs b/tests/rustdoc/auxiliary/extern-impl-trait.rs deleted file mode 100644 index dbd54393098..00000000000 --- a/tests/rustdoc/auxiliary/extern-impl-trait.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub trait Foo { - type Associated; -} - -pub struct X; -pub struct Y; - - -impl Foo for X { - type Associated = (); -} - -impl Foo for Y { - type Associated = (); -} - -impl X { - pub fn returns_sized<'a>(&'a self) -> impl Foo + 'a { - X - } -} - -impl Y { - pub fn returns_unsized<'a>(&'a self) -> Box + 'a> { - Box::new(X) - } -} diff --git a/tests/rustdoc/auxiliary/incoherent-impl-types.rs b/tests/rustdoc/auxiliary/incoherent-impl-types.rs deleted file mode 100644 index fc51e42e500..00000000000 --- a/tests/rustdoc/auxiliary/incoherent-impl-types.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_has_incoherent_inherent_impls] -pub trait FooTrait {} - -#[rustc_has_incoherent_inherent_impls] -pub struct FooStruct; diff --git a/tests/rustdoc/auxiliary/issue-100204-aux.rs b/tests/rustdoc/auxiliary/issue-100204-aux.rs deleted file mode 100644 index df1b59069be..00000000000 --- a/tests/rustdoc/auxiliary/issue-100204-aux.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_name="first"] - -pub mod prelude { - pub use crate::Bot; -} - -pub struct Bot; - -impl Bot { - pub fn new() -> Bot { - Bot - } -} diff --git a/tests/rustdoc/auxiliary/issue-17476.rs b/tests/rustdoc/auxiliary/issue-17476.rs deleted file mode 100644 index 0a63b893fff..00000000000 --- a/tests/rustdoc/auxiliary/issue-17476.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -#![doc(html_root_url = "http://example.com")] - -pub trait Foo { - fn foo(&self) {} -} diff --git a/tests/rustdoc/auxiliary/issue-21092.rs b/tests/rustdoc/auxiliary/issue-21092.rs deleted file mode 100644 index 49522e0d4b5..00000000000 --- a/tests/rustdoc/auxiliary/issue-21092.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub trait Foo { - type Bar; - fn foo(&self) {} -} - -pub struct Bar; - -impl Foo for Bar { - type Bar = i32; -} diff --git a/tests/rustdoc/auxiliary/issue-22025.rs b/tests/rustdoc/auxiliary/issue-22025.rs deleted file mode 100644 index 6bc55073283..00000000000 --- a/tests/rustdoc/auxiliary/issue-22025.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub mod foo { - - pub trait Foo {} - pub struct Bar; - - impl Foo for Bar {} - -} diff --git a/tests/rustdoc/auxiliary/issue-53689.rs b/tests/rustdoc/auxiliary/issue-53689.rs deleted file mode 100644 index 5003c2c00f4..00000000000 --- a/tests/rustdoc/auxiliary/issue-53689.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct MyStruct; diff --git a/tests/rustdoc/auxiliary/precise-capturing.rs b/tests/rustdoc/auxiliary/precise-capturing.rs deleted file mode 100644 index 531d4dfdccc..00000000000 --- a/tests/rustdoc/auxiliary/precise-capturing.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(precise_capturing)] - -pub fn cross_crate_empty() -> impl Sized + use<> {} - -pub fn cross_crate_missing() -> impl Sized {} - -pub fn cross_crate_args<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} diff --git a/tests/rustdoc/auxiliary/real_gimli.rs b/tests/rustdoc/auxiliary/real_gimli.rs deleted file mode 100644 index 871d9b31be9..00000000000 --- a/tests/rustdoc/auxiliary/real_gimli.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:realcore.rs - -#![crate_name = "real_gimli"] -#![feature(staged_api, extremely_unstable)] -#![unstable(feature = "rustc_private", issue = "none")] - -extern crate realcore; - -#[unstable(feature = "rustc_private", issue = "none")] -pub struct EndianSlice; - -#[unstable(feature = "rustc_private", issue = "none")] -impl realcore::Deref for EndianSlice {} diff --git a/tests/rustdoc/auxiliary/realcore.rs b/tests/rustdoc/auxiliary/realcore.rs deleted file mode 100644 index e0a906df002..00000000000 --- a/tests/rustdoc/auxiliary/realcore.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![crate_name = "realcore"] -#![feature(staged_api)] -#![unstable(feature = "extremely_unstable", issue = "none")] - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -pub struct Foo {} - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -pub trait Join {} - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -impl Join for Foo {} - -#[stable(feature = "faked_deref", since = "1.47.0")] -pub trait Deref {} diff --git a/tests/rustdoc/auxiliary/rustdoc-default-impl.rs b/tests/rustdoc/auxiliary/rustdoc-default-impl.rs deleted file mode 100644 index 032db3b25e6..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-default-impl.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(auto_traits)] - -pub mod bar { - use std::marker; - - pub auto trait Bar {} - - pub trait Foo { - fn foo(&self) {} - } - - impl Foo { - pub fn test(&self) {} - } - - pub struct TypeId; - - impl TypeId { - pub fn of() -> TypeId { - panic!() - } - } -} diff --git a/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs b/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs deleted file mode 100644 index 135987fc00d..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![feature(auto_traits)] - -pub auto trait AnAutoTrait {} diff --git a/tests/rustdoc/blanket-impl-29503.rs b/tests/rustdoc/blanket-impl-29503.rs deleted file mode 100644 index f43fe79ca58..00000000000 --- a/tests/rustdoc/blanket-impl-29503.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/29503 -#![crate_name="issue_29503"] - -use std::fmt; - -//@ has issue_29503/trait.MyTrait.html -pub trait MyTrait { - fn my_string(&self) -> String; -} - -//@ has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl MyTrait for Twhere T: Debug" -impl MyTrait for T -where - T: fmt::Debug, -{ - fn my_string(&self) -> String { - format!("{:?}", self) - } -} - -pub fn main() {} diff --git a/tests/rustdoc/blanket-impl-78673.rs b/tests/rustdoc/blanket-impl-78673.rs deleted file mode 100644 index 412d4057406..00000000000 --- a/tests/rustdoc/blanket-impl-78673.rs +++ /dev/null @@ -1,25 +0,0 @@ -// https://github.com/rust-lang/rust/issues/78673 -#![crate_name = "issue_78673"] - -pub trait Something {} - -pub trait AnAmazingTrait {} - -impl AnAmazingTrait for T {} - -//@ has 'issue_78673/struct.MyStruct.html' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' -//@ !has - '//*[@class="impl"]' 'AnAmazingTrait for T' -pub struct MyStruct; - -impl AnAmazingTrait for MyStruct {} - -// generic structs may have _both_ specific and blanket impls that apply - -//@ has 'issue_78673/struct.AnotherStruct.html' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for T' -pub struct AnotherStruct(T); - -impl Something for AnotherStruct {} -impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/const-display.rs b/tests/rustdoc/const-display.rs deleted file mode 100644 index bc4270c421d..00000000000 --- a/tests/rustdoc/const-display.rs +++ /dev/null @@ -1,92 +0,0 @@ -#![crate_name = "foo"] - -#![stable(feature = "rust1", since = "1.0.0")] - -#![feature(foo, foo2)] -#![feature(staged_api)] - -//@ has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature="foo", issue = "none")] -pub const fn foo() -> u32 { 42 } - -//@ has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature="foo", issue = "none")] -pub const unsafe fn foo_unsafe() -> u32 { 42 } - -//@ has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "humans", issue = "none")] -pub const fn foo2() -> u32 { 42 } - -//@ has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "humans", issue = "none")] -#[rustc_const_unstable(feature = "humans", issue = "none")] -pub const fn foo3() -> u32 { 42 } - -//@ has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' -//@ has - //span '1.0.0 (const: 1.0.0)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(feature = "rust1", since = "1.0.0")] -pub const fn bar2() -> u32 { 42 } - - -//@ has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "foo2", issue = "none")] -pub const unsafe fn foo2_gated() -> u32 { 42 } - -//@ has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(feature = "rust1", since = "1.0.0")] -pub const unsafe fn bar2_gated() -> u32 { 42 } - -#[unstable( - feature = "humans", - reason = "who ever let humans program computers, we're apparently really bad at it", - issue = "none", -)] -pub mod unstable { - //@ has 'foo/unstable/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' - //@ !hasraw - '//span[@class="since"]' - pub const unsafe fn bar_not_gated() -> u32 { 42 } -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Foo; - -impl Foo { - //@ has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="foo", issue = "none")] - pub const fn gated() -> u32 { 42 } - - //@ has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="foo", issue = "none")] - pub const unsafe fn gated_unsafe() -> u32 { 42 } - - //@ has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const2", since = "1.2.0")] - pub const fn stable_impl() -> u32 { 42 } -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Bar; - -impl Bar { - // Show non-const stabilities that are the same as the enclosing item. - //@ has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const2", since = "1.2.0")] - pub const fn stable_impl() -> u32 { 42 } -} diff --git a/tests/rustdoc/const-doc.rs b/tests/rustdoc/const-doc.rs deleted file mode 100644 index f33083a267c..00000000000 --- a/tests/rustdoc/const-doc.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::marker::PhantomData; - -pub struct Foo<'a> { - f: PhantomData<&'a u32>, -} - -pub struct ContentType { - pub ttype: Foo<'static>, - pub subtype: Foo<'static>, - pub params: Option>, -} - -impl ContentType { - //@ has const_doc/struct.ContentType.html - //@ has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' - pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, }, - subtype: Foo { f: PhantomData, }, - params: None, }; -} diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs deleted file mode 100644 index cceb0adac30..00000000000 --- a/tests/rustdoc/const-effect-param.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check that we don't render host effect parameters & arguments. - -#![crate_name = "foo"] -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Tr { - fn f(); -} - -//@ has foo/fn.g.html -//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g()' -/// foo -pub const fn g() {} diff --git a/tests/rustdoc/const-underscore.rs b/tests/rustdoc/const-underscore.rs deleted file mode 100644 index fafc4b4e25c..00000000000 --- a/tests/rustdoc/const-underscore.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: --document-private-items - -//@ !has const_underscore/constant._.html -const _: () = { - #[no_mangle] - extern "C" fn implementation_detail() {} -}; diff --git a/tests/rustdoc/const-value-display.rs b/tests/rustdoc/const-value-display.rs deleted file mode 100644 index 658978a3490..00000000000 --- a/tests/rustdoc/const-value-display.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/constant.HOUR_IN_SECONDS.html' -//@ has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' -pub const HOUR_IN_SECONDS: u64 = 60 * 60; - -//@ has 'foo/constant.NEGATIVE.html' -//@ has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' -pub const NEGATIVE: i64 = -60 * 60; diff --git a/tests/rustdoc/const.rs b/tests/rustdoc/const.rs deleted file mode 100644 index fe6a828505a..00000000000 --- a/tests/rustdoc/const.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type="lib"] - -pub struct Foo; - -impl Foo { - //@ has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' - pub const unsafe fn new() -> Foo { - Foo - } -} diff --git a/tests/rustdoc/constant/assoc-consts-underscore.rs b/tests/rustdoc/constant/assoc-consts-underscore.rs new file mode 100644 index 00000000000..f48098094db --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts-underscore.rs @@ -0,0 +1,30 @@ +pub struct Struct { + _private: (), +} + +pub trait Trait { + //@ has assoc_consts_underscore/trait.Trait.html '//pre[@class="rust item-decl"]' \ + // 'const REQUIRED: Struct;' + //@ !has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct = _' + //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' + const REQUIRED: Struct; + //@ has - '//pre[@class="rust item-decl"]' 'const OPTIONAL: Struct = _;' + //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' + const OPTIONAL: Struct = Struct { _private: () }; +} + +impl Trait for Struct { + //@ !has assoc_consts_underscore/struct.Struct.html '//*[@id="associatedconstant.REQUIRED"]' \ + // 'const REQUIRED: Struct = _' + //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' + const REQUIRED: Struct = Struct { _private: () }; + //@ !has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' + //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct' + const OPTIONAL: Struct = Struct { _private: () }; +} + +impl Struct { + //@ !has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct = _' + //@ has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct' + pub const INHERENT: Struct = Struct { _private: () }; +} diff --git a/tests/rustdoc/constant/assoc-consts-version.rs b/tests/rustdoc/constant/assoc-consts-version.rs new file mode 100644 index 00000000000..db4d759acab --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts-version.rs @@ -0,0 +1,15 @@ +#![crate_name = "foo"] + +#![feature(staged_api)] + +#![stable(since="1.1.1", feature="rust1")] + +#[stable(since="1.1.1", feature="rust1")] +pub struct SomeStruct; + +impl SomeStruct { + //@ has 'foo/struct.SomeStruct.html' \ + // '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2' + #[stable(since="1.1.2", feature="rust2")] + pub const SOME_CONST: usize = 0; +} diff --git a/tests/rustdoc/constant/assoc-consts.rs b/tests/rustdoc/constant/assoc-consts.rs new file mode 100644 index 00000000000..247b5b180a8 --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts.rs @@ -0,0 +1,103 @@ +pub trait Foo { + //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ + // 'const FOO: usize = 13usize;' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + const FOO: usize = 12 + 1; + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + const FOO_NO_DEFAULT: bool; + //@ !hasraw - FOO_HIDDEN + #[doc(hidden)] + const FOO_HIDDEN: u8 = 0; +} + +pub struct Bar; + +impl Foo for Bar { + //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + const FOO: usize = 12; + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + const FOO_NO_DEFAULT: bool = false; + //@ !hasraw - FOO_HIDDEN + #[doc(hidden)] + const FOO_HIDDEN: u8 = 0; +} + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ + // 'const BAR: usize' + pub const BAR: usize = 3; + + //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ + // "const BAR_ESCAPED: &'static str = \"markup\"" + pub const BAR_ESCAPED: &'static str = "markup"; +} + +pub struct Baz<'a, U: 'a, T>(T, &'a [U]); + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ + // "const BAZ: Baz<'static, u8, u32>" + pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]); +} + +pub fn f(_: &(ToString + 'static)) {} + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ + // "const F: fn(&(dyn ToString + 'static))" + pub const F: fn(_: &(ToString + 'static)) = f; +} + +impl Bar { + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' + const BAR_PRIVATE: char = 'a'; + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' + #[doc(hidden)] + pub const BAR_HIDDEN: &'static str = "a"; +} + +//@ has assoc_consts/trait.Qux.html +pub trait Qux { + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + /// Docs for QUX0 in trait. + const QUX0: u8; + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait." + /// Docs for QUX1 in trait. + const QUX1: i8; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + /// Docs for QUX_DEFAULT12 in trait. + const QUX_DEFAULT0: u16 = 1; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." + /// Docs for QUX_DEFAULT1 in trait. + const QUX_DEFAULT1: i16 = 2; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." + /// Docs for QUX_DEFAULT2 in trait. + const QUX_DEFAULT2: u32 = 3; +} + +//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' +impl Qux for Bar { + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + /// Docs for QUX0 in trait. + const QUX0: u8 = 4; + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl." + /// Docs for QUX1 in impl. + const QUX1: i8 = 5; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + const QUX_DEFAULT0: u16 = 6; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." + /// Docs for QUX_DEFAULT1 in impl. + const QUX_DEFAULT1: i16 = 7; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." +} diff --git a/tests/rustdoc/constant/associated-consts.rs b/tests/rustdoc/constant/associated-consts.rs new file mode 100644 index 00000000000..2a7269a89be --- /dev/null +++ b/tests/rustdoc/constant/associated-consts.rs @@ -0,0 +1,51 @@ +#![crate_name = "foo"] + +pub trait Trait { + const FOO: u32 = 12; + + fn foo(); +} + +pub struct Bar; + +//@ has 'foo/struct.Bar.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Trait for Bar { + const FOO: u32 = 1; + + fn foo() {} +} + +pub enum Foo { + A, +} + +//@ has 'foo/enum.Foo.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Trait for Foo { + const FOO: u32 = 1; + + fn foo() {} +} + +pub struct Baz; + +//@ has 'foo/struct.Baz.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Baz { + pub const FOO: u32 = 42; +} + +pub enum Quux { + B, +} + +//@ has 'foo/enum.Quux.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Quux { + pub const FOO: u32 = 42; +} diff --git a/tests/rustdoc/constant/const-display.rs b/tests/rustdoc/constant/const-display.rs new file mode 100644 index 00000000000..bc4270c421d --- /dev/null +++ b/tests/rustdoc/constant/const-display.rs @@ -0,0 +1,92 @@ +#![crate_name = "foo"] + +#![stable(feature = "rust1", since = "1.0.0")] + +#![feature(foo, foo2)] +#![feature(staged_api)] + +//@ has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature="foo", issue = "none")] +pub const fn foo() -> u32 { 42 } + +//@ has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature="foo", issue = "none")] +pub const unsafe fn foo_unsafe() -> u32 { 42 } + +//@ has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "humans", issue = "none")] +pub const fn foo2() -> u32 { 42 } + +//@ has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "humans", issue = "none")] +#[rustc_const_unstable(feature = "humans", issue = "none")] +pub const fn foo3() -> u32 { 42 } + +//@ has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' +//@ has - //span '1.0.0 (const: 1.0.0)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "rust1", since = "1.0.0")] +pub const fn bar2() -> u32 { 42 } + + +//@ has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "foo2", issue = "none")] +pub const unsafe fn foo2_gated() -> u32 { 42 } + +//@ has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "rust1", since = "1.0.0")] +pub const unsafe fn bar2_gated() -> u32 { 42 } + +#[unstable( + feature = "humans", + reason = "who ever let humans program computers, we're apparently really bad at it", + issue = "none", +)] +pub mod unstable { + //@ has 'foo/unstable/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' + //@ !hasraw - '//span[@class="since"]' + pub const unsafe fn bar_not_gated() -> u32 { 42 } +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Foo; + +impl Foo { + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature="foo", issue = "none")] + pub const fn gated() -> u32 { 42 } + + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature="foo", issue = "none")] + pub const unsafe fn gated_unsafe() -> u32 { 42 } + + //@ has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const2", since = "1.2.0")] + pub const fn stable_impl() -> u32 { 42 } +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Bar; + +impl Bar { + // Show non-const stabilities that are the same as the enclosing item. + //@ has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const2", since = "1.2.0")] + pub const fn stable_impl() -> u32 { 42 } +} diff --git a/tests/rustdoc/constant/const-doc.rs b/tests/rustdoc/constant/const-doc.rs new file mode 100644 index 00000000000..f33083a267c --- /dev/null +++ b/tests/rustdoc/constant/const-doc.rs @@ -0,0 +1,19 @@ +use std::marker::PhantomData; + +pub struct Foo<'a> { + f: PhantomData<&'a u32>, +} + +pub struct ContentType { + pub ttype: Foo<'static>, + pub subtype: Foo<'static>, + pub params: Option>, +} + +impl ContentType { + //@ has const_doc/struct.ContentType.html + //@ has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' + pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, }, + subtype: Foo { f: PhantomData, }, + params: None, }; +} diff --git a/tests/rustdoc/constant/const-effect-param.rs b/tests/rustdoc/constant/const-effect-param.rs new file mode 100644 index 00000000000..cceb0adac30 --- /dev/null +++ b/tests/rustdoc/constant/const-effect-param.rs @@ -0,0 +1,14 @@ +// Check that we don't render host effect parameters & arguments. + +#![crate_name = "foo"] +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Tr { + fn f(); +} + +//@ has foo/fn.g.html +//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g()' +/// foo +pub const fn g() {} diff --git a/tests/rustdoc/constant/const-underscore.rs b/tests/rustdoc/constant/const-underscore.rs new file mode 100644 index 00000000000..fafc4b4e25c --- /dev/null +++ b/tests/rustdoc/constant/const-underscore.rs @@ -0,0 +1,7 @@ +//@ compile-flags: --document-private-items + +//@ !has const_underscore/constant._.html +const _: () = { + #[no_mangle] + extern "C" fn implementation_detail() {} +}; diff --git a/tests/rustdoc/constant/const-value-display.rs b/tests/rustdoc/constant/const-value-display.rs new file mode 100644 index 00000000000..658978a3490 --- /dev/null +++ b/tests/rustdoc/constant/const-value-display.rs @@ -0,0 +1,9 @@ +#![crate_name = "foo"] + +//@ has 'foo/constant.HOUR_IN_SECONDS.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' +pub const HOUR_IN_SECONDS: u64 = 60 * 60; + +//@ has 'foo/constant.NEGATIVE.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' +pub const NEGATIVE: i64 = -60 * 60; diff --git a/tests/rustdoc/constant/const.rs b/tests/rustdoc/constant/const.rs new file mode 100644 index 00000000000..fe6a828505a --- /dev/null +++ b/tests/rustdoc/constant/const.rs @@ -0,0 +1,10 @@ +#![crate_type="lib"] + +pub struct Foo; + +impl Foo { + //@ has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' + pub const unsafe fn new() -> Foo { + Foo + } +} diff --git a/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs new file mode 100644 index 00000000000..c9408ef3360 --- /dev/null +++ b/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs @@ -0,0 +1,17 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Enumerable { + const N: usize; +} + +#[derive(Clone)] +pub struct SymmetricGroup +where + S: Enumerable, + [(); S::N]: Sized, +{ + _phantom: std::marker::PhantomData, +} + +fn main() {} diff --git a/tests/rustdoc/constant/generic-const-items.rs b/tests/rustdoc/constant/generic-const-items.rs new file mode 100644 index 00000000000..31c300f2ff1 --- /dev/null +++ b/tests/rustdoc/constant/generic-const-items.rs @@ -0,0 +1,38 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +//@ has 'generic_const_items/constant.K.html' +//@ has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +//@ has generic_const_items/trait.Trait.html +pub trait Trait { + //@ has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a T \ + // where \ + // T: 'a + Eq" + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +//@ has generic_const_items/struct.Implementor.html +//@ has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +impl Trait for Implementor { + //@ has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a str = \"C\" \ + // where \ + // str: 'a" + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/constant/generic_const_exprs.rs b/tests/rustdoc/constant/generic_const_exprs.rs new file mode 100644 index 00000000000..44f7bf5b24c --- /dev/null +++ b/tests/rustdoc/constant/generic_const_exprs.rs @@ -0,0 +1,24 @@ +// Regression test for . + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +#![crate_name = "foo"] + +//@ has 'foo/trait.Foo.html' + +pub trait Foo: Sized { + const WIDTH: usize; + + fn arrayify(self) -> [Self; Self::WIDTH]; +} + +impl Foo for T { + const WIDTH: usize = 1; + + //@ has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ + // 'fn arrayify(self) -> [Self; Self::WIDTH]' + fn arrayify(self) -> [Self; Self::WIDTH] { + [self] + } +} diff --git a/tests/rustdoc/constant/glob-shadowing-const.rs b/tests/rustdoc/constant/glob-shadowing-const.rs new file mode 100644 index 00000000000..fbc22dbccaa --- /dev/null +++ b/tests/rustdoc/constant/glob-shadowing-const.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/pull/83872#issuecomment-820101008 +#![crate_name="foo"] + +mod sub4 { + /// 0 + pub const X: usize = 0; + pub mod inner { + pub use super::*; + /// 1 + pub const X: usize = 1; + } +} + +#[doc(inline)] +pub use sub4::inner::*; + +//@ has 'foo/index.html' +//@ has - '//dd' '1' +//@ !has - '//dd' '0' +fn main() { assert_eq!(X, 1); } diff --git a/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs new file mode 100644 index 00000000000..e94c1ea5c61 --- /dev/null +++ b/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs @@ -0,0 +1,91 @@ +// Test that certain unevaluated constant expression arguments that are +// deemed too verbose or complex and that may leak private or +// `doc(hidden)` struct fields are not displayed in the documentation. +// +// Read the documentation of `rustdoc::clean::utils::print_const_expr` +// for further details. +#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +//@ has hide_complex_unevaluated_const_arguments/trait.Stage.html +pub trait Stage { + // A helper constant that prevents const expressions containing it + // from getting fully evaluated since it doesn't have a body and + // thus is non-reducible. This allows us to specifically test the + // pretty-printing of *unevaluated* consts. + const ABSTRACT: usize; + + // Currently considered "overly complex" by the `generic_const_exprs` + // feature. If / once this expression kind gets supported, this + // unevaluated const expression could leak the private struct field. + // + // FIXME: Once the line below compiles, make this a test that + // ensures that the private field is not printed. + // + //const ARRAY0: [u8; Struct { private: () } + Self::ABSTRACT]; + + // This assoc. const could leak the private assoc. function `Struct::new`. + // Ensure that this does not happen. + // + //@ has - '//*[@id="associatedconstant.ARRAY1"]' \ + // 'const ARRAY1: [u8; { _ }]' + const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] + where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; + + //@ has - '//*[@id="associatedconstant.VERBOSE"]' \ + // 'const VERBOSE: [u16; { _ }]' + const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] + where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; + + // Check that we do not leak the private struct field contained within + // the path. The output could definitely be improved upon + // (e.g. printing sth. akin to `>::OUT`) but + // right now “safe is safe”. + // + //@ has - '//*[@id="associatedconstant.PATH"]' \ + // 'const PATH: usize = _' + const PATH: usize = >::OUT; +} + +const fn compute(input: &str, extra: usize) -> usize { + input.len() + extra +} + +pub trait Helper { + const OUT: usize; +} + +impl Helper for St { + const OUT: usize = St::ABSTRACT; +} + +// Currently in rustdoc, const arguments are not evaluated in this position +// and therefore they fall under the realm of `print_const_expr`. +// If rustdoc gets patched to evaluate const arguments, it is fine to replace +// this test as long as one can ensure that private fields are not leaked! +// +//@ has hide_complex_unevaluated_const_arguments/trait.Sub.html \ +// '//pre[@class="rust item-decl"]' \ +// 'pub trait Sub: Sup<{ _ }, { _ }> { }' +pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} + +pub trait Sup {} + +#[derive(ConstParamTy, PartialEq, Eq)] +pub struct Struct { private: () } + +impl Struct { + const fn new() -> Self { Self { private: () } } + const fn do_something(self, x: usize) -> usize { + x + } +} +/* FIXME(const-trait): readd this +impl const std::ops::Add for Struct { + type Output = usize; + + fn add(self, _: usize) -> usize { 0 } +} +*/ diff --git a/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs b/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs new file mode 100644 index 00000000000..61ae8c801dd --- /dev/null +++ b/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs @@ -0,0 +1,71 @@ +// Regression test for issue #97933. +// +// Test that certain unevaluated constant expressions that are +// deemed too verbose or complex and that may leak private or +// `doc(hidden)` struct fields are not displayed in the documentation. +// +// Read the documentation of `rustdoc::clean::utils::print_const_expr` +// for further details. + +//@ has hide_complex_unevaluated_consts/trait.Container.html +pub trait Container { + // A helper constant that prevents const expressions containing it + // from getting fully evaluated since it doesn't have a body and + // thus is non-reducible. This allows us to specifically test the + // pretty-printing of *unevaluated* consts. + const ABSTRACT: i32; + + // Ensure that the private field does not get leaked: + // + //@ has - '//*[@id="associatedconstant.STRUCT0"]' \ + // 'const STRUCT0: Struct = _' + const STRUCT0: Struct = Struct { private: () }; + + //@ has - '//*[@id="associatedconstant.STRUCT1"]' \ + // 'const STRUCT1: (Struct,) = _' + const STRUCT1: (Struct,) = (Struct{private: /**/()},); + + // Although the struct field is public here, check that it is not + // displayed. In a future version of rustdoc, we definitely want to + // show it. However for the time being, the printing logic is a bit + // conservative. + // + //@ has - '//*[@id="associatedconstant.STRUCT2"]' \ + // 'const STRUCT2: Record = _' + const STRUCT2: Record = Record { public: 5 }; + + // Test that we do not show the incredibly verbose match expr: + // + //@ has - '//*[@id="associatedconstant.MATCH0"]' \ + // 'const MATCH0: i32 = _' + const MATCH0: i32 = match 234 { + 0 => 1, + _ => Self::ABSTRACT, + }; + + //@ has - '//*[@id="associatedconstant.MATCH1"]' \ + // 'const MATCH1: bool = _' + const MATCH1: bool = match Self::ABSTRACT { + _ => true, + }; + + // Check that we hide complex (arithmetic) operations. + // In this case, it is a bit unfortunate since the expression + // is not *that* verbose and it might be quite useful to the reader. + // + // However in general, the expression might be quite large and + // contain match expressions and structs with private fields. + // We would need to recurse over the whole expression and even more + // importantly respect operator precedence when pretty-printing + // the potentially partially censored expression. + // For now, the implementation is quite simple and the choices + // rather conservative. + // + //@ has - '//*[@id="associatedconstant.ARITH_OPS"]' \ + // 'const ARITH_OPS: i32 = _' + const ARITH_OPS: i32 = Self::ABSTRACT * 2 + 1; +} + +pub struct Struct { private: () } + +pub struct Record { pub public: i32 } diff --git a/tests/rustdoc/constant/ice-associated-const-equality-105952.rs b/tests/rustdoc/constant/ice-associated-const-equality-105952.rs new file mode 100644 index 00000000000..1bcdfac7342 --- /dev/null +++ b/tests/rustdoc/constant/ice-associated-const-equality-105952.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/105952 +#![crate_name = "foo"] + +#![feature(associated_const_equality)] +pub enum ParseMode { + Raw, +} +pub trait Parse { + const PARSE_MODE: ParseMode; +} +pub trait RenderRaw {} + +//@ hasraw foo/trait.RenderRaw.html 'impl' +//@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' +impl> RenderRaw for T {} diff --git a/tests/rustdoc/constant/legacy-const-generic.rs b/tests/rustdoc/constant/legacy-const-generic.rs new file mode 100644 index 00000000000..41df535f3e0 --- /dev/null +++ b/tests/rustdoc/constant/legacy-const-generic.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +//@ has 'foo/fn.foo.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' +#[rustc_legacy_const_generics(1)] +pub fn foo(x: usize, z: usize) -> [usize; 3] { + [x, Y, z] +} + +//@ has 'foo/fn.bar.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' +#[rustc_legacy_const_generics(1, 2)] +pub fn bar(x: usize) -> [usize; 3] { + [x, Y, z] +} diff --git a/tests/rustdoc/constant/link-assoc-const.rs b/tests/rustdoc/constant/link-assoc-const.rs new file mode 100644 index 00000000000..56b82fb2d39 --- /dev/null +++ b/tests/rustdoc/constant/link-assoc-const.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +//@ has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' +//@ has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' + +//! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`]. + +pub mod foo { + pub const FIRSTCONST: u32 = 42; +} + +pub struct Bar; + +impl Bar { + pub const CONST: u32 = 42; +} diff --git a/tests/rustdoc/constant/redirect-const.rs b/tests/rustdoc/constant/redirect-const.rs new file mode 100644 index 00000000000..e636a915f30 --- /dev/null +++ b/tests/rustdoc/constant/redirect-const.rs @@ -0,0 +1,13 @@ +#![crate_name="foo"] + +pub use hidden::STATIC_FOO; +pub use hidden::CONST_FOO; + +mod hidden { + //@ has foo/hidden/static.STATIC_FOO.html + //@ has - '//p/a' '../../foo/static.STATIC_FOO.html' + pub static STATIC_FOO: u64 = 0; + //@ has foo/hidden/constant.CONST_FOO.html + //@ has - '//p/a' '../../foo/constant.CONST_FOO.html' + pub const CONST_FOO: u64 = 0; +} diff --git a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs new file mode 100644 index 00000000000..8a86e3e5e97 --- /dev/null +++ b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs @@ -0,0 +1,73 @@ +// Test that we do not currently display `~const` in rustdoc +// as that syntax is currently provisional; `~const Destruct` has +// no effect on stable code so it should be hidden as well. +// +// To future blessers: make sure that `const_trait_impl` is +// stabilized when changing `@!has` to `@has`, and please do +// not remove this test. +// +// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const` +// FIXME(const_trait_impl) restore `const_trait` to `Destruct` +#![feature(const_trait_impl)] +#![crate_name = "foo"] + +use std::marker::Destruct; + +pub struct S(T); + +//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' +#[const_trait] +pub trait Tr { + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + fn a() + where + Option: /* ~const */ Fn() /* + ~const Destruct */, + { + } +} + +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' +impl const Tr for T +where + Option: /* ~const */ Fn() /* + ~const Destruct */, +{ + fn a() + where + Option: /* ~const */ Fn() /* + ~const Destruct */, + { + } +} + +//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' +pub const fn foo() +where + Option: /* ~const */ Fn() /* + ~const Destruct */, +{ + F::a() +} + +impl S { + //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + pub const fn foo() + where + B: /* ~const */ Fn() /* + ~const Destruct */, + { + B::a() + } +} diff --git a/tests/rustdoc/constant/show-const-contents.rs b/tests/rustdoc/constant/show-const-contents.rs new file mode 100644 index 00000000000..6d2701693ce --- /dev/null +++ b/tests/rustdoc/constant/show-const-contents.rs @@ -0,0 +1,68 @@ +// Test that the contents of constants are displayed as part of the +// documentation. + +//@ hasraw show_const_contents/constant.CONST_S.html 'show this' +//@ !hasraw show_const_contents/constant.CONST_S.html '; //' +pub const CONST_S: &'static str = "show this"; + +//@ hasraw show_const_contents/constant.CONST_I32.html '= 42;' +//@ !hasraw show_const_contents/constant.CONST_I32.html '; //' +pub const CONST_I32: i32 = 42; + +//@ hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' +//@ !hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' +pub const CONST_I32_HEX: i32 = 0x42; + +//@ hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' +//@ !hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' +pub const CONST_NEG_I32: i32 = -42; + +//@ hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' +//@ !hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' +pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; + +//@ hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' +pub const CONST_CALC_I32: i32 = 42 + 1; + +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '; //' +pub const CONST_REF_I32: &'static i32 = &42; + +//@ hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' +pub const CONST_I32_MAX: i32 = i32::MAX; + +//@ !hasraw show_const_contents/constant.UNIT.html '= ();' +//@ !hasraw show_const_contents/constant.UNIT.html '; //' +pub const UNIT: () = (); + +pub struct MyType(i32); + +//@ !hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' +//@ !hasraw show_const_contents/constant.MY_TYPE.html '; //' +pub const MY_TYPE: MyType = MyType(42); + +pub struct MyTypeWithStr(&'static str); + +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' +pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); + +//@ hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' +//@ hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' +pub use std::f32::consts::PI; + +//@ hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' +#[allow(deprecated, deprecated_in_future)] +pub use std::i32::MAX; + +macro_rules! int_module { + ($T:ident) => ( + pub const MIN: $T = $T::MIN; + ) +} + +//@ hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' +int_module!(i16); + +//@ has show_const_contents/constant.ESCAPE.html //pre '= r#""#;' +pub const ESCAPE: &str = r#""#; diff --git a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/cross-crate-hidden-impl-parameter.rs deleted file mode 100644 index ebfe251134a..00000000000 --- a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Issue #86448: test for cross-crate `doc(hidden)` -#![crate_name = "foo"] - -//@ aux-build:cross-crate-hidden-impl-parameter.rs -extern crate cross_crate_hidden_impl_parameter; - -pub use ::cross_crate_hidden_impl_parameter::{HiddenType, HiddenTrait}; // OK, not re-exported - -pub enum MyLibType {} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' -impl From for MyLibType { - fn from(it: HiddenType) -> MyLibType { - match it {} - } -} - -pub struct T(T); - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' -impl From>>>> for MyLibType { - fn from(it: T>>>) -> MyLibType { - todo!() - } -} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' -impl HiddenTrait for MyLibType {} - -//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' -impl From for T>>> { - fn from(it: MyLibType) -> T>>> { - match it {} - } -} diff --git a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs deleted file mode 100644 index 5812d414997..00000000000 --- a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/21474 -#![crate_name="issue_21474"] - -pub use inner::*; - -mod inner { - impl super::Blah for super::What { } -} - -pub trait Blah { } - -//@ count issue_21474/struct.What.html \ -// '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -pub struct What; diff --git a/tests/rustdoc/deduplicate-trait-impl-22025.rs b/tests/rustdoc/deduplicate-trait-impl-22025.rs deleted file mode 100644 index 7b1648a56ac..00000000000 --- a/tests/rustdoc/deduplicate-trait-impl-22025.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:issue-22025.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/22025 -#![crate_name="issue_22025"] - -extern crate issue_22025; - -pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/default-impl.rs b/tests/rustdoc/default-impl.rs deleted file mode 100644 index 2ba9c4ab5ad..00000000000 --- a/tests/rustdoc/default-impl.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:rustdoc-default-impl.rs -//@ ignore-cross-compile - -extern crate rustdoc_default_impl as foo; - -pub use foo::bar; - -pub fn wut() { -} diff --git a/tests/rustdoc/deprecated-impls.rs b/tests/rustdoc/deprecated-impls.rs deleted file mode 100644 index a57f26ec7fd..00000000000 --- a/tests/rustdoc/deprecated-impls.rs +++ /dev/null @@ -1,118 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo0.html -pub struct Foo0; - -impl Foo0 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' - //@ hasraw - 'fn_with_doc short' - //@ hasraw - 'fn_with_doc full' - /// fn_with_doc short - /// - /// fn_with_doc full - #[deprecated(since = "1.0.1", note = "fn_with_doc")] - pub fn fn_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' - #[deprecated(since = "1.0.2", note = "fn_without_doc")] - pub fn fn_without_doc() {} -} - -pub trait Bar { - /// fn_empty_with_doc short - /// - /// fn_empty_with_doc full - #[deprecated(since = "1.0.3", note = "fn_empty_with_doc")] - fn fn_empty_with_doc(); - - #[deprecated(since = "1.0.4", note = "fn_empty_without_doc")] - fn fn_empty_without_doc(); - - /// fn_def_with_doc short - /// - /// fn_def_with_doc full - #[deprecated(since = "1.0.5", note = "fn_def_with_doc")] - fn fn_def_with_doc() {} - - #[deprecated(since = "1.0.6", note = "fn_def_without_doc")] - fn fn_def_without_doc() {} - - /// fn_def_def_with_doc short - /// - /// fn_def_def_with_doc full - #[deprecated(since = "1.0.7", note = "fn_def_def_with_doc")] - fn fn_def_def_with_doc() {} - - #[deprecated(since = "1.0.8", note = "fn_def_def_without_doc")] - fn fn_def_def_without_doc() {} -} - -//@ has foo/struct.Foo1.html -pub struct Foo1; - -impl Bar for Foo1 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - //@ hasraw - 'fn_empty_with_doc_impl short' - //@ hasraw - 'fn_empty_with_doc_impl full' - /// fn_empty_with_doc_impl short - /// - /// fn_empty_with_doc_impl full - fn fn_empty_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - fn fn_empty_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - //@ hasraw - 'fn_def_with_doc_impl short' - //@ hasraw - 'fn_def_with_doc_impl full' - /// fn_def_with_doc_impl short - /// - /// fn_def_with_doc_impl full - fn fn_def_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - fn fn_def_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - //@ hasraw - 'fn_def_def_with_doc short' - //@ !hasraw - 'fn_def_def_with_doc full' - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' -} - -//@ has foo/struct.Foo2.html -pub struct Foo2; - -impl Bar for Foo2 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - //@ hasraw - 'fn_empty_with_doc short' - //@ !hasraw - 'fn_empty_with_doc full' - fn fn_empty_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - //@ hasraw - 'fn_empty_without_doc_impl short' - //@ hasraw - 'fn_empty_without_doc_impl full' - /// fn_empty_without_doc_impl short - /// - /// fn_empty_without_doc_impl full - fn fn_empty_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - //@ hasraw - 'fn_def_with_doc short' - //@ !hasraw - 'fn_def_with_doc full' - fn fn_def_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - //@ hasraw - 'fn_def_without_doc_impl short' - //@ hasraw - 'fn_def_without_doc_impl full' - /// fn_def_without_doc_impl short - /// - /// fn_def_without_doc_impl full - fn fn_def_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - //@ hasraw - 'fn_def_def_with_doc short' - //@ !hasraw - 'fn_def_def_with_doc full' - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' -} diff --git a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs deleted file mode 100644 index d5ee3d09276..00000000000 --- a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/33069 -#![crate_name="issue_33069"] - -pub trait Bar {} - -#[doc(hidden)] -pub mod hidden { - pub struct Foo; -} - -//@ has issue_33069/trait.Bar.html -//@ !has - '//code' 'impl Bar for Foo' -impl Bar for hidden::Foo {} diff --git a/tests/rustdoc/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/doc_auto_cfg_nested_impl.rs deleted file mode 100644 index f85d7b23637..00000000000 --- a/tests/rustdoc/doc_auto_cfg_nested_impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for . - -#![feature(doc_auto_cfg)] -#![crate_type = "lib"] -#![crate_name = "foo"] - -pub struct S; -pub trait MyTrait1 {} -pub trait MyTrait2 {} - -//@ has foo/struct.S.html -//@ has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ -// 'Available on non-crate feature coolstuff only.' -#[cfg(not(feature = "coolstuff"))] -impl MyTrait1 for S {} - -#[cfg(not(feature = "coolstuff"))] -mod submod { - use crate::{S, MyTrait2}; - // This impl should also have the `not(feature = "coolstuff")`. - //@ has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ - // 'Available on non-crate feature coolstuff only.' - impl MyTrait2 for S {} -} diff --git a/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs deleted file mode 100644 index c9408ef3360..00000000000 --- a/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -pub trait Enumerable { - const N: usize; -} - -#[derive(Clone)] -pub struct SymmetricGroup -where - S: Enumerable, - [(); S::N]: Sized, -{ - _phantom: std::marker::PhantomData, -} - -fn main() {} diff --git a/tests/rustdoc/duplicated_impl.rs b/tests/rustdoc/duplicated_impl.rs deleted file mode 100644 index e7828885cc1..00000000000 --- a/tests/rustdoc/duplicated_impl.rs +++ /dev/null @@ -1,14 +0,0 @@ -// This test ensures that the same implementation doesn't show more than once. -// It's a regression test for https://github.com/rust-lang/rust/issues/96036. - -#![crate_name = "foo"] - -// We check that there is only one "impl Something for T" listed in the -// blanket implementations. - -//@ has 'foo/struct.Whatever.html' -//@ count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 - -pub trait Something { } -pub struct Whatever; -impl Something for T {} diff --git a/tests/rustdoc/empty-impl-block.rs b/tests/rustdoc/empty-impl-block.rs deleted file mode 100644 index 91fd4a64ef9..00000000000 --- a/tests/rustdoc/empty-impl-block.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/struct.Foo.html' -pub struct Foo; - -//@ has - '//*[@class="docblock"]' 'Hello empty impl block!' -//@ has - '//*[@class="item-info"]' 'This impl block contains no items.' -/// Hello empty impl block! -impl Foo {} -// We ensure that this empty impl block without doc isn't rendered. -//@ count - '//*[@class="impl"]' 'impl Foo' 1 -impl Foo {} - -// Just to ensure that empty trait impl blocks are rendered. -pub struct Another; -pub trait Bar {} - -//@ has 'foo/struct.Another.html' -//@ has - '//h3[@class="code-header"]' 'impl Bar for Another' -impl Bar for Another {} diff --git a/tests/rustdoc/empty-impls.rs b/tests/rustdoc/empty-impls.rs deleted file mode 100644 index 912a8d3d913..00000000000 --- a/tests/rustdoc/empty-impls.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo.html -//@ has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' -pub struct Foo; - -pub trait EmptyTrait {} - -//@ has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' -impl EmptyTrait for Foo {} - -pub trait NotEmpty { - fn foo(&self); -} - -//@ has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' -impl NotEmpty for Foo { - fn foo(&self) {} -} diff --git a/tests/rustdoc/extern-impl-trait.rs b/tests/rustdoc/extern-impl-trait.rs deleted file mode 100644 index 65b7a8cef49..00000000000 --- a/tests/rustdoc/extern-impl-trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:extern-impl-trait.rs - -#![crate_name = "foo"] - -extern crate extern_impl_trait; - -//@ has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" -pub use extern_impl_trait::X; - -//@ has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" -pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/extern-impl.rs b/tests/rustdoc/extern-impl.rs deleted file mode 100644 index 4fc31393988..00000000000 --- a/tests/rustdoc/extern-impl.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo.html -pub struct Foo; - -impl Foo { - //@ has - '//h4[@class="code-header"]' 'fn rust0()' - pub fn rust0() {} - //@ has - '//h4[@class="code-header"]' 'fn rust1()' - pub extern "Rust" fn rust1() {} - //@ has - '//h4[@class="code-header"]' 'extern "C" fn c0()' - pub extern fn c0() {} - //@ has - '//h4[@class="code-header"]' 'extern "C" fn c1()' - pub extern "C" fn c1() {} - //@ has - '//h4[@class="code-header"]' 'extern "system" fn system0()' - pub extern "system" fn system0() {} -} - -//@ has foo/trait.Bar.html -pub trait Bar {} - -//@ has - '//h3[@class="code-header"]' 'impl Bar for fn()' -impl Bar for fn() {} -//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' -impl Bar for extern fn() {} -//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' -impl Bar for extern "system" fn() {} diff --git a/tests/rustdoc/foreign-implementors-js-43701.rs b/tests/rustdoc/foreign-implementors-js-43701.rs deleted file mode 100644 index 03147da02c2..00000000000 --- a/tests/rustdoc/foreign-implementors-js-43701.rs +++ /dev/null @@ -1,6 +0,0 @@ -// https://github.com/rust-lang/rust/issues/43701 -#![crate_name = "foo"] - -pub use std::vec::Vec; - -//@ !has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/generic-const-items.rs b/tests/rustdoc/generic-const-items.rs deleted file mode 100644 index 31c300f2ff1..00000000000 --- a/tests/rustdoc/generic-const-items.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![feature(generic_const_items)] -#![allow(incomplete_features)] - -//@ has 'generic_const_items/constant.K.html' -//@ has - '//*[@class="rust item-decl"]//code' \ -// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ -// where \ -// String: From;" -pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None -where - String: From; - -//@ has generic_const_items/trait.Trait.html -pub trait Trait { - //@ has - '//*[@id="associatedconstant.C"]' \ - // "const C<'a>: &'a T \ - // where \ - // T: 'a + Eq" - const C<'a>: &'a T - where - T: 'a + Eq; -} - -pub struct Implementor; - -//@ has generic_const_items/struct.Implementor.html -//@ has - '//h3[@class="code-header"]' 'impl Trait for Implementor' -impl Trait for Implementor { - //@ has - '//*[@id="associatedconstant.C"]' \ - // "const C<'a>: &'a str = \"C\" \ - // where \ - // str: 'a" - const C<'a>: &'a str = "C" - // In real code we could've left off this bound but adding it explicitly allows us to test if - // we render where-clauses on associated consts inside impl blocks correctly. - where - str: 'a; -} diff --git a/tests/rustdoc/generic-impl.rs b/tests/rustdoc/generic-impl.rs deleted file mode 100644 index 9d15d0fff77..00000000000 --- a/tests/rustdoc/generic-impl.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] - -use std::fmt; - -//@ !has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' -pub struct Bar; - -//@ has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl ToString for T' -pub struct Foo; -//@ has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' - -impl fmt::Display for Foo { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Foo") - } -} diff --git a/tests/rustdoc/generic_const_exprs.rs b/tests/rustdoc/generic_const_exprs.rs deleted file mode 100644 index 44f7bf5b24c..00000000000 --- a/tests/rustdoc/generic_const_exprs.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for . - -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - -#![crate_name = "foo"] - -//@ has 'foo/trait.Foo.html' - -pub trait Foo: Sized { - const WIDTH: usize; - - fn arrayify(self) -> [Self; Self::WIDTH]; -} - -impl Foo for T { - const WIDTH: usize = 1; - - //@ has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ - // 'fn arrayify(self) -> [Self; Self::WIDTH]' - fn arrayify(self) -> [Self; Self::WIDTH] { - [self] - } -} diff --git a/tests/rustdoc/glob-shadowing-const.rs b/tests/rustdoc/glob-shadowing-const.rs deleted file mode 100644 index fbc22dbccaa..00000000000 --- a/tests/rustdoc/glob-shadowing-const.rs +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/rust-lang/rust/pull/83872#issuecomment-820101008 -#![crate_name="foo"] - -mod sub4 { - /// 0 - pub const X: usize = 0; - pub mod inner { - pub use super::*; - /// 1 - pub const X: usize = 1; - } -} - -#[doc(inline)] -pub use sub4::inner::*; - -//@ has 'foo/index.html' -//@ has - '//dd' '1' -//@ !has - '//dd' '0' -fn main() { assert_eq!(X, 1); } diff --git a/tests/rustdoc/hidden-implementors-90781.rs b/tests/rustdoc/hidden-implementors-90781.rs deleted file mode 100644 index 960a85b91f0..00000000000 --- a/tests/rustdoc/hidden-implementors-90781.rs +++ /dev/null @@ -1,78 +0,0 @@ -//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items - -// regression test for https://github.com/rust-lang/rust/issues/90781 -#![crate_name = "foo"] - -//@ has foo/trait.TPubVis.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -pub trait TPubVis {} - -//@ has foo/trait.TPubHidden.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -#[doc(hidden)] -pub trait TPubHidden {} - -//@ has foo/trait.TPrivVis.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -trait TPrivVis {} - -#[doc(hidden)] -//@ has foo/trait.TPrivHidden.html -//@ has - '//*[@id="impl-TPrivHidden-for-HidPriv"]' 'HidPriv' -//@ has - '//*[@id="impl-TPrivHidden-for-HidPub"]' 'HidPub' -//@ has - '//*[@id="impl-TPrivHidden-for-VisPriv"]' 'VisPriv' -//@ has - '//*[@id="impl-TPrivHidden-for-VisPub"]' 'VisPub' -trait TPrivHidden {} - -//@ has foo/struct.VisPub.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -pub struct VisPub; - -//@ has foo/struct.VisPriv.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -struct VisPriv; - -//@ has foo/struct.HidPub.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -#[doc(hidden)] -pub struct HidPub; - -//@ has foo/struct.HidPriv.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -#[doc(hidden)] -struct HidPriv; - -macro_rules! implement { - ($trait:ident - $($struct:ident)+) => { - $( - impl $trait for $struct {} - )+ - } -} - - -implement!(TPubVis - VisPub VisPriv HidPub HidPriv); -implement!(TPubHidden - VisPub VisPriv HidPub HidPriv); -implement!(TPrivVis - VisPub VisPriv HidPub HidPriv); -implement!(TPrivHidden - VisPub VisPriv HidPub HidPriv); diff --git a/tests/rustdoc/hidden-impls.rs b/tests/rustdoc/hidden-impls.rs deleted file mode 100644 index 73deeed9e90..00000000000 --- a/tests/rustdoc/hidden-impls.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_name = "foo"] - -mod hidden { - #[derive(Clone)] - pub struct Foo; -} - -#[doc(hidden)] -pub mod __hidden { - pub use hidden::Foo; -} - -//@ has foo/trait.Clone.html -//@ !hasraw - 'Foo' -//@ has trait.impl/core/clone/trait.Clone.js -//@ !hasraw - 'Foo' -pub use std::clone::Clone; diff --git a/tests/rustdoc/hidden-trait-struct-impls.rs b/tests/rustdoc/hidden-trait-struct-impls.rs deleted file mode 100644 index 1010cb45960..00000000000 --- a/tests/rustdoc/hidden-trait-struct-impls.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![crate_name = "foo"] - -#[doc(hidden)] -pub trait Foo {} - -trait Dark {} - -pub trait Bam {} - -pub struct Bar; - -struct Hidden; - -//@ !has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' -impl Foo for Bar {} -//@ !has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' -impl Dark for Bar {} -//@ has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' -//@ has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' -impl Bam for Bar {} -//@ !has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' -impl Bam for Hidden {} diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs deleted file mode 100644 index e94c1ea5c61..00000000000 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Test that certain unevaluated constant expression arguments that are -// deemed too verbose or complex and that may leak private or -// `doc(hidden)` struct fields are not displayed in the documentation. -// -// Read the documentation of `rustdoc::clean::utils::print_const_expr` -// for further details. -#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)] -#![allow(incomplete_features)] - -use std::marker::ConstParamTy; - -//@ has hide_complex_unevaluated_const_arguments/trait.Stage.html -pub trait Stage { - // A helper constant that prevents const expressions containing it - // from getting fully evaluated since it doesn't have a body and - // thus is non-reducible. This allows us to specifically test the - // pretty-printing of *unevaluated* consts. - const ABSTRACT: usize; - - // Currently considered "overly complex" by the `generic_const_exprs` - // feature. If / once this expression kind gets supported, this - // unevaluated const expression could leak the private struct field. - // - // FIXME: Once the line below compiles, make this a test that - // ensures that the private field is not printed. - // - //const ARRAY0: [u8; Struct { private: () } + Self::ABSTRACT]; - - // This assoc. const could leak the private assoc. function `Struct::new`. - // Ensure that this does not happen. - // - //@ has - '//*[@id="associatedconstant.ARRAY1"]' \ - // 'const ARRAY1: [u8; { _ }]' - const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] - where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; - - //@ has - '//*[@id="associatedconstant.VERBOSE"]' \ - // 'const VERBOSE: [u16; { _ }]' - const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] - where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; - - // Check that we do not leak the private struct field contained within - // the path. The output could definitely be improved upon - // (e.g. printing sth. akin to `>::OUT`) but - // right now “safe is safe”. - // - //@ has - '//*[@id="associatedconstant.PATH"]' \ - // 'const PATH: usize = _' - const PATH: usize = >::OUT; -} - -const fn compute(input: &str, extra: usize) -> usize { - input.len() + extra -} - -pub trait Helper { - const OUT: usize; -} - -impl Helper for St { - const OUT: usize = St::ABSTRACT; -} - -// Currently in rustdoc, const arguments are not evaluated in this position -// and therefore they fall under the realm of `print_const_expr`. -// If rustdoc gets patched to evaluate const arguments, it is fine to replace -// this test as long as one can ensure that private fields are not leaked! -// -//@ has hide_complex_unevaluated_const_arguments/trait.Sub.html \ -// '//pre[@class="rust item-decl"]' \ -// 'pub trait Sub: Sup<{ _ }, { _ }> { }' -pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} - -pub trait Sup {} - -#[derive(ConstParamTy, PartialEq, Eq)] -pub struct Struct { private: () } - -impl Struct { - const fn new() -> Self { Self { private: () } } - const fn do_something(self, x: usize) -> usize { - x - } -} -/* FIXME(const-trait): readd this -impl const std::ops::Add for Struct { - type Output = usize; - - fn add(self, _: usize) -> usize { 0 } -} -*/ diff --git a/tests/rustdoc/hide-complex-unevaluated-consts.rs b/tests/rustdoc/hide-complex-unevaluated-consts.rs deleted file mode 100644 index 61ae8c801dd..00000000000 --- a/tests/rustdoc/hide-complex-unevaluated-consts.rs +++ /dev/null @@ -1,71 +0,0 @@ -// Regression test for issue #97933. -// -// Test that certain unevaluated constant expressions that are -// deemed too verbose or complex and that may leak private or -// `doc(hidden)` struct fields are not displayed in the documentation. -// -// Read the documentation of `rustdoc::clean::utils::print_const_expr` -// for further details. - -//@ has hide_complex_unevaluated_consts/trait.Container.html -pub trait Container { - // A helper constant that prevents const expressions containing it - // from getting fully evaluated since it doesn't have a body and - // thus is non-reducible. This allows us to specifically test the - // pretty-printing of *unevaluated* consts. - const ABSTRACT: i32; - - // Ensure that the private field does not get leaked: - // - //@ has - '//*[@id="associatedconstant.STRUCT0"]' \ - // 'const STRUCT0: Struct = _' - const STRUCT0: Struct = Struct { private: () }; - - //@ has - '//*[@id="associatedconstant.STRUCT1"]' \ - // 'const STRUCT1: (Struct,) = _' - const STRUCT1: (Struct,) = (Struct{private: /**/()},); - - // Although the struct field is public here, check that it is not - // displayed. In a future version of rustdoc, we definitely want to - // show it. However for the time being, the printing logic is a bit - // conservative. - // - //@ has - '//*[@id="associatedconstant.STRUCT2"]' \ - // 'const STRUCT2: Record = _' - const STRUCT2: Record = Record { public: 5 }; - - // Test that we do not show the incredibly verbose match expr: - // - //@ has - '//*[@id="associatedconstant.MATCH0"]' \ - // 'const MATCH0: i32 = _' - const MATCH0: i32 = match 234 { - 0 => 1, - _ => Self::ABSTRACT, - }; - - //@ has - '//*[@id="associatedconstant.MATCH1"]' \ - // 'const MATCH1: bool = _' - const MATCH1: bool = match Self::ABSTRACT { - _ => true, - }; - - // Check that we hide complex (arithmetic) operations. - // In this case, it is a bit unfortunate since the expression - // is not *that* verbose and it might be quite useful to the reader. - // - // However in general, the expression might be quite large and - // contain match expressions and structs with private fields. - // We would need to recurse over the whole expression and even more - // importantly respect operator precedence when pretty-printing - // the potentially partially censored expression. - // For now, the implementation is quite simple and the choices - // rather conservative. - // - //@ has - '//*[@id="associatedconstant.ARITH_OPS"]' \ - // 'const ARITH_OPS: i32 = _' - const ARITH_OPS: i32 = Self::ABSTRACT * 2 + 1; -} - -pub struct Struct { private: () } - -pub struct Record { pub public: i32 } diff --git a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs b/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs deleted file mode 100644 index 995121a8455..00000000000 --- a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs +++ /dev/null @@ -1,24 +0,0 @@ -// https://github.com/rust-lang/rust/issues/74083 -#![crate_name="foo"] - -use std::ops::Deref; - -pub struct Foo; - -impl Foo { - pub fn foo(&mut self) {} -} - -//@ has foo/struct.Bar.html -//@ !has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' -pub struct Bar { - foo: Foo, -} - -impl Deref for Bar { - type Target = Foo; - - fn deref(&self) -> &Foo { - &self.foo - } -} diff --git a/tests/rustdoc/ice-associated-const-equality-105952.rs b/tests/rustdoc/ice-associated-const-equality-105952.rs deleted file mode 100644 index 1bcdfac7342..00000000000 --- a/tests/rustdoc/ice-associated-const-equality-105952.rs +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/rust-lang/rust/issues/105952 -#![crate_name = "foo"] - -#![feature(associated_const_equality)] -pub enum ParseMode { - Raw, -} -pub trait Parse { - const PARSE_MODE: ParseMode; -} -pub trait RenderRaw {} - -//@ hasraw foo/trait.RenderRaw.html 'impl' -//@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' -impl> RenderRaw for T {} diff --git a/tests/rustdoc/impl-alias-substituted.rs b/tests/rustdoc/impl-alias-substituted.rs deleted file mode 100644 index 02efcd88df8..00000000000 --- a/tests/rustdoc/impl-alias-substituted.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub struct Matrix([[T; N]; M]); - -pub type Vector = Matrix; - -//@ has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Matrix" -impl Vector { - pub fn test() {} -} diff --git a/tests/rustdoc/impl-assoc-type-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs deleted file mode 100644 index c350456195d..00000000000 --- a/tests/rustdoc/impl-assoc-type-21092.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:issue-21092.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/21092 -#![crate_name="issue_21092"] - -extern crate issue_21092; - -//@ has issue_21092/struct.Bar.html -//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' -pub use issue_21092::{Foo, Bar}; diff --git a/tests/rustdoc/impl-associated-items-order.rs b/tests/rustdoc/impl-associated-items-order.rs deleted file mode 100644 index 759e0f0b400..00000000000 --- a/tests/rustdoc/impl-associated-items-order.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This test ensures that impl associated items always follow this order: -// -// 1. Consts -// 2. Types -// 3. Functions - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Bar.html' -pub struct Bar; - -impl Bar { - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ - // 'pub fn foo()' - pub fn foo() {} - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ - // 'pub const X: u8 = 12u8' - pub const X: u8 = 12; - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ - // 'pub type Y = u8' - pub type Y = u8; -} - -pub trait Foo { - const W: u32; - fn yeay(); - type Z; -} - -impl Foo for Bar { - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ - // 'type Z = u8' - type Z = u8; - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ - // 'const W: u32 = 12u32' - const W: u32 = 12; - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ - // 'fn yeay()' - fn yeay() {} -} diff --git a/tests/rustdoc/impl-associated-items-sidebar.rs b/tests/rustdoc/impl-associated-items-sidebar.rs deleted file mode 100644 index d393a577e50..00000000000 --- a/tests/rustdoc/impl-associated-items-sidebar.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This test ensures that impl/trait associated items are listed in the sidebar. - -// ignore-tidy-linelength - -#![feature(inherent_associated_types)] -#![feature(associated_type_defaults)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Bar.html' -pub struct Bar; - -impl Bar { - //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedconstant"]/li/a[@href="#associatedconstant.X"]' 'X' - pub const X: u8 = 12; - //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedtype"]/li/a[@href="#associatedtype.Y"]' 'Y' - pub type Y = u8; -} - -//@ has 'foo/trait.Foo.html' -pub trait Foo { - //@ has - '//*[@class="sidebar-elems"]//h3[5]' 'Required Methods' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][5]/li/a[@href="#tymethod.yeay"]' 'yeay' - fn yeay(); - //@ has - '//*[@class="sidebar-elems"]//h3[6]' 'Provided Methods' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][6]/li/a[@href="#method.boo"]' 'boo' - fn boo() {} - //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Required Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][1]/li/a[@href="#associatedconstant.W"]' 'W' - const W: u32; - //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Provided Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][2]/li/a[@href="#associatedconstant.U"]' 'U' - const U: u32 = 0; - //@ has - '//*[@class="sidebar-elems"]//h3[3]' 'Required Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][3]/li/a[@href="#associatedtype.Z"]' 'Z' - type Z; - //@ has - '//*[@class="sidebar-elems"]//h3[4]' 'Provided Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][4]/li/a[@href="#associatedtype.T"]' 'T' - type T = u32; -} diff --git a/tests/rustdoc/impl-blanket-53689.rs b/tests/rustdoc/impl-blanket-53689.rs deleted file mode 100644 index 4b1697349f2..00000000000 --- a/tests/rustdoc/impl-blanket-53689.rs +++ /dev/null @@ -1,17 +0,0 @@ -// https://github.com/rust-lang/rust/issues/53689 -//@ aux-build:issue-53689.rs - -#![crate_name = "foo"] - -extern crate issue_53689; - -//@ has foo/trait.MyTrait.html -//@ !hasraw - 'MyStruct' -//@ count - '//*[h3="impl MyTrait for T"]' 1 -pub trait MyTrait {} - -impl MyTrait for T {} - -mod a { - pub use issue_53689::MyStruct; -} diff --git a/tests/rustdoc/impl-box.rs b/tests/rustdoc/impl-box.rs deleted file mode 100644 index 1fb63e21685..00000000000 --- a/tests/rustdoc/impl-box.rs +++ /dev/null @@ -1,16 +0,0 @@ -// https://github.com/rust-lang/rust/issues/92940 -// -// Show traits implemented on fundamental types that wrap local ones. - -pub struct MyType; - -//@ has 'impl_box/struct.MyType.html' -//@ has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box' - -impl Iterator for Box { - type Item = (); - - fn next(&mut self) -> Option { - todo!() - } -} diff --git a/tests/rustdoc/impl-disambiguation.rs b/tests/rustdoc/impl-disambiguation.rs deleted file mode 100644 index cfd5013964b..00000000000 --- a/tests/rustdoc/impl-disambiguation.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![crate_name = "foo"] - -pub trait Foo {} - -pub struct Bar { field: T } - -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for Bar" -impl Foo for Bar {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for Bar" -impl Foo for Bar {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl<'a> Foo for &'a Bar" -impl<'a> Foo for &'a Bar {} - -pub mod mod1 { - pub struct Baz {} -} - -pub mod mod2 { - pub enum Baz {} -} - -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for foo::mod1::Baz" -impl Foo for mod1::Baz {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl<'a> Foo for &'a foo::mod2::Baz" -impl<'a> Foo for &'a mod2::Baz {} diff --git a/tests/rustdoc/impl-everywhere.rs b/tests/rustdoc/impl-everywhere.rs deleted file mode 100644 index d1a4e901bad..00000000000 --- a/tests/rustdoc/impl-everywhere.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![crate_name = "foo"] - -pub trait Foo {} -pub trait Foo2 {} - -pub struct Bar; - -impl Foo for Bar {} -impl Foo2 for Bar {} - -//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" -pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo { - x -} - -//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' -pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 { - Bar -} - -//@ has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' -pub fn foo_foo() -> impl Foo + Foo2 { - Bar -} - -//@ has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" -pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { -} diff --git a/tests/rustdoc/impl-in-const-block.rs b/tests/rustdoc/impl-in-const-block.rs deleted file mode 100644 index 3f757fa9566..00000000000 --- a/tests/rustdoc/impl-in-const-block.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Regression test for #83026. -// The goal of this test is to ensure that impl blocks inside -// const expressions are documented as well. - -#![crate_name = "foo"] - -//@ has 'foo/struct.A.html' -//@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' -//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' -//@ has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' -//@ has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' -//@ has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' -pub struct A; - -const _: () = { - impl A { - const FOO: () = { - impl A { - pub fn woo(&self) {} - } - }; - - pub fn new() -> A { - A - } - } -}; -pub const X: () = { - impl A { - pub fn bar(&self) {} - } -}; - -fn foo() { - impl A { - pub fn yoo() {} - } - const _: () = { - impl A { - pub fn yuu() {} - } - }; -} diff --git a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs deleted file mode 100644 index a514bc35bfc..00000000000 --- a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// There should be only `type A`. -//@ count - '//*[@class="item-table"]//dt' 1 -//@ has - '//dt/a[@href="type.A.html"]' 'A' - -mod foo { - pub struct S; -} - -use foo::S; - -pub type A = S; - -//@ has 'foo/type.A.html' -//@ has - '//*[@id="method.default"]/h4' 'fn default() -> Self' -impl Default for A { - fn default() -> Self { - S - } -} - -//@ has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' -impl A { - pub fn a(&self) {} -} diff --git a/tests/rustdoc/impl-parts-crosscrate.rs b/tests/rustdoc/impl-parts-crosscrate.rs deleted file mode 100644 index 631c8bb3eb3..00000000000 --- a/tests/rustdoc/impl-parts-crosscrate.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build:rustdoc-impl-parts-crosscrate.rs -//@ ignore-cross-compile - -#![feature(negative_impls)] - -extern crate rustdoc_impl_parts_crosscrate; - -pub struct Bar { t: T } - -// The output file is html embedded in javascript, so the html tags -// aren't stripped by the processing script and we can't check for the -// full impl string. Instead, just make sure something from each part -// is mentioned. - -//@ hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar -//@ hasraw - Send -//@ hasraw - !AnAutoTrait -//@ hasraw - Copy -impl !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar - where T: Copy {} diff --git a/tests/rustdoc/impl-parts.rs b/tests/rustdoc/impl-parts.rs deleted file mode 100644 index 4f281bfd63c..00000000000 --- a/tests/rustdoc/impl-parts.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(negative_impls)] -#![feature(auto_traits)] - -pub auto trait AnAutoTrait {} - -pub struct Foo { field: T } - -//@ has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !AnAutoTrait for Foowhere T: Sync + Clone," -//@ has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl !AnAutoTrait for Foowhere T: Sync + Clone," -impl !AnAutoTrait for Foo where T: Sync {} diff --git a/tests/rustdoc/impl-ref-20175.rs b/tests/rustdoc/impl-ref-20175.rs deleted file mode 100644 index b1a9286fd41..00000000000 --- a/tests/rustdoc/impl-ref-20175.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/20175 - -#![crate_name="issue_20175"] - -pub trait Foo { - fn foo(&self) {} -} - -pub struct Bar; - -//@ has issue_20175/struct.Bar.html \ -// '//*[@id="method.foo"]' \ -// 'fn foo' -impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/impl-trait-43869.rs b/tests/rustdoc/impl-trait-43869.rs deleted file mode 100644 index 89176f59ca1..00000000000 --- a/tests/rustdoc/impl-trait-43869.rs +++ /dev/null @@ -1,75 +0,0 @@ -// https://github.com/rust-lang/rust/issues/43869 -#![crate_name="foo"] - -pub fn g() -> impl Iterator { - Some(1u8).into_iter() -} - -#[allow(unused_parens)] -pub fn h() -> (impl Iterator) { - Some(1u8).into_iter() -} - -pub fn i() -> impl Iterator + 'static { - Some(1u8).into_iter() -} - -pub fn j() -> impl Iterator + Clone { - Some(1u8).into_iter() -} - -pub fn k() -> [impl Clone; 2] { - [123u32, 456u32] -} - -pub fn l() -> (impl Clone, impl Default) { - (789u32, -123i32) -} - -pub fn m() -> &'static impl Clone { - &1u8 -} - -pub fn n() -> *const impl Clone { - &1u8 -} - -pub fn o() -> &'static [impl Clone] { - b":)" -} - -// issue #44731 -pub fn test_44731_0() -> Box> { - Box::new(g()) -} - -pub fn test_44731_1() -> Result, ()> { - Ok(Box::new(j())) -} - -// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 -// -//pub fn test_44731_2() -> Box { -// Box::new(|_: u32| {}) -//} -// -//pub fn test_44731_3() -> Box impl Clone> { -// Box::new(|| 0u32) -//} - -pub fn test_44731_4() -> Box> { - Box::new(g()) -} - -//@ has foo/fn.g.html -//@ has foo/fn.h.html -//@ has foo/fn.i.html -//@ has foo/fn.j.html -//@ has foo/fn.k.html -//@ has foo/fn.l.html -//@ has foo/fn.m.html -//@ has foo/fn.n.html -//@ has foo/fn.o.html -//@ has foo/fn.test_44731_0.html -//@ has foo/fn.test_44731_1.html -//@ has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/impl-trait-alias.rs b/tests/rustdoc/impl-trait-alias.rs deleted file mode 100644 index f7ecfffbf46..00000000000 --- a/tests/rustdoc/impl-trait-alias.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(type_alias_impl_trait)] - -trait MyTrait {} -impl MyTrait for i32 {} - -//@ hasraw impl_trait_alias/type.Foo.html 'Foo' -/// debug type -pub type Foo = impl MyTrait; - -//@ hasraw impl_trait_alias/fn.foo.html 'foo' -/// debug function -pub fn foo() -> Foo { - 1 -} diff --git a/tests/rustdoc/impl-trait-precise-capturing.rs b/tests/rustdoc/impl-trait-precise-capturing.rs deleted file mode 100644 index 3ec8c578013..00000000000 --- a/tests/rustdoc/impl-trait-precise-capturing.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ aux-build:precise-capturing.rs - -#![crate_name = "foo"] - -extern crate precise_capturing; - -//@ has foo/fn.two.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'b, 'a>" -pub fn two<'a, 'b, 'c>() -> impl Sized + use<'b, 'a /* no 'c */> {} - -//@ has foo/fn.params.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" -pub fn params<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} - -//@ has foo/fn.none.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" -pub fn none() -> impl Sized + use<> {} - -//@ has foo/fn.first.html '//section[@id="main-content"]//pre' "-> impl use<> + Sized" -pub fn first() -> impl use<> + Sized {} - -//@ has foo/fn.cross_crate_empty.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" -pub use precise_capturing::cross_crate_empty; - -//@ matches foo/fn.cross_crate_missing.html '//section[@id="main-content"]//pre' "-> impl Sized$" -pub use precise_capturing::cross_crate_missing; - -//@ has foo/fn.cross_crate_args.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" -pub use precise_capturing::cross_crate_args; diff --git a/tests/rustdoc/impl-type-parameter-33592.rs b/tests/rustdoc/impl-type-parameter-33592.rs deleted file mode 100644 index ac5df460925..00000000000 --- a/tests/rustdoc/impl-type-parameter-33592.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/33592 -#![crate_name = "foo"] - -pub trait Foo {} - -pub struct Bar; - -pub struct Baz; - -//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Bar' -impl Foo for Bar {} - -//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Baz' -impl Foo for Baz {} diff --git a/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..15953122280 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs @@ -0,0 +1,5 @@ +#[doc(hidden)] +pub enum HiddenType {} + +#[doc(hidden)] +pub trait HiddenTrait {} diff --git a/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs b/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs new file mode 100644 index 00000000000..dbd54393098 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs @@ -0,0 +1,27 @@ +pub trait Foo { + type Associated; +} + +pub struct X; +pub struct Y; + + +impl Foo for X { + type Associated = (); +} + +impl Foo for Y { + type Associated = (); +} + +impl X { + pub fn returns_sized<'a>(&'a self) -> impl Foo + 'a { + X + } +} + +impl Y { + pub fn returns_unsized<'a>(&'a self) -> Box + 'a> { + Box::new(X) + } +} diff --git a/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs b/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs new file mode 100644 index 00000000000..fc51e42e500 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs @@ -0,0 +1,7 @@ +#![feature(rustc_attrs)] + +#[rustc_has_incoherent_inherent_impls] +pub trait FooTrait {} + +#[rustc_has_incoherent_inherent_impls] +pub struct FooStruct; diff --git a/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs b/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs new file mode 100644 index 00000000000..df1b59069be --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs @@ -0,0 +1,13 @@ +#![crate_name="first"] + +pub mod prelude { + pub use crate::Bot; +} + +pub struct Bot; + +impl Bot { + pub fn new() -> Bot { + Bot + } +} diff --git a/tests/rustdoc/impl/auxiliary/issue-17476.rs b/tests/rustdoc/impl/auxiliary/issue-17476.rs new file mode 100644 index 00000000000..0a63b893fff --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-17476.rs @@ -0,0 +1,7 @@ +//@ compile-flags: -Cmetadata=aux + +#![doc(html_root_url = "http://example.com")] + +pub trait Foo { + fn foo(&self) {} +} diff --git a/tests/rustdoc/impl/auxiliary/issue-21092.rs b/tests/rustdoc/impl/auxiliary/issue-21092.rs new file mode 100644 index 00000000000..49522e0d4b5 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-21092.rs @@ -0,0 +1,12 @@ +//@ compile-flags: -Cmetadata=aux + +pub trait Foo { + type Bar; + fn foo(&self) {} +} + +pub struct Bar; + +impl Foo for Bar { + type Bar = i32; +} diff --git a/tests/rustdoc/impl/auxiliary/issue-22025.rs b/tests/rustdoc/impl/auxiliary/issue-22025.rs new file mode 100644 index 00000000000..6bc55073283 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-22025.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -Cmetadata=aux + +pub mod foo { + + pub trait Foo {} + pub struct Bar; + + impl Foo for Bar {} + +} diff --git a/tests/rustdoc/impl/auxiliary/issue-53689.rs b/tests/rustdoc/impl/auxiliary/issue-53689.rs new file mode 100644 index 00000000000..5003c2c00f4 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-53689.rs @@ -0,0 +1 @@ +pub struct MyStruct; diff --git a/tests/rustdoc/impl/auxiliary/precise-capturing.rs b/tests/rustdoc/impl/auxiliary/precise-capturing.rs new file mode 100644 index 00000000000..531d4dfdccc --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/precise-capturing.rs @@ -0,0 +1,7 @@ +#![feature(precise_capturing)] + +pub fn cross_crate_empty() -> impl Sized + use<> {} + +pub fn cross_crate_missing() -> impl Sized {} + +pub fn cross_crate_args<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} diff --git a/tests/rustdoc/impl/auxiliary/real_gimli.rs b/tests/rustdoc/impl/auxiliary/real_gimli.rs new file mode 100644 index 00000000000..871d9b31be9 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/real_gimli.rs @@ -0,0 +1,13 @@ +//@ aux-build:realcore.rs + +#![crate_name = "real_gimli"] +#![feature(staged_api, extremely_unstable)] +#![unstable(feature = "rustc_private", issue = "none")] + +extern crate realcore; + +#[unstable(feature = "rustc_private", issue = "none")] +pub struct EndianSlice; + +#[unstable(feature = "rustc_private", issue = "none")] +impl realcore::Deref for EndianSlice {} diff --git a/tests/rustdoc/impl/auxiliary/realcore.rs b/tests/rustdoc/impl/auxiliary/realcore.rs new file mode 100644 index 00000000000..e0a906df002 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/realcore.rs @@ -0,0 +1,15 @@ +#![crate_name = "realcore"] +#![feature(staged_api)] +#![unstable(feature = "extremely_unstable", issue = "none")] + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +pub struct Foo {} + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +pub trait Join {} + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +impl Join for Foo {} + +#[stable(feature = "faked_deref", since = "1.47.0")] +pub trait Deref {} diff --git a/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs b/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs new file mode 100644 index 00000000000..032db3b25e6 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs @@ -0,0 +1,23 @@ +#![feature(auto_traits)] + +pub mod bar { + use std::marker; + + pub auto trait Bar {} + + pub trait Foo { + fn foo(&self) {} + } + + impl Foo { + pub fn test(&self) {} + } + + pub struct TypeId; + + impl TypeId { + pub fn of() -> TypeId { + panic!() + } + } +} diff --git a/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs b/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs new file mode 100644 index 00000000000..135987fc00d --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs @@ -0,0 +1,3 @@ +#![feature(auto_traits)] + +pub auto trait AnAutoTrait {} diff --git a/tests/rustdoc/impl/blanket-impl-29503.rs b/tests/rustdoc/impl/blanket-impl-29503.rs new file mode 100644 index 00000000000..f43fe79ca58 --- /dev/null +++ b/tests/rustdoc/impl/blanket-impl-29503.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/29503 +#![crate_name="issue_29503"] + +use std::fmt; + +//@ has issue_29503/trait.MyTrait.html +pub trait MyTrait { + fn my_string(&self) -> String; +} + +//@ has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl MyTrait for Twhere T: Debug" +impl MyTrait for T +where + T: fmt::Debug, +{ + fn my_string(&self) -> String { + format!("{:?}", self) + } +} + +pub fn main() {} diff --git a/tests/rustdoc/impl/blanket-impl-78673.rs b/tests/rustdoc/impl/blanket-impl-78673.rs new file mode 100644 index 00000000000..412d4057406 --- /dev/null +++ b/tests/rustdoc/impl/blanket-impl-78673.rs @@ -0,0 +1,25 @@ +// https://github.com/rust-lang/rust/issues/78673 +#![crate_name = "issue_78673"] + +pub trait Something {} + +pub trait AnAmazingTrait {} + +impl AnAmazingTrait for T {} + +//@ has 'issue_78673/struct.MyStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' +//@ !has - '//*[@class="impl"]' 'AnAmazingTrait for T' +pub struct MyStruct; + +impl AnAmazingTrait for MyStruct {} + +// generic structs may have _both_ specific and blanket impls that apply + +//@ has 'issue_78673/struct.AnotherStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for T' +pub struct AnotherStruct(T); + +impl Something for AnotherStruct {} +impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..ebfe251134a --- /dev/null +++ b/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs @@ -0,0 +1,35 @@ +// Issue #86448: test for cross-crate `doc(hidden)` +#![crate_name = "foo"] + +//@ aux-build:cross-crate-hidden-impl-parameter.rs +extern crate cross_crate_hidden_impl_parameter; + +pub use ::cross_crate_hidden_impl_parameter::{HiddenType, HiddenTrait}; // OK, not re-exported + +pub enum MyLibType {} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' +impl From for MyLibType { + fn from(it: HiddenType) -> MyLibType { + match it {} + } +} + +pub struct T(T); + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' +impl From>>>> for MyLibType { + fn from(it: T>>>) -> MyLibType { + todo!() + } +} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +impl HiddenTrait for MyLibType {} + +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' +impl From for T>>> { + fn from(it: MyLibType) -> T>>> { + match it {} + } +} diff --git a/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs new file mode 100644 index 00000000000..5812d414997 --- /dev/null +++ b/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/21474 +#![crate_name="issue_21474"] + +pub use inner::*; + +mod inner { + impl super::Blah for super::What { } +} + +pub trait Blah { } + +//@ count issue_21474/struct.What.html \ +// '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +pub struct What; diff --git a/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs b/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs new file mode 100644 index 00000000000..7b1648a56ac --- /dev/null +++ b/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs @@ -0,0 +1,9 @@ +//@ aux-build:issue-22025.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/22025 +#![crate_name="issue_22025"] + +extern crate issue_22025; + +pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/impl/default-impl.rs b/tests/rustdoc/impl/default-impl.rs new file mode 100644 index 00000000000..2ba9c4ab5ad --- /dev/null +++ b/tests/rustdoc/impl/default-impl.rs @@ -0,0 +1,9 @@ +//@ aux-build:rustdoc-default-impl.rs +//@ ignore-cross-compile + +extern crate rustdoc_default_impl as foo; + +pub use foo::bar; + +pub fn wut() { +} diff --git a/tests/rustdoc/impl/deprecated-impls.rs b/tests/rustdoc/impl/deprecated-impls.rs new file mode 100644 index 00000000000..a57f26ec7fd --- /dev/null +++ b/tests/rustdoc/impl/deprecated-impls.rs @@ -0,0 +1,118 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo0.html +pub struct Foo0; + +impl Foo0 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' + //@ hasraw - 'fn_with_doc short' + //@ hasraw - 'fn_with_doc full' + /// fn_with_doc short + /// + /// fn_with_doc full + #[deprecated(since = "1.0.1", note = "fn_with_doc")] + pub fn fn_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' + #[deprecated(since = "1.0.2", note = "fn_without_doc")] + pub fn fn_without_doc() {} +} + +pub trait Bar { + /// fn_empty_with_doc short + /// + /// fn_empty_with_doc full + #[deprecated(since = "1.0.3", note = "fn_empty_with_doc")] + fn fn_empty_with_doc(); + + #[deprecated(since = "1.0.4", note = "fn_empty_without_doc")] + fn fn_empty_without_doc(); + + /// fn_def_with_doc short + /// + /// fn_def_with_doc full + #[deprecated(since = "1.0.5", note = "fn_def_with_doc")] + fn fn_def_with_doc() {} + + #[deprecated(since = "1.0.6", note = "fn_def_without_doc")] + fn fn_def_without_doc() {} + + /// fn_def_def_with_doc short + /// + /// fn_def_def_with_doc full + #[deprecated(since = "1.0.7", note = "fn_def_def_with_doc")] + fn fn_def_def_with_doc() {} + + #[deprecated(since = "1.0.8", note = "fn_def_def_without_doc")] + fn fn_def_def_without_doc() {} +} + +//@ has foo/struct.Foo1.html +pub struct Foo1; + +impl Bar for Foo1 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc_impl short' + //@ hasraw - 'fn_empty_with_doc_impl full' + /// fn_empty_with_doc_impl short + /// + /// fn_empty_with_doc_impl full + fn fn_empty_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + fn fn_empty_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc_impl short' + //@ hasraw - 'fn_def_with_doc_impl full' + /// fn_def_with_doc_impl short + /// + /// fn_def_with_doc_impl full + fn fn_def_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + fn fn_def_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' +} + +//@ has foo/struct.Foo2.html +pub struct Foo2; + +impl Bar for Foo2 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc short' + //@ !hasraw - 'fn_empty_with_doc full' + fn fn_empty_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + //@ hasraw - 'fn_empty_without_doc_impl short' + //@ hasraw - 'fn_empty_without_doc_impl full' + /// fn_empty_without_doc_impl short + /// + /// fn_empty_without_doc_impl full + fn fn_empty_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc short' + //@ !hasraw - 'fn_def_with_doc full' + fn fn_def_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + //@ hasraw - 'fn_def_without_doc_impl short' + //@ hasraw - 'fn_def_without_doc_impl full' + /// fn_def_without_doc_impl short + /// + /// fn_def_without_doc_impl full + fn fn_def_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' +} diff --git a/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs new file mode 100644 index 00000000000..d5ee3d09276 --- /dev/null +++ b/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/33069 +#![crate_name="issue_33069"] + +pub trait Bar {} + +#[doc(hidden)] +pub mod hidden { + pub struct Foo; +} + +//@ has issue_33069/trait.Bar.html +//@ !has - '//code' 'impl Bar for Foo' +impl Bar for hidden::Foo {} diff --git a/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs new file mode 100644 index 00000000000..f85d7b23637 --- /dev/null +++ b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs @@ -0,0 +1,24 @@ +// Regression test for . + +#![feature(doc_auto_cfg)] +#![crate_type = "lib"] +#![crate_name = "foo"] + +pub struct S; +pub trait MyTrait1 {} +pub trait MyTrait2 {} + +//@ has foo/struct.S.html +//@ has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ +// 'Available on non-crate feature coolstuff only.' +#[cfg(not(feature = "coolstuff"))] +impl MyTrait1 for S {} + +#[cfg(not(feature = "coolstuff"))] +mod submod { + use crate::{S, MyTrait2}; + // This impl should also have the `not(feature = "coolstuff")`. + //@ has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ + // 'Available on non-crate feature coolstuff only.' + impl MyTrait2 for S {} +} diff --git a/tests/rustdoc/impl/duplicated_impl.rs b/tests/rustdoc/impl/duplicated_impl.rs new file mode 100644 index 00000000000..e7828885cc1 --- /dev/null +++ b/tests/rustdoc/impl/duplicated_impl.rs @@ -0,0 +1,14 @@ +// This test ensures that the same implementation doesn't show more than once. +// It's a regression test for https://github.com/rust-lang/rust/issues/96036. + +#![crate_name = "foo"] + +// We check that there is only one "impl Something for T" listed in the +// blanket implementations. + +//@ has 'foo/struct.Whatever.html' +//@ count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 + +pub trait Something { } +pub struct Whatever; +impl Something for T {} diff --git a/tests/rustdoc/impl/empty-impl-block.rs b/tests/rustdoc/impl/empty-impl-block.rs new file mode 100644 index 00000000000..91fd4a64ef9 --- /dev/null +++ b/tests/rustdoc/impl/empty-impl-block.rs @@ -0,0 +1,20 @@ +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +pub struct Foo; + +//@ has - '//*[@class="docblock"]' 'Hello empty impl block!' +//@ has - '//*[@class="item-info"]' 'This impl block contains no items.' +/// Hello empty impl block! +impl Foo {} +// We ensure that this empty impl block without doc isn't rendered. +//@ count - '//*[@class="impl"]' 'impl Foo' 1 +impl Foo {} + +// Just to ensure that empty trait impl blocks are rendered. +pub struct Another; +pub trait Bar {} + +//@ has 'foo/struct.Another.html' +//@ has - '//h3[@class="code-header"]' 'impl Bar for Another' +impl Bar for Another {} diff --git a/tests/rustdoc/impl/empty-impls.rs b/tests/rustdoc/impl/empty-impls.rs new file mode 100644 index 00000000000..912a8d3d913 --- /dev/null +++ b/tests/rustdoc/impl/empty-impls.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo.html +//@ has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' +pub struct Foo; + +pub trait EmptyTrait {} + +//@ has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' +impl EmptyTrait for Foo {} + +pub trait NotEmpty { + fn foo(&self); +} + +//@ has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' +impl NotEmpty for Foo { + fn foo(&self) {} +} diff --git a/tests/rustdoc/impl/extern-impl-trait.rs b/tests/rustdoc/impl/extern-impl-trait.rs new file mode 100644 index 00000000000..65b7a8cef49 --- /dev/null +++ b/tests/rustdoc/impl/extern-impl-trait.rs @@ -0,0 +1,11 @@ +//@ aux-build:extern-impl-trait.rs + +#![crate_name = "foo"] + +extern crate extern_impl_trait; + +//@ has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" +pub use extern_impl_trait::X; + +//@ has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" +pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/impl/extern-impl.rs b/tests/rustdoc/impl/extern-impl.rs new file mode 100644 index 00000000000..4fc31393988 --- /dev/null +++ b/tests/rustdoc/impl/extern-impl.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo.html +pub struct Foo; + +impl Foo { + //@ has - '//h4[@class="code-header"]' 'fn rust0()' + pub fn rust0() {} + //@ has - '//h4[@class="code-header"]' 'fn rust1()' + pub extern "Rust" fn rust1() {} + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c0()' + pub extern fn c0() {} + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c1()' + pub extern "C" fn c1() {} + //@ has - '//h4[@class="code-header"]' 'extern "system" fn system0()' + pub extern "system" fn system0() {} +} + +//@ has foo/trait.Bar.html +pub trait Bar {} + +//@ has - '//h3[@class="code-header"]' 'impl Bar for fn()' +impl Bar for fn() {} +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' +impl Bar for extern fn() {} +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' +impl Bar for extern "system" fn() {} diff --git a/tests/rustdoc/impl/foreign-implementors-js-43701.rs b/tests/rustdoc/impl/foreign-implementors-js-43701.rs new file mode 100644 index 00000000000..03147da02c2 --- /dev/null +++ b/tests/rustdoc/impl/foreign-implementors-js-43701.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/43701 +#![crate_name = "foo"] + +pub use std::vec::Vec; + +//@ !has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/impl/generic-impl.rs b/tests/rustdoc/impl/generic-impl.rs new file mode 100644 index 00000000000..9d15d0fff77 --- /dev/null +++ b/tests/rustdoc/impl/generic-impl.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +use std::fmt; + +//@ !has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' +pub struct Bar; + +//@ has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl ToString for T' +pub struct Foo; +//@ has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' + +impl fmt::Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Foo") + } +} diff --git a/tests/rustdoc/impl/hidden-implementors-90781.rs b/tests/rustdoc/impl/hidden-implementors-90781.rs new file mode 100644 index 00000000000..960a85b91f0 --- /dev/null +++ b/tests/rustdoc/impl/hidden-implementors-90781.rs @@ -0,0 +1,78 @@ +//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items + +// regression test for https://github.com/rust-lang/rust/issues/90781 +#![crate_name = "foo"] + +//@ has foo/trait.TPubVis.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +pub trait TPubVis {} + +//@ has foo/trait.TPubHidden.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +#[doc(hidden)] +pub trait TPubHidden {} + +//@ has foo/trait.TPrivVis.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +trait TPrivVis {} + +#[doc(hidden)] +//@ has foo/trait.TPrivHidden.html +//@ has - '//*[@id="impl-TPrivHidden-for-HidPriv"]' 'HidPriv' +//@ has - '//*[@id="impl-TPrivHidden-for-HidPub"]' 'HidPub' +//@ has - '//*[@id="impl-TPrivHidden-for-VisPriv"]' 'VisPriv' +//@ has - '//*[@id="impl-TPrivHidden-for-VisPub"]' 'VisPub' +trait TPrivHidden {} + +//@ has foo/struct.VisPub.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +pub struct VisPub; + +//@ has foo/struct.VisPriv.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +struct VisPriv; + +//@ has foo/struct.HidPub.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +#[doc(hidden)] +pub struct HidPub; + +//@ has foo/struct.HidPriv.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +#[doc(hidden)] +struct HidPriv; + +macro_rules! implement { + ($trait:ident - $($struct:ident)+) => { + $( + impl $trait for $struct {} + )+ + } +} + + +implement!(TPubVis - VisPub VisPriv HidPub HidPriv); +implement!(TPubHidden - VisPub VisPriv HidPub HidPriv); +implement!(TPrivVis - VisPub VisPriv HidPub HidPriv); +implement!(TPrivHidden - VisPub VisPriv HidPub HidPriv); diff --git a/tests/rustdoc/impl/hidden-impls.rs b/tests/rustdoc/impl/hidden-impls.rs new file mode 100644 index 00000000000..73deeed9e90 --- /dev/null +++ b/tests/rustdoc/impl/hidden-impls.rs @@ -0,0 +1,17 @@ +#![crate_name = "foo"] + +mod hidden { + #[derive(Clone)] + pub struct Foo; +} + +#[doc(hidden)] +pub mod __hidden { + pub use hidden::Foo; +} + +//@ has foo/trait.Clone.html +//@ !hasraw - 'Foo' +//@ has trait.impl/core/clone/trait.Clone.js +//@ !hasraw - 'Foo' +pub use std::clone::Clone; diff --git a/tests/rustdoc/impl/hidden-trait-struct-impls.rs b/tests/rustdoc/impl/hidden-trait-struct-impls.rs new file mode 100644 index 00000000000..1010cb45960 --- /dev/null +++ b/tests/rustdoc/impl/hidden-trait-struct-impls.rs @@ -0,0 +1,22 @@ +#![crate_name = "foo"] + +#[doc(hidden)] +pub trait Foo {} + +trait Dark {} + +pub trait Bam {} + +pub struct Bar; + +struct Hidden; + +//@ !has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' +impl Foo for Bar {} +//@ !has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' +impl Dark for Bar {} +//@ has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' +//@ has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' +impl Bam for Bar {} +//@ !has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' +impl Bam for Hidden {} diff --git a/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs b/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs new file mode 100644 index 00000000000..995121a8455 --- /dev/null +++ b/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/74083 +#![crate_name="foo"] + +use std::ops::Deref; + +pub struct Foo; + +impl Foo { + pub fn foo(&mut self) {} +} + +//@ has foo/struct.Bar.html +//@ !has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +pub struct Bar { + foo: Foo, +} + +impl Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &self.foo + } +} diff --git a/tests/rustdoc/impl/impl-alias-substituted.rs b/tests/rustdoc/impl/impl-alias-substituted.rs new file mode 100644 index 00000000000..02efcd88df8 --- /dev/null +++ b/tests/rustdoc/impl/impl-alias-substituted.rs @@ -0,0 +1,9 @@ +pub struct Matrix([[T; N]; M]); + +pub type Vector = Matrix; + +//@ has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Matrix" +impl Vector { + pub fn test() {} +} diff --git a/tests/rustdoc/impl/impl-assoc-type-21092.rs b/tests/rustdoc/impl/impl-assoc-type-21092.rs new file mode 100644 index 00000000000..c350456195d --- /dev/null +++ b/tests/rustdoc/impl/impl-assoc-type-21092.rs @@ -0,0 +1,11 @@ +//@ aux-build:issue-21092.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/21092 +#![crate_name="issue_21092"] + +extern crate issue_21092; + +//@ has issue_21092/struct.Bar.html +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' +pub use issue_21092::{Foo, Bar}; diff --git a/tests/rustdoc/impl/impl-associated-items-order.rs b/tests/rustdoc/impl/impl-associated-items-order.rs new file mode 100644 index 00000000000..759e0f0b400 --- /dev/null +++ b/tests/rustdoc/impl/impl-associated-items-order.rs @@ -0,0 +1,42 @@ +// This test ensures that impl associated items always follow this order: +// +// 1. Consts +// 2. Types +// 3. Functions + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Bar.html' +pub struct Bar; + +impl Bar { + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ + // 'pub fn foo()' + pub fn foo() {} + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ + // 'pub const X: u8 = 12u8' + pub const X: u8 = 12; + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ + // 'pub type Y = u8' + pub type Y = u8; +} + +pub trait Foo { + const W: u32; + fn yeay(); + type Z; +} + +impl Foo for Bar { + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ + // 'type Z = u8' + type Z = u8; + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ + // 'const W: u32 = 12u32' + const W: u32 = 12; + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ + // 'fn yeay()' + fn yeay() {} +} diff --git a/tests/rustdoc/impl/impl-associated-items-sidebar.rs b/tests/rustdoc/impl/impl-associated-items-sidebar.rs new file mode 100644 index 00000000000..d393a577e50 --- /dev/null +++ b/tests/rustdoc/impl/impl-associated-items-sidebar.rs @@ -0,0 +1,42 @@ +// This test ensures that impl/trait associated items are listed in the sidebar. + +// ignore-tidy-linelength + +#![feature(inherent_associated_types)] +#![feature(associated_type_defaults)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Bar.html' +pub struct Bar; + +impl Bar { + //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedconstant"]/li/a[@href="#associatedconstant.X"]' 'X' + pub const X: u8 = 12; + //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedtype"]/li/a[@href="#associatedtype.Y"]' 'Y' + pub type Y = u8; +} + +//@ has 'foo/trait.Foo.html' +pub trait Foo { + //@ has - '//*[@class="sidebar-elems"]//h3[5]' 'Required Methods' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][5]/li/a[@href="#tymethod.yeay"]' 'yeay' + fn yeay(); + //@ has - '//*[@class="sidebar-elems"]//h3[6]' 'Provided Methods' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][6]/li/a[@href="#method.boo"]' 'boo' + fn boo() {} + //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Required Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][1]/li/a[@href="#associatedconstant.W"]' 'W' + const W: u32; + //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Provided Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][2]/li/a[@href="#associatedconstant.U"]' 'U' + const U: u32 = 0; + //@ has - '//*[@class="sidebar-elems"]//h3[3]' 'Required Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][3]/li/a[@href="#associatedtype.Z"]' 'Z' + type Z; + //@ has - '//*[@class="sidebar-elems"]//h3[4]' 'Provided Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][4]/li/a[@href="#associatedtype.T"]' 'T' + type T = u32; +} diff --git a/tests/rustdoc/impl/impl-blanket-53689.rs b/tests/rustdoc/impl/impl-blanket-53689.rs new file mode 100644 index 00000000000..4b1697349f2 --- /dev/null +++ b/tests/rustdoc/impl/impl-blanket-53689.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/53689 +//@ aux-build:issue-53689.rs + +#![crate_name = "foo"] + +extern crate issue_53689; + +//@ has foo/trait.MyTrait.html +//@ !hasraw - 'MyStruct' +//@ count - '//*[h3="impl MyTrait for T"]' 1 +pub trait MyTrait {} + +impl MyTrait for T {} + +mod a { + pub use issue_53689::MyStruct; +} diff --git a/tests/rustdoc/impl/impl-box.rs b/tests/rustdoc/impl/impl-box.rs new file mode 100644 index 00000000000..1fb63e21685 --- /dev/null +++ b/tests/rustdoc/impl/impl-box.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/92940 +// +// Show traits implemented on fundamental types that wrap local ones. + +pub struct MyType; + +//@ has 'impl_box/struct.MyType.html' +//@ has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box' + +impl Iterator for Box { + type Item = (); + + fn next(&mut self) -> Option { + todo!() + } +} diff --git a/tests/rustdoc/impl/impl-disambiguation.rs b/tests/rustdoc/impl/impl-disambiguation.rs new file mode 100644 index 00000000000..cfd5013964b --- /dev/null +++ b/tests/rustdoc/impl/impl-disambiguation.rs @@ -0,0 +1,30 @@ +#![crate_name = "foo"] + +pub trait Foo {} + +pub struct Bar { field: T } + +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for Bar" +impl Foo for Bar {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for Bar" +impl Foo for Bar {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<'a> Foo for &'a Bar" +impl<'a> Foo for &'a Bar {} + +pub mod mod1 { + pub struct Baz {} +} + +pub mod mod2 { + pub enum Baz {} +} + +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for foo::mod1::Baz" +impl Foo for mod1::Baz {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<'a> Foo for &'a foo::mod2::Baz" +impl<'a> Foo for &'a mod2::Baz {} diff --git a/tests/rustdoc/impl/impl-everywhere.rs b/tests/rustdoc/impl/impl-everywhere.rs new file mode 100644 index 00000000000..d1a4e901bad --- /dev/null +++ b/tests/rustdoc/impl/impl-everywhere.rs @@ -0,0 +1,30 @@ +#![crate_name = "foo"] + +pub trait Foo {} +pub trait Foo2 {} + +pub struct Bar; + +impl Foo for Bar {} +impl Foo2 for Bar {} + +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" +pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo { + x +} + +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' +pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 { + Bar +} + +//@ has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' +pub fn foo_foo() -> impl Foo + Foo2 { + Bar +} + +//@ has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" +pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { +} diff --git a/tests/rustdoc/impl/impl-in-const-block.rs b/tests/rustdoc/impl/impl-in-const-block.rs new file mode 100644 index 00000000000..3f757fa9566 --- /dev/null +++ b/tests/rustdoc/impl/impl-in-const-block.rs @@ -0,0 +1,43 @@ +// Regression test for #83026. +// The goal of this test is to ensure that impl blocks inside +// const expressions are documented as well. + +#![crate_name = "foo"] + +//@ has 'foo/struct.A.html' +//@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' +//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' +//@ has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' +//@ has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' +//@ has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' +pub struct A; + +const _: () = { + impl A { + const FOO: () = { + impl A { + pub fn woo(&self) {} + } + }; + + pub fn new() -> A { + A + } + } +}; +pub const X: () = { + impl A { + pub fn bar(&self) {} + } +}; + +fn foo() { + impl A { + pub fn yoo() {} + } + const _: () = { + impl A { + pub fn yuu() {} + } + }; +} diff --git a/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs new file mode 100644 index 00000000000..a514bc35bfc --- /dev/null +++ b/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// There should be only `type A`. +//@ count - '//*[@class="item-table"]//dt' 1 +//@ has - '//dt/a[@href="type.A.html"]' 'A' + +mod foo { + pub struct S; +} + +use foo::S; + +pub type A = S; + +//@ has 'foo/type.A.html' +//@ has - '//*[@id="method.default"]/h4' 'fn default() -> Self' +impl Default for A { + fn default() -> Self { + S + } +} + +//@ has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' +impl A { + pub fn a(&self) {} +} diff --git a/tests/rustdoc/impl/impl-parts-crosscrate.rs b/tests/rustdoc/impl/impl-parts-crosscrate.rs new file mode 100644 index 00000000000..631c8bb3eb3 --- /dev/null +++ b/tests/rustdoc/impl/impl-parts-crosscrate.rs @@ -0,0 +1,20 @@ +//@ aux-build:rustdoc-impl-parts-crosscrate.rs +//@ ignore-cross-compile + +#![feature(negative_impls)] + +extern crate rustdoc_impl_parts_crosscrate; + +pub struct Bar { t: T } + +// The output file is html embedded in javascript, so the html tags +// aren't stripped by the processing script and we can't check for the +// full impl string. Instead, just make sure something from each part +// is mentioned. + +//@ hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar +//@ hasraw - Send +//@ hasraw - !AnAutoTrait +//@ hasraw - Copy +impl !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar + where T: Copy {} diff --git a/tests/rustdoc/impl/impl-parts.rs b/tests/rustdoc/impl/impl-parts.rs new file mode 100644 index 00000000000..4f281bfd63c --- /dev/null +++ b/tests/rustdoc/impl/impl-parts.rs @@ -0,0 +1,12 @@ +#![feature(negative_impls)] +#![feature(auto_traits)] + +pub auto trait AnAutoTrait {} + +pub struct Foo { field: T } + +//@ has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !AnAutoTrait for Foowhere T: Sync + Clone," +//@ has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl !AnAutoTrait for Foowhere T: Sync + Clone," +impl !AnAutoTrait for Foo where T: Sync {} diff --git a/tests/rustdoc/impl/impl-ref-20175.rs b/tests/rustdoc/impl/impl-ref-20175.rs new file mode 100644 index 00000000000..b1a9286fd41 --- /dev/null +++ b/tests/rustdoc/impl/impl-ref-20175.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/20175 + +#![crate_name="issue_20175"] + +pub trait Foo { + fn foo(&self) {} +} + +pub struct Bar; + +//@ has issue_20175/struct.Bar.html \ +// '//*[@id="method.foo"]' \ +// 'fn foo' +impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/impl/impl-trait-43869.rs b/tests/rustdoc/impl/impl-trait-43869.rs new file mode 100644 index 00000000000..89176f59ca1 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-43869.rs @@ -0,0 +1,75 @@ +// https://github.com/rust-lang/rust/issues/43869 +#![crate_name="foo"] + +pub fn g() -> impl Iterator { + Some(1u8).into_iter() +} + +#[allow(unused_parens)] +pub fn h() -> (impl Iterator) { + Some(1u8).into_iter() +} + +pub fn i() -> impl Iterator + 'static { + Some(1u8).into_iter() +} + +pub fn j() -> impl Iterator + Clone { + Some(1u8).into_iter() +} + +pub fn k() -> [impl Clone; 2] { + [123u32, 456u32] +} + +pub fn l() -> (impl Clone, impl Default) { + (789u32, -123i32) +} + +pub fn m() -> &'static impl Clone { + &1u8 +} + +pub fn n() -> *const impl Clone { + &1u8 +} + +pub fn o() -> &'static [impl Clone] { + b":)" +} + +// issue #44731 +pub fn test_44731_0() -> Box> { + Box::new(g()) +} + +pub fn test_44731_1() -> Result, ()> { + Ok(Box::new(j())) +} + +// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 +// +//pub fn test_44731_2() -> Box { +// Box::new(|_: u32| {}) +//} +// +//pub fn test_44731_3() -> Box impl Clone> { +// Box::new(|| 0u32) +//} + +pub fn test_44731_4() -> Box> { + Box::new(g()) +} + +//@ has foo/fn.g.html +//@ has foo/fn.h.html +//@ has foo/fn.i.html +//@ has foo/fn.j.html +//@ has foo/fn.k.html +//@ has foo/fn.l.html +//@ has foo/fn.m.html +//@ has foo/fn.n.html +//@ has foo/fn.o.html +//@ has foo/fn.test_44731_0.html +//@ has foo/fn.test_44731_1.html +//@ has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/impl/impl-trait-alias.rs b/tests/rustdoc/impl/impl-trait-alias.rs new file mode 100644 index 00000000000..f7ecfffbf46 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-alias.rs @@ -0,0 +1,14 @@ +#![feature(type_alias_impl_trait)] + +trait MyTrait {} +impl MyTrait for i32 {} + +//@ hasraw impl_trait_alias/type.Foo.html 'Foo' +/// debug type +pub type Foo = impl MyTrait; + +//@ hasraw impl_trait_alias/fn.foo.html 'foo' +/// debug function +pub fn foo() -> Foo { + 1 +} diff --git a/tests/rustdoc/impl/impl-trait-precise-capturing.rs b/tests/rustdoc/impl/impl-trait-precise-capturing.rs new file mode 100644 index 00000000000..3ec8c578013 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-precise-capturing.rs @@ -0,0 +1,26 @@ +//@ aux-build:precise-capturing.rs + +#![crate_name = "foo"] + +extern crate precise_capturing; + +//@ has foo/fn.two.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'b, 'a>" +pub fn two<'a, 'b, 'c>() -> impl Sized + use<'b, 'a /* no 'c */> {} + +//@ has foo/fn.params.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" +pub fn params<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} + +//@ has foo/fn.none.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" +pub fn none() -> impl Sized + use<> {} + +//@ has foo/fn.first.html '//section[@id="main-content"]//pre' "-> impl use<> + Sized" +pub fn first() -> impl use<> + Sized {} + +//@ has foo/fn.cross_crate_empty.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" +pub use precise_capturing::cross_crate_empty; + +//@ matches foo/fn.cross_crate_missing.html '//section[@id="main-content"]//pre' "-> impl Sized$" +pub use precise_capturing::cross_crate_missing; + +//@ has foo/fn.cross_crate_args.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" +pub use precise_capturing::cross_crate_args; diff --git a/tests/rustdoc/impl/impl-type-parameter-33592.rs b/tests/rustdoc/impl/impl-type-parameter-33592.rs new file mode 100644 index 00000000000..ac5df460925 --- /dev/null +++ b/tests/rustdoc/impl/impl-type-parameter-33592.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/33592 +#![crate_name = "foo"] + +pub trait Foo {} + +pub struct Bar; + +pub struct Baz; + +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Bar' +impl Foo for Bar {} + +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Baz' +impl Foo for Baz {} diff --git a/tests/rustdoc/impl/implementor-stable-version.rs b/tests/rustdoc/impl/implementor-stable-version.rs new file mode 100644 index 00000000000..cd4fa93f803 --- /dev/null +++ b/tests/rustdoc/impl/implementor-stable-version.rs @@ -0,0 +1,21 @@ +#![stable(feature = "bar", since = "3.3.3")] +#![crate_name = "foo"] + +#![feature(staged_api)] + +#[stable(feature = "bar", since = "3.3.3")] +pub trait Bar {} + +#[stable(feature = "baz", since = "3.3.3")] +pub trait Baz {} + +#[stable(feature = "baz", since = "3.3.3")] +pub struct Foo; + +//@ has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' +#[stable(feature = "foobar", since = "4.4.4")] +impl Bar for Foo {} + +//@ has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' +#[stable(feature = "foobaz", since = "3.3.3")] +impl Baz for Foo {} diff --git a/tests/rustdoc/impl/implementors-unstable-75588.rs b/tests/rustdoc/impl/implementors-unstable-75588.rs new file mode 100644 index 00000000000..44a785c4ad9 --- /dev/null +++ b/tests/rustdoc/impl/implementors-unstable-75588.rs @@ -0,0 +1,18 @@ +//@ aux-build:realcore.rs +//@ aux-build:real_gimli.rs + +// Ensure unstably exported traits have their Implementors sections. +// https://github.com/rust-lang/rust/issues/75588 + +#![crate_name = "foo"] +#![feature(extremely_unstable_foo)] + +extern crate realcore; +extern crate real_gimli; + +// issue #74672 +//@ !has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' +pub use realcore::Deref; + +//@ has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' +pub use realcore::Join; diff --git a/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs b/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs new file mode 100644 index 00000000000..ba6ed427871 --- /dev/null +++ b/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs @@ -0,0 +1,15 @@ +//@ aux-build:issue-100204-aux.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/100204 +#![crate_name="second"] + +extern crate first; + +pub mod prelude {} + +//@ has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +//@ has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +#[doc(inline)] +pub use first::*; diff --git a/tests/rustdoc/impl/manual_impl.rs b/tests/rustdoc/impl/manual_impl.rs new file mode 100644 index 00000000000..281262bb40a --- /dev/null +++ b/tests/rustdoc/impl/manual_impl.rs @@ -0,0 +1,77 @@ +//@ has manual_impl/trait.T.html +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' +/// Docs associated with the trait definition. +pub trait T { + /// Docs associated with the trait a_method definition. + fn a_method(&self) -> usize; + + /// Docs associated with the trait b_method definition. + fn b_method(&self) -> usize { + self.a_method() + } + + /// Docs associated with the trait c_method definition. + /// + /// There is another line + fn c_method(&self) -> usize { + self.a_method() + } +} + +//@ has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' +//@ !has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' +//@ !has - '//*[@class="docblock"]' 'There is another line' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' +pub struct S1(usize); + +/// Docs associated with the S1 trait implementation. +impl T for S1 { + /// Docs associated with the S1 trait a_method implementation. + fn a_method(&self) -> usize { + self.0 + } +} + +//@ has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +pub struct S2(usize); + +/// Docs associated with the S2 trait implementation. +impl T for S2 { + /// Docs associated with the S2 trait a_method implementation. + fn a_method(&self) -> usize { + self.0 + } + + /// Docs associated with the S2 trait c_method implementation. + fn c_method(&self) -> usize { + 5 + } +} + +//@ has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' +pub struct S3(usize); + +/// Docs associated with the S3 trait implementation. +impl T for S3 { + fn a_method(&self) -> usize { + self.0 + } + + /// Docs associated with the S3 trait b_method implementation. + fn b_method(&self) -> usize { + 5 + } +} diff --git a/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs new file mode 100644 index 00000000000..cda828d3967 --- /dev/null +++ b/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs @@ -0,0 +1,14 @@ +//@ aux-build:issue-17476.rs +//@ ignore-cross-compile +// https://github.com/rust-lang/rust/issues/17476 + +#![crate_name="issue_17476"] + +extern crate issue_17476; + +pub struct Foo; + +//@ has issue_17476/struct.Foo.html \ +// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ +// 'foo' +impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/impl/module-impls.rs b/tests/rustdoc/impl/module-impls.rs new file mode 100644 index 00000000000..b66721ecb13 --- /dev/null +++ b/tests/rustdoc/impl/module-impls.rs @@ -0,0 +1,5 @@ +#![crate_name = "foo"] + +pub use std::marker::Send; + +//@ !hasraw foo/index.html 'Implementations' diff --git a/tests/rustdoc/impl/must_implement_one_of.rs b/tests/rustdoc/impl/must_implement_one_of.rs new file mode 100644 index 00000000000..ab965bab356 --- /dev/null +++ b/tests/rustdoc/impl/must_implement_one_of.rs @@ -0,0 +1,10 @@ +#![crate_name = "c"] +#![feature(rustc_attrs)] + +#[rustc_must_implement_one_of(a, b)] +//@ matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ +// 'At least one of the `a`, `b` methods is required.$' +pub trait Trait { + fn a() {} + fn b() {} +} diff --git a/tests/rustdoc/impl/negative-impl-no-items.rs b/tests/rustdoc/impl/negative-impl-no-items.rs new file mode 100644 index 00000000000..c628e542033 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl-no-items.rs @@ -0,0 +1,26 @@ +// This test ensures that negative impls don't have items listed inside them. + +#![feature(negative_impls)] +#![crate_name = "foo"] + +pub struct Thing; + +//@ has 'foo/struct.Thing.html' +// We check the full path to ensure there is no `
` element. +//@ has - '//div[@id="trait-implementations-list"]/section[@id="impl-Iterator-for-Thing"]/h3' \ +// 'impl !Iterator for Thing' +impl !Iterator for Thing {} + +// This struct will allow us to compare both paths. +pub struct Witness; + +//@ has 'foo/struct.Witness.html' +//@ has - '//div[@id="trait-implementations-list"]/details//section[@id="impl-Iterator-for-Witness"]/h3' \ +// 'impl Iterator for Witness' +impl Iterator for Witness { + type Item = u8; + + fn next(&mut self) -> Option { + None + } +} diff --git a/tests/rustdoc/impl/negative-impl-sidebar.rs b/tests/rustdoc/impl/negative-impl-sidebar.rs new file mode 100644 index 00000000000..1742dce1945 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl-sidebar.rs @@ -0,0 +1,9 @@ +#![feature(negative_impls)] +#![crate_name = "foo"] + +pub struct Foo; + +//@ has foo/struct.Foo.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' +//@ has - '//*[@class="sidebar-elems"]//section//a' '!Sync' +impl !Sync for Foo {} diff --git a/tests/rustdoc/impl/negative-impl.rs b/tests/rustdoc/impl/negative-impl.rs new file mode 100644 index 00000000000..f057a749b72 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl.rs @@ -0,0 +1,14 @@ +#![feature(negative_impls)] + +//@ matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" +pub struct Alpha; +//@ matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo" +pub struct Bravo(B); + +//@ matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Send for Alpha" +impl !Send for Alpha {} + +//@ matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ +// impl !Send for Bravo" +impl !Send for Bravo {} diff --git a/tests/rustdoc/impl/return-impl-trait.rs b/tests/rustdoc/impl/return-impl-trait.rs new file mode 100644 index 00000000000..175867d2204 --- /dev/null +++ b/tests/rustdoc/impl/return-impl-trait.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +pub trait Backend {} + +impl Backend for () {} + +pub struct Module(T); + +pub type BackendImpl = impl Backend; + +//@ has return_impl_trait/fn.make_module.html +/// Documentation +pub fn make_module() -> Module { + Module(()) +} diff --git a/tests/rustdoc/impl/rustc-incoherent-impls.rs b/tests/rustdoc/impl/rustc-incoherent-impls.rs new file mode 100644 index 00000000000..81a7025906b --- /dev/null +++ b/tests/rustdoc/impl/rustc-incoherent-impls.rs @@ -0,0 +1,28 @@ +//@ aux-build:incoherent-impl-types.rs +//@ build-aux-docs + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +extern crate incoherent_impl_types; + +// The only way this actually shows up is if the type gets inlined. +#[doc(inline)] +pub use incoherent_impl_types::FooTrait; + +//@ has foo/trait.FooTrait.html +//@ count - '//section[@id="method.do_something"]' 1 +impl dyn FooTrait { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} + +#[doc(inline)] +pub use incoherent_impl_types::FooStruct; + +//@ has foo/struct.FooStruct.html +//@ count - '//section[@id="method.do_something"]' 1 +impl FooStruct { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} diff --git a/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..b0beb1bdfa0 --- /dev/null +++ b/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs @@ -0,0 +1,36 @@ +// test for `doc(hidden)` with impl parameters in the same crate. +#![crate_name = "foo"] + +#[doc(hidden)] +pub enum HiddenType {} + +#[doc(hidden)] +pub trait HiddenTrait {} + +pub enum MyLibType {} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' +impl From for MyLibType { + fn from(it: HiddenType) -> MyLibType { + match it {} + } +} + +pub struct T(T); + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' +impl From>>>> for MyLibType { + fn from(it: T>>>) -> MyLibType { + todo!() + } +} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +impl HiddenTrait for MyLibType {} + +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' +impl From for T>>> { + fn from(it: MyLibType) -> T>>> { + match it {} + } +} diff --git a/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs b/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs new file mode 100644 index 00000000000..b1bf029cf84 --- /dev/null +++ b/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/78701 +#![crate_name = "foo"] + +// This test ensures that if a blanket impl has the same ID as another impl, it'll +// link to the blanket impl and not the other impl. Basically, we're checking if +// the ID is correctly derived. + +//@ has 'foo/struct.AnotherStruct.html' +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 + +pub trait Something {} + +pub trait AnAmazingTrait {} + +impl AnAmazingTrait for T {} + +pub struct AnotherStruct(T); + +impl Something for AnotherStruct {} +impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/impl/struct-implementations-title.rs b/tests/rustdoc/impl/struct-implementations-title.rs new file mode 100644 index 00000000000..ca5b5c0ee20 --- /dev/null +++ b/tests/rustdoc/impl/struct-implementations-title.rs @@ -0,0 +1,9 @@ +#![crate_name = "foo"] + +pub struct Struc; + +//@ has foo/struct.Struc.html +//@ has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" +impl Struc { + pub const S: u64 = 0; +} diff --git a/tests/rustdoc/impl/trait-impl.rs b/tests/rustdoc/impl/trait-impl.rs new file mode 100644 index 00000000000..c65eecc4edf --- /dev/null +++ b/tests/rustdoc/impl/trait-impl.rs @@ -0,0 +1,45 @@ +pub trait Trait { + /// Some long docs here. + /// + /// These docs are long enough that a link will be added to the end. + fn a(); + + /// These docs contain a [reference link]. + /// + /// [reference link]: https://example.com + fn b(); + + /// ``` + /// This code block should not be in the output, but a Read more link should be generated + /// ``` + fn c(); + + /// Escaped formatting a\*b\*c\* works + fn d(); +} + +pub struct Struct; + +impl Trait for Struct { + //@ has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' + //@ !has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' + fn a() {} + + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' + fn b() {} + + //@ !has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' + fn c() {} + + //@ has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' + //@ !has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' + fn d() {} + + //@ has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' +} diff --git a/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs b/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs new file mode 100644 index 00000000000..8eb6d007525 --- /dev/null +++ b/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs @@ -0,0 +1,17 @@ +#![crate_name = "foo"] + +// https://github.com/rust-lang/rust/issues/45584 + +pub trait Bar {} + +//@ has 'foo/struct.Foo1.html' +pub struct Foo1; +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar for Foo1" +impl Bar for Foo1 {} + +//@ has 'foo/struct.Foo2.html' +pub struct Foo2; +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" +impl Bar<&'static Foo2, Foo2> for u8 {} diff --git a/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs b/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs new file mode 100644 index 00000000000..6d6e5e0a839 --- /dev/null +++ b/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs @@ -0,0 +1,17 @@ +//@ should-fail +// https://github.com/rust-lang/rust/issues/96381 + +#![allow(unused)] + +trait Foo: Sized { + fn bar(i: i32, t: T, s: &Self) -> (T, i32); +} + +impl Foo for () { + fn bar(i: _, t: _, s: _) -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + (1, 2) + } +} + +fn main() {} diff --git a/tests/rustdoc/impl/universal-impl-trait.rs b/tests/rustdoc/impl/universal-impl-trait.rs new file mode 100644 index 00000000000..b78d69c0690 --- /dev/null +++ b/tests/rustdoc/impl/universal-impl-trait.rs @@ -0,0 +1,55 @@ +#![crate_name = "foo"] + +use std::io::Read; +use std::borrow::Borrow; + +//@ has foo/fn.foo.html +//@ has - //pre 'foo(' +//@ matchesraw - '_x: impl (' + //@ matchesraw - '_x: impl (T); + +impl S { + //@ has foo/struct.S.html + //@ hasraw - 'bar(' + //@ matchesraw - '_bar: impl (' + //@ matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' + pub fn baz(_baz: S) { + } + + //@ hasraw - 'qux(' + //@ matchesraw - 'trait\.Read\.html' + pub fn qux(_qux: impl IntoIterator>) { + } +} + +//@ hasraw - 'method(' +//@ matchesraw - '_x: impl Trait for S {} + +//@ has foo/fn.much_universe.html +//@ matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' +//@ matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' +//@ matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' +pub fn much_universe< + T: Borrow, + U: IntoIterator>, +>( + _: impl Read + Clone, +) { +} diff --git a/tests/rustdoc/impl/unneeded-trait-implementations-title.rs b/tests/rustdoc/impl/unneeded-trait-implementations-title.rs new file mode 100644 index 00000000000..f7a97dfaaef --- /dev/null +++ b/tests/rustdoc/impl/unneeded-trait-implementations-title.rs @@ -0,0 +1,5 @@ +#![crate_name = "foo"] + +pub struct Bar; + +//@ count foo/struct.Bar.html '//*[@id="implementations"]' 0 diff --git a/tests/rustdoc/implementor-stable-version.rs b/tests/rustdoc/implementor-stable-version.rs deleted file mode 100644 index cd4fa93f803..00000000000 --- a/tests/rustdoc/implementor-stable-version.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![stable(feature = "bar", since = "3.3.3")] -#![crate_name = "foo"] - -#![feature(staged_api)] - -#[stable(feature = "bar", since = "3.3.3")] -pub trait Bar {} - -#[stable(feature = "baz", since = "3.3.3")] -pub trait Baz {} - -#[stable(feature = "baz", since = "3.3.3")] -pub struct Foo; - -//@ has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' -#[stable(feature = "foobar", since = "4.4.4")] -impl Bar for Foo {} - -//@ has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' -#[stable(feature = "foobaz", since = "3.3.3")] -impl Baz for Foo {} diff --git a/tests/rustdoc/implementors-unstable-75588.rs b/tests/rustdoc/implementors-unstable-75588.rs deleted file mode 100644 index 44a785c4ad9..00000000000 --- a/tests/rustdoc/implementors-unstable-75588.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ aux-build:realcore.rs -//@ aux-build:real_gimli.rs - -// Ensure unstably exported traits have their Implementors sections. -// https://github.com/rust-lang/rust/issues/75588 - -#![crate_name = "foo"] -#![feature(extremely_unstable_foo)] - -extern crate realcore; -extern crate real_gimli; - -// issue #74672 -//@ !has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' -pub use realcore::Deref; - -//@ has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' -pub use realcore::Join; diff --git a/tests/rustdoc/inline-impl-through-glob-import-100204.rs b/tests/rustdoc/inline-impl-through-glob-import-100204.rs deleted file mode 100644 index ba6ed427871..00000000000 --- a/tests/rustdoc/inline-impl-through-glob-import-100204.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:issue-100204-aux.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/100204 -#![crate_name="second"] - -extern crate first; - -pub mod prelude {} - -//@ has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' -//@ has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' -#[doc(inline)] -pub use first::*; diff --git a/tests/rustdoc/legacy-const-generic.rs b/tests/rustdoc/legacy-const-generic.rs deleted file mode 100644 index 41df535f3e0..00000000000 --- a/tests/rustdoc/legacy-const-generic.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -//@ has 'foo/fn.foo.html' -//@ has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' -#[rustc_legacy_const_generics(1)] -pub fn foo(x: usize, z: usize) -> [usize; 3] { - [x, Y, z] -} - -//@ has 'foo/fn.bar.html' -//@ has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' -#[rustc_legacy_const_generics(1, 2)] -pub fn bar(x: usize) -> [usize; 3] { - [x, Y, z] -} diff --git a/tests/rustdoc/link-assoc-const.rs b/tests/rustdoc/link-assoc-const.rs deleted file mode 100644 index 56b82fb2d39..00000000000 --- a/tests/rustdoc/link-assoc-const.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' -//@ has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' - -//! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`]. - -pub mod foo { - pub const FIRSTCONST: u32 = 42; -} - -pub struct Bar; - -impl Bar { - pub const CONST: u32 = 42; -} diff --git a/tests/rustdoc/manual_impl.rs b/tests/rustdoc/manual_impl.rs deleted file mode 100644 index 281262bb40a..00000000000 --- a/tests/rustdoc/manual_impl.rs +++ /dev/null @@ -1,77 +0,0 @@ -//@ has manual_impl/trait.T.html -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' -/// Docs associated with the trait definition. -pub trait T { - /// Docs associated with the trait a_method definition. - fn a_method(&self) -> usize; - - /// Docs associated with the trait b_method definition. - fn b_method(&self) -> usize { - self.a_method() - } - - /// Docs associated with the trait c_method definition. - /// - /// There is another line - fn c_method(&self) -> usize { - self.a_method() - } -} - -//@ has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' -//@ !has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' -//@ !has - '//*[@class="docblock"]' 'There is another line' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' -pub struct S1(usize); - -/// Docs associated with the S1 trait implementation. -impl T for S1 { - /// Docs associated with the S1 trait a_method implementation. - fn a_method(&self) -> usize { - self.0 - } -} - -//@ has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' -pub struct S2(usize); - -/// Docs associated with the S2 trait implementation. -impl T for S2 { - /// Docs associated with the S2 trait a_method implementation. - fn a_method(&self) -> usize { - self.0 - } - - /// Docs associated with the S2 trait c_method implementation. - fn c_method(&self) -> usize { - 5 - } -} - -//@ has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' -//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' -//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' -pub struct S3(usize); - -/// Docs associated with the S3 trait implementation. -impl T for S3 { - fn a_method(&self) -> usize { - self.0 - } - - /// Docs associated with the S3 trait b_method implementation. - fn b_method(&self) -> usize { - 5 - } -} diff --git a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs deleted file mode 100644 index cda828d3967..00000000000 --- a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ aux-build:issue-17476.rs -//@ ignore-cross-compile -// https://github.com/rust-lang/rust/issues/17476 - -#![crate_name="issue_17476"] - -extern crate issue_17476; - -pub struct Foo; - -//@ has issue_17476/struct.Foo.html \ -// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ -// 'foo' -impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/module-impls.rs b/tests/rustdoc/module-impls.rs deleted file mode 100644 index b66721ecb13..00000000000 --- a/tests/rustdoc/module-impls.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "foo"] - -pub use std::marker::Send; - -//@ !hasraw foo/index.html 'Implementations' diff --git a/tests/rustdoc/must_implement_one_of.rs b/tests/rustdoc/must_implement_one_of.rs deleted file mode 100644 index ab965bab356..00000000000 --- a/tests/rustdoc/must_implement_one_of.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_name = "c"] -#![feature(rustc_attrs)] - -#[rustc_must_implement_one_of(a, b)] -//@ matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ -// 'At least one of the `a`, `b` methods is required.$' -pub trait Trait { - fn a() {} - fn b() {} -} diff --git a/tests/rustdoc/negative-impl-no-items.rs b/tests/rustdoc/negative-impl-no-items.rs deleted file mode 100644 index c628e542033..00000000000 --- a/tests/rustdoc/negative-impl-no-items.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This test ensures that negative impls don't have items listed inside them. - -#![feature(negative_impls)] -#![crate_name = "foo"] - -pub struct Thing; - -//@ has 'foo/struct.Thing.html' -// We check the full path to ensure there is no `
` element. -//@ has - '//div[@id="trait-implementations-list"]/section[@id="impl-Iterator-for-Thing"]/h3' \ -// 'impl !Iterator for Thing' -impl !Iterator for Thing {} - -// This struct will allow us to compare both paths. -pub struct Witness; - -//@ has 'foo/struct.Witness.html' -//@ has - '//div[@id="trait-implementations-list"]/details//section[@id="impl-Iterator-for-Witness"]/h3' \ -// 'impl Iterator for Witness' -impl Iterator for Witness { - type Item = u8; - - fn next(&mut self) -> Option { - None - } -} diff --git a/tests/rustdoc/negative-impl-sidebar.rs b/tests/rustdoc/negative-impl-sidebar.rs deleted file mode 100644 index 1742dce1945..00000000000 --- a/tests/rustdoc/negative-impl-sidebar.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(negative_impls)] -#![crate_name = "foo"] - -pub struct Foo; - -//@ has foo/struct.Foo.html -//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' -//@ has - '//*[@class="sidebar-elems"]//section//a' '!Sync' -impl !Sync for Foo {} diff --git a/tests/rustdoc/negative-impl.rs b/tests/rustdoc/negative-impl.rs deleted file mode 100644 index f057a749b72..00000000000 --- a/tests/rustdoc/negative-impl.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(negative_impls)] - -//@ matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" -pub struct Alpha; -//@ matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo" -pub struct Bravo(B); - -//@ matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Send for Alpha" -impl !Send for Alpha {} - -//@ matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ -// impl !Send for Bravo" -impl !Send for Bravo {} diff --git a/tests/rustdoc/redirect-const.rs b/tests/rustdoc/redirect-const.rs deleted file mode 100644 index e636a915f30..00000000000 --- a/tests/rustdoc/redirect-const.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_name="foo"] - -pub use hidden::STATIC_FOO; -pub use hidden::CONST_FOO; - -mod hidden { - //@ has foo/hidden/static.STATIC_FOO.html - //@ has - '//p/a' '../../foo/static.STATIC_FOO.html' - pub static STATIC_FOO: u64 = 0; - //@ has foo/hidden/constant.CONST_FOO.html - //@ has - '//p/a' '../../foo/constant.CONST_FOO.html' - pub const CONST_FOO: u64 = 0; -} diff --git a/tests/rustdoc/return-impl-trait.rs b/tests/rustdoc/return-impl-trait.rs deleted file mode 100644 index 175867d2204..00000000000 --- a/tests/rustdoc/return-impl-trait.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(type_alias_impl_trait)] - -pub trait Backend {} - -impl Backend for () {} - -pub struct Module(T); - -pub type BackendImpl = impl Backend; - -//@ has return_impl_trait/fn.make_module.html -/// Documentation -pub fn make_module() -> Module { - Module(()) -} diff --git a/tests/rustdoc/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs deleted file mode 100644 index 8a86e3e5e97..00000000000 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Test that we do not currently display `~const` in rustdoc -// as that syntax is currently provisional; `~const Destruct` has -// no effect on stable code so it should be hidden as well. -// -// To future blessers: make sure that `const_trait_impl` is -// stabilized when changing `@!has` to `@has`, and please do -// not remove this test. -// -// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const` -// FIXME(const_trait_impl) restore `const_trait` to `Destruct` -#![feature(const_trait_impl)] -#![crate_name = "foo"] - -use std::marker::Destruct; - -pub struct S(T); - -//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' -#[const_trait] -pub trait Tr { - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' - //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' - //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - fn a() - where - Option: /* ~const */ Fn() /* + ~const Destruct */, - { - } -} - -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' -impl const Tr for T -where - Option: /* ~const */ Fn() /* + ~const Destruct */, -{ - fn a() - where - Option: /* ~const */ Fn() /* + ~const Destruct */, - { - } -} - -//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' -pub const fn foo() -where - Option: /* ~const */ Fn() /* + ~const Destruct */, -{ - F::a() -} - -impl S { - //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' - //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' - //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - pub const fn foo() - where - B: /* ~const */ Fn() /* + ~const Destruct */, - { - B::a() - } -} diff --git a/tests/rustdoc/rustc-incoherent-impls.rs b/tests/rustdoc/rustc-incoherent-impls.rs deleted file mode 100644 index 81a7025906b..00000000000 --- a/tests/rustdoc/rustc-incoherent-impls.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ aux-build:incoherent-impl-types.rs -//@ build-aux-docs - -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -extern crate incoherent_impl_types; - -// The only way this actually shows up is if the type gets inlined. -#[doc(inline)] -pub use incoherent_impl_types::FooTrait; - -//@ has foo/trait.FooTrait.html -//@ count - '//section[@id="method.do_something"]' 1 -impl dyn FooTrait { - #[rustc_allow_incoherent_impl] - pub fn do_something() {} -} - -#[doc(inline)] -pub use incoherent_impl_types::FooStruct; - -//@ has foo/struct.FooStruct.html -//@ count - '//section[@id="method.do_something"]' 1 -impl FooStruct { - #[rustc_allow_incoherent_impl] - pub fn do_something() {} -} diff --git a/tests/rustdoc/same-crate-hidden-impl-parameter.rs b/tests/rustdoc/same-crate-hidden-impl-parameter.rs deleted file mode 100644 index b0beb1bdfa0..00000000000 --- a/tests/rustdoc/same-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,36 +0,0 @@ -// test for `doc(hidden)` with impl parameters in the same crate. -#![crate_name = "foo"] - -#[doc(hidden)] -pub enum HiddenType {} - -#[doc(hidden)] -pub trait HiddenTrait {} - -pub enum MyLibType {} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' -impl From for MyLibType { - fn from(it: HiddenType) -> MyLibType { - match it {} - } -} - -pub struct T(T); - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' -impl From>>>> for MyLibType { - fn from(it: T>>>) -> MyLibType { - todo!() - } -} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' -impl HiddenTrait for MyLibType {} - -//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' -impl From for T>>> { - fn from(it: MyLibType) -> T>>> { - match it {} - } -} diff --git a/tests/rustdoc/show-const-contents.rs b/tests/rustdoc/show-const-contents.rs deleted file mode 100644 index 6d2701693ce..00000000000 --- a/tests/rustdoc/show-const-contents.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Test that the contents of constants are displayed as part of the -// documentation. - -//@ hasraw show_const_contents/constant.CONST_S.html 'show this' -//@ !hasraw show_const_contents/constant.CONST_S.html '; //' -pub const CONST_S: &'static str = "show this"; - -//@ hasraw show_const_contents/constant.CONST_I32.html '= 42;' -//@ !hasraw show_const_contents/constant.CONST_I32.html '; //' -pub const CONST_I32: i32 = 42; - -//@ hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' -//@ !hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' -pub const CONST_I32_HEX: i32 = 0x42; - -//@ hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' -//@ !hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' -pub const CONST_NEG_I32: i32 = -42; - -//@ hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' -//@ !hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' -pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; - -//@ hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' -pub const CONST_CALC_I32: i32 = 42 + 1; - -//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' -//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '; //' -pub const CONST_REF_I32: &'static i32 = &42; - -//@ hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' -pub const CONST_I32_MAX: i32 = i32::MAX; - -//@ !hasraw show_const_contents/constant.UNIT.html '= ();' -//@ !hasraw show_const_contents/constant.UNIT.html '; //' -pub const UNIT: () = (); - -pub struct MyType(i32); - -//@ !hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' -//@ !hasraw show_const_contents/constant.MY_TYPE.html '; //' -pub const MY_TYPE: MyType = MyType(42); - -pub struct MyTypeWithStr(&'static str); - -//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' -//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' -pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); - -//@ hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' -//@ hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' -pub use std::f32::consts::PI; - -//@ hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' -#[allow(deprecated, deprecated_in_future)] -pub use std::i32::MAX; - -macro_rules! int_module { - ($T:ident) => ( - pub const MIN: $T = $T::MIN; - ) -} - -//@ hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' -int_module!(i16); - -//@ has show_const_contents/constant.ESCAPE.html //pre '= r#""#;' -pub const ESCAPE: &str = r#""#; diff --git a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs b/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs deleted file mode 100644 index b1bf029cf84..00000000000 --- a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/78701 -#![crate_name = "foo"] - -// This test ensures that if a blanket impl has the same ID as another impl, it'll -// link to the blanket impl and not the other impl. Basically, we're checking if -// the ID is correctly derived. - -//@ has 'foo/struct.AnotherStruct.html' -//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 -//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 - -pub trait Something {} - -pub trait AnAmazingTrait {} - -impl AnAmazingTrait for T {} - -pub struct AnotherStruct(T); - -impl Something for AnotherStruct {} -impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/struct-implementations-title.rs b/tests/rustdoc/struct-implementations-title.rs deleted file mode 100644 index ca5b5c0ee20..00000000000 --- a/tests/rustdoc/struct-implementations-title.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_name = "foo"] - -pub struct Struc; - -//@ has foo/struct.Struc.html -//@ has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" -impl Struc { - pub const S: u64 = 0; -} diff --git a/tests/rustdoc/trait-impl.rs b/tests/rustdoc/trait-impl.rs deleted file mode 100644 index c65eecc4edf..00000000000 --- a/tests/rustdoc/trait-impl.rs +++ /dev/null @@ -1,45 +0,0 @@ -pub trait Trait { - /// Some long docs here. - /// - /// These docs are long enough that a link will be added to the end. - fn a(); - - /// These docs contain a [reference link]. - /// - /// [reference link]: https://example.com - fn b(); - - /// ``` - /// This code block should not be in the output, but a Read more link should be generated - /// ``` - fn c(); - - /// Escaped formatting a\*b\*c\* works - fn d(); -} - -pub struct Struct; - -impl Trait for Struct { - //@ has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' - //@ !has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' - //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' - //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' - fn a() {} - - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' - fn b() {} - - //@ !has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' - //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' - //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' - fn c() {} - - //@ has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' - //@ !has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' - fn d() {} - - //@ has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' -} diff --git a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs b/tests/rustdoc/trait-implementations-duplicate-self-45584.rs deleted file mode 100644 index 8eb6d007525..00000000000 --- a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_name = "foo"] - -// https://github.com/rust-lang/rust/issues/45584 - -pub trait Bar {} - -//@ has 'foo/struct.Foo1.html' -pub struct Foo1; -//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -//@ has - '//*[@class="impl"]' "impl Bar for Foo1" -impl Bar for Foo1 {} - -//@ has 'foo/struct.Foo2.html' -pub struct Foo2; -//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -//@ has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" -impl Bar<&'static Foo2, Foo2> for u8 {} diff --git a/tests/rustdoc/underscore-type-in-trait-impl-96381.rs b/tests/rustdoc/underscore-type-in-trait-impl-96381.rs deleted file mode 100644 index 6d6e5e0a839..00000000000 --- a/tests/rustdoc/underscore-type-in-trait-impl-96381.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ should-fail -// https://github.com/rust-lang/rust/issues/96381 - -#![allow(unused)] - -trait Foo: Sized { - fn bar(i: i32, t: T, s: &Self) -> (T, i32); -} - -impl Foo for () { - fn bar(i: _, t: _, s: _) -> _ { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - (1, 2) - } -} - -fn main() {} diff --git a/tests/rustdoc/universal-impl-trait.rs b/tests/rustdoc/universal-impl-trait.rs deleted file mode 100644 index b78d69c0690..00000000000 --- a/tests/rustdoc/universal-impl-trait.rs +++ /dev/null @@ -1,55 +0,0 @@ -#![crate_name = "foo"] - -use std::io::Read; -use std::borrow::Borrow; - -//@ has foo/fn.foo.html -//@ has - //pre 'foo(' -//@ matchesraw - '_x: impl (' - //@ matchesraw - '_x: impl (T); - -impl S { - //@ has foo/struct.S.html - //@ hasraw - 'bar(' - //@ matchesraw - '_bar: impl (' - //@ matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' - pub fn baz(_baz: S) { - } - - //@ hasraw - 'qux(' - //@ matchesraw - 'trait\.Read\.html' - pub fn qux(_qux: impl IntoIterator>) { - } -} - -//@ hasraw - 'method(' -//@ matchesraw - '_x: impl Trait for S {} - -//@ has foo/fn.much_universe.html -//@ matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' -//@ matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' -//@ matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' -pub fn much_universe< - T: Borrow, - U: IntoIterator>, ->( - _: impl Read + Clone, -) { -} diff --git a/tests/rustdoc/unneeded-trait-implementations-title.rs b/tests/rustdoc/unneeded-trait-implementations-title.rs deleted file mode 100644 index f7a97dfaaef..00000000000 --- a/tests/rustdoc/unneeded-trait-implementations-title.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "foo"] - -pub struct Bar; - -//@ count foo/struct.Bar.html '//*[@id="implementations"]' 0 -- cgit 1.4.1-3-g733a5 From fa2b9227a1065f7618eb90b52f6f617a13c55b30 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:08:06 +0200 Subject: Created `tests/rustdoc/assoc` subfolder to limit number of files at the top level --- tests/rustdoc/assoc-fns.rs | 13 ---- tests/rustdoc/assoc-item-cast.rs | 14 ---- tests/rustdoc/assoc-type-bindings-20646.rs | 28 -------- tests/rustdoc/assoc-types.rs | 37 ---------- tests/rustdoc/assoc/assoc-fns.rs | 13 ++++ tests/rustdoc/assoc/assoc-item-cast.rs | 14 ++++ tests/rustdoc/assoc/assoc-type-bindings-20646.rs | 28 ++++++++ tests/rustdoc/assoc/assoc-types.rs | 37 ++++++++++ .../cross-crate-hidden-assoc-trait-items.rs | 19 +++++ tests/rustdoc/assoc/auxiliary/issue-20646.rs | 7 ++ tests/rustdoc/assoc/auxiliary/issue-20727.rs | 30 ++++++++ .../assoc/auxiliary/normalize-assoc-item.rs | 12 ++++ .../assoc/cross-crate-hidden-assoc-trait-items.rs | 23 ++++++ tests/rustdoc/assoc/doc-assoc-item.rs | 18 +++++ .../assoc/inline-assoc-type-20727-bindings.rs | 25 +++++++ .../assoc/inline-assoc-type-20727-bounds-deref.rs | 27 +++++++ .../assoc/inline-assoc-type-20727-bounds-index.rs | 43 ++++++++++++ .../assoc/inline-assoc-type-20727-bounds.rs | 27 +++++++ tests/rustdoc/assoc/normalize-assoc-item.rs | 82 ++++++++++++++++++++++ .../cross-crate-hidden-assoc-trait-items.rs | 19 ----- tests/rustdoc/auxiliary/issue-20646.rs | 7 -- tests/rustdoc/auxiliary/issue-20727.rs | 30 -------- tests/rustdoc/auxiliary/normalize-assoc-item.rs | 12 ---- .../cross-crate-hidden-assoc-trait-items.rs | 23 ------ tests/rustdoc/doc-assoc-item.rs | 18 ----- tests/rustdoc/inline-assoc-type-20727-bindings.rs | 25 ------- .../inline-assoc-type-20727-bounds-deref.rs | 27 ------- .../inline-assoc-type-20727-bounds-index.rs | 43 ------------ tests/rustdoc/inline-assoc-type-20727-bounds.rs | 27 ------- tests/rustdoc/normalize-assoc-item.rs | 82 ---------------------- 30 files changed, 405 insertions(+), 405 deletions(-) delete mode 100644 tests/rustdoc/assoc-fns.rs delete mode 100644 tests/rustdoc/assoc-item-cast.rs delete mode 100644 tests/rustdoc/assoc-type-bindings-20646.rs delete mode 100644 tests/rustdoc/assoc-types.rs create mode 100644 tests/rustdoc/assoc/assoc-fns.rs create mode 100644 tests/rustdoc/assoc/assoc-item-cast.rs create mode 100644 tests/rustdoc/assoc/assoc-type-bindings-20646.rs create mode 100644 tests/rustdoc/assoc/assoc-types.rs create mode 100644 tests/rustdoc/assoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs create mode 100644 tests/rustdoc/assoc/auxiliary/issue-20646.rs create mode 100644 tests/rustdoc/assoc/auxiliary/issue-20727.rs create mode 100644 tests/rustdoc/assoc/auxiliary/normalize-assoc-item.rs create mode 100644 tests/rustdoc/assoc/cross-crate-hidden-assoc-trait-items.rs create mode 100644 tests/rustdoc/assoc/doc-assoc-item.rs create mode 100644 tests/rustdoc/assoc/inline-assoc-type-20727-bindings.rs create mode 100644 tests/rustdoc/assoc/inline-assoc-type-20727-bounds-deref.rs create mode 100644 tests/rustdoc/assoc/inline-assoc-type-20727-bounds-index.rs create mode 100644 tests/rustdoc/assoc/inline-assoc-type-20727-bounds.rs create mode 100644 tests/rustdoc/assoc/normalize-assoc-item.rs delete mode 100644 tests/rustdoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs delete mode 100644 tests/rustdoc/auxiliary/issue-20646.rs delete mode 100644 tests/rustdoc/auxiliary/issue-20727.rs delete mode 100644 tests/rustdoc/auxiliary/normalize-assoc-item.rs delete mode 100644 tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs delete mode 100644 tests/rustdoc/doc-assoc-item.rs delete mode 100644 tests/rustdoc/inline-assoc-type-20727-bindings.rs delete mode 100644 tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs delete mode 100644 tests/rustdoc/inline-assoc-type-20727-bounds-index.rs delete mode 100644 tests/rustdoc/inline-assoc-type-20727-bounds.rs delete mode 100644 tests/rustdoc/normalize-assoc-item.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/assoc-fns.rs b/tests/rustdoc/assoc-fns.rs deleted file mode 100644 index 6ffbebc3d27..00000000000 --- a/tests/rustdoc/assoc-fns.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Basic testing for associated functions (in traits, trait impls & inherent impls). - -//@ has assoc_fns/trait.Trait.html -pub trait Trait { - //@ has - '//*[@id="tymethod.required"]' 'fn required(first: i32, second: &str)' - fn required(first: i32, second: &str); - - //@ has - '//*[@id="method.provided"]' 'fn provided(only: ())' - fn provided(only: ()) {} - - //@ has - '//*[@id="tymethod.params_are_unnamed"]' 'fn params_are_unnamed(_: i32, _: u32)' - fn params_are_unnamed(_: i32, _: u32); -} diff --git a/tests/rustdoc/assoc-item-cast.rs b/tests/rustdoc/assoc-item-cast.rs deleted file mode 100644 index 17b7cf6f0da..00000000000 --- a/tests/rustdoc/assoc-item-cast.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![crate_name = "foo"] - -pub trait Expression { - type SqlType; -} - -pub trait AsExpression { - type Expression: Expression; - fn as_expression(self) -> Self::Expression; -} - -//@ has foo/type.AsExprOf.html -//@ has - '//pre[@class="rust item-decl"]' 'type AsExprOf = >::Expression;' -pub type AsExprOf = >::Expression; diff --git a/tests/rustdoc/assoc-type-bindings-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs deleted file mode 100644 index c79d07ff5bd..00000000000 --- a/tests/rustdoc/assoc-type-bindings-20646.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ aux-build:issue-20646.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/20646 -#![crate_name="issue_20646"] -#![feature(associated_types)] - -extern crate issue_20646; - -//@ has issue_20646/trait.Trait.html \ -// '//*[@id="associatedtype.Output"]' \ -// 'type Output' -pub trait Trait { - type Output; -} - -//@ has issue_20646/fn.fun.html \ -// '//pre[@class="rust item-decl"]' 'where T: Trait' -pub fn fun(_: T) where T: Trait {} - -pub mod reexport { - //@ has issue_20646/reexport/trait.Trait.html \ - // '//*[@id="associatedtype.Output"]' \ - // 'type Output' - //@ has issue_20646/reexport/fn.fun.html \ - // '//pre[@class="rust item-decl"]' 'where T: Trait' - pub use issue_20646::{Trait, fun}; -} diff --git a/tests/rustdoc/assoc-types.rs b/tests/rustdoc/assoc-types.rs deleted file mode 100644 index 8247d8b91e8..00000000000 --- a/tests/rustdoc/assoc-types.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![crate_type="lib"] - -//@ has assoc_types/trait.Index.html -pub trait Index { - //@ has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized' - type Output: ?Sized; - //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \ - // "fn index<'a>(&'a self, index: I) -> &'a Self::Output" - //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]//a[@href="trait.Index.html#associatedtype.Output"]' \ - // "Output" - fn index<'a>(&'a self, index: I) -> &'a Self::Output; -} - -//@ has assoc_types/fn.use_output.html -//@ has - '//pre[@class="rust item-decl"]' '-> &T::Output' -//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Index.html#associatedtype.Output"]' 'Output' -pub fn use_output>(obj: &T, index: usize) -> &T::Output { - obj.index(index) -} - -pub trait Feed { - type Input; -} - -//@ has assoc_types/fn.use_input.html -//@ has - '//pre[@class="rust item-decl"]' 'T::Input' -//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' -pub fn use_input(_feed: &T, _element: T::Input) { } - -//@ has assoc_types/fn.cmp_input.html -//@ has - '//pre[@class="rust item-decl"]' 'where T::Input: PartialEq' -//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' -pub fn cmp_input(a: &T::Input, b: &U::Input) -> bool - where T::Input: PartialEq -{ - a == b -} diff --git a/tests/rustdoc/assoc/assoc-fns.rs b/tests/rustdoc/assoc/assoc-fns.rs new file mode 100644 index 00000000000..6ffbebc3d27 --- /dev/null +++ b/tests/rustdoc/assoc/assoc-fns.rs @@ -0,0 +1,13 @@ +// Basic testing for associated functions (in traits, trait impls & inherent impls). + +//@ has assoc_fns/trait.Trait.html +pub trait Trait { + //@ has - '//*[@id="tymethod.required"]' 'fn required(first: i32, second: &str)' + fn required(first: i32, second: &str); + + //@ has - '//*[@id="method.provided"]' 'fn provided(only: ())' + fn provided(only: ()) {} + + //@ has - '//*[@id="tymethod.params_are_unnamed"]' 'fn params_are_unnamed(_: i32, _: u32)' + fn params_are_unnamed(_: i32, _: u32); +} diff --git a/tests/rustdoc/assoc/assoc-item-cast.rs b/tests/rustdoc/assoc/assoc-item-cast.rs new file mode 100644 index 00000000000..17b7cf6f0da --- /dev/null +++ b/tests/rustdoc/assoc/assoc-item-cast.rs @@ -0,0 +1,14 @@ +#![crate_name = "foo"] + +pub trait Expression { + type SqlType; +} + +pub trait AsExpression { + type Expression: Expression; + fn as_expression(self) -> Self::Expression; +} + +//@ has foo/type.AsExprOf.html +//@ has - '//pre[@class="rust item-decl"]' 'type AsExprOf = >::Expression;' +pub type AsExprOf = >::Expression; diff --git a/tests/rustdoc/assoc/assoc-type-bindings-20646.rs b/tests/rustdoc/assoc/assoc-type-bindings-20646.rs new file mode 100644 index 00000000000..c79d07ff5bd --- /dev/null +++ b/tests/rustdoc/assoc/assoc-type-bindings-20646.rs @@ -0,0 +1,28 @@ +//@ aux-build:issue-20646.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20646 +#![crate_name="issue_20646"] +#![feature(associated_types)] + +extern crate issue_20646; + +//@ has issue_20646/trait.Trait.html \ +// '//*[@id="associatedtype.Output"]' \ +// 'type Output' +pub trait Trait { + type Output; +} + +//@ has issue_20646/fn.fun.html \ +// '//pre[@class="rust item-decl"]' 'where T: Trait' +pub fn fun(_: T) where T: Trait {} + +pub mod reexport { + //@ has issue_20646/reexport/trait.Trait.html \ + // '//*[@id="associatedtype.Output"]' \ + // 'type Output' + //@ has issue_20646/reexport/fn.fun.html \ + // '//pre[@class="rust item-decl"]' 'where T: Trait' + pub use issue_20646::{Trait, fun}; +} diff --git a/tests/rustdoc/assoc/assoc-types.rs b/tests/rustdoc/assoc/assoc-types.rs new file mode 100644 index 00000000000..8247d8b91e8 --- /dev/null +++ b/tests/rustdoc/assoc/assoc-types.rs @@ -0,0 +1,37 @@ +#![crate_type="lib"] + +//@ has assoc_types/trait.Index.html +pub trait Index { + //@ has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized' + type Output: ?Sized; + //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \ + // "fn index<'a>(&'a self, index: I) -> &'a Self::Output" + //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]//a[@href="trait.Index.html#associatedtype.Output"]' \ + // "Output" + fn index<'a>(&'a self, index: I) -> &'a Self::Output; +} + +//@ has assoc_types/fn.use_output.html +//@ has - '//pre[@class="rust item-decl"]' '-> &T::Output' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Index.html#associatedtype.Output"]' 'Output' +pub fn use_output>(obj: &T, index: usize) -> &T::Output { + obj.index(index) +} + +pub trait Feed { + type Input; +} + +//@ has assoc_types/fn.use_input.html +//@ has - '//pre[@class="rust item-decl"]' 'T::Input' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' +pub fn use_input(_feed: &T, _element: T::Input) { } + +//@ has assoc_types/fn.cmp_input.html +//@ has - '//pre[@class="rust item-decl"]' 'where T::Input: PartialEq' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' +pub fn cmp_input(a: &T::Input, b: &U::Input) -> bool + where T::Input: PartialEq +{ + a == b +} diff --git a/tests/rustdoc/assoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs b/tests/rustdoc/assoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs new file mode 100644 index 00000000000..3baf8a6c07e --- /dev/null +++ b/tests/rustdoc/assoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs @@ -0,0 +1,19 @@ +pub trait Tr { + type VisibleAssoc; + #[doc(hidden)] + type HiddenAssoc; + + const VISIBLE_ASSOC: (); + #[doc(hidden)] + const HIDDEN_ASSOC: (); +} + +pub struct Ty; + +impl Tr for Ty { + type VisibleAssoc = (); + type HiddenAssoc = (); + + const VISIBLE_ASSOC: () = (); + const HIDDEN_ASSOC: () = (); +} diff --git a/tests/rustdoc/assoc/auxiliary/issue-20646.rs b/tests/rustdoc/assoc/auxiliary/issue-20646.rs new file mode 100644 index 00000000000..d1df1defb05 --- /dev/null +++ b/tests/rustdoc/assoc/auxiliary/issue-20646.rs @@ -0,0 +1,7 @@ +//@ compile-flags: -Cmetadata=aux + +pub trait Trait { + type Output; +} + +pub fn fun(_: T) where T: Trait {} diff --git a/tests/rustdoc/assoc/auxiliary/issue-20727.rs b/tests/rustdoc/assoc/auxiliary/issue-20727.rs new file mode 100644 index 00000000000..a102d1a4897 --- /dev/null +++ b/tests/rustdoc/assoc/auxiliary/issue-20727.rs @@ -0,0 +1,30 @@ +//@ compile-flags: -Cmetadata=aux + +pub trait Deref { + type Target: ?Sized; + + fn deref<'a>(&'a self) -> &'a Self::Target; +} + +pub trait Add { + type Output; + + fn add(self, rhs: RHS) -> Self::Output; +} + + +pub trait Bar {} +pub trait Deref2 { + type Target: Bar; + + fn deref(&self) -> Self::Target; +} + +pub trait Index { + type Output: ?Sized; + fn index(&self, index: Idx) -> &Self::Output; +} + +pub trait IndexMut: Index { + fn index_mut(&mut self, index: Idx) -> &mut Self::Output; +} diff --git a/tests/rustdoc/assoc/auxiliary/normalize-assoc-item.rs b/tests/rustdoc/assoc/auxiliary/normalize-assoc-item.rs new file mode 100644 index 00000000000..fbd111c3035 --- /dev/null +++ b/tests/rustdoc/assoc/auxiliary/normalize-assoc-item.rs @@ -0,0 +1,12 @@ +#![crate_name = "inner"] +pub trait MyTrait { + type Y; +} + +impl MyTrait for u32 { + type Y = i32; +} + +pub fn foo() -> ::Y { + 0 +} diff --git a/tests/rustdoc/assoc/cross-crate-hidden-assoc-trait-items.rs b/tests/rustdoc/assoc/cross-crate-hidden-assoc-trait-items.rs new file mode 100644 index 00000000000..d3771c2e7a2 --- /dev/null +++ b/tests/rustdoc/assoc/cross-crate-hidden-assoc-trait-items.rs @@ -0,0 +1,23 @@ +// Regression test for issue #95717 +// Hide cross-crate `#[doc(hidden)]` associated items in trait impls. + +#![crate_name = "dependent"] +//@ edition:2021 +//@ aux-crate:dependency=cross-crate-hidden-assoc-trait-items.rs + +// The trait `Tr` contains 2 hidden and 2 visisible associated items. +// Instead of checking for the absence of the hidden items, check for the presence of the +// visible items instead and assert that there are *exactly two* associated items +// (by counting the number of `section`s). This is more robust and future-proof. + +//@ has dependent/struct.Ty.html +//@ has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()' +//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()' +//@ count - '//*[@class="impl-items"]/section' 2 + +//@ has dependent/trait.Tr.html +//@ has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()' +//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()' +//@ count - '//*[@class="impl-items"]/section' 2 + +pub use dependency::{Tr, Ty}; diff --git a/tests/rustdoc/assoc/doc-assoc-item.rs b/tests/rustdoc/assoc/doc-assoc-item.rs new file mode 100644 index 00000000000..2eb82abfc0b --- /dev/null +++ b/tests/rustdoc/assoc/doc-assoc-item.rs @@ -0,0 +1,18 @@ +pub struct Foo { + x: T, +} + +pub trait Bar { + type Fuu; + + fn foo(foo: Self::Fuu); +} + +//@ has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl> Foo' +impl> Foo { + pub fn new(t: T) -> Foo { + Foo { + x: t, + } + } +} diff --git a/tests/rustdoc/assoc/inline-assoc-type-20727-bindings.rs b/tests/rustdoc/assoc/inline-assoc-type-20727-bindings.rs new file mode 100644 index 00000000000..b3447a759df --- /dev/null +++ b/tests/rustdoc/assoc/inline-assoc-type-20727-bindings.rs @@ -0,0 +1,25 @@ +//@ aux-build:issue-20727.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_2"] + +extern crate issue_20727; + +//@ has issue_20727_2/trait.Add.html +pub trait Add { + //@ has - '//pre[@class="rust item-decl"]' 'trait Add {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output;' + type Output; + + //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + fn add(self, rhs: RHS) -> Self::Output; +} + +//@ has issue_20727_2/reexport/trait.Add.html +pub mod reexport { + //@ has - '//pre[@class="rust item-decl"]' 'trait Add {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output;' + //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + pub use issue_20727::Add; +} diff --git a/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-deref.rs b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-deref.rs new file mode 100644 index 00000000000..afb9087cc7a --- /dev/null +++ b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-deref.rs @@ -0,0 +1,27 @@ +//@ aux-build:issue-20727.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_3"] + +extern crate issue_20727; + +pub trait Bar {} + +//@ has issue_20727_3/trait.Deref2.html +pub trait Deref2 { + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + type Target: Bar; + + //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + fn deref(&self) -> Self::Target; +} + +//@ has issue_20727_3/reexport/trait.Deref2.html +pub mod reexport { + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + pub use issue_20727::Deref2; +} diff --git a/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-index.rs b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-index.rs new file mode 100644 index 00000000000..9dd234e8202 --- /dev/null +++ b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds-index.rs @@ -0,0 +1,43 @@ +//@ aux-build:issue-20727.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_4"] + +extern crate issue_20727; + +//@ has issue_20727_4/trait.Index.html +pub trait Index { + //@ has - '//pre[@class="rust item-decl"]' 'trait Index {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + type Output: ?Sized; + + //@ has - '//pre[@class="rust item-decl"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + fn index(&self, index: Idx) -> &Self::Output; +} + +//@ has issue_20727_4/trait.IndexMut.html +pub trait IndexMut: Index { + //@ has - '//pre[@class="rust item-decl"]' \ + // 'trait IndexMut: Index {' + //@ has - '//pre[@class="rust item-decl"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + fn index_mut(&mut self, index: Idx) -> &mut Self::Output; +} + +pub mod reexport { + //@ has issue_20727_4/reexport/trait.Index.html + //@ has - '//pre[@class="rust item-decl"]' 'trait Indexwhere Idx: ?Sized,{' + //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + //@ has - '//pre[@class="rust item-decl"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + pub use issue_20727::Index; + + //@ has issue_20727_4/reexport/trait.IndexMut.html + //@ has - '//pre[@class="rust item-decl"]' \ + // 'trait IndexMut: Indexwhere Idx: ?Sized,{' + //@ has - '//pre[@class="rust item-decl"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + pub use issue_20727::IndexMut; +} diff --git a/tests/rustdoc/assoc/inline-assoc-type-20727-bounds.rs b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds.rs new file mode 100644 index 00000000000..bd8d46f4a56 --- /dev/null +++ b/tests/rustdoc/assoc/inline-assoc-type-20727-bounds.rs @@ -0,0 +1,27 @@ +//@ aux-build:issue-20727.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727"] + +extern crate issue_20727; + +//@ has issue_20727/trait.Deref.html +pub trait Deref { + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + type Target: ?Sized; + + //@ has - '//pre[@class="rust item-decl"]' \ + // "fn deref<'a>(&'a self) -> &'a Self::Target;" + fn deref<'a>(&'a self) -> &'a Self::Target; +} + +//@ has issue_20727/reexport/trait.Deref.html +pub mod reexport { + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + //@ has - '//pre[@class="rust item-decl"]' \ + // "fn deref<'a>(&'a self) -> &'a Self::Target;" + pub use issue_20727::Deref; +} diff --git a/tests/rustdoc/assoc/normalize-assoc-item.rs b/tests/rustdoc/assoc/normalize-assoc-item.rs new file mode 100644 index 00000000000..7ef9d3067e1 --- /dev/null +++ b/tests/rustdoc/assoc/normalize-assoc-item.rs @@ -0,0 +1,82 @@ +// ignore-tidy-linelength +//@ aux-build:normalize-assoc-item.rs +//@ build-aux-docs +//@ compile-flags:-Znormalize-docs + +pub trait Trait { + type X; +} + +impl Trait for usize { + type X = isize; +} + +impl Trait for () { + type X = fn() -> i32; +} + +impl Trait for isize { + type X = <() as Trait>::X; +} + +//@ has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust item-decl"]' 'pub fn f() -> isize' +pub fn f() -> ::X { + 0 +} + +//@ has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust item-decl"]' 'pub fn f2() -> fn() -> i32' +pub fn f2() -> ::X { + todo!() +} + +pub struct S { + //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box' + pub box_me_up: ::X, + //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)' + pub generic: as Trait>::X, +} + +impl Trait for S { + type X = Box; +} + +pub struct Generic(Inner); + +impl Trait for Generic { + type X = (Inner, Inner::X); +} + +// These can't be normalized because they depend on a generic parameter. +// However the user can choose whether the text should be displayed as `Inner::X` or `::X`. + +//@ has 'normalize_assoc_item/struct.Unknown.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown(pub ::X);' +pub struct Unknown(pub ::X); + +//@ has 'normalize_assoc_item/struct.Unknown2.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown2(pub Inner::X);' +pub struct Unknown2(pub Inner::X); + +trait Lifetimes<'a> { + type Y; +} + +impl<'a> Lifetimes<'a> for usize { + type Y = &'a isize; +} + +//@ has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &'static isize" +pub fn g() -> >::Y { + &0 +} + +//@ has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &'static isize" +pub const A: >::Y = &0; + +// test cross-crate re-exports +extern crate inner; +//@ has 'normalize_assoc_item/fn.foo.html' '//pre[@class="rust item-decl"]' "pub fn foo() -> i32" +pub use inner::foo; + +//@ has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h() -> IntoIter" +pub fn h() -> as IntoIterator>::IntoIter { + vec![].into_iter() +} diff --git a/tests/rustdoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs b/tests/rustdoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs deleted file mode 100644 index 3baf8a6c07e..00000000000 --- a/tests/rustdoc/auxiliary/cross-crate-hidden-assoc-trait-items.rs +++ /dev/null @@ -1,19 +0,0 @@ -pub trait Tr { - type VisibleAssoc; - #[doc(hidden)] - type HiddenAssoc; - - const VISIBLE_ASSOC: (); - #[doc(hidden)] - const HIDDEN_ASSOC: (); -} - -pub struct Ty; - -impl Tr for Ty { - type VisibleAssoc = (); - type HiddenAssoc = (); - - const VISIBLE_ASSOC: () = (); - const HIDDEN_ASSOC: () = (); -} diff --git a/tests/rustdoc/auxiliary/issue-20646.rs b/tests/rustdoc/auxiliary/issue-20646.rs deleted file mode 100644 index d1df1defb05..00000000000 --- a/tests/rustdoc/auxiliary/issue-20646.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub trait Trait { - type Output; -} - -pub fn fun(_: T) where T: Trait {} diff --git a/tests/rustdoc/auxiliary/issue-20727.rs b/tests/rustdoc/auxiliary/issue-20727.rs deleted file mode 100644 index a102d1a4897..00000000000 --- a/tests/rustdoc/auxiliary/issue-20727.rs +++ /dev/null @@ -1,30 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub trait Deref { - type Target: ?Sized; - - fn deref<'a>(&'a self) -> &'a Self::Target; -} - -pub trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - - -pub trait Bar {} -pub trait Deref2 { - type Target: Bar; - - fn deref(&self) -> Self::Target; -} - -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -pub trait IndexMut: Index { - fn index_mut(&mut self, index: Idx) -> &mut Self::Output; -} diff --git a/tests/rustdoc/auxiliary/normalize-assoc-item.rs b/tests/rustdoc/auxiliary/normalize-assoc-item.rs deleted file mode 100644 index fbd111c3035..00000000000 --- a/tests/rustdoc/auxiliary/normalize-assoc-item.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name = "inner"] -pub trait MyTrait { - type Y; -} - -impl MyTrait for u32 { - type Y = i32; -} - -pub fn foo() -> ::Y { - 0 -} diff --git a/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs b/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs deleted file mode 100644 index d3771c2e7a2..00000000000 --- a/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test for issue #95717 -// Hide cross-crate `#[doc(hidden)]` associated items in trait impls. - -#![crate_name = "dependent"] -//@ edition:2021 -//@ aux-crate:dependency=cross-crate-hidden-assoc-trait-items.rs - -// The trait `Tr` contains 2 hidden and 2 visisible associated items. -// Instead of checking for the absence of the hidden items, check for the presence of the -// visible items instead and assert that there are *exactly two* associated items -// (by counting the number of `section`s). This is more robust and future-proof. - -//@ has dependent/struct.Ty.html -//@ has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()' -//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()' -//@ count - '//*[@class="impl-items"]/section' 2 - -//@ has dependent/trait.Tr.html -//@ has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()' -//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()' -//@ count - '//*[@class="impl-items"]/section' 2 - -pub use dependency::{Tr, Ty}; diff --git a/tests/rustdoc/doc-assoc-item.rs b/tests/rustdoc/doc-assoc-item.rs deleted file mode 100644 index 2eb82abfc0b..00000000000 --- a/tests/rustdoc/doc-assoc-item.rs +++ /dev/null @@ -1,18 +0,0 @@ -pub struct Foo { - x: T, -} - -pub trait Bar { - type Fuu; - - fn foo(foo: Self::Fuu); -} - -//@ has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl> Foo' -impl> Foo { - pub fn new(t: T) -> Foo { - Foo { - x: t, - } - } -} diff --git a/tests/rustdoc/inline-assoc-type-20727-bindings.rs b/tests/rustdoc/inline-assoc-type-20727-bindings.rs deleted file mode 100644 index b3447a759df..00000000000 --- a/tests/rustdoc/inline-assoc-type-20727-bindings.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ aux-build:issue-20727.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/20727 -#![crate_name="issue_20727_2"] - -extern crate issue_20727; - -//@ has issue_20727_2/trait.Add.html -pub trait Add { - //@ has - '//pre[@class="rust item-decl"]' 'trait Add {' - //@ has - '//pre[@class="rust item-decl"]' 'type Output;' - type Output; - - //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' - fn add(self, rhs: RHS) -> Self::Output; -} - -//@ has issue_20727_2/reexport/trait.Add.html -pub mod reexport { - //@ has - '//pre[@class="rust item-decl"]' 'trait Add {' - //@ has - '//pre[@class="rust item-decl"]' 'type Output;' - //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' - pub use issue_20727::Add; -} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs deleted file mode 100644 index afb9087cc7a..00000000000 --- a/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ aux-build:issue-20727.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/20727 -#![crate_name="issue_20727_3"] - -extern crate issue_20727; - -pub trait Bar {} - -//@ has issue_20727_3/trait.Deref2.html -pub trait Deref2 { - //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' - type Target: Bar; - - //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' - fn deref(&self) -> Self::Target; -} - -//@ has issue_20727_3/reexport/trait.Deref2.html -pub mod reexport { - //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' - //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' - pub use issue_20727::Deref2; -} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs deleted file mode 100644 index 9dd234e8202..00000000000 --- a/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs +++ /dev/null @@ -1,43 +0,0 @@ -//@ aux-build:issue-20727.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/20727 -#![crate_name="issue_20727_4"] - -extern crate issue_20727; - -//@ has issue_20727_4/trait.Index.html -pub trait Index { - //@ has - '//pre[@class="rust item-decl"]' 'trait Index {' - //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' - type Output: ?Sized; - - //@ has - '//pre[@class="rust item-decl"]' \ - // 'fn index(&self, index: Idx) -> &Self::Output' - fn index(&self, index: Idx) -> &Self::Output; -} - -//@ has issue_20727_4/trait.IndexMut.html -pub trait IndexMut: Index { - //@ has - '//pre[@class="rust item-decl"]' \ - // 'trait IndexMut: Index {' - //@ has - '//pre[@class="rust item-decl"]' \ - // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' - fn index_mut(&mut self, index: Idx) -> &mut Self::Output; -} - -pub mod reexport { - //@ has issue_20727_4/reexport/trait.Index.html - //@ has - '//pre[@class="rust item-decl"]' 'trait Indexwhere Idx: ?Sized,{' - //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' - //@ has - '//pre[@class="rust item-decl"]' \ - // 'fn index(&self, index: Idx) -> &Self::Output' - pub use issue_20727::Index; - - //@ has issue_20727_4/reexport/trait.IndexMut.html - //@ has - '//pre[@class="rust item-decl"]' \ - // 'trait IndexMut: Indexwhere Idx: ?Sized,{' - //@ has - '//pre[@class="rust item-decl"]' \ - // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' - pub use issue_20727::IndexMut; -} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds.rs b/tests/rustdoc/inline-assoc-type-20727-bounds.rs deleted file mode 100644 index bd8d46f4a56..00000000000 --- a/tests/rustdoc/inline-assoc-type-20727-bounds.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ aux-build:issue-20727.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/20727 -#![crate_name="issue_20727"] - -extern crate issue_20727; - -//@ has issue_20727/trait.Deref.html -pub trait Deref { - //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' - //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' - type Target: ?Sized; - - //@ has - '//pre[@class="rust item-decl"]' \ - // "fn deref<'a>(&'a self) -> &'a Self::Target;" - fn deref<'a>(&'a self) -> &'a Self::Target; -} - -//@ has issue_20727/reexport/trait.Deref.html -pub mod reexport { - //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' - //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' - //@ has - '//pre[@class="rust item-decl"]' \ - // "fn deref<'a>(&'a self) -> &'a Self::Target;" - pub use issue_20727::Deref; -} diff --git a/tests/rustdoc/normalize-assoc-item.rs b/tests/rustdoc/normalize-assoc-item.rs deleted file mode 100644 index 7ef9d3067e1..00000000000 --- a/tests/rustdoc/normalize-assoc-item.rs +++ /dev/null @@ -1,82 +0,0 @@ -// ignore-tidy-linelength -//@ aux-build:normalize-assoc-item.rs -//@ build-aux-docs -//@ compile-flags:-Znormalize-docs - -pub trait Trait { - type X; -} - -impl Trait for usize { - type X = isize; -} - -impl Trait for () { - type X = fn() -> i32; -} - -impl Trait for isize { - type X = <() as Trait>::X; -} - -//@ has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust item-decl"]' 'pub fn f() -> isize' -pub fn f() -> ::X { - 0 -} - -//@ has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust item-decl"]' 'pub fn f2() -> fn() -> i32' -pub fn f2() -> ::X { - todo!() -} - -pub struct S { - //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box' - pub box_me_up: ::X, - //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)' - pub generic: as Trait>::X, -} - -impl Trait for S { - type X = Box; -} - -pub struct Generic(Inner); - -impl Trait for Generic { - type X = (Inner, Inner::X); -} - -// These can't be normalized because they depend on a generic parameter. -// However the user can choose whether the text should be displayed as `Inner::X` or `::X`. - -//@ has 'normalize_assoc_item/struct.Unknown.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown(pub ::X);' -pub struct Unknown(pub ::X); - -//@ has 'normalize_assoc_item/struct.Unknown2.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown2(pub Inner::X);' -pub struct Unknown2(pub Inner::X); - -trait Lifetimes<'a> { - type Y; -} - -impl<'a> Lifetimes<'a> for usize { - type Y = &'a isize; -} - -//@ has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &'static isize" -pub fn g() -> >::Y { - &0 -} - -//@ has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &'static isize" -pub const A: >::Y = &0; - -// test cross-crate re-exports -extern crate inner; -//@ has 'normalize_assoc_item/fn.foo.html' '//pre[@class="rust item-decl"]' "pub fn foo() -> i32" -pub use inner::foo; - -//@ has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h() -> IntoIter" -pub fn h() -> as IntoIterator>::IntoIter { - vec![].into_iter() -} -- cgit 1.4.1-3-g733a5 From 4b6bc735079bc07928efe791fecc9ec6cba81fe1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:13:39 +0200 Subject: Created `tests/rustdoc/enum` subfolder to limit number of files at the top level --- tests/rustdoc/auxiliary/enum-variant.rs | 48 ------ tests/rustdoc/auxiliary/variant-struct.rs | 5 - tests/rustdoc/enum-headings.rs | 40 ----- tests/rustdoc/enum-non-exhaustive-108925.rs | 13 -- .../rustdoc/enum-variant-doc-hidden-field-88600.rs | 37 ---- tests/rustdoc/enum-variant-fields-heading.rs | 18 -- .../enum-variant-fields-heading.variants.html | 3 - tests/rustdoc/enum-variant-value.rs | 191 --------------------- tests/rustdoc/enum/auxiliary/enum-variant.rs | 48 ++++++ tests/rustdoc/enum/auxiliary/variant-struct.rs | 5 + tests/rustdoc/enum/enum-headings.rs | 40 +++++ tests/rustdoc/enum/enum-non-exhaustive-108925.rs | 13 ++ .../enum/enum-variant-doc-hidden-field-88600.rs | 37 ++++ tests/rustdoc/enum/enum-variant-fields-heading.rs | 18 ++ .../enum/enum-variant-fields-heading.variants.html | 3 + tests/rustdoc/enum/enum-variant-value.rs | 191 +++++++++++++++++++++ .../enum/render-enum-variant-structlike-32395.rs | 18 ++ .../enum/strip-enum-variant.no-not-shown.html | 1 + tests/rustdoc/enum/strip-enum-variant.rs | 11 ++ .../render-enum-variant-structlike-32395.rs | 18 -- tests/rustdoc/strip-enum-variant.no-not-shown.html | 1 - tests/rustdoc/strip-enum-variant.rs | 11 -- 22 files changed, 385 insertions(+), 385 deletions(-) delete mode 100644 tests/rustdoc/auxiliary/enum-variant.rs delete mode 100644 tests/rustdoc/auxiliary/variant-struct.rs delete mode 100644 tests/rustdoc/enum-headings.rs delete mode 100644 tests/rustdoc/enum-non-exhaustive-108925.rs delete mode 100644 tests/rustdoc/enum-variant-doc-hidden-field-88600.rs delete mode 100644 tests/rustdoc/enum-variant-fields-heading.rs delete mode 100644 tests/rustdoc/enum-variant-fields-heading.variants.html delete mode 100644 tests/rustdoc/enum-variant-value.rs create mode 100644 tests/rustdoc/enum/auxiliary/enum-variant.rs create mode 100644 tests/rustdoc/enum/auxiliary/variant-struct.rs create mode 100644 tests/rustdoc/enum/enum-headings.rs create mode 100644 tests/rustdoc/enum/enum-non-exhaustive-108925.rs create mode 100644 tests/rustdoc/enum/enum-variant-doc-hidden-field-88600.rs create mode 100644 tests/rustdoc/enum/enum-variant-fields-heading.rs create mode 100644 tests/rustdoc/enum/enum-variant-fields-heading.variants.html create mode 100644 tests/rustdoc/enum/enum-variant-value.rs create mode 100644 tests/rustdoc/enum/render-enum-variant-structlike-32395.rs create mode 100644 tests/rustdoc/enum/strip-enum-variant.no-not-shown.html create mode 100644 tests/rustdoc/enum/strip-enum-variant.rs delete mode 100644 tests/rustdoc/render-enum-variant-structlike-32395.rs delete mode 100644 tests/rustdoc/strip-enum-variant.no-not-shown.html delete mode 100644 tests/rustdoc/strip-enum-variant.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/auxiliary/enum-variant.rs b/tests/rustdoc/auxiliary/enum-variant.rs deleted file mode 100644 index a0a7fd894f9..00000000000 --- a/tests/rustdoc/auxiliary/enum-variant.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![crate_name = "bar"] - -pub enum E { - A = 12, - B, - C = 1245, -} - -pub enum F { - A, - B, -} - -#[repr(u32)] -pub enum G { - A = 12, - B, - C(u32), -} - -pub enum H { - A, - C(u32), -} - -#[repr(C)] -pub enum N { - A, - B, -} - -#[repr(C)] -pub enum O { - A(u32), - B, -} - -#[repr(u32)] -pub enum P { - A, - B, -} - -#[repr(u32)] -pub enum Q { - A(u32), - B, -} diff --git a/tests/rustdoc/auxiliary/variant-struct.rs b/tests/rustdoc/auxiliary/variant-struct.rs deleted file mode 100644 index 0f3d2e5f1b7..00000000000 --- a/tests/rustdoc/auxiliary/variant-struct.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub enum Foo { - Bar { - qux: (), - } -} diff --git a/tests/rustdoc/enum-headings.rs b/tests/rustdoc/enum-headings.rs deleted file mode 100644 index 6deabf1cd9a..00000000000 --- a/tests/rustdoc/enum-headings.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![crate_name = "foo"] -//@ has foo/enum.Token.html -/// A token! -/// # First -/// Some following text... -//@ has - '//h2[@id="first"]' "First" -pub enum Token { - /// A declaration! - /// # Variant-First - /// Some following text... - //@ has - '//h4[@id="variant-first"]' "Variant-First" - Declaration { - /// A version! - /// # Variant-Field-First - /// Some following text... - //@ has - '//h5[@id="variant-field-first"]' "Variant-Field-First" - version: String, - }, - /// A Zoople! - /// # Variant-First - Zoople( - //@ has - '//h5[@id="variant-tuple-field-first"]' "Variant-Tuple-Field-First" - /// Zoople's first variant! - /// # Variant-Tuple-Field-First - /// Some following text... - usize, - ), - /// Unfinished business! - /// # Non-Exhaustive-First - /// Some following text... - //@ has - '//h4[@id="non-exhaustive-first"]' "Non-Exhaustive-First" - #[non_exhaustive] - Unfinished { - /// This is x. - /// # X-First - /// Some following text... - //@ has - '//h5[@id="x-first"]' "X-First" - x: usize, - }, -} diff --git a/tests/rustdoc/enum-non-exhaustive-108925.rs b/tests/rustdoc/enum-non-exhaustive-108925.rs deleted file mode 100644 index ea2462449d2..00000000000 --- a/tests/rustdoc/enum-non-exhaustive-108925.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/108925 -#![crate_name="foo"] - -//@ has foo/enum.MyThing.html -//@ has - '//code' 'Shown' -//@ !has - '//code' 'NotShown' -//@ !has - '//code' '// some variants omitted' -#[non_exhaustive] -pub enum MyThing { - Shown, - #[doc(hidden)] - NotShown, -} diff --git a/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs b/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs deleted file mode 100644 index f1d461c66c3..00000000000 --- a/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs +++ /dev/null @@ -1,37 +0,0 @@ -// This test ensure that #[doc(hidden)] is applied correctly in enum variant fields. -// https://github.com/rust-lang/rust/issues/88600 -#![crate_name = "foo"] - -// Denotes a field which should be hidden. -pub struct H; - -// Denotes a field which should not be hidden (shown). -pub struct S; - -//@ has foo/enum.FooEnum.html -pub enum FooEnum { - //@ has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(/* private fields */)' - //@ count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0 - HiddenTupleItem(#[doc(hidden)] H), - //@ has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(/* private fields */)' - //@ count - '//*[@id="variant.MultipleHidden.field.0"]' 0 - //@ count - '//*[@id="variant.MultipleHidden.field.1"]' 0 - MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H), - //@ has - '//*[@id="variant.MixedHiddenFirst"]//h3' 'MixedHiddenFirst(_, S)' - //@ count - '//*[@id="variant.MixedHiddenFirst.field.0"]' 0 - //@ has - '//*[@id="variant.MixedHiddenFirst.field.1"]' '1: S' - MixedHiddenFirst(#[doc(hidden)] H, /** dox */ S), - //@ has - '//*[@id="variant.MixedHiddenLast"]//h3' 'MixedHiddenLast(S, _)' - //@ has - '//*[@id="variant.MixedHiddenLast.field.0"]' '0: S' - //@ count - '//*[@id="variant.MixedHiddenLast.field.1"]' 0 - MixedHiddenLast(/** dox */ S, #[doc(hidden)] H), - //@ has - '//*[@id="variant.HiddenStruct"]//h3' 'HiddenStruct' - //@ count - '//*[@id="variant.HiddenStruct.field.h"]' 0 - //@ has - '//*[@id="variant.HiddenStruct.field.s"]' 's: S' - HiddenStruct { - #[doc(hidden)] - h: H, - /// dox - s: S, - }, -} diff --git a/tests/rustdoc/enum-variant-fields-heading.rs b/tests/rustdoc/enum-variant-fields-heading.rs deleted file mode 100644 index e210667d3c0..00000000000 --- a/tests/rustdoc/enum-variant-fields-heading.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This is a regression test for . -// It ensures that the "Fields" heading is not generated if no field is displayed. - -#![crate_name = "foo"] - -//@ has 'foo/enum.Foo.html' -//@ has - '//*[@id="variant.A"]' 'A' -//@ count - '//*[@id="variant.A.fields"]' 0 -//@ has - '//*[@id="variant.B"]' 'B' -//@ count - '//*[@id="variant.B.fields"]' 0 -//@ snapshot variants - '//*[@id="main-content"]/*[@class="variants"]' - -pub enum Foo { - /// A variant with no fields - A {}, - /// A variant with hidden fields - B { #[doc(hidden)] a: u8 }, -} diff --git a/tests/rustdoc/enum-variant-fields-heading.variants.html b/tests/rustdoc/enum-variant-fields-heading.variants.html deleted file mode 100644 index bcb36f7cf86..00000000000 --- a/tests/rustdoc/enum-variant-fields-heading.variants.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/tests/rustdoc/enum-variant-value.rs b/tests/rustdoc/enum-variant-value.rs deleted file mode 100644 index 1670de8a24f..00000000000 --- a/tests/rustdoc/enum-variant-value.rs +++ /dev/null @@ -1,191 +0,0 @@ -// This test ensures that the variant value is displayed with underscores but without -// a type name at the end. - -//@ aux-build:enum-variant.rs - -#![crate_name = "foo"] - -extern crate bar; - -// In this case, since all variants are C-like variants and at least one of them -// has its value set, we display values for all of them. - -//@ has 'foo/enum.A.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' -//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' -//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' -pub enum A { - A = 12, - B, - C = 1245, -} - -// In this case, all variants are C-like variants but none of them has its value set. -// Therefore we don't display values. - -//@ has 'foo/enum.B.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A,' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ matches - '//*[@id="variant.A"]/h3' '^A$' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -pub enum B { - A, - B, -} - -// In this case, not all variants are C-like variants so we don't display values. - -//@ has 'foo/enum.C.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' -#[repr(u32)] -pub enum C { - A = 12, - B, - C(u32), -} - -// In this case, not all variants are C-like variants and no C-like variant has its -// value set, so we don't display values. - -//@ has 'foo/enum.D.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A,' -//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' -//@ matches - '//*[@id="variant.A"]/h3' '^A$' -//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' -pub enum D { - A, - C(u32), -} - -//@ has 'foo/enum.E.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' -//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' -//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' -pub use bar::E; - -//@ has 'foo/enum.F.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A,' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ matches - '//*[@id="variant.A"]/h3' '^A$' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -pub use bar::F; - -//@ has 'foo/enum.G.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' -pub use bar::G; - -//@ has 'foo/enum.H.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A,' -//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' -//@ matches - '//*[@id="variant.A"]/h3' '^A$' -//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' -pub use bar::H; - -// Testing more complex cases. -pub const X: isize = 2; -//@ has 'foo/enum.I.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 2,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 4,' -//@ has - '//*[@class="rust item-decl"]/code' 'C = 9,' -//@ has - '//*[@class="rust item-decl"]/code' 'D = -1,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 2$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 4$' -//@ matches - '//*[@id="variant.C"]/h3' '^C = 9$' -//@ matches - '//*[@id="variant.D"]/h3' '^D = -1$' -#[repr(isize)] -pub enum I { - A = X, - B = X * 2, - C = Self::B as isize + X + 3, - D = -1, -} - -// Testing `repr`. - -//@ has 'foo/enum.J.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' -#[repr(C)] -pub enum J { - A, - B, -} - -//@ has 'foo/enum.K.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -#[repr(C)] -pub enum K { - A(u32), - B, -} - -//@ has 'foo/enum.L.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' -#[repr(u32)] -pub enum L { - A, - B, -} - -//@ has 'foo/enum.M.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -#[repr(u32)] -pub enum M { - A(u32), - B, -} - -//@ has 'foo/enum.N.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' -pub use bar::N; - -//@ has 'foo/enum.O.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -pub use bar::O; - -//@ has 'foo/enum.P.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' -//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' -//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' -//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' -pub use bar::P; - -//@ has 'foo/enum.Q.html' -//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' -//@ has - '//*[@class="rust item-decl"]/code' 'B,' -//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' -//@ matches - '//*[@id="variant.B"]/h3' '^B$' -pub use bar::Q; diff --git a/tests/rustdoc/enum/auxiliary/enum-variant.rs b/tests/rustdoc/enum/auxiliary/enum-variant.rs new file mode 100644 index 00000000000..a0a7fd894f9 --- /dev/null +++ b/tests/rustdoc/enum/auxiliary/enum-variant.rs @@ -0,0 +1,48 @@ +#![crate_name = "bar"] + +pub enum E { + A = 12, + B, + C = 1245, +} + +pub enum F { + A, + B, +} + +#[repr(u32)] +pub enum G { + A = 12, + B, + C(u32), +} + +pub enum H { + A, + C(u32), +} + +#[repr(C)] +pub enum N { + A, + B, +} + +#[repr(C)] +pub enum O { + A(u32), + B, +} + +#[repr(u32)] +pub enum P { + A, + B, +} + +#[repr(u32)] +pub enum Q { + A(u32), + B, +} diff --git a/tests/rustdoc/enum/auxiliary/variant-struct.rs b/tests/rustdoc/enum/auxiliary/variant-struct.rs new file mode 100644 index 00000000000..0f3d2e5f1b7 --- /dev/null +++ b/tests/rustdoc/enum/auxiliary/variant-struct.rs @@ -0,0 +1,5 @@ +pub enum Foo { + Bar { + qux: (), + } +} diff --git a/tests/rustdoc/enum/enum-headings.rs b/tests/rustdoc/enum/enum-headings.rs new file mode 100644 index 00000000000..6deabf1cd9a --- /dev/null +++ b/tests/rustdoc/enum/enum-headings.rs @@ -0,0 +1,40 @@ +#![crate_name = "foo"] +//@ has foo/enum.Token.html +/// A token! +/// # First +/// Some following text... +//@ has - '//h2[@id="first"]' "First" +pub enum Token { + /// A declaration! + /// # Variant-First + /// Some following text... + //@ has - '//h4[@id="variant-first"]' "Variant-First" + Declaration { + /// A version! + /// # Variant-Field-First + /// Some following text... + //@ has - '//h5[@id="variant-field-first"]' "Variant-Field-First" + version: String, + }, + /// A Zoople! + /// # Variant-First + Zoople( + //@ has - '//h5[@id="variant-tuple-field-first"]' "Variant-Tuple-Field-First" + /// Zoople's first variant! + /// # Variant-Tuple-Field-First + /// Some following text... + usize, + ), + /// Unfinished business! + /// # Non-Exhaustive-First + /// Some following text... + //@ has - '//h4[@id="non-exhaustive-first"]' "Non-Exhaustive-First" + #[non_exhaustive] + Unfinished { + /// This is x. + /// # X-First + /// Some following text... + //@ has - '//h5[@id="x-first"]' "X-First" + x: usize, + }, +} diff --git a/tests/rustdoc/enum/enum-non-exhaustive-108925.rs b/tests/rustdoc/enum/enum-non-exhaustive-108925.rs new file mode 100644 index 00000000000..ea2462449d2 --- /dev/null +++ b/tests/rustdoc/enum/enum-non-exhaustive-108925.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/108925 +#![crate_name="foo"] + +//@ has foo/enum.MyThing.html +//@ has - '//code' 'Shown' +//@ !has - '//code' 'NotShown' +//@ !has - '//code' '// some variants omitted' +#[non_exhaustive] +pub enum MyThing { + Shown, + #[doc(hidden)] + NotShown, +} diff --git a/tests/rustdoc/enum/enum-variant-doc-hidden-field-88600.rs b/tests/rustdoc/enum/enum-variant-doc-hidden-field-88600.rs new file mode 100644 index 00000000000..f1d461c66c3 --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-doc-hidden-field-88600.rs @@ -0,0 +1,37 @@ +// This test ensure that #[doc(hidden)] is applied correctly in enum variant fields. +// https://github.com/rust-lang/rust/issues/88600 +#![crate_name = "foo"] + +// Denotes a field which should be hidden. +pub struct H; + +// Denotes a field which should not be hidden (shown). +pub struct S; + +//@ has foo/enum.FooEnum.html +pub enum FooEnum { + //@ has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(/* private fields */)' + //@ count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0 + HiddenTupleItem(#[doc(hidden)] H), + //@ has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(/* private fields */)' + //@ count - '//*[@id="variant.MultipleHidden.field.0"]' 0 + //@ count - '//*[@id="variant.MultipleHidden.field.1"]' 0 + MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H), + //@ has - '//*[@id="variant.MixedHiddenFirst"]//h3' 'MixedHiddenFirst(_, S)' + //@ count - '//*[@id="variant.MixedHiddenFirst.field.0"]' 0 + //@ has - '//*[@id="variant.MixedHiddenFirst.field.1"]' '1: S' + MixedHiddenFirst(#[doc(hidden)] H, /** dox */ S), + //@ has - '//*[@id="variant.MixedHiddenLast"]//h3' 'MixedHiddenLast(S, _)' + //@ has - '//*[@id="variant.MixedHiddenLast.field.0"]' '0: S' + //@ count - '//*[@id="variant.MixedHiddenLast.field.1"]' 0 + MixedHiddenLast(/** dox */ S, #[doc(hidden)] H), + //@ has - '//*[@id="variant.HiddenStruct"]//h3' 'HiddenStruct' + //@ count - '//*[@id="variant.HiddenStruct.field.h"]' 0 + //@ has - '//*[@id="variant.HiddenStruct.field.s"]' 's: S' + HiddenStruct { + #[doc(hidden)] + h: H, + /// dox + s: S, + }, +} diff --git a/tests/rustdoc/enum/enum-variant-fields-heading.rs b/tests/rustdoc/enum/enum-variant-fields-heading.rs new file mode 100644 index 00000000000..e210667d3c0 --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-fields-heading.rs @@ -0,0 +1,18 @@ +// This is a regression test for . +// It ensures that the "Fields" heading is not generated if no field is displayed. + +#![crate_name = "foo"] + +//@ has 'foo/enum.Foo.html' +//@ has - '//*[@id="variant.A"]' 'A' +//@ count - '//*[@id="variant.A.fields"]' 0 +//@ has - '//*[@id="variant.B"]' 'B' +//@ count - '//*[@id="variant.B.fields"]' 0 +//@ snapshot variants - '//*[@id="main-content"]/*[@class="variants"]' + +pub enum Foo { + /// A variant with no fields + A {}, + /// A variant with hidden fields + B { #[doc(hidden)] a: u8 }, +} diff --git a/tests/rustdoc/enum/enum-variant-fields-heading.variants.html b/tests/rustdoc/enum/enum-variant-fields-heading.variants.html new file mode 100644 index 00000000000..bcb36f7cf86 --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-fields-heading.variants.html @@ -0,0 +1,3 @@ +
§

A

A variant with no fields

+
§

B

A variant with hidden fields

+
\ No newline at end of file diff --git a/tests/rustdoc/enum/enum-variant-value.rs b/tests/rustdoc/enum/enum-variant-value.rs new file mode 100644 index 00000000000..1670de8a24f --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-value.rs @@ -0,0 +1,191 @@ +// This test ensures that the variant value is displayed with underscores but without +// a type name at the end. + +//@ aux-build:enum-variant.rs + +#![crate_name = "foo"] + +extern crate bar; + +// In this case, since all variants are C-like variants and at least one of them +// has its value set, we display values for all of them. + +//@ has 'foo/enum.A.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' +pub enum A { + A = 12, + B, + C = 1245, +} + +// In this case, all variants are C-like variants but none of them has its value set. +// Therefore we don't display values. + +//@ has 'foo/enum.B.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +pub enum B { + A, + B, +} + +// In this case, not all variants are C-like variants so we don't display values. + +//@ has 'foo/enum.C.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' +#[repr(u32)] +pub enum C { + A = 12, + B, + C(u32), +} + +// In this case, not all variants are C-like variants and no C-like variant has its +// value set, so we don't display values. + +//@ has 'foo/enum.D.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' +pub enum D { + A, + C(u32), +} + +//@ has 'foo/enum.E.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' +pub use bar::E; + +//@ has 'foo/enum.F.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +pub use bar::F; + +//@ has 'foo/enum.G.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' +pub use bar::G; + +//@ has 'foo/enum.H.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' +pub use bar::H; + +// Testing more complex cases. +pub const X: isize = 2; +//@ has 'foo/enum.I.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 2,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 4,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 9,' +//@ has - '//*[@class="rust item-decl"]/code' 'D = -1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 2$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 4$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 9$' +//@ matches - '//*[@id="variant.D"]/h3' '^D = -1$' +#[repr(isize)] +pub enum I { + A = X, + B = X * 2, + C = Self::B as isize + X + 3, + D = -1, +} + +// Testing `repr`. + +//@ has 'foo/enum.J.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' +#[repr(C)] +pub enum J { + A, + B, +} + +//@ has 'foo/enum.K.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +#[repr(C)] +pub enum K { + A(u32), + B, +} + +//@ has 'foo/enum.L.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' +#[repr(u32)] +pub enum L { + A, + B, +} + +//@ has 'foo/enum.M.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +#[repr(u32)] +pub enum M { + A(u32), + B, +} + +//@ has 'foo/enum.N.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' +pub use bar::N; + +//@ has 'foo/enum.O.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +pub use bar::O; + +//@ has 'foo/enum.P.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' +pub use bar::P; + +//@ has 'foo/enum.Q.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +pub use bar::Q; diff --git a/tests/rustdoc/enum/render-enum-variant-structlike-32395.rs b/tests/rustdoc/enum/render-enum-variant-structlike-32395.rs new file mode 100644 index 00000000000..d4cefb2911d --- /dev/null +++ b/tests/rustdoc/enum/render-enum-variant-structlike-32395.rs @@ -0,0 +1,18 @@ +//@ aux-build:variant-struct.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/32395 +#![crate_name="issue_32395"] + +//@ has variant_struct/enum.Foo.html +//@ !hasraw - 'pub qux' +//@ !hasraw - 'pub(crate) qux' +//@ !hasraw - 'pub Bar' +extern crate variant_struct; + +//@ has issue_32395/enum.Foo.html +//@ !hasraw - 'pub qux' +//@ !hasraw - 'pub(crate) qux' +//@ !hasraw - 'pub Bar' +pub use variant_struct::Foo; diff --git a/tests/rustdoc/enum/strip-enum-variant.no-not-shown.html b/tests/rustdoc/enum/strip-enum-variant.no-not-shown.html new file mode 100644 index 00000000000..d7a36cc631a --- /dev/null +++ b/tests/rustdoc/enum/strip-enum-variant.no-not-shown.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/rustdoc/enum/strip-enum-variant.rs b/tests/rustdoc/enum/strip-enum-variant.rs new file mode 100644 index 00000000000..9874588ef59 --- /dev/null +++ b/tests/rustdoc/enum/strip-enum-variant.rs @@ -0,0 +1,11 @@ +//@ has strip_enum_variant/enum.MyThing.html +//@ has - '//code' 'Shown' +//@ !has - '//code' 'NotShown' +//@ has - '//code' '// some variants omitted' +// Also check that `NotShown` isn't displayed in the sidebar. +//@ snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block variant"]' +pub enum MyThing { + Shown, + #[doc(hidden)] + NotShown, +} diff --git a/tests/rustdoc/render-enum-variant-structlike-32395.rs b/tests/rustdoc/render-enum-variant-structlike-32395.rs deleted file mode 100644 index d4cefb2911d..00000000000 --- a/tests/rustdoc/render-enum-variant-structlike-32395.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ aux-build:variant-struct.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/32395 -#![crate_name="issue_32395"] - -//@ has variant_struct/enum.Foo.html -//@ !hasraw - 'pub qux' -//@ !hasraw - 'pub(crate) qux' -//@ !hasraw - 'pub Bar' -extern crate variant_struct; - -//@ has issue_32395/enum.Foo.html -//@ !hasraw - 'pub qux' -//@ !hasraw - 'pub(crate) qux' -//@ !hasraw - 'pub Bar' -pub use variant_struct::Foo; diff --git a/tests/rustdoc/strip-enum-variant.no-not-shown.html b/tests/rustdoc/strip-enum-variant.no-not-shown.html deleted file mode 100644 index d7a36cc631a..00000000000 --- a/tests/rustdoc/strip-enum-variant.no-not-shown.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/rustdoc/strip-enum-variant.rs b/tests/rustdoc/strip-enum-variant.rs deleted file mode 100644 index 9874588ef59..00000000000 --- a/tests/rustdoc/strip-enum-variant.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ has strip_enum_variant/enum.MyThing.html -//@ has - '//code' 'Shown' -//@ !has - '//code' 'NotShown' -//@ has - '//code' '// some variants omitted' -// Also check that `NotShown` isn't displayed in the sidebar. -//@ snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block variant"]' -pub enum MyThing { - Shown, - #[doc(hidden)] - NotShown, -} -- cgit 1.4.1-3-g733a5 From e245c3bc6bb7d278106649be9a03fc9b374e196b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:18:50 +0200 Subject: Move primitive rustdoc tests into the `primitive` sub folder --- tests/rustdoc/auxiliary/issue-15318.rs | 17 ------- tests/rustdoc/auxiliary/primitive-doc.rs | 11 ----- tests/rustdoc/cross-crate-primitive-doc.rs | 16 ------- tests/rustdoc/no_std-primitive.rs | 6 --- tests/rustdoc/primitive-link.rs | 14 ------ tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs | 9 ---- tests/rustdoc/primitive-raw-pointer-link-15318.rs | 13 ----- ...rimitive-raw-pointer-link-no-inlined-15318-2.rs | 15 ------ tests/rustdoc/primitive-reference.rs | 36 -------------- tests/rustdoc/primitive-slice-auto-trait.rs | 14 ------ tests/rustdoc/primitive-tuple-auto-trait.rs | 22 --------- tests/rustdoc/primitive-tuple-variadic.rs | 55 ---------------------- tests/rustdoc/primitive-unit-auto-trait.rs | 14 ------ tests/rustdoc/primitive/auxiliary/issue-15318.rs | 17 +++++++ tests/rustdoc/primitive/auxiliary/primitive-doc.rs | 11 +++++ .../rustdoc/primitive/cross-crate-primitive-doc.rs | 16 +++++++ tests/rustdoc/primitive/no_std-primitive.rs | 6 +++ tests/rustdoc/primitive/primitive-link.rs | 14 ++++++ .../primitive/primitive-raw-pointer-dox-15318-3.rs | 9 ++++ .../primitive/primitive-raw-pointer-link-15318.rs | 13 +++++ ...rimitive-raw-pointer-link-no-inlined-15318-2.rs | 15 ++++++ tests/rustdoc/primitive/primitive-reference.rs | 36 ++++++++++++++ .../primitive/primitive-slice-auto-trait.rs | 14 ++++++ .../primitive/primitive-tuple-auto-trait.rs | 22 +++++++++ .../rustdoc/primitive/primitive-tuple-variadic.rs | 55 ++++++++++++++++++++++ .../rustdoc/primitive/primitive-unit-auto-trait.rs | 14 ++++++ ...search-index-primitive-inherent-method-23511.rs | 16 +++++++ ...search-index-primitive-inherent-method-23511.rs | 16 ------- 28 files changed, 258 insertions(+), 258 deletions(-) delete mode 100644 tests/rustdoc/auxiliary/issue-15318.rs delete mode 100644 tests/rustdoc/auxiliary/primitive-doc.rs delete mode 100644 tests/rustdoc/cross-crate-primitive-doc.rs delete mode 100644 tests/rustdoc/no_std-primitive.rs delete mode 100644 tests/rustdoc/primitive-link.rs delete mode 100644 tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs delete mode 100644 tests/rustdoc/primitive-raw-pointer-link-15318.rs delete mode 100644 tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs delete mode 100644 tests/rustdoc/primitive-reference.rs delete mode 100644 tests/rustdoc/primitive-slice-auto-trait.rs delete mode 100644 tests/rustdoc/primitive-tuple-auto-trait.rs delete mode 100644 tests/rustdoc/primitive-tuple-variadic.rs delete mode 100644 tests/rustdoc/primitive-unit-auto-trait.rs create mode 100644 tests/rustdoc/primitive/auxiliary/issue-15318.rs create mode 100644 tests/rustdoc/primitive/auxiliary/primitive-doc.rs create mode 100644 tests/rustdoc/primitive/cross-crate-primitive-doc.rs create mode 100644 tests/rustdoc/primitive/no_std-primitive.rs create mode 100644 tests/rustdoc/primitive/primitive-link.rs create mode 100644 tests/rustdoc/primitive/primitive-raw-pointer-dox-15318-3.rs create mode 100644 tests/rustdoc/primitive/primitive-raw-pointer-link-15318.rs create mode 100644 tests/rustdoc/primitive/primitive-raw-pointer-link-no-inlined-15318-2.rs create mode 100644 tests/rustdoc/primitive/primitive-reference.rs create mode 100644 tests/rustdoc/primitive/primitive-slice-auto-trait.rs create mode 100644 tests/rustdoc/primitive/primitive-tuple-auto-trait.rs create mode 100644 tests/rustdoc/primitive/primitive-tuple-variadic.rs create mode 100644 tests/rustdoc/primitive/primitive-unit-auto-trait.rs create mode 100644 tests/rustdoc/primitive/search-index-primitive-inherent-method-23511.rs delete mode 100644 tests/rustdoc/search-index-primitive-inherent-method-23511.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/auxiliary/issue-15318.rs b/tests/rustdoc/auxiliary/issue-15318.rs deleted file mode 100644 index d3dc89113fc..00000000000 --- a/tests/rustdoc/auxiliary/issue-15318.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ no-prefer-dynamic -//@ compile-flags: -Cmetadata=aux -#![crate_type = "rlib"] -#![doc(html_root_url = "http://example.com/")] -#![feature(rustc_attrs)] -#![feature(lang_items)] -#![no_std] - -#[lang = "eh_personality"] -fn foo() {} - -#[panic_handler] -fn bar(_: &core::panic::PanicInfo) -> ! { loop {} } - -/// dox -#[rustc_doc_primitive = "pointer"] -pub mod ptr {} diff --git a/tests/rustdoc/auxiliary/primitive-doc.rs b/tests/rustdoc/auxiliary/primitive-doc.rs deleted file mode 100644 index 859716c38e4..00000000000 --- a/tests/rustdoc/auxiliary/primitive-doc.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ compile-flags: --crate-type lib -//@ edition: 2018 - -#![feature(rustc_attrs)] -#![feature(no_core)] -#![no_core] - -#[rustc_doc_primitive = "usize"] -/// This is the built-in type `usize`. -mod usize { -} diff --git a/tests/rustdoc/cross-crate-primitive-doc.rs b/tests/rustdoc/cross-crate-primitive-doc.rs deleted file mode 100644 index 0ffde5b0f2d..00000000000 --- a/tests/rustdoc/cross-crate-primitive-doc.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ aux-build:primitive-doc.rs -//@ compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options -//@ only-linux - -#![feature(no_core, lang_items)] -#![no_core] - -#[lang = "sized"] -trait Sized {} - -extern crate primitive_doc; - -//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize' -//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'link' -/// [link](usize) -pub fn foo() -> usize { 0 } diff --git a/tests/rustdoc/no_std-primitive.rs b/tests/rustdoc/no_std-primitive.rs deleted file mode 100644 index 78076a601de..00000000000 --- a/tests/rustdoc/no_std-primitive.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![no_std] - -/// Link to [intra-doc link][u8] -//@ has 'no_std_primitive/fn.foo.html' '//a[@href="{{channel}}/core/primitive.u8.html"]' 'intra-doc link' -//@ has - '//a[@href="{{channel}}/core/primitive.u8.html"]' 'u8' -pub fn foo() -> u8 {} diff --git a/tests/rustdoc/primitive-link.rs b/tests/rustdoc/primitive-link.rs deleted file mode 100644 index 3fe9cdc3ca7..00000000000 --- a/tests/rustdoc/primitive-link.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![crate_name = "foo"] - - -//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' -//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i64.html"]' 'i64' -//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html"]' 'std::primitive::i32' -//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.str.html"]' 'std::primitive::str' - -//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' - -/// It contains [`u32`] and [i64]. -/// It also links to [std::primitive::i32], [std::primitive::str], -/// and [`std::primitive::i32::MAX`]. -pub struct Foo; diff --git a/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs deleted file mode 100644 index 5520abf2925..00000000000 --- a/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs +++ /dev/null @@ -1,9 +0,0 @@ -// https://github.com/rust-lang/rust/issues/15318 -#![crate_name="issue_15318_3"] -#![feature(rustc_attrs)] - -//@ has issue_15318_3/primitive.pointer.html - -/// dox -#[rustc_doc_primitive = "pointer"] -pub mod ptr {} diff --git a/tests/rustdoc/primitive-raw-pointer-link-15318.rs b/tests/rustdoc/primitive-raw-pointer-link-15318.rs deleted file mode 100644 index a6f6f67dc84..00000000000 --- a/tests/rustdoc/primitive-raw-pointer-link-15318.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:issue-15318.rs -//@ ignore-cross-compile -// https://github.com/rust-lang/rust/issues/15318 - -#![crate_name="issue_15318"] -#![no_std] - -extern crate issue_15318; - -//@ has issue_15318/fn.bar.html \ -// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ -// '*mut T' -pub fn bar(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs deleted file mode 100644 index 16b007e8bbd..00000000000 --- a/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:issue-15318.rs -//@ ignore-cross-compile -// https://github.com/rust-lang/rust/issues/15318 - -#![crate_name="issue_15318_2"] -#![no_std] - -extern crate issue_15318; - -pub use issue_15318::ptr; - -//@ !has issue_15318_2/fn.bar.html \ -// '//*[@href="primitive.pointer.html"]' \ -// '*mut T' -pub fn bar(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive-reference.rs b/tests/rustdoc/primitive-reference.rs deleted file mode 100644 index bd6b2a32f75..00000000000 --- a/tests/rustdoc/primitive-reference.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![crate_name = "foo"] - -#![feature(rustc_attrs)] - -//@ has foo/index.html -//@ has - '//h2[@id="primitives"]' 'Primitive Types' -//@ has - '//a[@href="primitive.reference.html"]' 'reference' -//@ has - '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' -//@ has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' -//@ has foo/primitive.reference.html -//@ has - '//h1' 'Primitive Type reference' -//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' - -// There should be only one implementation listed. -//@ count - '//*[@class="impl"]' 1 -//@ has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ -// 'impl Foo<&A> for &B' -#[rustc_doc_primitive = "reference"] -/// this is a test! -mod reference {} - -pub struct Bar; - -// This implementation should **not** show up. -impl From<&T> for Bar { - fn from(s: &T) -> Self { - Bar - } -} - -pub trait Foo { - fn stuff(&self, other: &T) {} -} - -// This implementation should show up. -impl Foo<&A> for &B {} diff --git a/tests/rustdoc/primitive-slice-auto-trait.rs b/tests/rustdoc/primitive-slice-auto-trait.rs deleted file mode 100644 index 647c1cca948..00000000000 --- a/tests/rustdoc/primitive-slice-auto-trait.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ compile-flags: --crate-type lib -//@ edition: 2018 - -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -//@ has foo/primitive.slice.html '//h1' 'Primitive Type slice' -//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for [T]where T: Send' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for [T]where T: Sync' -#[rustc_doc_primitive = "slice"] -/// this is a test! -mod slice_prim {} diff --git a/tests/rustdoc/primitive-tuple-auto-trait.rs b/tests/rustdoc/primitive-tuple-auto-trait.rs deleted file mode 100644 index 51300bd6b2f..00000000000 --- a/tests/rustdoc/primitive-tuple-auto-trait.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ compile-flags: --crate-type lib -//@ edition: 2018 - -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -//@ has foo/primitive.tuple.html '//h1' 'Primitive Type tuple' -//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' -#[rustc_doc_primitive = "tuple"] -/// this is a test! -/// -// Hardcoded anchor to header written in library/core/src/primitive_docs.rs -//@ has - '//h2[@id="trait-implementations-1"]' 'Trait implementations' -/// # Trait implementations -/// -/// This header is hard-coded in the HTML format linking for `#[doc(fake_variadics)]`. -/// To make sure it gets linked correctly, we need to make sure the hardcoded anchor -/// in the code matches what rustdoc generates for the header. -mod tuple_prim {} diff --git a/tests/rustdoc/primitive-tuple-variadic.rs b/tests/rustdoc/primitive-tuple-variadic.rs deleted file mode 100644 index bab5eaae9a2..00000000000 --- a/tests/rustdoc/primitive-tuple-variadic.rs +++ /dev/null @@ -1,55 +0,0 @@ -//@ compile-flags: --crate-type lib -//@ edition: 2018 - -#![crate_name = "foo"] -#![feature(rustdoc_internals)] - -pub trait Foo {} - -//@ has foo/trait.Foo.html -//@ has - '//section[@id="impl-Foo-for-(T,)"]/h3' 'impl Foo for (T₁, T₂, …, Tₙ)' -#[doc(fake_variadic)] -impl Foo for (T,) {} - -pub trait Bar {} - -//@ has foo/trait.Bar.html -//@ has - '//section[@id="impl-Bar-for-(U,)"]/h3' 'impl Bar for (U₁, U₂, …, Uₙ)' -#[doc(fake_variadic)] -impl Bar for (U,) {} - -pub trait Baz { fn baz(&self) -> T { todo!() } } - -//@ has foo/trait.Baz.html -//@ has - '//section[@id="impl-Baz%3C(T,)%3E-for-%5BT;+1%5D"]/h3' 'impl Baz<(T₁, T₂, …, Tₙ)> for [T; N]' -#[doc(fake_variadic)] -impl Baz<(T,)> for [T; 1] {} - -//@ has foo/trait.Baz.html -//@ has - '//section[@id="impl-Baz%3C%5BT;+1%5D%3E-for-(T,)"]/h3' 'impl Baz<[T; N]> for (T₁, T₂, …, Tₙ)' -#[doc(fake_variadic)] -impl Baz<[T; 1]> for (T,) {} - -//@ has foo/trait.Baz.html -//@ has - '//section[@id="impl-Baz%3CT%3E-for-(T,)"]/h3' 'impl Baz for (T₁, T₂, …, Tₙ)' -#[doc(fake_variadic)] -impl Baz for (T,) {} - -pub trait Qux {} - -pub struct NewType(T); - -//@ has foo/trait.Qux.html -//@ has - '//section[@id="impl-Qux-for-NewType%3C(T,)%3E"]/h3' 'impl Qux for NewType<(T₁, T₂, …, Tₙ)>' -#[doc(fake_variadic)] -impl Qux for NewType<(T,)> {} - -//@ has foo/trait.Qux.html -//@ has - '//section[@id="impl-Qux-for-NewType%3CNewType%3C(T,)%3E%3E"]/h3' 'impl Qux for NewType>' -#[doc(fake_variadic)] -impl Qux for NewType> {} - -//@ has foo/trait.Qux.html -//@ has - '//section[@id="impl-Qux-for-NewType%3Cfn(T)+-%3E+Out%3E"]/h3' 'impl Qux for NewType Out>' -#[doc(fake_variadic)] -impl Qux for NewType Out> {} diff --git a/tests/rustdoc/primitive-unit-auto-trait.rs b/tests/rustdoc/primitive-unit-auto-trait.rs deleted file mode 100644 index 7dada1f9832..00000000000 --- a/tests/rustdoc/primitive-unit-auto-trait.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ compile-flags: --crate-type lib -//@ edition: 2018 - -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -//@ has foo/primitive.unit.html '//h1' 'Primitive Type unit' -//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' -//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' -#[rustc_doc_primitive = "unit"] -/// this is a test! -mod unit_prim {} diff --git a/tests/rustdoc/primitive/auxiliary/issue-15318.rs b/tests/rustdoc/primitive/auxiliary/issue-15318.rs new file mode 100644 index 00000000000..d3dc89113fc --- /dev/null +++ b/tests/rustdoc/primitive/auxiliary/issue-15318.rs @@ -0,0 +1,17 @@ +//@ no-prefer-dynamic +//@ compile-flags: -Cmetadata=aux +#![crate_type = "rlib"] +#![doc(html_root_url = "http://example.com/")] +#![feature(rustc_attrs)] +#![feature(lang_items)] +#![no_std] + +#[lang = "eh_personality"] +fn foo() {} + +#[panic_handler] +fn bar(_: &core::panic::PanicInfo) -> ! { loop {} } + +/// dox +#[rustc_doc_primitive = "pointer"] +pub mod ptr {} diff --git a/tests/rustdoc/primitive/auxiliary/primitive-doc.rs b/tests/rustdoc/primitive/auxiliary/primitive-doc.rs new file mode 100644 index 00000000000..859716c38e4 --- /dev/null +++ b/tests/rustdoc/primitive/auxiliary/primitive-doc.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --crate-type lib +//@ edition: 2018 + +#![feature(rustc_attrs)] +#![feature(no_core)] +#![no_core] + +#[rustc_doc_primitive = "usize"] +/// This is the built-in type `usize`. +mod usize { +} diff --git a/tests/rustdoc/primitive/cross-crate-primitive-doc.rs b/tests/rustdoc/primitive/cross-crate-primitive-doc.rs new file mode 100644 index 00000000000..0ffde5b0f2d --- /dev/null +++ b/tests/rustdoc/primitive/cross-crate-primitive-doc.rs @@ -0,0 +1,16 @@ +//@ aux-build:primitive-doc.rs +//@ compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options +//@ only-linux + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +extern crate primitive_doc; + +//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize' +//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'link' +/// [link](usize) +pub fn foo() -> usize { 0 } diff --git a/tests/rustdoc/primitive/no_std-primitive.rs b/tests/rustdoc/primitive/no_std-primitive.rs new file mode 100644 index 00000000000..78076a601de --- /dev/null +++ b/tests/rustdoc/primitive/no_std-primitive.rs @@ -0,0 +1,6 @@ +#![no_std] + +/// Link to [intra-doc link][u8] +//@ has 'no_std_primitive/fn.foo.html' '//a[@href="{{channel}}/core/primitive.u8.html"]' 'intra-doc link' +//@ has - '//a[@href="{{channel}}/core/primitive.u8.html"]' 'u8' +pub fn foo() -> u8 {} diff --git a/tests/rustdoc/primitive/primitive-link.rs b/tests/rustdoc/primitive/primitive-link.rs new file mode 100644 index 00000000000..3fe9cdc3ca7 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-link.rs @@ -0,0 +1,14 @@ +#![crate_name = "foo"] + + +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i64.html"]' 'i64' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html"]' 'std::primitive::i32' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.str.html"]' 'std::primitive::str' + +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' + +/// It contains [`u32`] and [i64]. +/// It also links to [std::primitive::i32], [std::primitive::str], +/// and [`std::primitive::i32::MAX`]. +pub struct Foo; diff --git a/tests/rustdoc/primitive/primitive-raw-pointer-dox-15318-3.rs b/tests/rustdoc/primitive/primitive-raw-pointer-dox-15318-3.rs new file mode 100644 index 00000000000..5520abf2925 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-raw-pointer-dox-15318-3.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/15318 +#![crate_name="issue_15318_3"] +#![feature(rustc_attrs)] + +//@ has issue_15318_3/primitive.pointer.html + +/// dox +#[rustc_doc_primitive = "pointer"] +pub mod ptr {} diff --git a/tests/rustdoc/primitive/primitive-raw-pointer-link-15318.rs b/tests/rustdoc/primitive/primitive-raw-pointer-link-15318.rs new file mode 100644 index 00000000000..a6f6f67dc84 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-raw-pointer-link-15318.rs @@ -0,0 +1,13 @@ +//@ aux-build:issue-15318.rs +//@ ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 + +#![crate_name="issue_15318"] +#![no_std] + +extern crate issue_15318; + +//@ has issue_15318/fn.bar.html \ +// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ +// '*mut T' +pub fn bar(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive/primitive-raw-pointer-link-no-inlined-15318-2.rs b/tests/rustdoc/primitive/primitive-raw-pointer-link-no-inlined-15318-2.rs new file mode 100644 index 00000000000..16b007e8bbd --- /dev/null +++ b/tests/rustdoc/primitive/primitive-raw-pointer-link-no-inlined-15318-2.rs @@ -0,0 +1,15 @@ +//@ aux-build:issue-15318.rs +//@ ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 + +#![crate_name="issue_15318_2"] +#![no_std] + +extern crate issue_15318; + +pub use issue_15318::ptr; + +//@ !has issue_15318_2/fn.bar.html \ +// '//*[@href="primitive.pointer.html"]' \ +// '*mut T' +pub fn bar(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive/primitive-reference.rs b/tests/rustdoc/primitive/primitive-reference.rs new file mode 100644 index 00000000000..bd6b2a32f75 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-reference.rs @@ -0,0 +1,36 @@ +#![crate_name = "foo"] + +#![feature(rustc_attrs)] + +//@ has foo/index.html +//@ has - '//h2[@id="primitives"]' 'Primitive Types' +//@ has - '//a[@href="primitive.reference.html"]' 'reference' +//@ has - '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' +//@ has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' +//@ has foo/primitive.reference.html +//@ has - '//h1' 'Primitive Type reference' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' + +// There should be only one implementation listed. +//@ count - '//*[@class="impl"]' 1 +//@ has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ +// 'impl Foo<&A> for &B' +#[rustc_doc_primitive = "reference"] +/// this is a test! +mod reference {} + +pub struct Bar; + +// This implementation should **not** show up. +impl From<&T> for Bar { + fn from(s: &T) -> Self { + Bar + } +} + +pub trait Foo { + fn stuff(&self, other: &T) {} +} + +// This implementation should show up. +impl Foo<&A> for &B {} diff --git a/tests/rustdoc/primitive/primitive-slice-auto-trait.rs b/tests/rustdoc/primitive/primitive-slice-auto-trait.rs new file mode 100644 index 00000000000..647c1cca948 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-slice-auto-trait.rs @@ -0,0 +1,14 @@ +//@ compile-flags: --crate-type lib +//@ edition: 2018 + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +//@ has foo/primitive.slice.html '//h1' 'Primitive Type slice' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for [T]where T: Send' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for [T]where T: Sync' +#[rustc_doc_primitive = "slice"] +/// this is a test! +mod slice_prim {} diff --git a/tests/rustdoc/primitive/primitive-tuple-auto-trait.rs b/tests/rustdoc/primitive/primitive-tuple-auto-trait.rs new file mode 100644 index 00000000000..51300bd6b2f --- /dev/null +++ b/tests/rustdoc/primitive/primitive-tuple-auto-trait.rs @@ -0,0 +1,22 @@ +//@ compile-flags: --crate-type lib +//@ edition: 2018 + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +//@ has foo/primitive.tuple.html '//h1' 'Primitive Type tuple' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' +#[rustc_doc_primitive = "tuple"] +/// this is a test! +/// +// Hardcoded anchor to header written in library/core/src/primitive_docs.rs +//@ has - '//h2[@id="trait-implementations-1"]' 'Trait implementations' +/// # Trait implementations +/// +/// This header is hard-coded in the HTML format linking for `#[doc(fake_variadics)]`. +/// To make sure it gets linked correctly, we need to make sure the hardcoded anchor +/// in the code matches what rustdoc generates for the header. +mod tuple_prim {} diff --git a/tests/rustdoc/primitive/primitive-tuple-variadic.rs b/tests/rustdoc/primitive/primitive-tuple-variadic.rs new file mode 100644 index 00000000000..bab5eaae9a2 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-tuple-variadic.rs @@ -0,0 +1,55 @@ +//@ compile-flags: --crate-type lib +//@ edition: 2018 + +#![crate_name = "foo"] +#![feature(rustdoc_internals)] + +pub trait Foo {} + +//@ has foo/trait.Foo.html +//@ has - '//section[@id="impl-Foo-for-(T,)"]/h3' 'impl Foo for (T₁, T₂, …, Tₙ)' +#[doc(fake_variadic)] +impl Foo for (T,) {} + +pub trait Bar {} + +//@ has foo/trait.Bar.html +//@ has - '//section[@id="impl-Bar-for-(U,)"]/h3' 'impl Bar for (U₁, U₂, …, Uₙ)' +#[doc(fake_variadic)] +impl Bar for (U,) {} + +pub trait Baz { fn baz(&self) -> T { todo!() } } + +//@ has foo/trait.Baz.html +//@ has - '//section[@id="impl-Baz%3C(T,)%3E-for-%5BT;+1%5D"]/h3' 'impl Baz<(T₁, T₂, …, Tₙ)> for [T; N]' +#[doc(fake_variadic)] +impl Baz<(T,)> for [T; 1] {} + +//@ has foo/trait.Baz.html +//@ has - '//section[@id="impl-Baz%3C%5BT;+1%5D%3E-for-(T,)"]/h3' 'impl Baz<[T; N]> for (T₁, T₂, …, Tₙ)' +#[doc(fake_variadic)] +impl Baz<[T; 1]> for (T,) {} + +//@ has foo/trait.Baz.html +//@ has - '//section[@id="impl-Baz%3CT%3E-for-(T,)"]/h3' 'impl Baz for (T₁, T₂, …, Tₙ)' +#[doc(fake_variadic)] +impl Baz for (T,) {} + +pub trait Qux {} + +pub struct NewType(T); + +//@ has foo/trait.Qux.html +//@ has - '//section[@id="impl-Qux-for-NewType%3C(T,)%3E"]/h3' 'impl Qux for NewType<(T₁, T₂, …, Tₙ)>' +#[doc(fake_variadic)] +impl Qux for NewType<(T,)> {} + +//@ has foo/trait.Qux.html +//@ has - '//section[@id="impl-Qux-for-NewType%3CNewType%3C(T,)%3E%3E"]/h3' 'impl Qux for NewType>' +#[doc(fake_variadic)] +impl Qux for NewType> {} + +//@ has foo/trait.Qux.html +//@ has - '//section[@id="impl-Qux-for-NewType%3Cfn(T)+-%3E+Out%3E"]/h3' 'impl Qux for NewType Out>' +#[doc(fake_variadic)] +impl Qux for NewType Out> {} diff --git a/tests/rustdoc/primitive/primitive-unit-auto-trait.rs b/tests/rustdoc/primitive/primitive-unit-auto-trait.rs new file mode 100644 index 00000000000..7dada1f9832 --- /dev/null +++ b/tests/rustdoc/primitive/primitive-unit-auto-trait.rs @@ -0,0 +1,14 @@ +//@ compile-flags: --crate-type lib +//@ edition: 2018 + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +//@ has foo/primitive.unit.html '//h1' 'Primitive Type unit' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' +#[rustc_doc_primitive = "unit"] +/// this is a test! +mod unit_prim {} diff --git a/tests/rustdoc/primitive/search-index-primitive-inherent-method-23511.rs b/tests/rustdoc/primitive/search-index-primitive-inherent-method-23511.rs new file mode 100644 index 00000000000..6054d8f12f5 --- /dev/null +++ b/tests/rustdoc/primitive/search-index-primitive-inherent-method-23511.rs @@ -0,0 +1,16 @@ +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_std] + +// https://github.com/rust-lang/rust/issues/23511 +#![crate_name="issue_23511"] + +pub mod str { + #![rustc_doc_primitive = "str"] + + impl str { + //@ hasraw search-index.js foo + #[rustc_allow_incoherent_impl] + pub fn foo(&self) {} + } +} diff --git a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs deleted file mode 100644 index 6054d8f12f5..00000000000 --- a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(rustc_attrs)] -#![feature(rustdoc_internals)] -#![no_std] - -// https://github.com/rust-lang/rust/issues/23511 -#![crate_name="issue_23511"] - -pub mod str { - #![rustc_doc_primitive = "str"] - - impl str { - //@ hasraw search-index.js foo - #[rustc_allow_incoherent_impl] - pub fn foo(&self) {} - } -} -- cgit 1.4.1-3-g733a5 From e14e19a67dcdd7437b29bd37b4aa1fde3e5fecee Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:30:40 +0200 Subject: Created `tests/rustdoc/extern` subfolder to limit number of files at the top level --- .../extern-default-method.no_href_on_anchor.html | 1 - tests/rustdoc/auxiliary/extern-links.rs | 1 - tests/rustdoc/auxiliary/external-cross-doc.md | 4 --- tests/rustdoc/auxiliary/external-cross.rs | 3 --- tests/rustdoc/auxiliary/external-doc.md | 3 --- tests/rustdoc/auxiliary/html_root.rs | 2 -- tests/rustdoc/auxiliary/issue-30109-1.rs | 1 - tests/rustdoc/auxiliary/no_html_root.rs | 1 - tests/rustdoc/auxiliary/panic-item.rs | 17 ------------- tests/rustdoc/auxiliary/pub-extern-crate.rs | 2 -- .../auxiliary/rustdoc-extern-default-method.rs | 11 -------- tests/rustdoc/auxiliary/rustdoc-extern-method.rs | 7 ------ tests/rustdoc/extern-default-method.rs | 23 ----------------- tests/rustdoc/extern-fn-22038.rs | 22 ---------------- tests/rustdoc/extern-html-root-url-precedence.rs | 7 ------ tests/rustdoc/extern-html-root-url.rs | 18 -------------- tests/rustdoc/extern-links.rs | 21 ---------------- tests/rustdoc/extern-method.rs | 19 -------------- tests/rustdoc/extern/auxiliary/empty.rs | 1 + tests/rustdoc/extern/auxiliary/extern-links.rs | 1 + .../rustdoc/extern/auxiliary/external-cross-doc.md | 4 +++ tests/rustdoc/extern/auxiliary/external-cross.rs | 3 +++ tests/rustdoc/extern/auxiliary/external-doc.md | 3 +++ tests/rustdoc/extern/auxiliary/html_root.rs | 2 ++ tests/rustdoc/extern/auxiliary/issue-30109-1.rs | 1 + tests/rustdoc/extern/auxiliary/no_html_root.rs | 1 + tests/rustdoc/extern/auxiliary/panic-item.rs | 17 +++++++++++++ tests/rustdoc/extern/auxiliary/pub-extern-crate.rs | 2 ++ .../auxiliary/rustdoc-extern-default-method.rs | 11 ++++++++ .../extern/auxiliary/rustdoc-extern-method.rs | 7 ++++++ tests/rustdoc/extern/auxiliary/variant-struct.rs | 5 ++++ .../extern-default-method.no_href_on_anchor.html | 1 + tests/rustdoc/extern/extern-default-method.rs | 23 +++++++++++++++++ tests/rustdoc/extern/extern-fn-22038.rs | 22 ++++++++++++++++ .../extern/extern-html-root-url-precedence.rs | 7 ++++++ tests/rustdoc/extern/extern-html-root-url.rs | 18 ++++++++++++++ tests/rustdoc/extern/extern-links.rs | 21 ++++++++++++++++ tests/rustdoc/extern/extern-method.rs | 19 ++++++++++++++ tests/rustdoc/extern/external-cross.rs | 10 ++++++++ tests/rustdoc/extern/external-doc.rs | 14 +++++++++++ tests/rustdoc/extern/hidden-extern-34025.rs | 13 ++++++++++ tests/rustdoc/extern/link-extern-crate-33178.rs | 17 +++++++++++++ .../rustdoc/extern/link-extern-crate-item-30109.rs | 17 +++++++++++++ .../extern/link-extern-crate-title-33178.rs | 13 ++++++++++ tests/rustdoc/extern/pub-extern-crate.rs | 9 +++++++ tests/rustdoc/extern/unsafe-extern-blocks.rs | 29 ++++++++++++++++++++++ tests/rustdoc/extern/unused-extern-crate.rs | 2 ++ tests/rustdoc/external-cross.rs | 10 -------- tests/rustdoc/external-doc.rs | 14 ----------- tests/rustdoc/hidden-extern-34025.rs | 13 ---------- tests/rustdoc/link-extern-crate-33178.rs | 17 ------------- tests/rustdoc/link-extern-crate-item-30109.rs | 17 ------------- tests/rustdoc/link-extern-crate-title-33178.rs | 13 ---------- tests/rustdoc/pub-extern-crate.rs | 9 ------- tests/rustdoc/unsafe-extern-blocks.rs | 29 ---------------------- tests/rustdoc/unused-extern-crate.rs | 2 -- 56 files changed, 293 insertions(+), 287 deletions(-) delete mode 100644 tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html delete mode 100644 tests/rustdoc/auxiliary/extern-links.rs delete mode 100644 tests/rustdoc/auxiliary/external-cross-doc.md delete mode 100644 tests/rustdoc/auxiliary/external-cross.rs delete mode 100644 tests/rustdoc/auxiliary/external-doc.md delete mode 100644 tests/rustdoc/auxiliary/html_root.rs delete mode 100644 tests/rustdoc/auxiliary/issue-30109-1.rs delete mode 100644 tests/rustdoc/auxiliary/no_html_root.rs delete mode 100644 tests/rustdoc/auxiliary/panic-item.rs delete mode 100644 tests/rustdoc/auxiliary/pub-extern-crate.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-extern-method.rs delete mode 100644 tests/rustdoc/extern-default-method.rs delete mode 100644 tests/rustdoc/extern-fn-22038.rs delete mode 100644 tests/rustdoc/extern-html-root-url-precedence.rs delete mode 100644 tests/rustdoc/extern-html-root-url.rs delete mode 100644 tests/rustdoc/extern-links.rs delete mode 100644 tests/rustdoc/extern-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/empty.rs create mode 100644 tests/rustdoc/extern/auxiliary/extern-links.rs create mode 100644 tests/rustdoc/extern/auxiliary/external-cross-doc.md create mode 100644 tests/rustdoc/extern/auxiliary/external-cross.rs create mode 100644 tests/rustdoc/extern/auxiliary/external-doc.md create mode 100644 tests/rustdoc/extern/auxiliary/html_root.rs create mode 100644 tests/rustdoc/extern/auxiliary/issue-30109-1.rs create mode 100644 tests/rustdoc/extern/auxiliary/no_html_root.rs create mode 100644 tests/rustdoc/extern/auxiliary/panic-item.rs create mode 100644 tests/rustdoc/extern/auxiliary/pub-extern-crate.rs create mode 100644 tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/variant-struct.rs create mode 100644 tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html create mode 100644 tests/rustdoc/extern/extern-default-method.rs create mode 100644 tests/rustdoc/extern/extern-fn-22038.rs create mode 100644 tests/rustdoc/extern/extern-html-root-url-precedence.rs create mode 100644 tests/rustdoc/extern/extern-html-root-url.rs create mode 100644 tests/rustdoc/extern/extern-links.rs create mode 100644 tests/rustdoc/extern/extern-method.rs create mode 100644 tests/rustdoc/extern/external-cross.rs create mode 100644 tests/rustdoc/extern/external-doc.rs create mode 100644 tests/rustdoc/extern/hidden-extern-34025.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-33178.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-item-30109.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-title-33178.rs create mode 100644 tests/rustdoc/extern/pub-extern-crate.rs create mode 100644 tests/rustdoc/extern/unsafe-extern-blocks.rs create mode 100644 tests/rustdoc/extern/unused-extern-crate.rs delete mode 100644 tests/rustdoc/external-cross.rs delete mode 100644 tests/rustdoc/external-doc.rs delete mode 100644 tests/rustdoc/hidden-extern-34025.rs delete mode 100644 tests/rustdoc/link-extern-crate-33178.rs delete mode 100644 tests/rustdoc/link-extern-crate-item-30109.rs delete mode 100644 tests/rustdoc/link-extern-crate-title-33178.rs delete mode 100644 tests/rustdoc/pub-extern-crate.rs delete mode 100644 tests/rustdoc/unsafe-extern-blocks.rs delete mode 100644 tests/rustdoc/unused-extern-crate.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html deleted file mode 100644 index ef14836ccb8..00000000000 --- a/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html +++ /dev/null @@ -1 +0,0 @@ -provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/auxiliary/extern-links.rs b/tests/rustdoc/auxiliary/extern-links.rs deleted file mode 100644 index 4a835673a59..00000000000 --- a/tests/rustdoc/auxiliary/extern-links.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Foo; diff --git a/tests/rustdoc/auxiliary/external-cross-doc.md b/tests/rustdoc/auxiliary/external-cross-doc.md deleted file mode 100644 index d3c85326559..00000000000 --- a/tests/rustdoc/auxiliary/external-cross-doc.md +++ /dev/null @@ -1,4 +0,0 @@ -# Cross-crate imported docs - -This file is to make sure `#[doc = include_str!("file.md")]` works when you re-export an item with included -docs. diff --git a/tests/rustdoc/auxiliary/external-cross.rs b/tests/rustdoc/auxiliary/external-cross.rs deleted file mode 100644 index 5de63cdabc6..00000000000 --- a/tests/rustdoc/auxiliary/external-cross.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[deny(missing_docs)] -#[doc = include_str!("external-cross-doc.md")] -pub struct NeedMoreDocs; diff --git a/tests/rustdoc/auxiliary/external-doc.md b/tests/rustdoc/auxiliary/external-doc.md deleted file mode 100644 index babde0a05ad..00000000000 --- a/tests/rustdoc/auxiliary/external-doc.md +++ /dev/null @@ -1,3 +0,0 @@ -# External Docs - -This file is here to test the `#[doc = include_str!("file")]` attribute. diff --git a/tests/rustdoc/auxiliary/html_root.rs b/tests/rustdoc/auxiliary/html_root.rs deleted file mode 100644 index 4eb0b700f8f..00000000000 --- a/tests/rustdoc/auxiliary/html_root.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![doc(html_root_url="https://example.com/html_root")] -pub fn foo() {} diff --git a/tests/rustdoc/auxiliary/issue-30109-1.rs b/tests/rustdoc/auxiliary/issue-30109-1.rs deleted file mode 100644 index ca05a6a9076..00000000000 --- a/tests/rustdoc/auxiliary/issue-30109-1.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Bar; diff --git a/tests/rustdoc/auxiliary/no_html_root.rs b/tests/rustdoc/auxiliary/no_html_root.rs deleted file mode 100644 index c5c0bc606cd..00000000000 --- a/tests/rustdoc/auxiliary/no_html_root.rs +++ /dev/null @@ -1 +0,0 @@ -pub fn bar() {} diff --git a/tests/rustdoc/auxiliary/panic-item.rs b/tests/rustdoc/auxiliary/panic-item.rs deleted file mode 100644 index ccf784f7284..00000000000 --- a/tests/rustdoc/auxiliary/panic-item.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ no-prefer-dynamic -#![crate_type = "lib"] -#![no_std] -#![feature(lang_items)] - -use core::panic::PanicInfo; -use core::sync::atomic::{self, Ordering}; - -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop { - atomic::compiler_fence(Ordering::SeqCst); - } -} - -#[lang = "eh_personality"] -fn foo() {} diff --git a/tests/rustdoc/auxiliary/pub-extern-crate.rs b/tests/rustdoc/auxiliary/pub-extern-crate.rs deleted file mode 100644 index 8c89c8d6c76..00000000000 --- a/tests/rustdoc/auxiliary/pub-extern-crate.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![crate_name = "inner"] -pub struct SomeStruct; diff --git a/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs b/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs deleted file mode 100644 index 12934238a8e..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![crate_type="lib"] - -pub trait Trait { - fn provided(&self) {} -} - -pub struct Struct; - -impl Trait for Struct { - fn provided(&self) {} -} diff --git a/tests/rustdoc/auxiliary/rustdoc-extern-method.rs b/tests/rustdoc/auxiliary/rustdoc-extern-method.rs deleted file mode 100644 index e493048d9da..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-extern-method.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_type="lib"] -#![feature(unboxed_closures)] - -pub trait Foo { - extern "rust-call" fn foo(&self, _: ()) -> i32; - extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 } -} diff --git a/tests/rustdoc/extern-default-method.rs b/tests/rustdoc/extern-default-method.rs deleted file mode 100644 index 1af9fab152e..00000000000 --- a/tests/rustdoc/extern-default-method.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ aux-build:rustdoc-extern-default-method.rs -//@ ignore-cross-compile -// ignore-tidy-linelength - -extern crate rustdoc_extern_default_method as ext; - -// For this test, the dependency is compiled but not documented. -// -// Still, the struct from the external crate and its impl should be documented since -// the struct is re-exported from this crate. -// However, the method in the trait impl should *not* have a link (an `href` attribute) to -// its corresponding item in the trait declaration since it would otherwise be broken. -// -// In older versions of rustdoc, the impl item (`a[@class="fn"]`) used to link to -// `#method.provided` – i.e. "to itself". Put in quotes since that was actually incorrect in -// general: If the type `Struct` also had an inherent method called `provided`, the impl item -// would link to that one even though those two methods are distinct items! - -//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 -//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 -//@ snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' -//@ has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided -pub use ext::Struct; diff --git a/tests/rustdoc/extern-fn-22038.rs b/tests/rustdoc/extern-fn-22038.rs deleted file mode 100644 index 206c6e181d1..00000000000 --- a/tests/rustdoc/extern-fn-22038.rs +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/rust-lang/rust/issues/22038 -#![crate_name="issue_22038"] - -extern "C" { - //@ has issue_22038/fn.foo1.html \ - // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' - pub fn foo1(); -} - -extern "system" { - //@ has issue_22038/fn.foo2.html \ - // '//pre[@class="rust item-decl"]' 'pub unsafe extern "system" fn foo2()' - pub fn foo2(); -} - -//@ has issue_22038/fn.bar.html \ -// '//pre[@class="rust item-decl"]' 'pub extern "C" fn bar()' -pub extern "C" fn bar() {} - -//@ has issue_22038/fn.baz.html \ -// '//pre[@class="rust item-decl"]' 'pub extern "system" fn baz()' -pub extern "system" fn baz() {} diff --git a/tests/rustdoc/extern-html-root-url-precedence.rs b/tests/rustdoc/extern-html-root-url-precedence.rs deleted file mode 100644 index 93775087997..00000000000 --- a/tests/rustdoc/extern-html-root-url-precedence.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 --extern-html-root-takes-precedence - -//@ has extern_html_root_url_precedence/index.html -// --extern-html-root should take precedence if `--takes-precedence` is passed -//@ has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' -#[doc(no_inline)] -pub use std::iter; diff --git a/tests/rustdoc/extern-html-root-url.rs b/tests/rustdoc/extern-html-root-url.rs deleted file mode 100644 index a503e829de4..00000000000 --- a/tests/rustdoc/extern-html-root-url.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ compile-flags:-Z unstable-options --extern-html-root-url html_root=https://example.com/override --extern-html-root-url no_html_root=https://example.com/override -//@ aux-build:html_root.rs -//@ aux-build:no_html_root.rs -// NOTE: intentionally does not build any auxiliary docs - -extern crate html_root; -extern crate no_html_root; - -//@ has extern_html_root_url/index.html -// `html_root_url` should override `--extern-html-root-url` -//@ has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' -#[doc(no_inline)] -pub use html_root::foo; - -#[doc(no_inline)] -// `--extern-html-root-url` should apply if no `html_root_url` is given -//@ has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' -pub use no_html_root::bar; diff --git a/tests/rustdoc/extern-links.rs b/tests/rustdoc/extern-links.rs deleted file mode 100644 index d1fee224755..00000000000 --- a/tests/rustdoc/extern-links.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ aux-build:extern-links.rs -//@ ignore-cross-compile - -#![crate_name = "foo"] - -pub extern crate extern_links; - -//@ !has foo/index.html '//a' 'extern_links' -#[doc(no_inline)] -pub use extern_links as extern_links2; - -//@ !has foo/index.html '//a' 'Foo' -#[doc(no_inline)] -pub use extern_links::Foo; - -#[doc(hidden)] -pub mod hidden { - //@ !has foo/hidden/extern_links/index.html - //@ !has foo/hidden/extern_links/struct.Foo.html - pub use extern_links; -} diff --git a/tests/rustdoc/extern-method.rs b/tests/rustdoc/extern-method.rs deleted file mode 100644 index c3e042f2da8..00000000000 --- a/tests/rustdoc/extern-method.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ aux-build:rustdoc-extern-method.rs -//@ ignore-cross-compile - -#![feature(unboxed_closures)] - -extern crate rustdoc_extern_method as foo; - -//@ has extern_method/trait.Foo.html //pre "pub trait Foo" -//@ has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' -//@ has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' -pub use foo::Foo; - -//@ has extern_method/trait.Bar.html //pre "pub trait Bar" -pub trait Bar { - //@ has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' - extern "rust-call" fn bar(&self, _: ()); - //@ has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' - extern "rust-call" fn bar_(&self, _: ()) { } -} diff --git a/tests/rustdoc/extern/auxiliary/empty.rs b/tests/rustdoc/extern/auxiliary/empty.rs new file mode 100644 index 00000000000..d11c69f812a --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/empty.rs @@ -0,0 +1 @@ +// intentionally empty diff --git a/tests/rustdoc/extern/auxiliary/extern-links.rs b/tests/rustdoc/extern/auxiliary/extern-links.rs new file mode 100644 index 00000000000..4a835673a59 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/extern-links.rs @@ -0,0 +1 @@ +pub struct Foo; diff --git a/tests/rustdoc/extern/auxiliary/external-cross-doc.md b/tests/rustdoc/extern/auxiliary/external-cross-doc.md new file mode 100644 index 00000000000..d3c85326559 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-cross-doc.md @@ -0,0 +1,4 @@ +# Cross-crate imported docs + +This file is to make sure `#[doc = include_str!("file.md")]` works when you re-export an item with included +docs. diff --git a/tests/rustdoc/extern/auxiliary/external-cross.rs b/tests/rustdoc/extern/auxiliary/external-cross.rs new file mode 100644 index 00000000000..5de63cdabc6 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-cross.rs @@ -0,0 +1,3 @@ +#[deny(missing_docs)] +#[doc = include_str!("external-cross-doc.md")] +pub struct NeedMoreDocs; diff --git a/tests/rustdoc/extern/auxiliary/external-doc.md b/tests/rustdoc/extern/auxiliary/external-doc.md new file mode 100644 index 00000000000..babde0a05ad --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-doc.md @@ -0,0 +1,3 @@ +# External Docs + +This file is here to test the `#[doc = include_str!("file")]` attribute. diff --git a/tests/rustdoc/extern/auxiliary/html_root.rs b/tests/rustdoc/extern/auxiliary/html_root.rs new file mode 100644 index 00000000000..4eb0b700f8f --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/html_root.rs @@ -0,0 +1,2 @@ +#![doc(html_root_url="https://example.com/html_root")] +pub fn foo() {} diff --git a/tests/rustdoc/extern/auxiliary/issue-30109-1.rs b/tests/rustdoc/extern/auxiliary/issue-30109-1.rs new file mode 100644 index 00000000000..ca05a6a9076 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/issue-30109-1.rs @@ -0,0 +1 @@ +pub struct Bar; diff --git a/tests/rustdoc/extern/auxiliary/no_html_root.rs b/tests/rustdoc/extern/auxiliary/no_html_root.rs new file mode 100644 index 00000000000..c5c0bc606cd --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/no_html_root.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/tests/rustdoc/extern/auxiliary/panic-item.rs b/tests/rustdoc/extern/auxiliary/panic-item.rs new file mode 100644 index 00000000000..ccf784f7284 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/panic-item.rs @@ -0,0 +1,17 @@ +//@ no-prefer-dynamic +#![crate_type = "lib"] +#![no_std] +#![feature(lang_items)] + +use core::panic::PanicInfo; +use core::sync::atomic::{self, Ordering}; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop { + atomic::compiler_fence(Ordering::SeqCst); + } +} + +#[lang = "eh_personality"] +fn foo() {} diff --git a/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs b/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs new file mode 100644 index 00000000000..8c89c8d6c76 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs @@ -0,0 +1,2 @@ +#![crate_name = "inner"] +pub struct SomeStruct; diff --git a/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs b/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs new file mode 100644 index 00000000000..12934238a8e --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs @@ -0,0 +1,11 @@ +#![crate_type="lib"] + +pub trait Trait { + fn provided(&self) {} +} + +pub struct Struct; + +impl Trait for Struct { + fn provided(&self) {} +} diff --git a/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs b/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs new file mode 100644 index 00000000000..e493048d9da --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs @@ -0,0 +1,7 @@ +#![crate_type="lib"] +#![feature(unboxed_closures)] + +pub trait Foo { + extern "rust-call" fn foo(&self, _: ()) -> i32; + extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 } +} diff --git a/tests/rustdoc/extern/auxiliary/variant-struct.rs b/tests/rustdoc/extern/auxiliary/variant-struct.rs new file mode 100644 index 00000000000..0f3d2e5f1b7 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/variant-struct.rs @@ -0,0 +1,5 @@ +pub enum Foo { + Bar { + qux: (), + } +} diff --git a/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html new file mode 100644 index 00000000000..ef14836ccb8 --- /dev/null +++ b/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html @@ -0,0 +1 @@ +provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/extern/extern-default-method.rs b/tests/rustdoc/extern/extern-default-method.rs new file mode 100644 index 00000000000..1af9fab152e --- /dev/null +++ b/tests/rustdoc/extern/extern-default-method.rs @@ -0,0 +1,23 @@ +//@ aux-build:rustdoc-extern-default-method.rs +//@ ignore-cross-compile +// ignore-tidy-linelength + +extern crate rustdoc_extern_default_method as ext; + +// For this test, the dependency is compiled but not documented. +// +// Still, the struct from the external crate and its impl should be documented since +// the struct is re-exported from this crate. +// However, the method in the trait impl should *not* have a link (an `href` attribute) to +// its corresponding item in the trait declaration since it would otherwise be broken. +// +// In older versions of rustdoc, the impl item (`a[@class="fn"]`) used to link to +// `#method.provided` – i.e. "to itself". Put in quotes since that was actually incorrect in +// general: If the type `Struct` also had an inherent method called `provided`, the impl item +// would link to that one even though those two methods are distinct items! + +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 +//@ snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' +//@ has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided +pub use ext::Struct; diff --git a/tests/rustdoc/extern/extern-fn-22038.rs b/tests/rustdoc/extern/extern-fn-22038.rs new file mode 100644 index 00000000000..206c6e181d1 --- /dev/null +++ b/tests/rustdoc/extern/extern-fn-22038.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/22038 +#![crate_name="issue_22038"] + +extern "C" { + //@ has issue_22038/fn.foo1.html \ + // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' + pub fn foo1(); +} + +extern "system" { + //@ has issue_22038/fn.foo2.html \ + // '//pre[@class="rust item-decl"]' 'pub unsafe extern "system" fn foo2()' + pub fn foo2(); +} + +//@ has issue_22038/fn.bar.html \ +// '//pre[@class="rust item-decl"]' 'pub extern "C" fn bar()' +pub extern "C" fn bar() {} + +//@ has issue_22038/fn.baz.html \ +// '//pre[@class="rust item-decl"]' 'pub extern "system" fn baz()' +pub extern "system" fn baz() {} diff --git a/tests/rustdoc/extern/extern-html-root-url-precedence.rs b/tests/rustdoc/extern/extern-html-root-url-precedence.rs new file mode 100644 index 00000000000..93775087997 --- /dev/null +++ b/tests/rustdoc/extern/extern-html-root-url-precedence.rs @@ -0,0 +1,7 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 --extern-html-root-takes-precedence + +//@ has extern_html_root_url_precedence/index.html +// --extern-html-root should take precedence if `--takes-precedence` is passed +//@ has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' +#[doc(no_inline)] +pub use std::iter; diff --git a/tests/rustdoc/extern/extern-html-root-url.rs b/tests/rustdoc/extern/extern-html-root-url.rs new file mode 100644 index 00000000000..a503e829de4 --- /dev/null +++ b/tests/rustdoc/extern/extern-html-root-url.rs @@ -0,0 +1,18 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url html_root=https://example.com/override --extern-html-root-url no_html_root=https://example.com/override +//@ aux-build:html_root.rs +//@ aux-build:no_html_root.rs +// NOTE: intentionally does not build any auxiliary docs + +extern crate html_root; +extern crate no_html_root; + +//@ has extern_html_root_url/index.html +// `html_root_url` should override `--extern-html-root-url` +//@ has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' +#[doc(no_inline)] +pub use html_root::foo; + +#[doc(no_inline)] +// `--extern-html-root-url` should apply if no `html_root_url` is given +//@ has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' +pub use no_html_root::bar; diff --git a/tests/rustdoc/extern/extern-links.rs b/tests/rustdoc/extern/extern-links.rs new file mode 100644 index 00000000000..d1fee224755 --- /dev/null +++ b/tests/rustdoc/extern/extern-links.rs @@ -0,0 +1,21 @@ +//@ aux-build:extern-links.rs +//@ ignore-cross-compile + +#![crate_name = "foo"] + +pub extern crate extern_links; + +//@ !has foo/index.html '//a' 'extern_links' +#[doc(no_inline)] +pub use extern_links as extern_links2; + +//@ !has foo/index.html '//a' 'Foo' +#[doc(no_inline)] +pub use extern_links::Foo; + +#[doc(hidden)] +pub mod hidden { + //@ !has foo/hidden/extern_links/index.html + //@ !has foo/hidden/extern_links/struct.Foo.html + pub use extern_links; +} diff --git a/tests/rustdoc/extern/extern-method.rs b/tests/rustdoc/extern/extern-method.rs new file mode 100644 index 00000000000..c3e042f2da8 --- /dev/null +++ b/tests/rustdoc/extern/extern-method.rs @@ -0,0 +1,19 @@ +//@ aux-build:rustdoc-extern-method.rs +//@ ignore-cross-compile + +#![feature(unboxed_closures)] + +extern crate rustdoc_extern_method as foo; + +//@ has extern_method/trait.Foo.html //pre "pub trait Foo" +//@ has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' +//@ has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' +pub use foo::Foo; + +//@ has extern_method/trait.Bar.html //pre "pub trait Bar" +pub trait Bar { + //@ has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' + extern "rust-call" fn bar(&self, _: ()); + //@ has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' + extern "rust-call" fn bar_(&self, _: ()) { } +} diff --git a/tests/rustdoc/extern/external-cross.rs b/tests/rustdoc/extern/external-cross.rs new file mode 100644 index 00000000000..13646ec38cf --- /dev/null +++ b/tests/rustdoc/extern/external-cross.rs @@ -0,0 +1,10 @@ +//@ aux-build:external-cross.rs +//@ ignore-cross-compile + +#![crate_name="host"] + +extern crate external_cross; + +//@ has host/struct.NeedMoreDocs.html +//@ has - '//h2' 'Cross-crate imported docs' +pub use external_cross::NeedMoreDocs; diff --git a/tests/rustdoc/extern/external-doc.rs b/tests/rustdoc/extern/external-doc.rs new file mode 100644 index 00000000000..c81aa17ed5a --- /dev/null +++ b/tests/rustdoc/extern/external-doc.rs @@ -0,0 +1,14 @@ +//@ has external_doc/struct.IncludeStrDocs.html +//@ has - '//h2' 'External Docs' +//@ has - '//h3' 'Inline Docs' +#[doc = include_str!("auxiliary/external-doc.md")] +/// ## Inline Docs +pub struct IncludeStrDocs; + +macro_rules! dir { () => { "auxiliary" } } + +//@ has external_doc/struct.EagerExpansion.html +//@ has - '//h2' 'External Docs' +#[doc = include_str!(concat!(dir!(), "/external-doc.md"))] +/// ## Inline Docs +pub struct EagerExpansion; diff --git a/tests/rustdoc/extern/hidden-extern-34025.rs b/tests/rustdoc/extern/hidden-extern-34025.rs new file mode 100644 index 00000000000..2a7b21a874d --- /dev/null +++ b/tests/rustdoc/extern/hidden-extern-34025.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/34025 +#![crate_name = "foo"] + +//@ !has 'foo/sys/index.html' +//@ !has 'foo/sys/sidebar-items.js' +#[doc(hidden)] +pub mod sys { + extern "C" { + //@ !has 'foo/sys/fn.foo.html' + #[doc(hidden)] + pub fn foo(); + } +} diff --git a/tests/rustdoc/extern/link-extern-crate-33178.rs b/tests/rustdoc/extern/link-extern-crate-33178.rs new file mode 100644 index 00000000000..94822798af3 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-33178.rs @@ -0,0 +1,17 @@ +//@ aux-build:empty.rs +//@ aux-build:variant-struct.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178"] + +//@ has issue_33178/index.html +//@ has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty +pub extern crate empty; + +//@ has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct +pub extern crate variant_struct as foo; + +//@ has - '//a[@title="mod issue_33178"][@href="index.html"]' self +pub extern crate self as bar; diff --git a/tests/rustdoc/extern/link-extern-crate-item-30109.rs b/tests/rustdoc/extern/link-extern-crate-item-30109.rs new file mode 100644 index 00000000000..544cfa14971 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-item-30109.rs @@ -0,0 +1,17 @@ +//@ build-aux-docs +//@ aux-build:issue-30109-1.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/30109 +#![crate_name="issue_30109"] + +pub mod quux { + extern crate issue_30109_1 as bar; + use self::bar::Bar; + + pub trait Foo {} + + //@ has issue_30109/quux/trait.Foo.html \ + // '//a/@href' '../issue_30109_1/struct.Bar.html' + impl Foo for Bar {} +} diff --git a/tests/rustdoc/extern/link-extern-crate-title-33178.rs b/tests/rustdoc/extern/link-extern-crate-title-33178.rs new file mode 100644 index 00000000000..39c4fec1cd9 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-title-33178.rs @@ -0,0 +1,13 @@ +//@ aux-build:empty.rs +//@ aux-build:variant-struct.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178_1"] + +//@ has issue_33178_1/index.html +//@ !has - //a/@title empty +pub extern crate empty; + +//@ !has - //a/@title variant_struct +pub extern crate variant_struct as foo; diff --git a/tests/rustdoc/extern/pub-extern-crate.rs b/tests/rustdoc/extern/pub-extern-crate.rs new file mode 100644 index 00000000000..05f70301e33 --- /dev/null +++ b/tests/rustdoc/extern/pub-extern-crate.rs @@ -0,0 +1,9 @@ +//@ aux-build:pub-extern-crate.rs + +//@ has pub_extern_crate/index.html +//@ !has - '//code' 'pub extern crate inner' +//@ has - '//a/@href' 'inner/index.html' +//@ has pub_extern_crate/inner/index.html +//@ has pub_extern_crate/inner/struct.SomeStruct.html +#[doc(inline)] +pub extern crate inner; diff --git a/tests/rustdoc/extern/unsafe-extern-blocks.rs b/tests/rustdoc/extern/unsafe-extern-blocks.rs new file mode 100644 index 00000000000..9a4e292dc83 --- /dev/null +++ b/tests/rustdoc/extern/unsafe-extern-blocks.rs @@ -0,0 +1,29 @@ +// Test to ensure the feature is working as expected. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' + +// First we check that both the static and the function have a "sup" element +// to tell they're unsafe. + +//@ count - '//dl[@class="item-table"]//sup[@title="unsafe static"]' 1 +//@ has - '//dl[@class="item-table"]//sup[@title="unsafe static"]' '⚠' +//@ count - '//dl[@class="item-table"]//sup[@title="unsafe function"]' 1 +//@ has - '//dl[@class="item-table"]//sup[@title="unsafe function"]' '⚠' + +unsafe extern "C" { + //@ has 'foo/static.FOO.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32' + pub safe static FOO: i32; + //@ has 'foo/static.BAR.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe static BAR: i32' + pub static BAR: i32; + + //@ has 'foo/fn.foo.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub extern "C" fn foo()' + pub safe fn foo(); + //@ has 'foo/fn.bar.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn bar()' + pub fn bar(); +} diff --git a/tests/rustdoc/extern/unused-extern-crate.rs b/tests/rustdoc/extern/unused-extern-crate.rs new file mode 100644 index 00000000000..cdc00fd313a --- /dev/null +++ b/tests/rustdoc/extern/unused-extern-crate.rs @@ -0,0 +1,2 @@ +//@ aux-crate:panic_item=panic-item.rs +//@ has unused_extern_crate/index.html diff --git a/tests/rustdoc/external-cross.rs b/tests/rustdoc/external-cross.rs deleted file mode 100644 index 13646ec38cf..00000000000 --- a/tests/rustdoc/external-cross.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ aux-build:external-cross.rs -//@ ignore-cross-compile - -#![crate_name="host"] - -extern crate external_cross; - -//@ has host/struct.NeedMoreDocs.html -//@ has - '//h2' 'Cross-crate imported docs' -pub use external_cross::NeedMoreDocs; diff --git a/tests/rustdoc/external-doc.rs b/tests/rustdoc/external-doc.rs deleted file mode 100644 index c81aa17ed5a..00000000000 --- a/tests/rustdoc/external-doc.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ has external_doc/struct.IncludeStrDocs.html -//@ has - '//h2' 'External Docs' -//@ has - '//h3' 'Inline Docs' -#[doc = include_str!("auxiliary/external-doc.md")] -/// ## Inline Docs -pub struct IncludeStrDocs; - -macro_rules! dir { () => { "auxiliary" } } - -//@ has external_doc/struct.EagerExpansion.html -//@ has - '//h2' 'External Docs' -#[doc = include_str!(concat!(dir!(), "/external-doc.md"))] -/// ## Inline Docs -pub struct EagerExpansion; diff --git a/tests/rustdoc/hidden-extern-34025.rs b/tests/rustdoc/hidden-extern-34025.rs deleted file mode 100644 index 2a7b21a874d..00000000000 --- a/tests/rustdoc/hidden-extern-34025.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/34025 -#![crate_name = "foo"] - -//@ !has 'foo/sys/index.html' -//@ !has 'foo/sys/sidebar-items.js' -#[doc(hidden)] -pub mod sys { - extern "C" { - //@ !has 'foo/sys/fn.foo.html' - #[doc(hidden)] - pub fn foo(); - } -} diff --git a/tests/rustdoc/link-extern-crate-33178.rs b/tests/rustdoc/link-extern-crate-33178.rs deleted file mode 100644 index 94822798af3..00000000000 --- a/tests/rustdoc/link-extern-crate-33178.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ aux-build:empty.rs -//@ aux-build:variant-struct.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/33178 -#![crate_name="issue_33178"] - -//@ has issue_33178/index.html -//@ has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty -pub extern crate empty; - -//@ has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct -pub extern crate variant_struct as foo; - -//@ has - '//a[@title="mod issue_33178"][@href="index.html"]' self -pub extern crate self as bar; diff --git a/tests/rustdoc/link-extern-crate-item-30109.rs b/tests/rustdoc/link-extern-crate-item-30109.rs deleted file mode 100644 index 544cfa14971..00000000000 --- a/tests/rustdoc/link-extern-crate-item-30109.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ build-aux-docs -//@ aux-build:issue-30109-1.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/30109 -#![crate_name="issue_30109"] - -pub mod quux { - extern crate issue_30109_1 as bar; - use self::bar::Bar; - - pub trait Foo {} - - //@ has issue_30109/quux/trait.Foo.html \ - // '//a/@href' '../issue_30109_1/struct.Bar.html' - impl Foo for Bar {} -} diff --git a/tests/rustdoc/link-extern-crate-title-33178.rs b/tests/rustdoc/link-extern-crate-title-33178.rs deleted file mode 100644 index 39c4fec1cd9..00000000000 --- a/tests/rustdoc/link-extern-crate-title-33178.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:empty.rs -//@ aux-build:variant-struct.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/33178 -#![crate_name="issue_33178_1"] - -//@ has issue_33178_1/index.html -//@ !has - //a/@title empty -pub extern crate empty; - -//@ !has - //a/@title variant_struct -pub extern crate variant_struct as foo; diff --git a/tests/rustdoc/pub-extern-crate.rs b/tests/rustdoc/pub-extern-crate.rs deleted file mode 100644 index 05f70301e33..00000000000 --- a/tests/rustdoc/pub-extern-crate.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:pub-extern-crate.rs - -//@ has pub_extern_crate/index.html -//@ !has - '//code' 'pub extern crate inner' -//@ has - '//a/@href' 'inner/index.html' -//@ has pub_extern_crate/inner/index.html -//@ has pub_extern_crate/inner/struct.SomeStruct.html -#[doc(inline)] -pub extern crate inner; diff --git a/tests/rustdoc/unsafe-extern-blocks.rs b/tests/rustdoc/unsafe-extern-blocks.rs deleted file mode 100644 index 9a4e292dc83..00000000000 --- a/tests/rustdoc/unsafe-extern-blocks.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Test to ensure the feature is working as expected. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' - -// First we check that both the static and the function have a "sup" element -// to tell they're unsafe. - -//@ count - '//dl[@class="item-table"]//sup[@title="unsafe static"]' 1 -//@ has - '//dl[@class="item-table"]//sup[@title="unsafe static"]' '⚠' -//@ count - '//dl[@class="item-table"]//sup[@title="unsafe function"]' 1 -//@ has - '//dl[@class="item-table"]//sup[@title="unsafe function"]' '⚠' - -unsafe extern "C" { - //@ has 'foo/static.FOO.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32' - pub safe static FOO: i32; - //@ has 'foo/static.BAR.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe static BAR: i32' - pub static BAR: i32; - - //@ has 'foo/fn.foo.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub extern "C" fn foo()' - pub safe fn foo(); - //@ has 'foo/fn.bar.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn bar()' - pub fn bar(); -} diff --git a/tests/rustdoc/unused-extern-crate.rs b/tests/rustdoc/unused-extern-crate.rs deleted file mode 100644 index cdc00fd313a..00000000000 --- a/tests/rustdoc/unused-extern-crate.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ aux-crate:panic_item=panic-item.rs -//@ has unused_extern_crate/index.html -- cgit 1.4.1-3-g733a5 From 27e39c3ac6173e4a9e9e1439bfc48f0ca1505542 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:35:41 +0200 Subject: Created `tests/rustdoc/async` subfolder to limit number of files at the top level --- tests/rustdoc/async-fn-opaque-item.rs | 15 ---- tests/rustdoc/async-fn.rs | 99 ------------------------ tests/rustdoc/async-move-doctest.rs | 12 --- tests/rustdoc/async-trait-sig.rs | 13 ---- tests/rustdoc/async-trait.rs | 15 ---- tests/rustdoc/async/async-fn-opaque-item.rs | 15 ++++ tests/rustdoc/async/async-fn.rs | 99 ++++++++++++++++++++++++ tests/rustdoc/async/async-move-doctest.rs | 12 +++ tests/rustdoc/async/async-trait-sig.rs | 13 ++++ tests/rustdoc/async/async-trait.rs | 15 ++++ tests/rustdoc/async/auxiliary/async-trait-dep.rs | 8 ++ tests/rustdoc/auxiliary/async-trait-dep.rs | 8 -- 12 files changed, 162 insertions(+), 162 deletions(-) delete mode 100644 tests/rustdoc/async-fn-opaque-item.rs delete mode 100644 tests/rustdoc/async-fn.rs delete mode 100644 tests/rustdoc/async-move-doctest.rs delete mode 100644 tests/rustdoc/async-trait-sig.rs delete mode 100644 tests/rustdoc/async-trait.rs create mode 100644 tests/rustdoc/async/async-fn-opaque-item.rs create mode 100644 tests/rustdoc/async/async-fn.rs create mode 100644 tests/rustdoc/async/async-move-doctest.rs create mode 100644 tests/rustdoc/async/async-trait-sig.rs create mode 100644 tests/rustdoc/async/async-trait.rs create mode 100644 tests/rustdoc/async/auxiliary/async-trait-dep.rs delete mode 100644 tests/rustdoc/auxiliary/async-trait-dep.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/async-fn-opaque-item.rs b/tests/rustdoc/async-fn-opaque-item.rs deleted file mode 100644 index d45183f96dd..00000000000 --- a/tests/rustdoc/async-fn-opaque-item.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ compile-flags: --document-private-items --crate-type=lib -//@ edition: 2021 - -// Issue 109931 -- test against accidentally documenting the `impl Future` -// that comes from an async fn desugaring. - -// Check that we don't document an unnamed opaque type -//@ !has async_fn_opaque_item/opaque..html - -// Checking there is only a "Functions" header and no "Opaque types". -//@ has async_fn_opaque_item/index.html -//@ count - '//*[@class="section-header"]' 1 -//@ has - '//*[@class="section-header"]' 'Functions' - -pub async fn test() {} diff --git a/tests/rustdoc/async-fn.rs b/tests/rustdoc/async-fn.rs deleted file mode 100644 index 3d49766c55e..00000000000 --- a/tests/rustdoc/async-fn.rs +++ /dev/null @@ -1,99 +0,0 @@ -//@ edition:2018 -//@ has async_fn/fn.foo.html '//pre[@class="rust item-decl"]' 'pub async fn foo() -> Option' -pub async fn foo() -> Option { - None -} - -//@ has async_fn/fn.bar.html '//pre[@class="rust item-decl"]' 'pub async fn bar(a: i32, b: i32) -> i32' -pub async fn bar(a: i32, b: i32) -> i32 { - 0 -} - -//@ has async_fn/fn.baz.html '//pre[@class="rust item-decl"]' 'pub async fn baz(a: T) -> T' -pub async fn baz(a: T) -> T { - a -} - -//@ has async_fn/fn.qux.html '//pre[@class="rust item-decl"]' 'pub async unsafe fn qux() -> char' -pub async unsafe fn qux() -> char { - '⚠' -} - -//@ has async_fn/fn.mut_args.html '//pre[@class="rust item-decl"]' 'pub async fn mut_args(a: usize)' -pub async fn mut_args(mut a: usize) {} - -//@ has async_fn/fn.mut_ref.html '//pre[@class="rust item-decl"]' 'pub async fn mut_ref(x: i32)' -pub async fn mut_ref(ref mut x: i32) {} - -trait Bar {} - -impl Bar for () {} - -//@ has async_fn/fn.quux.html '//pre[@class="rust item-decl"]' 'pub async fn quux() -> impl Bar' -pub async fn quux() -> impl Bar { - () -} - -//@ has async_fn/struct.Foo.html -//@ matches - '//h4[@class="code-header"]' 'pub async fn f\(\)$' -//@ matches - '//h4[@class="code-header"]' 'pub async unsafe fn g\(\)$' -//@ matches - '//h4[@class="code-header"]' 'pub async fn mut_self\(self, first: usize\)$' -pub struct Foo; - -impl Foo { - pub async fn f() {} - pub async unsafe fn g() {} - pub async fn mut_self(mut self, mut first: usize) {} -} - -pub trait Pattern<'a> {} - -impl Pattern<'_> for () {} - -pub trait Trait {} -//@ has async_fn/fn.const_generics.html -//@ has - '//pre[@class="rust item-decl"]' 'pub async fn const_generics(_: impl Trait)' -pub async fn const_generics(_: impl Trait) {} - -// test that elided lifetimes are properly elided and not displayed as `'_` -// regression test for #63037 -//@ has async_fn/fn.elided.html -//@ has - '//pre[@class="rust item-decl"]' 'pub async fn elided(foo: &str) -> &str' -pub async fn elided(foo: &str) -> &str { "" } -// This should really be shown as written, but for implementation reasons it's difficult. -// See `impl Clean for TyKind::Ref`. -//@ has async_fn/fn.user_elided.html -//@ has - '//pre[@class="rust item-decl"]' 'pub async fn user_elided(foo: &str) -> &str' -pub async fn user_elided(foo: &'_ str) -> &str { "" } -//@ has async_fn/fn.static_trait.html -//@ has - '//pre[@class="rust item-decl"]' 'pub async fn static_trait(foo: &str) -> Box' -pub async fn static_trait(foo: &str) -> Box { Box::new(()) } -//@ has async_fn/fn.lifetime_for_trait.html -//@ has - '//pre[@class="rust item-decl"]' "pub async fn lifetime_for_trait(foo: &str) -> Box" -pub async fn lifetime_for_trait(foo: &str) -> Box { Box::new(()) } -//@ has async_fn/fn.elided_in_input_trait.html -//@ has - '//pre[@class="rust item-decl"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" -pub async fn elided_in_input_trait(t: impl Pattern<'_>) {} - -struct AsyncFdReadyGuard<'a, T> { x: &'a T } - -impl Foo { - //@ has async_fn/struct.Foo.html - //@ has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator' - pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator { - [0].iter() - } - // taken from `tokio` as an example of a method that was particularly bad before - //@ has - '//*[@class="method"]' "pub async fn readable(&self) -> Result, ()>" - pub async fn readable(&self) -> Result, ()> { Err(()) } - //@ has - '//*[@class="method"]' "pub async fn mut_self(&mut self)" - pub async fn mut_self(&mut self) {} -} - -// test named lifetimes, just in case -//@ has async_fn/fn.named.html -//@ has - '//pre[@class="rust item-decl"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" -pub async fn named<'a, 'b>(foo: &'a str) -> &'b str { "" } -//@ has async_fn/fn.named_trait.html -//@ has - '//pre[@class="rust item-decl"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" -pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {} diff --git a/tests/rustdoc/async-move-doctest.rs b/tests/rustdoc/async-move-doctest.rs deleted file mode 100644 index e18ec353533..00000000000 --- a/tests/rustdoc/async-move-doctest.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ compile-flags:--test -//@ edition:2018 - -// Prior to setting the default edition for the doctest pre-parser, -// this doctest would fail due to a fatal parsing error. -// see https://github.com/rust-lang/rust/issues/59313 - -//! ``` -//! fn foo() { -//! drop(async move {}); -//! } -//! ``` diff --git a/tests/rustdoc/async-trait-sig.rs b/tests/rustdoc/async-trait-sig.rs deleted file mode 100644 index be790f6ed7f..00000000000 --- a/tests/rustdoc/async-trait-sig.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ edition:2021 - -#![allow(incomplete_features)] - -pub trait Foo { - //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn bar() -> i32" - async fn bar() -> i32; - - //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn baz() -> i32" - async fn baz() -> i32 { - 1 - } -} diff --git a/tests/rustdoc/async-trait.rs b/tests/rustdoc/async-trait.rs deleted file mode 100644 index a6ee340e2dd..00000000000 --- a/tests/rustdoc/async-trait.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:async-trait-dep.rs -//@ edition:2021 - -#![allow(incomplete_features)] - -extern crate async_trait_dep; - -pub struct Oink {} - -//@ has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()" -impl async_trait_dep::Meow for Oink { - async fn woof() { - todo!() - } -} diff --git a/tests/rustdoc/async/async-fn-opaque-item.rs b/tests/rustdoc/async/async-fn-opaque-item.rs new file mode 100644 index 00000000000..d45183f96dd --- /dev/null +++ b/tests/rustdoc/async/async-fn-opaque-item.rs @@ -0,0 +1,15 @@ +//@ compile-flags: --document-private-items --crate-type=lib +//@ edition: 2021 + +// Issue 109931 -- test against accidentally documenting the `impl Future` +// that comes from an async fn desugaring. + +// Check that we don't document an unnamed opaque type +//@ !has async_fn_opaque_item/opaque..html + +// Checking there is only a "Functions" header and no "Opaque types". +//@ has async_fn_opaque_item/index.html +//@ count - '//*[@class="section-header"]' 1 +//@ has - '//*[@class="section-header"]' 'Functions' + +pub async fn test() {} diff --git a/tests/rustdoc/async/async-fn.rs b/tests/rustdoc/async/async-fn.rs new file mode 100644 index 00000000000..3d49766c55e --- /dev/null +++ b/tests/rustdoc/async/async-fn.rs @@ -0,0 +1,99 @@ +//@ edition:2018 +//@ has async_fn/fn.foo.html '//pre[@class="rust item-decl"]' 'pub async fn foo() -> Option' +pub async fn foo() -> Option { + None +} + +//@ has async_fn/fn.bar.html '//pre[@class="rust item-decl"]' 'pub async fn bar(a: i32, b: i32) -> i32' +pub async fn bar(a: i32, b: i32) -> i32 { + 0 +} + +//@ has async_fn/fn.baz.html '//pre[@class="rust item-decl"]' 'pub async fn baz(a: T) -> T' +pub async fn baz(a: T) -> T { + a +} + +//@ has async_fn/fn.qux.html '//pre[@class="rust item-decl"]' 'pub async unsafe fn qux() -> char' +pub async unsafe fn qux() -> char { + '⚠' +} + +//@ has async_fn/fn.mut_args.html '//pre[@class="rust item-decl"]' 'pub async fn mut_args(a: usize)' +pub async fn mut_args(mut a: usize) {} + +//@ has async_fn/fn.mut_ref.html '//pre[@class="rust item-decl"]' 'pub async fn mut_ref(x: i32)' +pub async fn mut_ref(ref mut x: i32) {} + +trait Bar {} + +impl Bar for () {} + +//@ has async_fn/fn.quux.html '//pre[@class="rust item-decl"]' 'pub async fn quux() -> impl Bar' +pub async fn quux() -> impl Bar { + () +} + +//@ has async_fn/struct.Foo.html +//@ matches - '//h4[@class="code-header"]' 'pub async fn f\(\)$' +//@ matches - '//h4[@class="code-header"]' 'pub async unsafe fn g\(\)$' +//@ matches - '//h4[@class="code-header"]' 'pub async fn mut_self\(self, first: usize\)$' +pub struct Foo; + +impl Foo { + pub async fn f() {} + pub async unsafe fn g() {} + pub async fn mut_self(mut self, mut first: usize) {} +} + +pub trait Pattern<'a> {} + +impl Pattern<'_> for () {} + +pub trait Trait {} +//@ has async_fn/fn.const_generics.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn const_generics(_: impl Trait)' +pub async fn const_generics(_: impl Trait) {} + +// test that elided lifetimes are properly elided and not displayed as `'_` +// regression test for #63037 +//@ has async_fn/fn.elided.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn elided(foo: &str) -> &str' +pub async fn elided(foo: &str) -> &str { "" } +// This should really be shown as written, but for implementation reasons it's difficult. +// See `impl Clean for TyKind::Ref`. +//@ has async_fn/fn.user_elided.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn user_elided(foo: &str) -> &str' +pub async fn user_elided(foo: &'_ str) -> &str { "" } +//@ has async_fn/fn.static_trait.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn static_trait(foo: &str) -> Box' +pub async fn static_trait(foo: &str) -> Box { Box::new(()) } +//@ has async_fn/fn.lifetime_for_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn lifetime_for_trait(foo: &str) -> Box" +pub async fn lifetime_for_trait(foo: &str) -> Box { Box::new(()) } +//@ has async_fn/fn.elided_in_input_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" +pub async fn elided_in_input_trait(t: impl Pattern<'_>) {} + +struct AsyncFdReadyGuard<'a, T> { x: &'a T } + +impl Foo { + //@ has async_fn/struct.Foo.html + //@ has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator' + pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator { + [0].iter() + } + // taken from `tokio` as an example of a method that was particularly bad before + //@ has - '//*[@class="method"]' "pub async fn readable(&self) -> Result, ()>" + pub async fn readable(&self) -> Result, ()> { Err(()) } + //@ has - '//*[@class="method"]' "pub async fn mut_self(&mut self)" + pub async fn mut_self(&mut self) {} +} + +// test named lifetimes, just in case +//@ has async_fn/fn.named.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" +pub async fn named<'a, 'b>(foo: &'a str) -> &'b str { "" } +//@ has async_fn/fn.named_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" +pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {} diff --git a/tests/rustdoc/async/async-move-doctest.rs b/tests/rustdoc/async/async-move-doctest.rs new file mode 100644 index 00000000000..e18ec353533 --- /dev/null +++ b/tests/rustdoc/async/async-move-doctest.rs @@ -0,0 +1,12 @@ +//@ compile-flags:--test +//@ edition:2018 + +// Prior to setting the default edition for the doctest pre-parser, +// this doctest would fail due to a fatal parsing error. +// see https://github.com/rust-lang/rust/issues/59313 + +//! ``` +//! fn foo() { +//! drop(async move {}); +//! } +//! ``` diff --git a/tests/rustdoc/async/async-trait-sig.rs b/tests/rustdoc/async/async-trait-sig.rs new file mode 100644 index 00000000000..be790f6ed7f --- /dev/null +++ b/tests/rustdoc/async/async-trait-sig.rs @@ -0,0 +1,13 @@ +//@ edition:2021 + +#![allow(incomplete_features)] + +pub trait Foo { + //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn bar() -> i32" + async fn bar() -> i32; + + //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn baz() -> i32" + async fn baz() -> i32 { + 1 + } +} diff --git a/tests/rustdoc/async/async-trait.rs b/tests/rustdoc/async/async-trait.rs new file mode 100644 index 00000000000..a6ee340e2dd --- /dev/null +++ b/tests/rustdoc/async/async-trait.rs @@ -0,0 +1,15 @@ +//@ aux-build:async-trait-dep.rs +//@ edition:2021 + +#![allow(incomplete_features)] + +extern crate async_trait_dep; + +pub struct Oink {} + +//@ has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()" +impl async_trait_dep::Meow for Oink { + async fn woof() { + todo!() + } +} diff --git a/tests/rustdoc/async/auxiliary/async-trait-dep.rs b/tests/rustdoc/async/auxiliary/async-trait-dep.rs new file mode 100644 index 00000000000..d89ec6d2998 --- /dev/null +++ b/tests/rustdoc/async/auxiliary/async-trait-dep.rs @@ -0,0 +1,8 @@ +//@ edition:2021 + +#![allow(incomplete_features)] + +pub trait Meow { + /// Who's a good dog? + async fn woof(); +} diff --git a/tests/rustdoc/auxiliary/async-trait-dep.rs b/tests/rustdoc/auxiliary/async-trait-dep.rs deleted file mode 100644 index d89ec6d2998..00000000000 --- a/tests/rustdoc/auxiliary/async-trait-dep.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ edition:2021 - -#![allow(incomplete_features)] - -pub trait Meow { - /// Who's a good dog? - async fn woof(); -} -- cgit 1.4.1-3-g733a5
§

A

A variant with no fields

-
§

B

A variant with hidden fields

-