diff options
Diffstat (limited to 'tests/rustdoc')
50 files changed, 468 insertions, 47 deletions
diff --git a/tests/rustdoc/issue-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs index e525d85e2..26bb59c18 100644 --- a/tests/rustdoc/issue-15169.rs +++ b/tests/rustdoc/anchor-id-trait-method-15169.rs @@ -1,3 +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/issue-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs index b2ee9c260..375b5b5b2 100644 --- a/tests/rustdoc/issue-20646.rs +++ b/tests/rustdoc/assoc-type-bindings-20646.rs @@ -1,6 +1,8 @@ // 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; diff --git a/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs b/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs new file mode 100644 index 000000000..f4e020b3b --- /dev/null +++ b/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs @@ -0,0 +1,5 @@ +pub struct InlineOne<A> { + pub inline: A +} + +pub type InlineU64 = InlineOne<u64>; diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs new file mode 100644 index 000000000..f50a9b96d --- /dev/null +++ b/tests/rustdoc/const-effect-param.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] +#![feature(effects, 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<T: Tr>()' +/// foo +pub const fn g<T: ~const Tr>() {} diff --git a/tests/rustdoc/const-fn-effects.rs b/tests/rustdoc/const-fn-effects.rs new file mode 100644 index 000000000..7c19b4b2c --- /dev/null +++ b/tests/rustdoc/const-fn-effects.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] +#![feature(effects)] + +// @has foo/fn.bar.html +// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' +/// foo +pub const fn bar() -> usize { + 2 +} + +// @has foo/struct.Foo.html +// @has - '//*[@class="method"]' 'const fn new()' +pub struct Foo(usize); + +impl Foo { + pub const fn new() -> Foo { + Foo(0) + } +} diff --git a/tests/rustdoc/const-generics/const-generic-defaults.rs b/tests/rustdoc/const-generics/const-generic-defaults.rs index f781c6a62..7a0a79411 100644 --- a/tests/rustdoc/const-generics/const-generic-defaults.rs +++ b/tests/rustdoc/const-generics/const-generic-defaults.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] // @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ -// 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(_);' +// 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(' pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(T); diff --git a/tests/rustdoc/const-generics/const-generics-docs.rs b/tests/rustdoc/const-generics/const-generics-docs.rs index 828486a41..70a9518f0 100644 --- a/tests/rustdoc/const-generics/const-generics-docs.rs +++ b/tests/rustdoc/const-generics/const-generics-docs.rs @@ -33,7 +33,7 @@ impl<const N: usize> Trait<N> for [u8; N] {} // @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ // 'pub struct Foo<const N: usize> where u8: Trait<N>' pub struct Foo<const N: usize> where u8: Trait<N>; -// @has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(_)' +// @has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(' pub struct Bar<T, const N: usize>([T; N]); // @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Foo<M>where u8: Trait<M>' @@ -92,7 +92,7 @@ macro_rules! define_me { } // @has foo/struct.Foz.html '//pre[@class="rust item-decl"]' \ -// 'pub struct Foz<const N: usize>(_);' +// 'pub struct Foz<const N: usize>(/* private fields */);' define_me!(Foz<N>); trait Q { diff --git a/tests/rustdoc/custom_code_classes.rs b/tests/rustdoc/custom_code_classes.rs new file mode 100644 index 000000000..cd20d8b7d --- /dev/null +++ b/tests/rustdoc/custom_code_classes.rs @@ -0,0 +1,28 @@ +// Test for `custom_code_classes_in_docs` feature. + +#![feature(custom_code_classes_in_docs)] +#![crate_name = "foo"] +#![feature(no_core)] +#![no_core] + +// @has 'foo/struct.Bar.html' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever hoho-c"]' 'main;' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever2 haha-c"]' 'main;' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever4 huhu-c"]' 'main;' + +/// ```{class=hoho-c},whatever +/// main; +/// ``` +/// +/// Testing multiple kinds of orders. +/// +/// ```whatever2 {class=haha-c} +/// main; +/// ``` +/// +/// Testing with multiple "unknown". Only the first should be used. +/// +/// ```whatever4,{.huhu-c} whatever5 +/// main; +/// ``` +pub struct Bar; diff --git a/tests/rustdoc/issue-19190-2.rs b/tests/rustdoc/deref-methods-19190-foreign-type.rs index b6416e2e5..c83269921 100644 --- a/tests/rustdoc/issue-19190-2.rs +++ b/tests/rustdoc/deref-methods-19190-foreign-type.rs @@ -1,3 +1,7 @@ +// https://github.com/rust-lang/rust/issues/19190 + +#![crate_name="issue_19190_2"] + use std::ops::Deref; pub struct Bar; diff --git a/tests/rustdoc/issue-19190-3.rs b/tests/rustdoc/deref-methods-19190-inline.rs index 4d34ce650..619b268d6 100644 --- a/tests/rustdoc/issue-19190-3.rs +++ b/tests/rustdoc/deref-methods-19190-inline.rs @@ -1,6 +1,9 @@ // aux-build:issue-19190-3.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190_3"] + extern crate issue_19190_3; use std::ops::Deref; diff --git a/tests/rustdoc/issue-19190.rs b/tests/rustdoc/deref-methods-19190.rs index 2046273e2..4c274d82f 100644 --- a/tests/rustdoc/issue-19190.rs +++ b/tests/rustdoc/deref-methods-19190.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190"] + use std::ops::Deref; pub struct Foo; diff --git a/tests/rustdoc/issue-13698.rs b/tests/rustdoc/doc-hidden-method-13698.rs index 3046a8a28..f1bd6e73b 100644 --- a/tests/rustdoc/issue-13698.rs +++ b/tests/rustdoc/doc-hidden-method-13698.rs @@ -1,6 +1,9 @@ // aux-build:issue-13698.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/13698 +#![crate_name="issue_13698"] + extern crate issue_13698; pub struct Foo; diff --git a/tests/rustdoc/issue-18199.rs b/tests/rustdoc/doc-test-attr-18199.rs index 9cc58b162..c9d223532 100644 --- a/tests/rustdoc/issue-18199.rs +++ b/tests/rustdoc/doc-test-attr-18199.rs @@ -1,4 +1,5 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/18199 #![doc(test(attr(feature(staged_api))))] diff --git a/tests/rustdoc/issue-15347.rs b/tests/rustdoc/document-hidden-items-15347.rs index e93d74011..d8a760e56 100644 --- a/tests/rustdoc/issue-15347.rs +++ b/tests/rustdoc/document-hidden-items-15347.rs @@ -1,4 +1,7 @@ // compile-flags: -Z unstable-options --document-hidden-items +// https://github.com/rust-lang/rust/issues/15347 + +#![crate_name="issue_15347"] // @has issue_15347/fn.foo.html #[doc(hidden)] diff --git a/tests/rustdoc/issue-12834.rs b/tests/rustdoc/highlight-invalid-rust-12834.rs index 9605a1e78..f8acc5002 100644 --- a/tests/rustdoc/issue-12834.rs +++ b/tests/rustdoc/highlight-invalid-rust-12834.rs @@ -1,6 +1,8 @@ // Tests that failing to syntax highlight a rust code-block doesn't cause // rustdoc to fail, while still rendering the code-block (without highlighting). +// https://github.com/rust-lang/rust/issues/12834 +#![crate_name="issue_12834"] #![allow(rustdoc::invalid_rust_codeblocks)] // @has issue_12834/fn.foo.html diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs new file mode 100644 index 000000000..25615a73c --- /dev/null +++ b/tests/rustdoc/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="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +// @has foo/struct.Bar.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0' + // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +} diff --git a/tests/rustdoc/issue-19181.rs b/tests/rustdoc/ice-type-error-19181.rs index 3dea152fc..3ced61366 100644 --- a/tests/rustdoc/issue-19181.rs +++ b/tests/rustdoc/ice-type-error-19181.rs @@ -1,4 +1,5 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/19181 // rustdoc should not panic when target crate has compilation errors diff --git a/tests/rustdoc/issue-20175.rs b/tests/rustdoc/impl-ref-20175.rs index 6a42e2afb..a92db2d0a 100644 --- a/tests/rustdoc/issue-20175.rs +++ b/tests/rustdoc/impl-ref-20175.rs @@ -1,3 +1,7 @@ +// https://github.com/rust-lang/rust/issues/20175 + +#![crate_name="issue_20175"] + pub trait Foo { fn foo(&self) {} } diff --git a/tests/rustdoc/issue-16265-1.rs b/tests/rustdoc/infinite-redirection-16265-1.rs index 2fda637a6..7d72469bd 100644 --- a/tests/rustdoc/issue-16265-1.rs +++ b/tests/rustdoc/infinite-redirection-16265-1.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_1"] + pub struct Foo; // @hasraw issue_16265_1/traits/index.html 'source' diff --git a/tests/rustdoc/issue-16265-2.rs b/tests/rustdoc/infinite-redirection-16265-2.rs index c3eb35617..7a4791c5f 100644 --- a/tests/rustdoc/issue-16265-2.rs +++ b/tests/rustdoc/infinite-redirection-16265-2.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_2"] + // @hasraw issue_16265_2/index.html 'source' trait Y {} diff --git a/tests/rustdoc/issue-20727-2.rs b/tests/rustdoc/inline-assoc-type-20727-bindings.rs index c1aa9617b..e59dec29d 100644 --- a/tests/rustdoc/issue-20727-2.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bindings.rs @@ -1,6 +1,9 @@ // 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 diff --git a/tests/rustdoc/issue-20727-3.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs index 2f9d91fc5..005ee3e32 100644 --- a/tests/rustdoc/issue-20727-3.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs @@ -1,6 +1,9 @@ // 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 {} diff --git a/tests/rustdoc/issue-20727-4.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs index ec9f18fc3..1a3f4cd20 100644 --- a/tests/rustdoc/issue-20727-4.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs @@ -1,6 +1,9 @@ // 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 diff --git a/tests/rustdoc/issue-20727.rs b/tests/rustdoc/inline-assoc-type-20727-bounds.rs index 266848bee..7cbc8d381 100644 --- a/tests/rustdoc/issue-20727.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds.rs @@ -1,6 +1,9 @@ // 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 diff --git a/tests/rustdoc/inline_cross/async-fn.rs b/tests/rustdoc/inline_cross/async-fn.rs new file mode 100644 index 000000000..95e175aab --- /dev/null +++ b/tests/rustdoc/inline_cross/async-fn.rs @@ -0,0 +1,19 @@ +// Regression test for issue #115760. +// Check that we render the correct return type of free and +// associated async functions reexported from external crates. + +// aux-crate:async_fn=async-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" +pub use async_fn::load; + +// @has user/trait.Load.html +// @has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Load; + +// @has user/struct.Loader.html +// @has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Loader; diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs new file mode 100644 index 000000000..767564ed1 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -0,0 +1,18 @@ +#![feature(async_fn_in_trait)] +// edition: 2021 + +pub async fn load() -> i32 { + 0 +} + +pub trait Load { + async fn run(&self) -> i32; +} + +pub struct Loader; + +impl Load for Loader { + async fn run(&self) -> i32 { + 1 + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/const-fn.rs b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs new file mode 100644 index 000000000..26332b419 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs @@ -0,0 +1,5 @@ +#![feature(effects)] + +pub const fn load() -> i32 { + 0 +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 19433c968..42cfc3dc3 100644 --- a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -33,9 +33,3 @@ pub struct Foo; impl Foo { pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} } - -pub struct Bar; - -impl Bar { - pub async fn async_foo(&self) {} -} diff --git a/tests/rustdoc/inline_cross/const-fn.rs b/tests/rustdoc/inline_cross/const-fn.rs new file mode 100644 index 000000000..24934b873 --- /dev/null +++ b/tests/rustdoc/inline_cross/const-fn.rs @@ -0,0 +1,10 @@ +// Regression test for issue #116629. +// Check that we render the correct generic params of const fn + +// aux-crate:const_fn=const-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn load() -> i32" +pub use const_fn::load; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index b6a1552bc..5c802c514 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -33,15 +33,7 @@ pub use impl_trait_aux::func4; // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; -// @has impl_trait/fn.async_fn.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn async_fn()" -pub use impl_trait_aux::async_fn; - // @has impl_trait/struct.Foo.html // @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; - -// @has impl_trait/struct.Bar.html -// @has - '//*[@id="method.async_foo"]' "pub async fn async_foo(" -pub use impl_trait_aux::Bar; diff --git a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs index 910824839..5d2c553d8 100644 --- a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs +++ b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs @@ -8,7 +8,7 @@ // @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' // We also ensure we don't have another item displayed. // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 2 -// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' mod other { diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs index b0c225401..3b836a219 100644 --- a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs +++ b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs @@ -104,7 +104,7 @@ pub mod glob_reexport { // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' - // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' + // @has - '//*[@id="main-content"]/*[@class="small-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. @@ -135,9 +135,9 @@ pub mod doc_hidden_reexport { // @has - '//a[@class="struct"]' 'Reexport' // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. // @has - '//*[@class="desc docblock-short"]' 'Visible. Original.' + /// Visible. + pub use self::Bar3 as Reexport; /// Hidden. #[doc(hidden)] pub use crate::private::Bar3; - /// Visible. - pub use self::Bar3 as Reexport; } diff --git a/tests/rustdoc/issue-32077-type-alias-impls.rs b/tests/rustdoc/issue-32077-type-alias-impls.rs new file mode 100644 index 000000000..ac486c36a --- /dev/null +++ b/tests/rustdoc/issue-32077-type-alias-impls.rs @@ -0,0 +1,66 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/32077>. + +#![crate_name = "foo"] + +pub struct GenericStruct<T>(T); + +impl<T> GenericStruct<T> { + pub fn on_gen(arg: T) {} +} + +impl GenericStruct<u32> { + pub fn on_u32(arg: u32) {} +} + +pub trait Foo {} +pub trait Bar {} + +impl<T> Foo for GenericStruct<T> {} +impl Bar for GenericStruct<u32> {} + +// @has 'foo/type.TypedefStruct.html' +// We check that "Aliased type" is also present as a title in the sidebar. +// @has - '//*[@class="sidebar-elems"]//h3/a[@href="#aliased-type"]' 'Aliased type' +// We check that we have the implementation of the type alias itself. +// @has - '//*[@id="impl-TypedefStruct"]/h3' 'impl TypedefStruct' +// @has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()' +// @has - '//*[@id="impl-GenericStruct%3CT%3E"]/h3' 'impl<T> GenericStruct<T>' +// @has - '//*[@id="method.on_gen"]/h4' 'pub fn on_gen(arg: T)' +// @has - '//*[@id="impl-Foo-for-GenericStruct%3CT%3E"]/h3' 'impl<T> Foo for GenericStruct<T>' +// This trait implementation doesn't match the type alias parameters so shouldn't appear in docs. +// @!has - '//h3' 'impl Bar for GenericStruct<u32> {}' +// Same goes for the `Deref` impl. +// @!has - '//h2' 'Methods from Deref<Target = u32>' +// @count - '//nav[@class="sidebar"]//a' 'on_alias' 1 +// @count - '//nav[@class="sidebar"]//a' 'on_gen' 1 +// @count - '//nav[@class="sidebar"]//a' 'Foo' 1 +// @!has - '//nav[@class="sidebar"]//a' 'Bar' +// @!has - '//nav[@class="sidebar"]//a' 'on_u32' +pub type TypedefStruct = GenericStruct<u8>; + +impl TypedefStruct { + pub fn on_alias() {} +} + +impl std::ops::Deref for GenericStruct<u32> { + type Target = u32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +pub struct Wrap<T>(GenericStruct<T>); + +// @has 'foo/type.Alias.html' +// @has - '//h2' 'Methods from Deref<Target = u32>' +// @has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl<T> Deref for Wrap<T>' +pub type Alias = Wrap<u32>; + +impl<T> std::ops::Deref for Wrap<T> { + type Target = GenericStruct<T>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/tests/rustdoc/issue-88600.rs b/tests/rustdoc/issue-88600.rs index db0d102b7..f89af472f 100644 --- a/tests/rustdoc/issue-88600.rs +++ b/tests/rustdoc/issue-88600.rs @@ -8,10 +8,10 @@ pub struct S; // @has issue_88600/enum.FooEnum.html pub enum FooEnum { - // @has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(_)' + // @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(_, _)' + // @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), diff --git a/tests/rustdoc/issue-16019.rs b/tests/rustdoc/macro-ice-16019.rs index 239d92378..d0f82e0a3 100644 --- a/tests/rustdoc/issue-16019.rs +++ b/tests/rustdoc/macro-ice-16019.rs @@ -1,3 +1,5 @@ +// https://github.com/rust-lang/rust/issues/16019 + macro_rules! define_struct { ($rounds:expr) => ( struct Struct { diff --git a/tests/rustdoc/issue-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs index a5b484c98..e52ab6f38 100644 --- a/tests/rustdoc/issue-17476.rs +++ b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs @@ -1,5 +1,8 @@ // aux-build:issue-17476.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/17476 + +#![crate_name="issue_17476"] extern crate issue_17476; diff --git a/tests/rustdoc/no-crate-filter.rs b/tests/rustdoc/no-crate-filter.rs deleted file mode 100644 index b2f899064..000000000 --- a/tests/rustdoc/no-crate-filter.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_name = "foo"] - -// compile-flags: -Z unstable-options --disable-per-crate-search - -// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' '' -pub struct Foo; diff --git a/tests/rustdoc/issue-15318-3.rs b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs index 2dab8f948..80c559756 100644 --- a/tests/rustdoc/issue-15318-3.rs +++ b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs @@ -1,3 +1,5 @@ +// https://github.com/rust-lang/rust/issues/15318 +#![crate_name="issue_15318_3"] #![feature(rustc_attrs)] // @has issue_15318_3/primitive.pointer.html diff --git a/tests/rustdoc/issue-15318.rs b/tests/rustdoc/primitive-raw-pointer-link-15318.rs index 0349fe285..77f25ff4c 100644 --- a/tests/rustdoc/issue-15318.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-15318.rs @@ -1,6 +1,8 @@ // 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; diff --git a/tests/rustdoc/issue-15318-2.rs b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs index 614f2c1c0..1b35bb185 100644 --- a/tests/rustdoc/issue-15318-2.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs @@ -1,5 +1,8 @@ // 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; diff --git a/tests/rustdoc/private-fields-tuple-struct.rs b/tests/rustdoc/private-fields-tuple-struct.rs new file mode 100644 index 000000000..c6989dd8c --- /dev/null +++ b/tests/rustdoc/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/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs index 5d742dc39..7f56b2ffe 100644 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/rfc-2632-const-trait-impl.rs @@ -5,6 +5,8 @@ // To future blessers: make sure that `const_trait_impl` is // stabilized when changing `@!has` to `@has`, and please do // not remove this test. +// +// FIXME(effects) add `const_trait` to `Fn` so we use `~const` #![feature(const_trait_impl)] #![crate_name = "foo"] @@ -22,9 +24,9 @@ pub trait Tr<T> { // @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"]/span[@class="where fmt-newline"]' ': Fn' - fn a<A: ~const Fn() + ~const Destruct>() + fn a<A: /* ~const */ Fn() + ~const Destruct>() where - Option<A>: ~const Fn() + ~const Destruct, + Option<A>: /* ~const */ Fn() + ~const Destruct, { } } @@ -34,13 +36,13 @@ pub trait Tr<T> { // @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"]/span[@class="where fmt-newline"]' ': Fn' -impl<T: ~const Fn() + ~const Destruct> const Tr<T> for T +impl<T: /* ~const */ Fn() + ~const Destruct> const Tr<T> for T where - Option<T>: ~const Fn() + ~const Destruct, + Option<T>: /* ~const */ Fn() + ~const Destruct, { - fn a<A: ~const Fn() + ~const Destruct>() + fn a<A: /* ~const */ Fn() + ~const Destruct>() where - Option<A>: ~const Fn() + ~const Destruct, + Option<A>: /* ~const */ Fn() + ~const Destruct, { } } @@ -49,9 +51,9 @@ where // @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' '~const' // @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Fn' -pub const fn foo<F: ~const Fn() + ~const Destruct>() +pub const fn foo<F: /* ~const */ Fn() + ~const Destruct>() where - Option<F>: ~const Fn() + ~const Destruct, + Option<F>: /* ~const */ Fn() + ~const Destruct, { F::a() } @@ -61,9 +63,9 @@ impl<T> S<T> { // @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"]/span[@class="where fmt-newline"]' ': Fn' - pub const fn foo<B, C: ~const Fn() + ~const Destruct>() + pub const fn foo<B, C: /* ~const */ Fn() + ~const Destruct>() where - B: ~const Fn() + ~const Destruct, + B: /* ~const */ Fn() + ~const Destruct, { B::a() } diff --git a/tests/rustdoc/show-const-contents.rs b/tests/rustdoc/show-const-contents.rs index 69e742ee7..91df03adb 100644 --- a/tests/rustdoc/show-const-contents.rs +++ b/tests/rustdoc/show-const-contents.rs @@ -47,7 +47,7 @@ pub struct MyTypeWithStr(&'static str); // @!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.14159265358979323846264338327950288f32;' +// @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; diff --git a/tests/rustdoc/sidebar-all-page.rs b/tests/rustdoc/sidebar-all-page.rs index 45a6ba8ed..4c8a0f543 100644 --- a/tests/rustdoc/sidebar-all-page.rs +++ b/tests/rustdoc/sidebar-all-page.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] - #![feature(rustc_attrs)] // @has 'foo/all.html' @@ -9,7 +8,7 @@ // @has - '//*[@class="sidebar-elems"]//li' 'Functions' // @has - '//*[@class="sidebar-elems"]//li' 'Traits' // @has - '//*[@class="sidebar-elems"]//li' 'Macros' -// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions' +// @has - '//*[@class="sidebar-elems"]//li' 'Type Aliases' // @has - '//*[@class="sidebar-elems"]//li' 'Constants' // @has - '//*[@class="sidebar-elems"]//li' 'Statics' // @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' @@ -26,7 +25,7 @@ pub fn foo() {} pub trait Trait {} #[macro_export] macro_rules! foo { - () => {} + () => {}; } pub type Type = u8; pub const FOO: u8 = 0; diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index e1feb1cd6..f6a059de6 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -30,7 +30,7 @@ pub struct FooStruct; // @matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum' pub enum FooEnum {} -// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType' +// @matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType' // @matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType' pub type FooType = FooStruct; diff --git a/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs new file mode 100644 index 000000000..ff84352d7 --- /dev/null +++ b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs @@ -0,0 +1,34 @@ +#![crate_name = "inner_types_lazy"] + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// @has 'inner_types_lazy/struct.Pair.html' +pub struct Pair<A, B> { + pub first: A, + pub second: B, +} + +// @has 'inner_types_lazy/type.ReversedTypesPair.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 0 +pub type ReversedTypesPair<Q, R> = Pair<R, Q>; + +// @has 'inner_types_lazy/type.ReadWrite.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 2 +pub type ReadWrite<R, W> = Pair<R, W> +where + R: std::io::Read, + W: std::io::Write; + +// @has 'inner_types_lazy/type.VecPair.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 0 +pub type VecPair<U, V> = Pair<Vec<U>, Vec<V>>; diff --git a/tests/rustdoc/typedef-inner-variants.rs b/tests/rustdoc/typedef-inner-variants.rs new file mode 100644 index 000000000..b734714fd --- /dev/null +++ b/tests/rustdoc/typedef-inner-variants.rs @@ -0,0 +1,119 @@ +// This test checks different combinations of structs, enums, and unions +// for the "Show Aliased Type" feature on type definition. + +#![crate_name = "inner_variants"] + +// aux-build:cross_crate_generic_typedef.rs +extern crate cross_crate_generic_typedef; + +pub struct Adt; +pub struct Ty; +pub struct TyCtxt; + +pub trait Interner { + type Adt; + type Ty; +} + +impl Interner for TyCtxt { + type Adt = Adt; + type Ty = Ty; +} + +// @has 'inner_variants/type.AliasTy.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +pub type AliasTy = Ty; + +// @has 'inner_variants/enum.IrTyKind.html' +pub enum IrTyKind<A, I: Interner> { + /// Doc comment for AdtKind + AdtKind(I::Adt), + /// and another one for TyKind + TyKind(I::Adt, <I as Interner>::Ty), + // no comment + StructKind { a: A, }, + #[doc(hidden)] + Unspecified, +} + +// @has 'inner_variants/type.NearlyTyKind.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 1 +// @count - '//*[@id="fields"]' 0 +pub type NearlyTyKind<A> = IrTyKind<A, TyCtxt>; + +// @has 'inner_variants/type.TyKind.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 1 +// @count - '//*[@id="fields"]' 0 +// @count - '//*[@class="variant"]' 3 +// @matches - '//pre[@class="rust item-decl"]//code' "enum TyKind" +// @has - '//pre[@class="rust item-decl"]//code/a[1]' "Adt" +// @has - '//pre[@class="rust item-decl"]//code/a[2]' "Adt" +// @has - '//pre[@class="rust item-decl"]//code/a[3]' "Ty" +// @has - '//pre[@class="rust item-decl"]//code/a[4]' "i64" +pub type TyKind = IrTyKind<i64, TyCtxt>; + +// @has 'inner_variants/union.OneOr.html' +pub union OneOr<A: Copy> { + pub one: i64, + pub or: A, +} + +// @has 'inner_variants/type.OneOrF64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 2 +// @matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64" +pub type OneOrF64 = OneOr<f64>; + +// @has 'inner_variants/struct.One.html' +pub struct One<T> { + pub val: T, + #[doc(hidden)] + pub __hidden: T, + __private: T, +} + +// @has 'inner_variants/type.OneU64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct OneU64" +// @matches - '//pre[@class="rust item-decl"]//code' "pub val" +pub type OneU64 = One<u64>; + +// @has 'inner_variants/struct.OnceA.html' +pub struct OnceA<'a, A> { + pub a: &'a A, +} + +// @has 'inner_variants/type.Once.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>" +// @matches - '//pre[@class="rust item-decl"]//code' "&'a" +pub type Once<'a> = OnceA<'a, i64>; + +// @has 'inner_variants/struct.HighlyGenericStruct.html' +pub struct HighlyGenericStruct<A, B, C, D> { + pub z: (A, B, C, D) +} + +// @has 'inner_variants/type.HighlyGenericAABB.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>" +// @matches - '//pre[@class="rust item-decl"]//code' "pub z" +pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>; + +// @has 'inner_variants/type.InlineU64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +pub use cross_crate_generic_typedef::InlineU64; diff --git a/tests/rustdoc/where.SWhere_Simd_item-decl.html b/tests/rustdoc/where.SWhere_Simd_item-decl.html index 3e72ba2b7..46708b9e4 100644 --- a/tests/rustdoc/where.SWhere_Simd_item-decl.html +++ b/tests/rustdoc/where.SWhere_Simd_item-decl.html @@ -1,3 +1,3 @@ -<pre class="rust item-decl"><code>pub struct Simd<T>(_) +<pre class="rust item-decl"><code>pub struct Simd<T>(/* private fields */) <span class="where">where T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre> diff --git a/tests/rustdoc/where.alpha_trait_decl.html b/tests/rustdoc/where.alpha_trait_decl.html index a7700055c..0c0b2d1ce 100644 --- a/tests/rustdoc/where.alpha_trait_decl.html +++ b/tests/rustdoc/where.alpha_trait_decl.html @@ -1,3 +1,3 @@ -<code>pub struct Alpha<A>(_) +<code>pub struct Alpha<A>(/* private fields */) <span class="where">where A: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code>
\ No newline at end of file diff --git a/tests/rustdoc/where.rs b/tests/rustdoc/where.rs index 2aa9c8b54..aea02c140 100644 --- a/tests/rustdoc/where.rs +++ b/tests/rustdoc/where.rs @@ -4,7 +4,7 @@ use std::io::Lines; pub trait MyTrait { fn dummy(&self) { } } -// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait" +// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(/* private fields */) where A: MyTrait" // @snapshot alpha_trait_decl - '//*[@class="rust item-decl"]/code' pub struct Alpha<A>(A) where A: MyTrait; // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait" |