From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- .../anchor-id-duplicate-method-name-25001.rs | 46 +++++ tests/rustdoc/anchor-id-trait-tymethod-28478.rs | 34 ++++ tests/rustdoc/async-trait-sig.rs | 1 - tests/rustdoc/async-trait.rs | 1 - tests/rustdoc/auxiliary/async-trait-dep.rs | 1 - tests/rustdoc/auxiliary/enum-variant.rs | 48 ++++++ tests/rustdoc/auxiliary/issue-21801.rs | 9 - tests/rustdoc/auxiliary/issue-23207-1.rs | 3 - tests/rustdoc/auxiliary/issue-23207-2.rs | 5 - tests/rustdoc/auxiliary/issue-27362-aux.rs | 10 -- tests/rustdoc/auxiliary/issue-29584.rs | 10 -- tests/rustdoc/blanket-impl-29503.rs | 21 +++ tests/rustdoc/blanket-reexport-item.rs | 2 +- tests/rustdoc/const-effect-param.rs | 2 + tests/rustdoc/const-generics/add-impl.rs | 2 +- tests/rustdoc/const-generics/const-impl.rs | 6 +- tests/rustdoc/const-rendering-macros-33302.rs | 54 ++++++ tests/rustdoc/crate-version-escape.rs | 2 +- tests/rustdoc/crate-version-extra.rs | 7 + tests/rustdoc/crate-version.rs | 2 +- .../decl-trailing-whitespace.declaration.html | 14 +- tests/rustdoc/decl-trailing-whitespace.rs | 8 +- .../rustdoc/deduplicate-glob-import-impl-21474.rs | 14 ++ tests/rustdoc/deduplicate-trait-impl-22025.rs | 9 + tests/rustdoc/deprecated-future-staged-api.rs | 6 +- tests/rustdoc/deref/deref-mut-methods.rs | 2 +- tests/rustdoc/deref/deref-recursive-pathbuf.rs | 4 +- tests/rustdoc/disambiguate-anchors-32890.rs | 20 +++ tests/rustdoc/disambiguate-anchors-header-29449.rs | 23 +++ .../rustdoc/doc-hidden-trait-implementors-33069.rs | 13 ++ tests/rustdoc/doctest-cfg-feature-30252.rs | 9 + tests/rustdoc/doctest-hide-empty-line-23106.rs | 10 ++ tests/rustdoc/doctest-ignore-32556.rs | 8 + .../rustdoc/doctest-markdown-inline-parse-23744.rs | 15 ++ .../doctest-multi-line-string-literal-25944.rs | 14 ++ tests/rustdoc/enum-variant-value.rs | 191 +++++++++++++++++++++ tests/rustdoc/extern-fn-22038.rs | 22 +++ tests/rustdoc/generic-impl.rs | 4 +- tests/rustdoc/hidden-extern-34025.rs | 13 ++ tests/rustdoc/hidden-impls.rs | 2 +- .../hide-complex-unevaluated-const-arguments.rs | 11 +- tests/rustdoc/html-no-source.rs | 12 +- tests/rustdoc/ice-reexport-crate-root-28927.rs | 9 + tests/rustdoc/impl-assoc-type-21092.rs | 11 ++ tests/rustdoc/impl-parts-crosscrate.rs | 2 +- tests/rustdoc/impl-type-parameter-33592.rs | 14 ++ tests/rustdoc/implementor-stable-version.rs | 16 +- tests/rustdoc/inline_cross/attributes.rs | 7 + tests/rustdoc/inline_cross/auxiliary/async-fn.rs | 1 - tests/rustdoc/inline_cross/auxiliary/attributes.rs | 2 + .../inline_cross/auxiliary/const-effect-param.rs | 16 ++ tests/rustdoc/inline_cross/auxiliary/const-fn.rs | 5 - .../inline_cross/auxiliary/default-generic-args.rs | 45 +++++ tests/rustdoc/inline_cross/auxiliary/fn-type.rs | 1 + .../inline_cross/auxiliary/impl_trait_aux.rs | 2 +- .../rustdoc/inline_cross/auxiliary/issue-21801.rs | 9 + .../inline_cross/auxiliary/issue-23207-1.rs | 3 + .../inline_cross/auxiliary/issue-23207-2.rs | 5 + .../inline_cross/auxiliary/issue-27362-aux.rs | 10 ++ .../rustdoc/inline_cross/auxiliary/issue-29584.rs | 10 ++ .../inline_cross/auxiliary/non_lifetime_binders.rs | 10 ++ tests/rustdoc/inline_cross/auxiliary/repr.rs | 22 ++- .../auxiliary/ret-pos-impl-trait-in-trait.rs | 2 - tests/rustdoc/inline_cross/const-effect-param.rs | 29 ++++ tests/rustdoc/inline_cross/const-fn-27362.rs | 13 ++ tests/rustdoc/inline_cross/const-fn.rs | 10 -- .../deduplicate-inlined-items-23207.rs | 12 ++ tests/rustdoc/inline_cross/default-generic-args.rs | 104 +++++++++++ .../doc-hidden-extern-trait-impl-29584.rs | 11 ++ tests/rustdoc/inline_cross/dyn_trait.rs | 8 +- tests/rustdoc/inline_cross/fn-type.rs | 12 ++ tests/rustdoc/inline_cross/impl_trait.rs | 6 +- tests/rustdoc/inline_cross/implementors-js.rs | 10 +- tests/rustdoc/inline_cross/non_lifetime_binders.rs | 13 ++ tests/rustdoc/inline_cross/repr.rs | 21 ++- .../inline_cross/sugar-closure-crate-21801.rs | 12 ++ tests/rustdoc/intra-doc/prim-associated-traits.rs | 2 +- tests/rustdoc/issue-112515-impl-ty-alias.rs | 30 ---- tests/rustdoc/issue-115295-macro-const-display.rs | 40 +++++ tests/rustdoc/issue-21092.rs | 8 - tests/rustdoc/issue-21474.rs | 11 -- tests/rustdoc/issue-21801.rs | 9 - tests/rustdoc/issue-22025.rs | 6 - tests/rustdoc/issue-22038.rs | 19 -- tests/rustdoc/issue-23106.rs | 7 - tests/rustdoc/issue-23207.rs | 9 - tests/rustdoc/issue-23511.rs | 13 -- tests/rustdoc/issue-23744.rs | 12 -- tests/rustdoc/issue-23812.rs | 36 ---- tests/rustdoc/issue-25001.rs | 43 ----- tests/rustdoc/issue-25944.rs | 11 -- tests/rustdoc/issue-26606.rs | 11 -- tests/rustdoc/issue-26995.rs | 7 - tests/rustdoc/issue-27104.rs | 10 -- tests/rustdoc/issue-27362.rs | 10 -- tests/rustdoc/issue-27759.rs | 14 -- tests/rustdoc/issue-27862.rs | 4 - tests/rustdoc/issue-28478.rs | 31 ---- tests/rustdoc/issue-28927.rs | 6 - tests/rustdoc/issue-29449.rs | 20 --- tests/rustdoc/issue-29503.rs | 18 -- tests/rustdoc/issue-29584.rs | 8 - tests/rustdoc/issue-30109.rs | 14 -- tests/rustdoc/issue-30252.rs | 6 - tests/rustdoc/issue-30366.rs | 6 - tests/rustdoc/issue-31808.rs | 11 -- tests/rustdoc/issue-31899.rs | 59 ------- tests/rustdoc/issue-32077-type-alias-impls.rs | 66 ------- tests/rustdoc/issue-32374.rs | 31 ---- tests/rustdoc/issue-32395.rs | 15 -- tests/rustdoc/issue-32556.rs | 5 - tests/rustdoc/issue-32890.rs | 17 -- tests/rustdoc/issue-33069.rs | 10 -- tests/rustdoc/issue-33178-1.rs | 10 -- tests/rustdoc/issue-33178.rs | 14 -- tests/rustdoc/issue-33302.rs | 51 ------ tests/rustdoc/issue-33592.rs | 13 -- tests/rustdoc/issue-34025.rs | 12 -- tests/rustdoc/issue-34274.rs | 10 -- tests/rustdoc/issue-43701.rs | 2 +- tests/rustdoc/issue-78701.rs | 2 +- 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/logo-class-default.rs | 6 +- tests/rustdoc/logo-class-rust.rs | 7 + tests/rustdoc/logo-class.rs | 2 +- tests/rustdoc/macro-doc-comment-23812.rs | 39 +++++ tests/rustdoc/markdown-table-escape-pipe-27862.rs | 7 + tests/rustdoc/normalize-assoc-item.rs | 4 +- tests/rustdoc/not-wf-ambiguous-normalization.rs | 24 --- .../doc-notable_trait_box_is_not_an_iterator.rs | 11 +- tests/rustdoc/primitive/primitive-generic-impl.rs | 2 +- .../render-enum-variant-structlike-32395.rs | 18 ++ tests/rustdoc/repr.rs | 29 ++++ ...search-index-primitive-inherent-method-23511.rs | 16 ++ tests/rustdoc/sidebar-items.rs | 7 + tests/rustdoc/sidebar-links-to-foreign-impl.rs | 4 +- tests/rustdoc/source-version-separator.rs | 10 +- tests/rustdoc/src-link-external-macro-26606.rs | 14 ++ tests/rustdoc/src-links-auto-impls.rs | 4 +- tests/rustdoc/src-links-inlined-34274.rs | 11 ++ tests/rustdoc/src-mod-path-absolute-26995.rs | 10 ++ .../staged-api-deprecated-unstable-32374.rs | 33 ++++ tests/rustdoc/staged-api-feature-issue-27759.rs | 17 ++ tests/rustdoc/strip-enum-variant.no-not-shown.html | 2 +- tests/rustdoc/strip-enum-variant.rs | 2 +- tests/rustdoc/strip-priv-imports-pass-27104.rs | 13 ++ tests/rustdoc/summary-codeblock-31899.rs | 62 +++++++ tests/rustdoc/summary-reference-link-30366.rs | 9 + tests/rustdoc/titles.rs | 3 +- tests/rustdoc/trait-object-safe.rs | 27 +++ .../type-alias/auxiliary/parent-crate-115718.rs | 9 + tests/rustdoc/type-alias/cross-crate-115718.rs | 34 ++++ tests/rustdoc/type-alias/deeply-nested-112515.rs | 30 ++++ tests/rustdoc/type-alias/deref-32077.rs | 70 ++++++++ tests/rustdoc/type-alias/same-crate-115718.rs | 34 ++++ tests/rustdoc/version-separator-without-source.rs | 12 +- tests/rustdoc/where-clause-order.rs | 13 +- .../whitespace-after-where-clause.enum.html | 2 +- .../whitespace-after-where-clause.enum2.html | 2 +- tests/rustdoc/whitespace-after-where-clause.rs | 15 +- .../whitespace-after-where-clause.struct.html | 2 +- .../whitespace-after-where-clause.struct2.html | 2 +- .../whitespace-after-where-clause.union.html | 2 +- .../whitespace-after-where-clause.union2.html | 2 +- 166 files changed, 1674 insertions(+), 897 deletions(-) create mode 100644 tests/rustdoc/anchor-id-duplicate-method-name-25001.rs create mode 100644 tests/rustdoc/anchor-id-trait-tymethod-28478.rs create mode 100644 tests/rustdoc/auxiliary/enum-variant.rs delete mode 100644 tests/rustdoc/auxiliary/issue-21801.rs delete mode 100644 tests/rustdoc/auxiliary/issue-23207-1.rs delete mode 100644 tests/rustdoc/auxiliary/issue-23207-2.rs delete mode 100644 tests/rustdoc/auxiliary/issue-27362-aux.rs delete mode 100644 tests/rustdoc/auxiliary/issue-29584.rs create mode 100644 tests/rustdoc/blanket-impl-29503.rs create mode 100644 tests/rustdoc/const-rendering-macros-33302.rs create mode 100644 tests/rustdoc/crate-version-extra.rs create mode 100644 tests/rustdoc/deduplicate-glob-import-impl-21474.rs create mode 100644 tests/rustdoc/deduplicate-trait-impl-22025.rs create mode 100644 tests/rustdoc/disambiguate-anchors-32890.rs create mode 100644 tests/rustdoc/disambiguate-anchors-header-29449.rs create mode 100644 tests/rustdoc/doc-hidden-trait-implementors-33069.rs create mode 100644 tests/rustdoc/doctest-cfg-feature-30252.rs create mode 100644 tests/rustdoc/doctest-hide-empty-line-23106.rs create mode 100644 tests/rustdoc/doctest-ignore-32556.rs create mode 100644 tests/rustdoc/doctest-markdown-inline-parse-23744.rs create mode 100644 tests/rustdoc/doctest-multi-line-string-literal-25944.rs create mode 100644 tests/rustdoc/enum-variant-value.rs create mode 100644 tests/rustdoc/extern-fn-22038.rs create mode 100644 tests/rustdoc/hidden-extern-34025.rs create mode 100644 tests/rustdoc/ice-reexport-crate-root-28927.rs create mode 100644 tests/rustdoc/impl-assoc-type-21092.rs create mode 100644 tests/rustdoc/impl-type-parameter-33592.rs create mode 100644 tests/rustdoc/inline_cross/attributes.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/attributes.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs delete mode 100644 tests/rustdoc/inline_cross/auxiliary/const-fn.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/fn-type.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/issue-21801.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/issue-29584.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs create mode 100644 tests/rustdoc/inline_cross/const-effect-param.rs create mode 100644 tests/rustdoc/inline_cross/const-fn-27362.rs delete mode 100644 tests/rustdoc/inline_cross/const-fn.rs create mode 100644 tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs create mode 100644 tests/rustdoc/inline_cross/default-generic-args.rs create mode 100644 tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs create mode 100644 tests/rustdoc/inline_cross/fn-type.rs create mode 100644 tests/rustdoc/inline_cross/non_lifetime_binders.rs create mode 100644 tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs delete mode 100644 tests/rustdoc/issue-112515-impl-ty-alias.rs create mode 100644 tests/rustdoc/issue-115295-macro-const-display.rs delete mode 100644 tests/rustdoc/issue-21092.rs delete mode 100644 tests/rustdoc/issue-21474.rs delete mode 100644 tests/rustdoc/issue-21801.rs delete mode 100644 tests/rustdoc/issue-22025.rs delete mode 100644 tests/rustdoc/issue-22038.rs delete mode 100644 tests/rustdoc/issue-23106.rs delete mode 100644 tests/rustdoc/issue-23207.rs delete mode 100644 tests/rustdoc/issue-23511.rs delete mode 100644 tests/rustdoc/issue-23744.rs delete mode 100644 tests/rustdoc/issue-23812.rs delete mode 100644 tests/rustdoc/issue-25001.rs delete mode 100644 tests/rustdoc/issue-25944.rs delete mode 100644 tests/rustdoc/issue-26606.rs delete mode 100644 tests/rustdoc/issue-26995.rs delete mode 100644 tests/rustdoc/issue-27104.rs delete mode 100644 tests/rustdoc/issue-27362.rs delete mode 100644 tests/rustdoc/issue-27759.rs delete mode 100644 tests/rustdoc/issue-27862.rs delete mode 100644 tests/rustdoc/issue-28478.rs delete mode 100644 tests/rustdoc/issue-28927.rs delete mode 100644 tests/rustdoc/issue-29449.rs delete mode 100644 tests/rustdoc/issue-29503.rs delete mode 100644 tests/rustdoc/issue-29584.rs delete mode 100644 tests/rustdoc/issue-30109.rs delete mode 100644 tests/rustdoc/issue-30252.rs delete mode 100644 tests/rustdoc/issue-30366.rs delete mode 100644 tests/rustdoc/issue-31808.rs delete mode 100644 tests/rustdoc/issue-31899.rs delete mode 100644 tests/rustdoc/issue-32077-type-alias-impls.rs delete mode 100644 tests/rustdoc/issue-32374.rs delete mode 100644 tests/rustdoc/issue-32395.rs delete mode 100644 tests/rustdoc/issue-32556.rs delete mode 100644 tests/rustdoc/issue-32890.rs delete mode 100644 tests/rustdoc/issue-33069.rs delete mode 100644 tests/rustdoc/issue-33178-1.rs delete mode 100644 tests/rustdoc/issue-33178.rs delete mode 100644 tests/rustdoc/issue-33302.rs delete mode 100644 tests/rustdoc/issue-33592.rs delete mode 100644 tests/rustdoc/issue-34025.rs delete mode 100644 tests/rustdoc/issue-34274.rs create mode 100644 tests/rustdoc/link-extern-crate-33178.rs create mode 100644 tests/rustdoc/link-extern-crate-item-30109.rs create mode 100644 tests/rustdoc/link-extern-crate-title-33178.rs create mode 100644 tests/rustdoc/logo-class-rust.rs create mode 100644 tests/rustdoc/macro-doc-comment-23812.rs create mode 100644 tests/rustdoc/markdown-table-escape-pipe-27862.rs delete mode 100644 tests/rustdoc/not-wf-ambiguous-normalization.rs create mode 100644 tests/rustdoc/render-enum-variant-structlike-32395.rs create mode 100644 tests/rustdoc/repr.rs create mode 100644 tests/rustdoc/search-index-primitive-inherent-method-23511.rs create mode 100644 tests/rustdoc/src-link-external-macro-26606.rs create mode 100644 tests/rustdoc/src-links-inlined-34274.rs create mode 100644 tests/rustdoc/src-mod-path-absolute-26995.rs create mode 100644 tests/rustdoc/staged-api-deprecated-unstable-32374.rs create mode 100644 tests/rustdoc/staged-api-feature-issue-27759.rs create mode 100644 tests/rustdoc/strip-priv-imports-pass-27104.rs create mode 100644 tests/rustdoc/summary-codeblock-31899.rs create mode 100644 tests/rustdoc/summary-reference-link-30366.rs create mode 100644 tests/rustdoc/trait-object-safe.rs create mode 100644 tests/rustdoc/type-alias/auxiliary/parent-crate-115718.rs create mode 100644 tests/rustdoc/type-alias/cross-crate-115718.rs create mode 100644 tests/rustdoc/type-alias/deeply-nested-112515.rs create mode 100644 tests/rustdoc/type-alias/deref-32077.rs create mode 100644 tests/rustdoc/type-alias/same-crate-115718.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 new file mode 100644 index 000000000..ffb0765d3 --- /dev/null +++ b/tests/rustdoc/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-1"]//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"]//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-tymethod-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs new file mode 100644 index 000000000..5685040dc --- /dev/null +++ b/tests/rustdoc/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/async-trait-sig.rs b/tests/rustdoc/async-trait-sig.rs index 2578bc8f7..db1848f71 100644 --- a/tests/rustdoc/async-trait-sig.rs +++ b/tests/rustdoc/async-trait-sig.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Foo { diff --git a/tests/rustdoc/async-trait.rs b/tests/rustdoc/async-trait.rs index a473e4674..8de95aac2 100644 --- a/tests/rustdoc/async-trait.rs +++ b/tests/rustdoc/async-trait.rs @@ -1,7 +1,6 @@ // aux-build:async-trait-dep.rs // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] extern crate async_trait_dep; diff --git a/tests/rustdoc/auxiliary/async-trait-dep.rs b/tests/rustdoc/auxiliary/async-trait-dep.rs index 10a55dd02..d455ee99e 100644 --- a/tests/rustdoc/auxiliary/async-trait-dep.rs +++ b/tests/rustdoc/auxiliary/async-trait-dep.rs @@ -1,6 +1,5 @@ // edition:2021 -#![feature(async_fn_in_trait)] #![allow(incomplete_features)] pub trait Meow { diff --git a/tests/rustdoc/auxiliary/enum-variant.rs b/tests/rustdoc/auxiliary/enum-variant.rs new file mode 100644 index 000000000..a0a7fd894 --- /dev/null +++ b/tests/rustdoc/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/auxiliary/issue-21801.rs b/tests/rustdoc/auxiliary/issue-21801.rs deleted file mode 100644 index 732612ff0..000000000 --- a/tests/rustdoc/auxiliary/issue-21801.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: -Cmetadata=aux - -pub struct Foo; - -impl Foo { - pub fn new(f: F) -> Foo where F: FnMut() -> i32 { - loop {} - } -} diff --git a/tests/rustdoc/auxiliary/issue-23207-1.rs b/tests/rustdoc/auxiliary/issue-23207-1.rs deleted file mode 100644 index 8531d5f1a..000000000 --- a/tests/rustdoc/auxiliary/issue-23207-1.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod fmt { - pub struct Error; -} diff --git a/tests/rustdoc/auxiliary/issue-23207-2.rs b/tests/rustdoc/auxiliary/issue-23207-2.rs deleted file mode 100644 index b92b16653..000000000 --- a/tests/rustdoc/auxiliary/issue-23207-2.rs +++ /dev/null @@ -1,5 +0,0 @@ -extern crate issue_23207_1; - -pub mod fmt { - pub use issue_23207_1::fmt::Error; -} diff --git a/tests/rustdoc/auxiliary/issue-27362-aux.rs b/tests/rustdoc/auxiliary/issue-27362-aux.rs deleted file mode 100644 index 077bdc33e..000000000 --- a/tests/rustdoc/auxiliary/issue-27362-aux.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -Cmetadata=aux - -pub const fn foo() {} -pub const unsafe fn bar() {} - -pub struct Foo; - -impl Foo { - pub const unsafe fn baz() {} -} diff --git a/tests/rustdoc/auxiliary/issue-29584.rs b/tests/rustdoc/auxiliary/issue-29584.rs deleted file mode 100644 index a9b8796c0..000000000 --- a/tests/rustdoc/auxiliary/issue-29584.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -Cmetadata=aux - -pub struct Foo; - -#[doc(hidden)] -mod bar { - trait Bar {} - - impl Bar for ::Foo {} -} diff --git a/tests/rustdoc/blanket-impl-29503.rs b/tests/rustdoc/blanket-impl-29503.rs new file mode 100644 index 000000000..d6a132e1c --- /dev/null +++ b/tests/rustdoc/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/blanket-reexport-item.rs b/tests/rustdoc/blanket-reexport-item.rs index 437f0001f..315a38c30 100644 --- a/tests/rustdoc/blanket-reexport-item.rs +++ b/tests/rustdoc/blanket-reexport-item.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-S"]//h3[@class="code-header"]' 'impl Into for T' +// @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 {} diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs index f50a9b96d..b6379c05a 100644 --- a/tests/rustdoc/const-effect-param.rs +++ b/tests/rustdoc/const-effect-param.rs @@ -1,3 +1,5 @@ +// Check that we don't render host effect parameters & arguments. + #![crate_name = "foo"] #![feature(effects, const_trait_impl)] diff --git a/tests/rustdoc/const-generics/add-impl.rs b/tests/rustdoc/const-generics/add-impl.rs index 195e47bc8..df490d2c6 100644 --- a/tests/rustdoc/const-generics/add-impl.rs +++ b/tests/rustdoc/const-generics/add-impl.rs @@ -7,7 +7,7 @@ pub struct Simd { inner: T, } -// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add> for Simd' +// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add for Simd' impl Add for Simd { type Output = Self; diff --git a/tests/rustdoc/const-generics/const-impl.rs b/tests/rustdoc/const-generics/const-impl.rs index 152b643bf..f4eefcc1c 100644 --- a/tests/rustdoc/const-generics/const-impl.rs +++ b/tests/rustdoc/const-generics/const-impl.rs @@ -2,7 +2,9 @@ #![feature(adt_const_params)] #![crate_name = "foo"] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] pub enum Order { Sorted, Unsorted, @@ -31,7 +33,7 @@ impl VSet { pub struct Escape; -// @has foo/struct.Escape.html '//*[@id="impl-Escape%3Cr%23%22%3Cscript%3Ealert(%22Escape%22);%3C/script%3E%22%23%3E"]/h3[@class="code-header"]' 'impl Escapealert("Escape");"#>' +// @has foo/struct.Escape.html '//*[@id="impl-Escape%3C%22%3Cscript%3Ealert(%5C%22Escape%5C%22);%3C/script%3E%22%3E"]/h3[@class="code-header"]' 'impl Escapealert("Escape");"#>' impl Escapealert("Escape");"#> { pub fn f() {} } diff --git a/tests/rustdoc/const-rendering-macros-33302.rs b/tests/rustdoc/const-rendering-macros-33302.rs new file mode 100644 index 000000000..0f5cb9214 --- /dev/null +++ b/tests/rustdoc/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/crate-version-escape.rs b/tests/rustdoc/crate-version-escape.rs index 8413709f1..f134d9baa 100644 --- a/tests/rustdoc/crate-version-escape.rs +++ b/tests/rustdoc/crate-version-escape.rs @@ -2,4 +2,4 @@ #![crate_name = "foo"] -// @has 'foo/index.html' '//li[@class="version"]' 'Version ' +// @has 'foo/index.html' '//*[@class="version"]' '' diff --git a/tests/rustdoc/crate-version-extra.rs b/tests/rustdoc/crate-version-extra.rs new file mode 100644 index 000000000..72a2c4ba5 --- /dev/null +++ b/tests/rustdoc/crate-version-extra.rs @@ -0,0 +1,7 @@ +// compile-flags: '--crate-version=1.3.37-nightly (203c57dbe 2023-09-17)' + +#![crate_name="foo"] + +// main version next to logo, extra version data below it +// @has 'foo/index.html' '//h2/span[@class="version"]' '1.3.37-nightly' +// @has 'foo/index.html' '//nav[@class="sidebar"]/div[@class="version"]' '(203c57dbe 2023-09-17)' diff --git a/tests/rustdoc/crate-version.rs b/tests/rustdoc/crate-version.rs index 2592c9853..d4be845b7 100644 --- a/tests/rustdoc/crate-version.rs +++ b/tests/rustdoc/crate-version.rs @@ -1,3 +1,3 @@ // compile-flags: --crate-version=1.3.37 -// @has 'crate_version/index.html' '//*[@class="version"]' 'Version 1.3.37' +// @has 'crate_version/index.html' '//*[@class="version"]' '1.3.37' diff --git a/tests/rustdoc/decl-trailing-whitespace.declaration.html b/tests/rustdoc/decl-trailing-whitespace.declaration.html index d73393633..59c318c16 100644 --- a/tests/rustdoc/decl-trailing-whitespace.declaration.html +++ b/tests/rustdoc/decl-trailing-whitespace.declaration.html @@ -1,22 +1,16 @@ pub trait Write { // Required methods fn poll_write( - self: Option<String>, + self, cx: &mut Option<String>, buf: &mut [usize] ) -> Option<Result<usize, Error>>; - fn poll_flush( - self: Option<String>, - cx: &mut Option<String> - ) -> Option<Result<(), Error>>; - fn poll_close( - self: Option<String>, - cx: &mut Option<String> - ) -> Option<Result<(), Error>>; + fn poll_flush(self, cx: &mut Option<String>) -> Option<Result<(), Error>>; + fn poll_close(self, cx: &mut Option<String>) -> Option<Result<(), Error>>; // Provided method fn poll_write_vectored( - self: Option<String>, + self, cx: &mut Option<String>, bufs: &[usize] ) -> Option<Result<usize, Error>> { ... } diff --git a/tests/rustdoc/decl-trailing-whitespace.rs b/tests/rustdoc/decl-trailing-whitespace.rs index d2a12435d..667837743 100644 --- a/tests/rustdoc/decl-trailing-whitespace.rs +++ b/tests/rustdoc/decl-trailing-whitespace.rs @@ -9,21 +9,21 @@ pub struct Error; pub trait Write { // @snapshot 'declaration' - '//*[@class="rust item-decl"]//code' fn poll_write( - self: Option, + self, cx: &mut Option, buf: &mut [usize] ) -> Option>; fn poll_flush( - self: Option, + self, cx: &mut Option ) -> Option>; fn poll_close( - self: Option, + self, cx: &mut Option, ) -> Option>; fn poll_write_vectored( - self: Option, + self, cx: &mut Option, bufs: &[usize] ) -> Option> {} diff --git a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs new file mode 100644 index 000000000..2a675b4b6 --- /dev/null +++ b/tests/rustdoc/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/deduplicate-trait-impl-22025.rs b/tests/rustdoc/deduplicate-trait-impl-22025.rs new file mode 100644 index 000000000..65a556e3a --- /dev/null +++ b/tests/rustdoc/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/deprecated-future-staged-api.rs b/tests/rustdoc/deprecated-future-staged-api.rs index 2670e7f5d..09120b8d4 100644 --- a/tests/rustdoc/deprecated-future-staged-api.rs +++ b/tests/rustdoc/deprecated-future-staged-api.rs @@ -1,12 +1,12 @@ #![feature(staged_api)] -#![stable(feature = "deprecated-future-staged-api", since = "1.0.0")] +#![stable(feature = "deprecated_future_staged_api", since = "1.0.0")] // @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ // 'Deprecation planned' // @has deprecated_future_staged_api/struct.S1.html '//*[@class="stab deprecated"]' \ // 'Deprecating in 99.99.99: effectively never' #[deprecated(since = "99.99.99", note = "effectively never")] -#[stable(feature = "deprecated-future-staged-api", since = "1.0.0")] +#[stable(feature = "deprecated_future_staged_api", since = "1.0.0")] pub struct S1; // @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ @@ -14,5 +14,5 @@ pub struct S1; // @has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \ // 'Deprecating in a future Rust version: literally never' #[deprecated(since = "TBD", note = "literally never")] -#[stable(feature = "deprecated-future-staged-api", since = "1.0.0")] +#[stable(feature = "deprecated_future_staged_api", since = "1.0.0")] pub struct S2; diff --git a/tests/rustdoc/deref/deref-mut-methods.rs b/tests/rustdoc/deref/deref-mut-methods.rs index fdf843422..65681f812 100644 --- a/tests/rustdoc/deref/deref-mut-methods.rs +++ b/tests/rustdoc/deref/deref-mut-methods.rs @@ -9,7 +9,7 @@ impl Foo { } // @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.foo"]' 'foo' +// @has - '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.foo"]' 'foo' pub struct Bar { foo: Foo, } diff --git a/tests/rustdoc/deref/deref-recursive-pathbuf.rs b/tests/rustdoc/deref/deref-recursive-pathbuf.rs index be2b42b5a..7aee3147b 100644 --- a/tests/rustdoc/deref/deref-recursive-pathbuf.rs +++ b/tests/rustdoc/deref/deref-recursive-pathbuf.rs @@ -8,9 +8,9 @@ // @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref' // @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' // @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.as_path"]' 'as_path' +// @has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.as_path"]' 'as_path' // @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Path"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.exists"]' 'exists' +// @has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.exists"]' 'exists' #![crate_name = "foo"] diff --git a/tests/rustdoc/disambiguate-anchors-32890.rs b/tests/rustdoc/disambiguate-anchors-32890.rs new file mode 100644 index 000000000..d88601d65 --- /dev/null +++ b/tests/rustdoc/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/disambiguate-anchors-header-29449.rs b/tests/rustdoc/disambiguate-anchors-header-29449.rs new file mode 100644 index 000000000..38a4954fc --- /dev/null +++ b/tests/rustdoc/disambiguate-anchors-header-29449.rs @@ -0,0 +1,23 @@ +// 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"]//a' 'Examples' + // @has - '//*[@id="panics"]//a' 'Panics' + /// # Examples + /// # Panics + pub fn bar() {} + + // @has - '//*[@id="examples-1"]//a' 'Examples' + /// # Examples + pub fn bar_1() {} + + // @has - '//*[@id="examples-2"]//a' 'Examples' + // @has - '//*[@id="panics-1"]//a' 'Panics' + /// # Examples + /// # Panics + pub fn bar_2() {} +} diff --git a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs new file mode 100644 index 000000000..35570668e --- /dev/null +++ b/tests/rustdoc/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/doctest-cfg-feature-30252.rs b/tests/rustdoc/doctest-cfg-feature-30252.rs new file mode 100644 index 000000000..ceb8076fe --- /dev/null +++ b/tests/rustdoc/doctest-cfg-feature-30252.rs @@ -0,0 +1,9 @@ +// compile-flags:--test --cfg feature="bar" + +// https://github.com/rust-lang/rust/issues/30252 +#![crate_name="issue_30252"] + +/// ```rust +/// assert_eq!(cfg!(feature = "bar"), true); +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest-hide-empty-line-23106.rs b/tests/rustdoc/doctest-hide-empty-line-23106.rs new file mode 100644 index 000000000..8e1e2cf09 --- /dev/null +++ b/tests/rustdoc/doctest-hide-empty-line-23106.rs @@ -0,0 +1,10 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/23106 +#![crate_name="issue_23106"] + +/// ``` +/// # +/// ``` +pub fn main() { +} diff --git a/tests/rustdoc/doctest-ignore-32556.rs b/tests/rustdoc/doctest-ignore-32556.rs new file mode 100644 index 000000000..99da9358b --- /dev/null +++ b/tests/rustdoc/doctest-ignore-32556.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/32556 +#![crate_name="issue_32556"] + +/// Blah blah blah +/// ```ignore (testing rustdoc's handling of ignore) +/// bad_assert!(); +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest-markdown-inline-parse-23744.rs b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs new file mode 100644 index 000000000..128e2daba --- /dev/null +++ b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs @@ -0,0 +1,15 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/23744 +#![crate_name="issue_23744"] + +/// Example of rustdoc incorrectly parsing ```rust,should_panic. +/// +/// ```should_panic +/// fn main() { panic!("fee"); } +/// ``` +/// +/// ```rust,should_panic +/// fn main() { panic!("fum"); } +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest-multi-line-string-literal-25944.rs b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs new file mode 100644 index 000000000..eec796e4f --- /dev/null +++ b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs @@ -0,0 +1,14 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/25944 +#![crate_name="issue_25944"] + +/// ``` +/// let a = r#" +/// foo +/// bar"#; +/// let b = "\nfoo\nbar"; +/// assert_eq!(a, b); +/// ``` +pub fn main() { +} diff --git a/tests/rustdoc/enum-variant-value.rs b/tests/rustdoc/enum-variant-value.rs new file mode 100644 index 000000000..096f8cd41 --- /dev/null +++ b/tests/rustdoc/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/extern-fn-22038.rs b/tests/rustdoc/extern-fn-22038.rs new file mode 100644 index 000000000..72d39c32a --- /dev/null +++ b/tests/rustdoc/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/generic-impl.rs b/tests/rustdoc/generic-impl.rs index 6f68b1574..f62540c6b 100644 --- a/tests/rustdoc/generic-impl.rs +++ b/tests/rustdoc/generic-impl.rs @@ -5,9 +5,9 @@ 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-Foo"]//h3[@class="code-header"]' 'impl ToString for T' +// @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-Foo"]' 'ToString' +// @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 { diff --git a/tests/rustdoc/hidden-extern-34025.rs b/tests/rustdoc/hidden-extern-34025.rs new file mode 100644 index 000000000..81ccf2a0e --- /dev/null +++ b/tests/rustdoc/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/hidden-impls.rs b/tests/rustdoc/hidden-impls.rs index 26e2e0e06..3283fbfec 100644 --- a/tests/rustdoc/hidden-impls.rs +++ b/tests/rustdoc/hidden-impls.rs @@ -12,6 +12,6 @@ pub mod __hidden { // @has foo/trait.Clone.html // @!hasraw - 'Foo' -// @has implementors/core/clone/trait.Clone.js +// @has trait.impl/core/clone/trait.Clone.js // @!hasraw - 'Foo' pub use std::clone::Clone; diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs index 6006354eb..d728f772a 100644 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs @@ -4,9 +4,11 @@ // // Read the documentation of `rustdoc::clean::utils::print_const_expr` // for further details. -#![feature(const_trait_impl, generic_const_exprs)] +#![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 @@ -29,11 +31,13 @@ pub trait Stage { // // @has - '//*[@id="associatedconstant.ARRAY1"]' \ // 'const ARRAY1: [u8; { _ }]' - const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]; + 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]; + 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 @@ -69,6 +73,7 @@ pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} pub trait Sup {} +#[derive(ConstParamTy, PartialEq, Eq)] pub struct Struct { private: () } impl Struct { diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs index 25615a73c..b91aa4120 100644 --- a/tests/rustdoc/html-no-source.rs +++ b/tests/rustdoc/html-no-source.rs @@ -11,20 +11,20 @@ // @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 · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.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 · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.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 ·' + // @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/ice-reexport-crate-root-28927.rs b/tests/rustdoc/ice-reexport-crate-root-28927.rs new file mode 100644 index 000000000..26debfc60 --- /dev/null +++ b/tests/rustdoc/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/impl-assoc-type-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs new file mode 100644 index 000000000..f01f098a9 --- /dev/null +++ b/tests/rustdoc/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-parts-crosscrate.rs b/tests/rustdoc/impl-parts-crosscrate.rs index 34733f1f8..da109ea70 100644 --- a/tests/rustdoc/impl-parts-crosscrate.rs +++ b/tests/rustdoc/impl-parts-crosscrate.rs @@ -12,7 +12,7 @@ pub struct Bar { t: T } // full impl string. Instead, just make sure something from each part // is mentioned. -// @hasraw implementors/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar +// @hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar // @hasraw - Send // @hasraw - !AnAutoTrait // @hasraw - Copy diff --git a/tests/rustdoc/impl-type-parameter-33592.rs b/tests/rustdoc/impl-type-parameter-33592.rs new file mode 100644 index 000000000..77f53710e --- /dev/null +++ b/tests/rustdoc/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/implementor-stable-version.rs b/tests/rustdoc/implementor-stable-version.rs index a1f3fd5a8..9c5b9b7e3 100644 --- a/tests/rustdoc/implementor-stable-version.rs +++ b/tests/rustdoc/implementor-stable-version.rs @@ -1,21 +1,21 @@ -#![stable(feature = "bar", since = "OLD 1.0")] +#![stable(feature = "bar", since = "3.3.3")] #![crate_name = "foo"] #![feature(staged_api)] -#[stable(feature = "bar", since = "OLD 1.0")] +#[stable(feature = "bar", since = "3.3.3")] pub trait Bar {} -#[stable(feature = "baz", since = "OLD 1.0")] +#[stable(feature = "baz", since = "3.3.3")] pub trait Baz {} -#[stable(feature = "baz", since = "OLD 1.0")] +#[stable(feature = "baz", since = "3.3.3")] pub struct Foo; -// @has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' 'NEW 2.0' -#[stable(feature = "foobar", since = "NEW 2.0")] +// @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"]' 'OLD 1.0' -#[stable(feature = "foobaz", since = "OLD 1.0")] +// @!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/inline_cross/attributes.rs b/tests/rustdoc/inline_cross/attributes.rs new file mode 100644 index 000000000..c0b75c48f --- /dev/null +++ b/tests/rustdoc/inline_cross/attributes.rs @@ -0,0 +1,7 @@ +// aux-crate:attributes=attributes.rs +// edition:2021 +#![crate_name = "user"] + +// @has 'user/struct.NonExhaustive.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]' +pub use attributes::NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs index 767564ed1..564ca7d67 100644 --- a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -1,4 +1,3 @@ -#![feature(async_fn_in_trait)] // edition: 2021 pub async fn load() -> i32 { diff --git a/tests/rustdoc/inline_cross/auxiliary/attributes.rs b/tests/rustdoc/inline_cross/auxiliary/attributes.rs new file mode 100644 index 000000000..c6f155d4b --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/attributes.rs @@ -0,0 +1,2 @@ +#[non_exhaustive] +pub struct NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs new file mode 100644 index 000000000..b0c21ffae --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs @@ -0,0 +1,16 @@ +#![feature(effects, const_trait_impl)] + +#[const_trait] +pub trait Resource {} + +pub const fn load() -> i32 { + 0 +} + +pub const fn lock() {} + +#[allow(non_upper_case_globals)] +pub trait Clash {} + +#[allow(non_upper_case_globals)] +pub const fn clash, const host: u64>() {} diff --git a/tests/rustdoc/inline_cross/auxiliary/const-fn.rs b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs deleted file mode 100644 index 26332b419..000000000 --- a/tests/rustdoc/inline_cross/auxiliary/const-fn.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(effects)] - -pub const fn load() -> i32 { - 0 -} diff --git a/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs new file mode 100644 index 000000000..1e31f1892 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs @@ -0,0 +1,45 @@ +pub type BoxedStr = Box; +pub type IntMap = std::collections::HashMap; + +pub struct TyPair(T, U); + +pub type T0 = TyPair; +pub type T1 = TyPair; +pub type T2 = TyPair; +pub type T3 = TyPair; + +pub struct CtPair; + +pub type C0 = CtPair<43, 43>; +pub type C1 = CtPair<0, 1>; +pub type C2 = CtPair<{1 + 2}, 3>; + +pub struct Re<'a, U = &'a ()>(&'a (), U); + +pub type R0<'q> = Re<'q>; +pub type R1<'q> = Re<'q, &'q ()>; +pub type R2<'q> = Re<'q, &'static ()>; +pub type H0 = fn(for<'a> fn(Re<'a>)); +pub type H1 = for<'b> fn(for<'a> fn(Re<'a, &'b ()>)); +pub type H2 = for<'a> fn(for<'b> fn(Re<'a, &'b ()>)); + +pub struct Proj::Assoc>(T, U); +pub trait Basis { type Assoc; } +impl Basis for () { type Assoc = bool; } + +pub type P0 = Proj<()>; +pub type P1 = Proj<(), bool>; +pub type P2 = Proj<(), ()>; + +pub struct Alpha fn(&'any ())>(T); + +pub type A0 = Alpha; +pub type A1 = Alpha fn(&'arbitrary ())>; + +pub struct Multi(A, B); + +pub type M0 = Multi; + +pub trait Trait<'a, T = &'a ()> {} + +pub type F = dyn for<'a> Trait<'a>; diff --git a/tests/rustdoc/inline_cross/auxiliary/fn-type.rs b/tests/rustdoc/inline_cross/auxiliary/fn-type.rs new file mode 100644 index 000000000..dacda516b --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/fn-type.rs @@ -0,0 +1 @@ +pub type F = for<'z, 'a, '_unused> fn(&'z for<'b> fn(&'b str), &'a ()) -> &'a (); diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 42cfc3dc3..fa61312eb 100644 --- a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -15,7 +15,7 @@ pub fn func4>(_x: T) {} pub fn func5( _f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other = ()>, - _a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, + _a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, ) {} pub trait Other { diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs b/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs new file mode 100644 index 000000000..732612ff0 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs @@ -0,0 +1,9 @@ +// compile-flags: -Cmetadata=aux + +pub struct Foo; + +impl Foo { + pub fn new(f: F) -> Foo where F: FnMut() -> i32 { + loop {} + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs new file mode 100644 index 000000000..8531d5f1a --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs @@ -0,0 +1,3 @@ +pub mod fmt { + pub struct Error; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs new file mode 100644 index 000000000..b92b16653 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs @@ -0,0 +1,5 @@ +extern crate issue_23207_1; + +pub mod fmt { + pub use issue_23207_1::fmt::Error; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs b/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs new file mode 100644 index 000000000..077bdc33e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs @@ -0,0 +1,10 @@ +// compile-flags: -Cmetadata=aux + +pub const fn foo() {} +pub const unsafe fn bar() {} + +pub struct Foo; + +impl Foo { + pub const unsafe fn baz() {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs new file mode 100644 index 000000000..a9b8796c0 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-29584.rs @@ -0,0 +1,10 @@ +// compile-flags: -Cmetadata=aux + +pub struct Foo; + +#[doc(hidden)] +mod bar { + trait Bar {} + + impl Bar for ::Foo {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs b/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs new file mode 100644 index 000000000..9170be168 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs @@ -0,0 +1,10 @@ +#![feature(non_lifetime_binders)] + +pub trait Trait {} + +pub fn f(_: impl for Trait) {} + +pub fn g(_: T) +where + T: for Trait, +{} diff --git a/tests/rustdoc/inline_cross/auxiliary/repr.rs b/tests/rustdoc/inline_cross/auxiliary/repr.rs index 4a6648a64..35f08c11b 100644 --- a/tests/rustdoc/inline_cross/auxiliary/repr.rs +++ b/tests/rustdoc/inline_cross/auxiliary/repr.rs @@ -10,7 +10,7 @@ pub struct ReprSimd { } #[repr(transparent)] pub struct ReprTransparent { - field: u8, + pub field: u8, } #[repr(isize)] pub enum ReprIsize { @@ -20,3 +20,23 @@ pub enum ReprIsize { pub enum ReprU8 { Bla, } + +#[repr(transparent)] // private +pub struct ReprTransparentPrivField { + field: u32, // non-1-ZST field +} + +#[repr(transparent)] // public +pub struct ReprTransparentPriv1ZstFields { + marker0: Marker, + pub main: u64, // non-1-ZST field + marker1: Marker, +} + +#[repr(transparent)] // private +pub struct ReprTransparentPrivFieldPub1ZstFields { + main: [u16; 0], // non-1-ZST field + pub marker: Marker, +} + +pub struct Marker; // 1-ZST diff --git a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs index c72f01115..08a3f5176 100644 --- a/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs +++ b/tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs @@ -1,5 +1,3 @@ -#![feature(return_position_impl_trait_in_trait)] - pub trait Trait { fn create() -> impl Iterator { std::iter::empty() diff --git a/tests/rustdoc/inline_cross/const-effect-param.rs b/tests/rustdoc/inline_cross/const-effect-param.rs new file mode 100644 index 000000000..1d003e28f --- /dev/null +++ b/tests/rustdoc/inline_cross/const-effect-param.rs @@ -0,0 +1,29 @@ +// Regression test for issue #116629. +// Check that we don't render host effect parameters & arguments. + +// aux-crate:const_effect_param=const-effect-param.rs +// edition: 2021 +#![crate_name = "user"] + +// Don't render the host param on `load` and the host arg `host` passed to `Resource`. +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn load() -> i32\ +// where \ +// R: Resource" +pub use const_effect_param::load; + +// Don't render the host arg `true` passed to `Resource`. +// @has user/fn.lock.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn lock()\ +// where \ +// R: Resource" +pub use const_effect_param::lock; + +// Regression test for an issue introduced in PR #116670. +// Don't hide the const param `host` since it actually isn't the host effect param. +// @has user/fn.clash.html +// @has - '//pre[@class="rust item-decl"]' \ +// "pub const fn clash()\ +// where \ +// T: Clash" +pub use const_effect_param::clash; diff --git a/tests/rustdoc/inline_cross/const-fn-27362.rs b/tests/rustdoc/inline_cross/const-fn-27362.rs new file mode 100644 index 000000000..39b904662 --- /dev/null +++ b/tests/rustdoc/inline_cross/const-fn-27362.rs @@ -0,0 +1,13 @@ +// aux-build:issue-27362-aux.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/27362 +#![crate_name="issue_27362"] + +extern crate issue_27362_aux; + +pub use issue_27362_aux::*; + +// @matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" +// @matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" +// @matches issue_27362/struct.Foo.html '//h4[@class="code-header"]' "const unsafe fn baz()" diff --git a/tests/rustdoc/inline_cross/const-fn.rs b/tests/rustdoc/inline_cross/const-fn.rs deleted file mode 100644 index 24934b873..000000000 --- a/tests/rustdoc/inline_cross/const-fn.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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/deduplicate-inlined-items-23207.rs b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs new file mode 100644 index 000000000..4e9596db5 --- /dev/null +++ b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs @@ -0,0 +1,12 @@ +// aux-build:issue-23207-1.rs +// aux-build:issue-23207-2.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/23207 +#![crate_name="issue_23207"] + +extern crate issue_23207_2; + +// @has issue_23207/fmt/index.html +// @count - '//*[@class="struct"]' 1 +pub use issue_23207_2::fmt; diff --git a/tests/rustdoc/inline_cross/default-generic-args.rs b/tests/rustdoc/inline_cross/default-generic-args.rs new file mode 100644 index 000000000..c9a87a199 --- /dev/null +++ b/tests/rustdoc/inline_cross/default-generic-args.rs @@ -0,0 +1,104 @@ +#![crate_name = "user"] +// aux-crate:default_generic_args=default-generic-args.rs +// edition:2021 + +// @has user/type.BoxedStr.html +// @has - '//*[@class="rust item-decl"]//code' "Box" +pub use default_generic_args::BoxedStr; + +// @has user/type.IntMap.html +// @has - '//*[@class="rust item-decl"]//code' "HashMap" +pub use default_generic_args::IntMap; + +// @has user/type.T0.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair" +pub use default_generic_args::T0; + +// @has user/type.T1.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair" +pub use default_generic_args::T1; + +// @has user/type.T2.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair" +pub use default_generic_args::T2; + +// @has user/type.T3.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair" +pub use default_generic_args::T3; + +// @has user/type.C0.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<43>" +pub use default_generic_args::C0; + +// @has user/type.C1.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<0, 1>" +pub use default_generic_args::C1; + +// @has user/type.C2.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair" +pub use default_generic_args::C2; + +// @has user/type.R0.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R0; + +// @has user/type.R1.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R1; + +// @has user/type.R2.html +// Check that we consider regions: +// @has - '//*[@class="rust item-decl"]//code' "Re<'q, &'static ()>" +pub use default_generic_args::R2; + +// @has user/type.H0.html +// Check that we handle higher-ranked regions correctly: +// @has - '//*[@class="rust item-decl"]//code' "fn(_: for<'a> fn(_: Re<'a>))" +pub use default_generic_args::H0; + +// @has user/type.H1.html +// Check that we don't conflate distinct universially quantified regions (#1): +// @has - '//*[@class="rust item-decl"]//code' "for<'b> fn(_: for<'a> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H1; + +// @has user/type.H2.html +// Check that we don't conflate distinct universially quantified regions (#2): +// @has - '//*[@class="rust item-decl"]//code' "for<'a> fn(_: for<'b> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H2; + +// @has user/type.P0.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<()>" +pub use default_generic_args::P0; + +// @has user/type.P1.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), bool>" +pub use default_generic_args::P1; + +// @has user/type.P2.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), ()>" +pub use default_generic_args::P2; + +// @has user/type.A0.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A0; + +// @has user/type.A1.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A1; + +// @has user/type.M0.html +// Test that we don't elide `u64` even if it coincides with `A`'s default precisely because +// `()` is not the default of `B`. Mindlessly eliding `u64` would lead to `M<()>` which is a +// different type (`M<(), u64>` versus `M`). +// @has - '//*[@class="rust item-decl"]//code' "Multi" +pub use default_generic_args::M0; + +// @has user/type.F.html +// FIXME: Ideally, we would elide `&'a ()` but `'a` is an escaping bound var which we can't reason +// about at the moment since we don't keep track of bound vars. +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait<'a, &'a ()>" +pub use default_generic_args::F; diff --git a/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs new file mode 100644 index 000000000..b246e94e0 --- /dev/null +++ b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs @@ -0,0 +1,11 @@ +// aux-build:issue-29584.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/29584 +#![crate_name="issue_29584"] + +extern crate issue_29584; + +// @has issue_29584/struct.Foo.html +// @!hasraw - 'impl Bar for' +pub use issue_29584::Foo; diff --git a/tests/rustdoc/inline_cross/dyn_trait.rs b/tests/rustdoc/inline_cross/dyn_trait.rs index 679972f03..9871be79c 100644 --- a/tests/rustdoc/inline_cross/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/dyn_trait.rs @@ -75,16 +75,16 @@ pub use dyn_trait::AmbiguousBoundWrappedEarly1; pub use dyn_trait::AmbiguousBoundWrappedStatic; // @has user/type.NoBoundsWrappedDefaulted.html -// @has - '//*[@class="rust item-decl"]//code' "Box;" +// @has - '//*[@class="rust item-decl"]//code' "Box;" pub use dyn_trait::NoBoundsWrappedDefaulted; // @has user/type.NoBoundsWrappedEarly.html -// @has - '//*[@class="rust item-decl"]//code' "Box;" +// @has - '//*[@class="rust item-decl"]//code' "Box;" pub use dyn_trait::NoBoundsWrappedEarly; // @has user/fn.nbwl.html -// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box)" +// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box)" pub use dyn_trait::no_bounds_wrapped_late as nbwl; // @has user/fn.nbwel.html -// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box)" +// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box)" // NB: It might seem counterintuitive to display the explicitly elided lifetime `'_` here instead of // eliding it but this behavior is correct: The default is `'static` here which != `'_`. pub use dyn_trait::no_bounds_wrapped_elided as nbwel; diff --git a/tests/rustdoc/inline_cross/fn-type.rs b/tests/rustdoc/inline_cross/fn-type.rs new file mode 100644 index 000000000..e65790d3b --- /dev/null +++ b/tests/rustdoc/inline_cross/fn-type.rs @@ -0,0 +1,12 @@ +// Make sure that we print the higher-ranked parameters of cross-crate function pointer types. +// They should be rendered exactly as the user wrote it, i.e., in source order and with unused +// parameters present, not stripped. + +// aux-crate:fn_type=fn-type.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/type.F.html +// @has - '//*[@class="rust item-decl"]//code' \ +// "for<'z, 'a, '_unused> fn(_: &'z for<'b> fn(_: &'b str), _: &'a ()) -> &'a ();" +pub use fn_type::F; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index 5c802c514..3a2f5d160 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -4,7 +4,7 @@ extern crate impl_trait_aux; // @has impl_trait/fn.func.html -// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into> + 'a)" +// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into> + 'a)" // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func; @@ -29,11 +29,11 @@ pub use impl_trait_aux::func4; // @has impl_trait/fn.func5.html // @has - '//pre[@class="rust item-decl"]' "func5(" // @has - '//pre[@class="rust item-decl"]' "_f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other = ()>," -// @has - '//pre[@class="rust item-decl"]' "_a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" +// @has - '//pre[@class="rust item-decl"]' "_a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; // @has impl_trait/struct.Foo.html -// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into> + 'a)" +// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; diff --git a/tests/rustdoc/inline_cross/implementors-js.rs b/tests/rustdoc/inline_cross/implementors-js.rs index c79f05d8d..c17d52d0f 100644 --- a/tests/rustdoc/inline_cross/implementors-js.rs +++ b/tests/rustdoc/inline_cross/implementors-js.rs @@ -4,13 +4,13 @@ extern crate implementors_inline; -// @!has implementors/implementors_js/trait.MyTrait.js -// @has implementors/implementors_inline/my_trait/trait.MyTrait.js -// @!has implementors/implementors_inline/prelude/trait.MyTrait.js +// @!has trait.impl/implementors_js/trait.MyTrait.js +// @has trait.impl/implementors_inline/my_trait/trait.MyTrait.js +// @!has trait.impl/implementors_inline/prelude/trait.MyTrait.js // @has implementors_inline/my_trait/trait.MyTrait.html -// @has - '//script/@src' '../../implementors/implementors_inline/my_trait/trait.MyTrait.js' +// @has - '//script/@src' '../../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' // @has implementors_js/trait.MyTrait.html -// @has - '//script/@src' '../implementors/implementors_inline/my_trait/trait.MyTrait.js' +// @has - '//script/@src' '../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' /// When re-exporting this trait, the HTML will be inlined, /// but, vitally, the JavaScript will be located only at the /// one canonical path. diff --git a/tests/rustdoc/inline_cross/non_lifetime_binders.rs b/tests/rustdoc/inline_cross/non_lifetime_binders.rs new file mode 100644 index 000000000..9d3085c3e --- /dev/null +++ b/tests/rustdoc/inline_cross/non_lifetime_binders.rs @@ -0,0 +1,13 @@ +// aux-crate:non_lifetime_binders=non_lifetime_binders.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.f.html +// @has - '//pre[@class="rust item-decl"]' "f(_: impl for Trait)" +pub use non_lifetime_binders::f; + +// @has user/fn.g.html +// @has - '//pre[@class="rust item-decl"]' "g(_: T)\ +// where \ +// T: for Trait" +pub use non_lifetime_binders::g; diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs index 9e107cee9..2f3d8f003 100644 --- a/tests/rustdoc/inline_cross/repr.rs +++ b/tests/rustdoc/inline_cross/repr.rs @@ -9,21 +9,32 @@ extern crate repr; // @has 'foo/struct.ReprC.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' -#[doc(inline)] pub use repr::ReprC; // @has 'foo/struct.ReprSimd.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' -#[doc(inline)] pub use repr::ReprSimd; // @has 'foo/struct.ReprTransparent.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' -#[doc(inline)] pub use repr::ReprTransparent; // @has 'foo/enum.ReprIsize.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' -#[doc(inline)] pub use repr::ReprIsize; // @has 'foo/enum.ReprU8.html' // @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' -#[doc(inline)] pub use repr::ReprU8; + +// Regression test for . +// Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one +// field is public in case all fields are 1-ZST fields. + +// @has 'foo/struct.ReprTransparentPrivField.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivField; + +// @has 'foo/struct.ReprTransparentPriv1ZstFields.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPriv1ZstFields; + +// @has 'foo/struct.ReprTransparentPrivFieldPub1ZstFields.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +pub use repr::ReprTransparentPrivFieldPub1ZstFields; diff --git a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs new file mode 100644 index 000000000..bcbb2e9f4 --- /dev/null +++ b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs @@ -0,0 +1,12 @@ +// aux-build:issue-21801.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/21801 +#![crate_name="issue_21801"] + +extern crate issue_21801; + +// @has issue_21801/struct.Foo.html +// @has - '//*[@id="method.new"]' \ +// 'fn new(f: F) -> Foowhere F: FnMut() -> i32' +pub use issue_21801::Foo; diff --git a/tests/rustdoc/intra-doc/prim-associated-traits.rs b/tests/rustdoc/intra-doc/prim-associated-traits.rs index 8639a24f7..71d7d2189 100644 --- a/tests/rustdoc/intra-doc/prim-associated-traits.rs +++ b/tests/rustdoc/intra-doc/prim-associated-traits.rs @@ -41,6 +41,6 @@ pub struct Number { pub u_128: u128, pub ch: char, pub boolean: bool, - pub string: str, + pub string: &'static str, pub n: !, } diff --git a/tests/rustdoc/issue-112515-impl-ty-alias.rs b/tests/rustdoc/issue-112515-impl-ty-alias.rs deleted file mode 100644 index 161188ee5..000000000 --- a/tests/rustdoc/issue-112515-impl-ty-alias.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Regression test for . -// It's to ensure that this code doesn't have infinite loop in rustdoc when -// trying to retrive type alias implementations. - -// ignore-tidy-linelength - -pub type Boom = S, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>; -pub struct S(T, U); - -pub trait A {} - -pub trait B { - type P; -} - -impl A for u64 {} - -impl A for S {} - -impl B for S -where - T: B, - >::P: A, -{ - type P = (); -} - -impl B for S { - type P = (); -} diff --git a/tests/rustdoc/issue-115295-macro-const-display.rs b/tests/rustdoc/issue-115295-macro-const-display.rs new file mode 100644 index 000000000..2916c7a84 --- /dev/null +++ b/tests/rustdoc/issue-115295-macro-const-display.rs @@ -0,0 +1,40 @@ +#![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/issue-21092.rs b/tests/rustdoc/issue-21092.rs deleted file mode 100644 index b054145a4..000000000 --- a/tests/rustdoc/issue-21092.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:issue-21092.rs -// ignore-cross-compile - -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/issue-21474.rs b/tests/rustdoc/issue-21474.rs deleted file mode 100644 index 5de26abac..000000000 --- a/tests/rustdoc/issue-21474.rs +++ /dev/null @@ -1,11 +0,0 @@ -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/issue-21801.rs b/tests/rustdoc/issue-21801.rs deleted file mode 100644 index 29d2ec64c..000000000 --- a/tests/rustdoc/issue-21801.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:issue-21801.rs -// ignore-cross-compile - -extern crate issue_21801; - -// @has issue_21801/struct.Foo.html -// @has - '//*[@id="method.new"]' \ -// 'fn new(f: F) -> Foowhere F: FnMut() -> i32' -pub use issue_21801::Foo; diff --git a/tests/rustdoc/issue-22025.rs b/tests/rustdoc/issue-22025.rs deleted file mode 100644 index a721a15f4..000000000 --- a/tests/rustdoc/issue-22025.rs +++ /dev/null @@ -1,6 +0,0 @@ -// aux-build:issue-22025.rs -// ignore-cross-compile - -extern crate issue_22025; - -pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/issue-22038.rs b/tests/rustdoc/issue-22038.rs deleted file mode 100644 index de6cc7870..000000000 --- a/tests/rustdoc/issue-22038.rs +++ /dev/null @@ -1,19 +0,0 @@ -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/issue-23106.rs b/tests/rustdoc/issue-23106.rs deleted file mode 100644 index 8cda2fc33..000000000 --- a/tests/rustdoc/issue-23106.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags:--test - -/// ``` -/// # -/// ``` -pub fn main() { -} diff --git a/tests/rustdoc/issue-23207.rs b/tests/rustdoc/issue-23207.rs deleted file mode 100644 index 1a4b849ee..000000000 --- a/tests/rustdoc/issue-23207.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:issue-23207-1.rs -// aux-build:issue-23207-2.rs -// ignore-cross-compile - -extern crate issue_23207_2; - -// @has issue_23207/fmt/index.html -// @count - '//*[@class="struct"]' 1 -pub use issue_23207_2::fmt; diff --git a/tests/rustdoc/issue-23511.rs b/tests/rustdoc/issue-23511.rs deleted file mode 100644 index 21d028424..000000000 --- a/tests/rustdoc/issue-23511.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] -#![feature(rustdoc_internals)] -#![no_std] - -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/issue-23744.rs b/tests/rustdoc/issue-23744.rs deleted file mode 100644 index 642817396..000000000 --- a/tests/rustdoc/issue-23744.rs +++ /dev/null @@ -1,12 +0,0 @@ -// compile-flags:--test - -/// Example of rustdoc incorrectly parsing ```rust,should_panic. -/// -/// ```should_panic -/// fn main() { panic!("fee"); } -/// ``` -/// -/// ```rust,should_panic -/// fn main() { panic!("fum"); } -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/issue-23812.rs b/tests/rustdoc/issue-23812.rs deleted file mode 100644 index 08fd1833b..000000000 --- a/tests/rustdoc/issue-23812.rs +++ /dev/null @@ -1,36 +0,0 @@ -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/issue-25001.rs b/tests/rustdoc/issue-25001.rs deleted file mode 100644 index 268fae594..000000000 --- a/tests/rustdoc/issue-25001.rs +++ /dev/null @@ -1,43 +0,0 @@ -// @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-1"]//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"]//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/issue-25944.rs b/tests/rustdoc/issue-25944.rs deleted file mode 100644 index 49625294b..000000000 --- a/tests/rustdoc/issue-25944.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags:--test - -/// ``` -/// let a = r#" -/// foo -/// bar"#; -/// let b = "\nfoo\nbar"; -/// assert_eq!(a, b); -/// ``` -pub fn main() { -} diff --git a/tests/rustdoc/issue-26606.rs b/tests/rustdoc/issue-26606.rs deleted file mode 100644 index d5cb2c710..000000000 --- a/tests/rustdoc/issue-26606.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:issue-26606-macro.rs -// ignore-cross-compile -// build-aux-docs - -// @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/issue-26606.rs.html#11"]' 'source' -make_item!(FOO); diff --git a/tests/rustdoc/issue-26995.rs b/tests/rustdoc/issue-26995.rs deleted file mode 100644 index fedc9f517..000000000 --- a/tests/rustdoc/issue-26995.rs +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-windows -// compile-flags: --no-defaults - -// @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/issue-27104.rs b/tests/rustdoc/issue-27104.rs deleted file mode 100644 index 9f2fd9071..000000000 --- a/tests/rustdoc/issue-27104.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags:--no-defaults --passes strip-priv-imports -// aux-build:empty.rs -// ignore-cross-compile - -// @has issue_27104/index.html -// @!hasraw - 'extern crate std' -// @!hasraw - 'use std::prelude::' - -// @hasraw - 'pub extern crate empty' -pub extern crate empty; diff --git a/tests/rustdoc/issue-27362.rs b/tests/rustdoc/issue-27362.rs deleted file mode 100644 index 097e4e3b0..000000000 --- a/tests/rustdoc/issue-27362.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:issue-27362-aux.rs -// ignore-cross-compile - -extern crate issue_27362_aux; - -pub use issue_27362_aux::*; - -// @matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" -// @matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" -// @matches issue_27362/struct.Foo.html '//h4[@class="code-header"]' "const unsafe fn baz()" diff --git a/tests/rustdoc/issue-27759.rs b/tests/rustdoc/issue-27759.rs deleted file mode 100644 index 65e0f7cb8..000000000 --- a/tests/rustdoc/issue-27759.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(staged_api)] -#![doc(issue_tracker_base_url = "http://issue_url/")] - -#![unstable(feature="test", issue="27759")] - -// @has issue_27759/unstable/index.html -// @hasraw - 'test #27759' -#[unstable(feature="test", issue="27759")] -pub mod unstable { - // @has issue_27759/unstable/fn.issue.html - // @hasraw - 'test_function #12345' - #[unstable(feature="test_function", issue="12345")] - pub fn issue() {} -} diff --git a/tests/rustdoc/issue-27862.rs b/tests/rustdoc/issue-27862.rs deleted file mode 100644 index 77522f1be..000000000 --- a/tests/rustdoc/issue-27862.rs +++ /dev/null @@ -1,4 +0,0 @@ -/// Tests | Table -/// ------|------------- -/// t = b | id = \|x\| x -pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x' diff --git a/tests/rustdoc/issue-28478.rs b/tests/rustdoc/issue-28478.rs deleted file mode 100644 index 497276e68..000000000 --- a/tests/rustdoc/issue-28478.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![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/issue-28927.rs b/tests/rustdoc/issue-28927.rs deleted file mode 100644 index 38a520850..000000000 --- a/tests/rustdoc/issue-28927.rs +++ /dev/null @@ -1,6 +0,0 @@ -// aux-build:issue-28927-2.rs -// aux-build:issue-28927-1.rs -// ignore-cross-compile - -pub extern crate issue_28927_1 as inner1; -pub use inner1 as foo; diff --git a/tests/rustdoc/issue-29449.rs b/tests/rustdoc/issue-29449.rs deleted file mode 100644 index 0d829cf6f..000000000 --- a/tests/rustdoc/issue-29449.rs +++ /dev/null @@ -1,20 +0,0 @@ -// @has issue_29449/struct.Foo.html -pub struct Foo; - -impl Foo { - // @has - '//*[@id="examples"]//a' 'Examples' - // @has - '//*[@id="panics"]//a' 'Panics' - /// # Examples - /// # Panics - pub fn bar() {} - - // @has - '//*[@id="examples-1"]//a' 'Examples' - /// # Examples - pub fn bar_1() {} - - // @has - '//*[@id="examples-2"]//a' 'Examples' - // @has - '//*[@id="panics-1"]//a' 'Panics' - /// # Examples - /// # Panics - pub fn bar_2() {} -} diff --git a/tests/rustdoc/issue-29503.rs b/tests/rustdoc/issue-29503.rs deleted file mode 100644 index 01ae44385..000000000 --- a/tests/rustdoc/issue-29503.rs +++ /dev/null @@ -1,18 +0,0 @@ -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/issue-29584.rs b/tests/rustdoc/issue-29584.rs deleted file mode 100644 index 4364a9649..000000000 --- a/tests/rustdoc/issue-29584.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:issue-29584.rs -// ignore-cross-compile - -extern crate issue_29584; - -// @has issue_29584/struct.Foo.html -// @!hasraw - 'impl Bar for' -pub use issue_29584::Foo; diff --git a/tests/rustdoc/issue-30109.rs b/tests/rustdoc/issue-30109.rs deleted file mode 100644 index e9447538a..000000000 --- a/tests/rustdoc/issue-30109.rs +++ /dev/null @@ -1,14 +0,0 @@ -// build-aux-docs -// aux-build:issue-30109-1.rs -// ignore-cross-compile - -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/issue-30252.rs b/tests/rustdoc/issue-30252.rs deleted file mode 100644 index c3777362a..000000000 --- a/tests/rustdoc/issue-30252.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags:--test --cfg feature="bar" - -/// ```rust -/// assert_eq!(cfg!(feature = "bar"), true); -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/issue-30366.rs b/tests/rustdoc/issue-30366.rs deleted file mode 100644 index c6274a058..000000000 --- a/tests/rustdoc/issue-30366.rs +++ /dev/null @@ -1,6 +0,0 @@ -// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' - -/// Describe it. [Link somewhere][1]. -/// -/// [1]: http://www.rust-lang.org/ -pub fn here_is_a_fn() { } diff --git a/tests/rustdoc/issue-31808.rs b/tests/rustdoc/issue-31808.rs deleted file mode 100644 index e55c5bd4f..000000000 --- a/tests/rustdoc/issue-31808.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Test that associated item impls on primitive types don't crash rustdoc - -pub trait Foo { - const BAR: usize; - type BAZ; -} - -impl Foo for () { - const BAR: usize = 0; - type BAZ = usize; -} diff --git a/tests/rustdoc/issue-31899.rs b/tests/rustdoc/issue-31899.rs deleted file mode 100644 index 3eee37446..000000000 --- a/tests/rustdoc/issue-31899.rs +++ /dev/null @@ -1,59 +0,0 @@ -// @has issue_31899/index.html -// @hasraw - 'Make this line a bit longer.' -// @!hasraw - 'rust rust-example-rendered' -// @!hasraw - 'use ndarray::arr2' -// @!hasraw - 'prohibited' - -/// A tuple or fixed size array that can be used to index an array. -/// Make this line a bit longer. -/// -/// ``` -/// use ndarray::arr2; -/// -/// let mut a = arr2(&[[0, 1], [0, 0]]); -/// a[[1, 1]] = 1; -/// assert_eq!(a[[0, 1]], 1); -/// assert_eq!(a[[1, 1]], 1); -/// ``` -/// -/// **Note** the blanket implementation that's not visible in rustdoc: -/// `impl NdIndex for D where D: Dimension { ... }` -pub fn bar() {} - -/// Some line -/// -/// # prohibited -pub fn foo() {} - -/// Some line -/// -/// 1. prohibited -/// 2. bar -pub fn baz() {} - -/// Some line -/// -/// - prohibited -/// - bar -pub fn qux() {} - -/// Some line -/// -/// * prohibited -/// * bar -pub fn quz() {} - -/// Some line -/// -/// > prohibited -/// > bar -pub fn qur() {} - -/// Some line -/// -/// prohibited -/// ===== -/// -/// Second -/// ------ -pub fn qut() {} diff --git a/tests/rustdoc/issue-32077-type-alias-impls.rs b/tests/rustdoc/issue-32077-type-alias-impls.rs deleted file mode 100644 index ac486c36a..000000000 --- a/tests/rustdoc/issue-32077-type-alias-impls.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Regression test for . - -#![crate_name = "foo"] - -pub struct GenericStruct(T); - -impl GenericStruct { - pub fn on_gen(arg: T) {} -} - -impl GenericStruct { - pub fn on_u32(arg: u32) {} -} - -pub trait Foo {} -pub trait Bar {} - -impl Foo for GenericStruct {} -impl Bar for GenericStruct {} - -// @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 GenericStruct' -// @has - '//*[@id="method.on_gen"]/h4' 'pub fn on_gen(arg: T)' -// @has - '//*[@id="impl-Foo-for-GenericStruct%3CT%3E"]/h3' 'impl Foo for GenericStruct' -// This trait implementation doesn't match the type alias parameters so shouldn't appear in docs. -// @!has - '//h3' 'impl Bar for GenericStruct {}' -// Same goes for the `Deref` impl. -// @!has - '//h2' 'Methods from Deref' -// @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; - -impl TypedefStruct { - pub fn on_alias() {} -} - -impl std::ops::Deref for GenericStruct { - type Target = u32; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -pub struct Wrap(GenericStruct); - -// @has 'foo/type.Alias.html' -// @has - '//h2' 'Methods from Deref' -// @has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl Deref for Wrap' -pub type Alias = Wrap; - -impl std::ops::Deref for Wrap { - type Target = GenericStruct; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} diff --git a/tests/rustdoc/issue-32374.rs b/tests/rustdoc/issue-32374.rs deleted file mode 100644 index 985bf03a1..000000000 --- a/tests/rustdoc/issue-32374.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(staged_api)] -#![doc(issue_tracker_base_url = "https://issue_url/")] -#![unstable(feature = "test", issue = "32374")] - -// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ -// 'Deprecated' -// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab unstable"]' \ -// 'Experimental' -// @matches issue_32374/index.html '//*[@class="desc docblock-short"]/text()' 'Docs' - -// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎' -// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \ -// 'Deprecated since 1.0.0: text' -// @hasraw - 'test #32374' -// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬' -// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ -// 'This is a nightly-only experimental API. \(test\s#32374\)$' -/// Docs -#[deprecated(since = "1.0.0", note = "text")] -#[unstable(feature = "test", issue = "32374")] -pub struct T; - -// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎' -// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ -// 'Deprecated since 1.0.0: deprecated' -// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬' -// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ -// 'This is a nightly-only experimental API. (test #32374)' -#[deprecated(since = "1.0.0", note = "deprecated")] -#[unstable(feature = "test", issue = "32374", reason = "unstable")] -pub struct U; diff --git a/tests/rustdoc/issue-32395.rs b/tests/rustdoc/issue-32395.rs deleted file mode 100644 index 5552300f9..000000000 --- a/tests/rustdoc/issue-32395.rs +++ /dev/null @@ -1,15 +0,0 @@ -// aux-build:variant-struct.rs -// build-aux-docs -// ignore-cross-compile - -// @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/issue-32556.rs b/tests/rustdoc/issue-32556.rs deleted file mode 100644 index e1cf11509..000000000 --- a/tests/rustdoc/issue-32556.rs +++ /dev/null @@ -1,5 +0,0 @@ -/// Blah blah blah -/// ```ignore (testing rustdoc's handling of ignore) -/// bad_assert!(); -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/issue-32890.rs b/tests/rustdoc/issue-32890.rs deleted file mode 100644 index 970954433..000000000 --- a/tests/rustdoc/issue-32890.rs +++ /dev/null @@ -1,17 +0,0 @@ -// @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/issue-33069.rs b/tests/rustdoc/issue-33069.rs deleted file mode 100644 index 0213a53ca..000000000 --- a/tests/rustdoc/issue-33069.rs +++ /dev/null @@ -1,10 +0,0 @@ -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/issue-33178-1.rs b/tests/rustdoc/issue-33178-1.rs deleted file mode 100644 index 4dc425346..000000000 --- a/tests/rustdoc/issue-33178-1.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:empty.rs -// aux-build:variant-struct.rs -// ignore-cross-compile - -// @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/issue-33178.rs b/tests/rustdoc/issue-33178.rs deleted file mode 100644 index ed643f5ae..000000000 --- a/tests/rustdoc/issue-33178.rs +++ /dev/null @@ -1,14 +0,0 @@ -// aux-build:empty.rs -// aux-build:variant-struct.rs -// build-aux-docs -// ignore-cross-compile - -// @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/issue-33302.rs b/tests/rustdoc/issue-33302.rs deleted file mode 100644 index a316f3ad9..000000000 --- a/tests/rustdoc/issue-33302.rs +++ /dev/null @@ -1,51 +0,0 @@ -// 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/issue-33592.rs b/tests/rustdoc/issue-33592.rs deleted file mode 100644 index 7a128f0b8..000000000 --- a/tests/rustdoc/issue-33592.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![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/issue-34025.rs b/tests/rustdoc/issue-34025.rs deleted file mode 100644 index 9b9f21cb3..000000000 --- a/tests/rustdoc/issue-34025.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![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/issue-34274.rs b/tests/rustdoc/issue-34274.rs deleted file mode 100644 index ce5be84a5..000000000 --- a/tests/rustdoc/issue-34274.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:issue-34274.rs -// build-aux-docs -// ignore-cross-compile - -#![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/issue-43701.rs b/tests/rustdoc/issue-43701.rs index 44335e961..de772881e 100644 --- a/tests/rustdoc/issue-43701.rs +++ b/tests/rustdoc/issue-43701.rs @@ -2,4 +2,4 @@ pub use std::vec::Vec; -// @!has implementors/core/clone/trait.Clone.js +// @!has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/issue-78701.rs b/tests/rustdoc/issue-78701.rs index e3e46468f..3f1638d5f 100644 --- a/tests/rustdoc/issue-78701.rs +++ b/tests/rustdoc/issue-78701.rs @@ -6,7 +6,7 @@ // @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-AnotherStruct%3CT%3E"]' 1 +// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 pub trait Something {} diff --git a/tests/rustdoc/link-extern-crate-33178.rs b/tests/rustdoc/link-extern-crate-33178.rs new file mode 100644 index 000000000..6a63712c4 --- /dev/null +++ b/tests/rustdoc/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/link-extern-crate-item-30109.rs b/tests/rustdoc/link-extern-crate-item-30109.rs new file mode 100644 index 000000000..c83234352 --- /dev/null +++ b/tests/rustdoc/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/link-extern-crate-title-33178.rs b/tests/rustdoc/link-extern-crate-title-33178.rs new file mode 100644 index 000000000..d2f115a38 --- /dev/null +++ b/tests/rustdoc/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/logo-class-default.rs b/tests/rustdoc/logo-class-default.rs index d2d439199..6b46b4605 100644 --- a/tests/rustdoc/logo-class-default.rs +++ b/tests/rustdoc/logo-class-default.rs @@ -1,4 +1,4 @@ -// Note: this test is paired with logo-class.rs. -// @has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' -// @has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +// Note: this test is paired with logo-class.rs and logo-class-rust.rs. +// @!has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img' '' +// @!has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img' '' pub struct SomeStruct; diff --git a/tests/rustdoc/logo-class-rust.rs b/tests/rustdoc/logo-class-rust.rs new file mode 100644 index 000000000..d4f6113c0 --- /dev/null +++ b/tests/rustdoc/logo-class-rust.rs @@ -0,0 +1,7 @@ +#![feature(rustdoc_internals)] +#![allow(internal_features)] +#![doc(rust_logo)] +// Note: this test is paired with logo-class.rs and logo-class-default.rs. +// @has logo_class_rust/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' +// @has src/logo_class_rust/logo-class-rust.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +pub struct SomeStruct; diff --git a/tests/rustdoc/logo-class.rs b/tests/rustdoc/logo-class.rs index d3aa446da..d15ce134c 100644 --- a/tests/rustdoc/logo-class.rs +++ b/tests/rustdoc/logo-class.rs @@ -1,6 +1,6 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png")] -// Note: this test is paired with logo-class-default.rs. +// Note: this test is paired with logo-class-default.rs and logo-class-rust.rs. // @has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' // @!has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' diff --git a/tests/rustdoc/macro-doc-comment-23812.rs b/tests/rustdoc/macro-doc-comment-23812.rs new file mode 100644 index 000000000..57c18510b --- /dev/null +++ b/tests/rustdoc/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/markdown-table-escape-pipe-27862.rs b/tests/rustdoc/markdown-table-escape-pipe-27862.rs new file mode 100644 index 000000000..9af75d248 --- /dev/null +++ b/tests/rustdoc/markdown-table-escape-pipe-27862.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/27862 +#![crate_name="issue_27862"] + +/// Tests | Table +/// ------|------------- +/// t = b | id = \|x\| x +pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x' diff --git a/tests/rustdoc/normalize-assoc-item.rs b/tests/rustdoc/normalize-assoc-item.rs index c6fd5e110..d39e1b15a 100644 --- a/tests/rustdoc/normalize-assoc-item.rs +++ b/tests/rustdoc/normalize-assoc-item.rs @@ -30,7 +30,7 @@ pub fn f2() -> ::X { } pub struct S { - // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box' + // @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, @@ -76,7 +76,7 @@ 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" +// @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/not-wf-ambiguous-normalization.rs b/tests/rustdoc/not-wf-ambiguous-normalization.rs deleted file mode 100644 index 1e9f925f8..000000000 --- a/tests/rustdoc/not-wf-ambiguous-normalization.rs +++ /dev/null @@ -1,24 +0,0 @@ -// compile-flags: -Znormalize-docs - -#![feature(type_alias_impl_trait)] - -trait Allocator { - type Buffer; -} - -struct DefaultAllocator; - -// This unconstrained impl parameter causes the normalization of -// `::Buffer` to be ambiguous, -// which caused an ICE with `-Znormalize-docs`. -impl Allocator for DefaultAllocator { - type Buffer = (); -} - -type A = impl Fn(::Buffer); - -fn foo() -> A { - |_| () -} - -fn main() {} diff --git a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs index 3fb00c7db..6b94d7994 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs @@ -3,25 +3,28 @@ #![feature(no_core)] #![no_core] #[lang = "owned_box"] -pub struct Box; +pub struct Box(*const T); impl Box { pub fn new(x: T) -> Box { - Box + Box(std::ptr::null()) } } +#[lang = "sized"] +trait Sized {} + #[doc(notable_trait)] pub trait FakeIterator {} impl FakeIterator for Box {} #[lang = "pin"] -pub struct Pin; +pub struct Pin(T); impl Pin { pub fn new(x: T) -> Pin { - Pin + Pin(x) } } diff --git a/tests/rustdoc/primitive/primitive-generic-impl.rs b/tests/rustdoc/primitive/primitive-generic-impl.rs index 2da8ae6ff..558336d73 100644 --- a/tests/rustdoc/primitive/primitive-generic-impl.rs +++ b/tests/rustdoc/primitive/primitive-generic-impl.rs @@ -1,7 +1,7 @@ #![feature(rustc_attrs)] #![crate_name = "foo"] -// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-i32"]//h3[@class="code-header"]' 'impl ToString for T' +// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl ToString for T' #[rustc_doc_primitive = "i32"] /// Some useless docs, wouhou! diff --git a/tests/rustdoc/render-enum-variant-structlike-32395.rs b/tests/rustdoc/render-enum-variant-structlike-32395.rs new file mode 100644 index 000000000..2200d8ec6 --- /dev/null +++ b/tests/rustdoc/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/repr.rs b/tests/rustdoc/repr.rs new file mode 100644 index 000000000..fbb46e126 --- /dev/null +++ b/tests/rustdoc/repr.rs @@ -0,0 +1,29 @@ +// Regression test for . +// Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one +// field is public in case all fields are 1-ZST fields. + +// @has 'repr/struct.ReprTransparentPrivField.html' +// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // private +pub struct ReprTransparentPrivField { + field: u32, // non-1-ZST field +} + +// @has 'repr/struct.ReprTransparentPriv1ZstFields.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // public +pub struct ReprTransparentPriv1ZstFields { + marker0: Marker, + pub main: u64, // non-1-ZST field + marker1: Marker, +} + +// @has 'repr/struct.ReprTransparentPub1ZstField.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[repr(transparent)] // public +pub struct ReprTransparentPub1ZstField { + marker0: Marker, + pub marker1: Marker, +} + +struct Marker; // 1-ZST diff --git a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs new file mode 100644 index 000000000..1d0fe27e1 --- /dev/null +++ b/tests/rustdoc/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/sidebar-items.rs b/tests/rustdoc/sidebar-items.rs index 6f7afa59b..b746f6982 100644 --- a/tests/rustdoc/sidebar-items.rs +++ b/tests/rustdoc/sidebar-items.rs @@ -14,6 +14,7 @@ // @has - '//*[@class="sidebar-elems"]//section//a' 'Output' // @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Extra' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety' pub trait Foo { const FOO: usize; const BAR: u32 = 0; @@ -24,6 +25,12 @@ pub trait Foo { fn bar() -> Self::Output; } +// @has foo/trait.Safe.html +// @!has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' '' +pub trait Safe { + fn access(&self); +} + // @has foo/struct.Bar.html // @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' diff --git a/tests/rustdoc/sidebar-links-to-foreign-impl.rs b/tests/rustdoc/sidebar-links-to-foreign-impl.rs index caa17dfbb..733a18ad9 100644 --- a/tests/rustdoc/sidebar-links-to-foreign-impl.rs +++ b/tests/rustdoc/sidebar-links-to-foreign-impl.rs @@ -7,8 +7,8 @@ // @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' // @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32' -// @has - "//*[@class=\"sidebar-elems\"]//section//a[@href=\"#impl-Foo-for-%26'a+str\"]" "&'a str" -// @has - "//*[@id=\"impl-Foo-for-%26'a+str\"]//h3[@class=\"code-header\"]" "impl<'a> Foo for &'a str" +// @has - "//*[@class=\"sidebar-elems\"]//section//a[@href=\"#impl-Foo-for-%26str\"]" "&'a str" +// @has - "//*[@id=\"impl-Foo-for-%26str\"]//h3[@class=\"code-header\"]" "impl<'a> Foo for &'a str" pub trait Foo {} impl Foo for u32 {} diff --git a/tests/rustdoc/source-version-separator.rs b/tests/rustdoc/source-version-separator.rs index 14580373b..7256f7315 100644 --- a/tests/rustdoc/source-version-separator.rs +++ b/tests/rustdoc/source-version-separator.rs @@ -3,23 +3,23 @@ #![feature(staged_api)] // @has foo/trait.Bar.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub trait Bar { - // @has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0 · source' + // @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 · source' +// @has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · source' // @has foo/struct.Foo.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "baz", since = "1.0")] pub struct Foo; impl Foo { - // @has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0 · source' + // @has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · source' #[stable(feature = "foobar", since = "3.0")] pub fn foofoo() {} } diff --git a/tests/rustdoc/src-link-external-macro-26606.rs b/tests/rustdoc/src-link-external-macro-26606.rs new file mode 100644 index 000000000..de717a527 --- /dev/null +++ b/tests/rustdoc/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/src-links-auto-impls.rs b/tests/rustdoc/src-links-auto-impls.rs index 1c8d15731..08a497d4c 100644 --- a/tests/rustdoc/src-links-auto-impls.rs +++ b/tests/rustdoc/src-links-auto-impls.rs @@ -5,8 +5,8 @@ // @!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-Unsized"]/h3[@class="code-header"]' 'impl Any for T' -// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="src rightside"]' '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-inlined-34274.rs b/tests/rustdoc/src-links-inlined-34274.rs new file mode 100644 index 000000000..a3c9bf7e4 --- /dev/null +++ b/tests/rustdoc/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/src-mod-path-absolute-26995.rs b/tests/rustdoc/src-mod-path-absolute-26995.rs new file mode 100644 index 000000000..b67fd9b26 --- /dev/null +++ b/tests/rustdoc/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/staged-api-deprecated-unstable-32374.rs b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs new file mode 100644 index 000000000..d282dea90 --- /dev/null +++ b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs @@ -0,0 +1,33 @@ +// https://github.com/rust-lang/rust/issues/32374 +#![feature(staged_api)] +#![doc(issue_tracker_base_url = "https://issue_url/")] +#![unstable(feature = "test", issue = "32374")] +#![crate_name="issue_32374"] + +// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ +// 'Deprecated' +// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab unstable"]' \ +// 'Experimental' +// @matches issue_32374/index.html '//*[@class="desc docblock-short"]/text()' 'Docs' + +// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎' +// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \ +// 'Deprecated since 1.0.0: text' +// @hasraw - 'test #32374' +// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬' +// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ +// 'This is a nightly-only experimental API. \(test\s#32374\)$' +/// Docs +#[deprecated(since = "1.0.0", note = "text")] +#[unstable(feature = "test", issue = "32374")] +pub struct T; + +// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎' +// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ +// 'Deprecated since 1.0.0: deprecated' +// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬' +// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ +// 'This is a nightly-only experimental API. (test #32374)' +#[deprecated(since = "1.0.0", note = "deprecated")] +#[unstable(feature = "test", issue = "32374", reason = "unstable")] +pub struct U; diff --git a/tests/rustdoc/staged-api-feature-issue-27759.rs b/tests/rustdoc/staged-api-feature-issue-27759.rs new file mode 100644 index 000000000..56a45a600 --- /dev/null +++ b/tests/rustdoc/staged-api-feature-issue-27759.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/27759 +#![crate_name="issue_27759"] + +#![feature(staged_api)] +#![doc(issue_tracker_base_url = "http://issue_url/")] + +#![unstable(feature="test", issue="27759")] + +// @has issue_27759/unstable/index.html +// @hasraw - 'test #27759' +#[unstable(feature="test", issue="27759")] +pub mod unstable { + // @has issue_27759/unstable/fn.issue.html + // @hasraw - 'test_function #12345' + #[unstable(feature="test_function", issue="12345")] + pub fn issue() {} +} diff --git a/tests/rustdoc/strip-enum-variant.no-not-shown.html b/tests/rustdoc/strip-enum-variant.no-not-shown.html index 782198956..e07233529 100644 --- a/tests/rustdoc/strip-enum-variant.no-not-shown.html +++ b/tests/rustdoc/strip-enum-variant.no-not-shown.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/rustdoc/strip-enum-variant.rs b/tests/rustdoc/strip-enum-variant.rs index 8753a7dc6..2512fa34b 100644 --- a/tests/rustdoc/strip-enum-variant.rs +++ b/tests/rustdoc/strip-enum-variant.rs @@ -3,7 +3,7 @@ // @!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"][1]' +// @snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block variant"]' pub enum MyThing { Shown, #[doc(hidden)] diff --git a/tests/rustdoc/strip-priv-imports-pass-27104.rs b/tests/rustdoc/strip-priv-imports-pass-27104.rs new file mode 100644 index 000000000..e400a8f50 --- /dev/null +++ b/tests/rustdoc/strip-priv-imports-pass-27104.rs @@ -0,0 +1,13 @@ +// compile-flags:--no-defaults --passes strip-priv-imports +// aux-build:empty.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/27104 +#![crate_name="issue_27104"] + +// @has issue_27104/index.html +// @!hasraw - 'extern crate std' +// @!hasraw - 'use std::prelude::' + +// @hasraw - 'pub extern crate empty' +pub extern crate empty; diff --git a/tests/rustdoc/summary-codeblock-31899.rs b/tests/rustdoc/summary-codeblock-31899.rs new file mode 100644 index 000000000..c1b33058c --- /dev/null +++ b/tests/rustdoc/summary-codeblock-31899.rs @@ -0,0 +1,62 @@ +// https://github.com/rust-lang/rust/issues/31899 +#![crate_name="issue_31899"] + +// @has issue_31899/index.html +// @hasraw - 'Make this line a bit longer.' +// @!hasraw - 'rust rust-example-rendered' +// @!hasraw - 'use ndarray::arr2' +// @!hasraw - 'prohibited' + +/// A tuple or fixed size array that can be used to index an array. +/// Make this line a bit longer. +/// +/// ``` +/// use ndarray::arr2; +/// +/// let mut a = arr2(&[[0, 1], [0, 0]]); +/// a[[1, 1]] = 1; +/// assert_eq!(a[[0, 1]], 1); +/// assert_eq!(a[[1, 1]], 1); +/// ``` +/// +/// **Note** the blanket implementation that's not visible in rustdoc: +/// `impl NdIndex for D where D: Dimension { ... }` +pub fn bar() {} + +/// Some line +/// +/// # prohibited +pub fn foo() {} + +/// Some line +/// +/// 1. prohibited +/// 2. bar +pub fn baz() {} + +/// Some line +/// +/// - prohibited +/// - bar +pub fn qux() {} + +/// Some line +/// +/// * prohibited +/// * bar +pub fn quz() {} + +/// Some line +/// +/// > prohibited +/// > bar +pub fn qur() {} + +/// Some line +/// +/// prohibited +/// ===== +/// +/// Second +/// ------ +pub fn qut() {} diff --git a/tests/rustdoc/summary-reference-link-30366.rs b/tests/rustdoc/summary-reference-link-30366.rs new file mode 100644 index 000000000..5b9854c53 --- /dev/null +++ b/tests/rustdoc/summary-reference-link-30366.rs @@ -0,0 +1,9 @@ +// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' + +// https://github.com/rust-lang/rust/issues/30366 +#![crate_name="issue_30366"] + +/// Describe it. [Link somewhere][1]. +/// +/// [1]: http://www.rust-lang.org/ +pub fn here_is_a_fn() { } diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index f6a059de6..f9da5a813 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -2,7 +2,8 @@ #![feature(rustc_attrs)] // @matches 'foo/index.html' '//h1' 'Crate foo' -// @matches 'foo/index.html' '//h2[@class="location"]' 'Crate foo' +// @matches 'foo/index.html' '//div[@class="sidebar-crate"]/h2/a' 'foo' +// @count 'foo/index.html' '//h2[@class="location"]' 0 // @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod' // @matches 'foo/foo_mod/index.html' '//h2[@class="location"]' 'Module foo_mod' diff --git a/tests/rustdoc/trait-object-safe.rs b/tests/rustdoc/trait-object-safe.rs new file mode 100644 index 000000000..818843f75 --- /dev/null +++ b/tests/rustdoc/trait-object-safe.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +// @has 'foo/trait.Unsafe.html' +// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +// @has - '//*[@id="object-safety"]' 'Object Safety' +pub trait Unsafe { + fn foo() -> Self; +} + +// @has 'foo/trait.Unsafe2.html' +// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +// @has - '//*[@id="object-safety"]' 'Object Safety' +pub trait Unsafe2 { + fn foo(i: T); +} + +// @has 'foo/trait.Safe.html' +// @!has - '//*[@class="object-safety-info"]' '' +// @!has - '//*[@id="object-safety"]' '' +pub trait Safe { + fn foo(&self); +} + +// @has 'foo/struct.Foo.html' +// @!has - '//*[@class="object-safety-info"]' '' +// @!has - '//*[@id="object-safety"]' '' +pub struct Foo; diff --git a/tests/rustdoc/type-alias/auxiliary/parent-crate-115718.rs b/tests/rustdoc/type-alias/auxiliary/parent-crate-115718.rs new file mode 100644 index 000000000..3607612c2 --- /dev/null +++ b/tests/rustdoc/type-alias/auxiliary/parent-crate-115718.rs @@ -0,0 +1,9 @@ +pub struct MyStruct(T); + +pub trait MyTrait1 { + fn method_trait_1(); +} + +impl MyTrait1 for MyStruct { + fn method_trait_1() {} +} diff --git a/tests/rustdoc/type-alias/cross-crate-115718.rs b/tests/rustdoc/type-alias/cross-crate-115718.rs new file mode 100644 index 000000000..372e62e42 --- /dev/null +++ b/tests/rustdoc/type-alias/cross-crate-115718.rs @@ -0,0 +1,34 @@ +// aux-build: parent-crate-115718.rs + +// https://github.com/rust-lang/rust/issues/115718 +#![crate_name = "foo"] + +extern crate parent_crate_115718; + +use parent_crate_115718::MyStruct; + +pub trait MyTrait2 { + fn method_trait_2(); +} + +impl MyTrait2 for MyStruct { + fn method_trait_2() {} +} + +pub trait MyTrait3 { + fn method_trait_3(); +} + +impl MyTrait3 for MyType { + fn method_trait_3() {} +} + +// @hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_1' +// @hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_2' +// Avoid duplicating these docs. +// @!hasraw 'foo/type.MyType.html' 'method_trait_1' +// @!hasraw 'foo/type.MyType.html' 'method_trait_2' +// The one made directly on the type alias should be attached to the HTML instead. +// @!hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_3' +// @hasraw 'foo/type.MyType.html' 'method_trait_3' +pub type MyType = MyStruct; diff --git a/tests/rustdoc/type-alias/deeply-nested-112515.rs b/tests/rustdoc/type-alias/deeply-nested-112515.rs new file mode 100644 index 000000000..161188ee5 --- /dev/null +++ b/tests/rustdoc/type-alias/deeply-nested-112515.rs @@ -0,0 +1,30 @@ +// Regression test for . +// It's to ensure that this code doesn't have infinite loop in rustdoc when +// trying to retrive type alias implementations. + +// ignore-tidy-linelength + +pub type Boom = S, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>; +pub struct S(T, U); + +pub trait A {} + +pub trait B { + type P; +} + +impl A for u64 {} + +impl A for S {} + +impl B for S +where + T: B, + >::P: A, +{ + type P = (); +} + +impl B for S { + type P = (); +} diff --git a/tests/rustdoc/type-alias/deref-32077.rs b/tests/rustdoc/type-alias/deref-32077.rs new file mode 100644 index 000000000..186ebb1a6 --- /dev/null +++ b/tests/rustdoc/type-alias/deref-32077.rs @@ -0,0 +1,70 @@ +// Regression test for . + +#![crate_name = "foo"] + +pub struct GenericStruct(T); + +impl GenericStruct { + pub fn on_gen(arg: T) {} +} + +impl GenericStruct { + pub fn on_u32(arg: u32) {} +} + +pub trait Foo {} +pub trait Bar {} + +impl Foo for GenericStruct {} +impl Bar for GenericStruct {} + +// @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-GenericStruct%3Cu8%3E"]/h3' 'impl TypedefStruct' +// @has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()' +// This trait implementation doesn't match the type alias parameters so shouldn't appear in docs. +// @!has - '//h3' 'impl Bar for GenericStruct {}' +// Same goes for the `Deref` impl. +// @!has - '//h2' 'Methods from Deref' +// @count - '//nav[@class="sidebar"]//a' 'on_alias' 1 +// @!has - '//nav[@class="sidebar"]//a' 'on_gen' +// @!has - '//nav[@class="sidebar"]//a' 'Foo' +// @!has - '//nav[@class="sidebar"]//a' 'Bar' +// @!has - '//nav[@class="sidebar"]//a' 'on_u32' +// TypedefStruct inlined to GenericStruct +// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'TypedefStruct' +// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'method.on_gen' +// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'Foo' +pub type TypedefStruct = GenericStruct; + +impl TypedefStruct { + pub fn on_alias() {} +} + +impl std::ops::Deref for GenericStruct { + type Target = u32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +pub struct Wrap(GenericStruct); + +// @has 'foo/type.Alias.html' +// @!has - '//h2' 'Methods from Deref' +// @!has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl Deref for Wrap' +// @hasraw 'type.impl/foo/struct.Wrap.js' 'impl-Deref-for-Wrap%3CT%3E' +// Deref Methods aren't gathered for type aliases, though the actual impl is. +// @!hasraw 'type.impl/foo/struct.Wrap.js' 'BITS' +pub type Alias = Wrap; + +impl std::ops::Deref for Wrap { + type Target = GenericStruct; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/tests/rustdoc/type-alias/same-crate-115718.rs b/tests/rustdoc/type-alias/same-crate-115718.rs new file mode 100644 index 000000000..26e5db85c --- /dev/null +++ b/tests/rustdoc/type-alias/same-crate-115718.rs @@ -0,0 +1,34 @@ +// https://github.com/rust-lang/rust/issues/115718 +#![crate_name = "foo"] + +pub trait MyTrait1 { + fn method_trait_1(); +} + +pub trait MyTrait2 { + fn method_trait_2(); +} + +pub struct MyStruct(T); + +impl MyStruct { + pub fn method_u32() {} +} + +impl MyStruct { + pub fn method_u16() {} +} + +impl MyTrait1 for MyStruct { + fn method_trait_1() {} +} + +impl MyTrait2 for MyStruct { + fn method_trait_2() {} +} + +// @hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u16' +// @!hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u32' +// @!hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_1' +// @hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_2' +pub type MyType = MyStruct; diff --git a/tests/rustdoc/version-separator-without-source.rs b/tests/rustdoc/version-separator-without-source.rs index 04ea46a7f..4a855b7bb 100644 --- a/tests/rustdoc/version-separator-without-source.rs +++ b/tests/rustdoc/version-separator-without-source.rs @@ -4,20 +4,20 @@ #![crate_name = "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 · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.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 · ' +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.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 ·' + // @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/where-clause-order.rs b/tests/rustdoc/where-clause-order.rs index b10f8f685..e3184b646 100644 --- a/tests/rustdoc/where-clause-order.rs +++ b/tests/rustdoc/where-clause-order.rs @@ -7,7 +7,7 @@ where } // @has 'foo/trait.SomeTrait.html' -// @has - "//*[@id='impl-SomeTrait%3C(A,+B,+C,+D,+E)%3E-for-(A,+B,+C,+D,+E)']/h3" "impl SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E)where A: PartialOrd + PartialEq, B: PartialOrd + PartialEq, C: PartialOrd + PartialEq, D: PartialOrd + PartialEq, E: PartialOrd + PartialEq + ?Sized, " +// @has - "//*[@id='impl-SomeTrait-for-(A,+B,+C,+D,+E)']/h3" "impl SomeTrait for (A, B, C, D, E)where A: PartialOrd + PartialEq, B: PartialOrd + PartialEq, C: PartialOrd + PartialEq, D: PartialOrd + PartialEq, E: PartialOrd + PartialEq + ?Sized, " impl SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E) where A: PartialOrd + PartialEq, @@ -17,3 +17,14 @@ where E: PartialOrd + PartialEq + ?Sized, { } + +// @has - "//*[@id='impl-SomeTrait%3C(A,+B,+C,+D)%3E-for-(A,+B,+C,+D,+E)']/h3" "impl SomeTrait<(A, B, C, D)> for (A, B, C, D, E)where A: PartialOrd + PartialEq, B: PartialOrd + PartialEq, C: PartialOrd + PartialEq, D: PartialOrd + PartialEq, E: PartialOrd + PartialEq + ?Sized, " +impl SomeTrait<(A, B, C, D)> for (A, B, C, D, E) +where + A: PartialOrd + PartialEq, + B: PartialOrd + PartialEq, + C: PartialOrd + PartialEq, + D: PartialOrd + PartialEq, + E: PartialOrd + PartialEq + ?Sized, +{ +} diff --git a/tests/rustdoc/whitespace-after-where-clause.enum.html b/tests/rustdoc/whitespace-after-where-clause.enum.html index 20b60b68e..ff4971f33 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum2.html b/tests/rustdoc/whitespace-after-where-clause.enum2.html index 065ce757d..bfc50f8ad 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum2.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@ -
pub enum Cow2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
+
pub enum Cow2<'a, B: ?Sized + ToOwned<()> + 'a> {
     Borrowed(&'a B),
     Whatever(u32),
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.rs b/tests/rustdoc/whitespace-after-where-clause.rs index b540c7c97..832d3728e 100644 --- a/tests/rustdoc/whitespace-after-where-clause.rs +++ b/tests/rustdoc/whitespace-after-where-clause.rs @@ -6,7 +6,8 @@ // @has 'foo/trait.ToOwned.html' // @snapshot trait - '//*[@class="rust item-decl"]' pub trait ToOwned -where T: Clone +where + T: Clone, { type Owned; fn to_owned(&self) -> Self::Owned; @@ -26,7 +27,7 @@ pub trait ToOwned2 { // @snapshot enum - '//*[@class="rust item-decl"]' pub enum Cow<'a, B: ?Sized + 'a> where - B: ToOwned, + B: ToOwned<()>, { Borrowed(&'a B), Whatever(u32), @@ -35,7 +36,7 @@ where // @has 'foo/enum.Cow2.html' // @snapshot enum2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub enum Cow2<'a, B: ?Sized + ToOwned + 'a> { +pub enum Cow2<'a, B: ?Sized + ToOwned<()> + 'a> { Borrowed(&'a B), Whatever(u32), } @@ -44,7 +45,7 @@ pub enum Cow2<'a, B: ?Sized + ToOwned + 'a> { // @snapshot struct - '//*[@class="rust item-decl"]' pub struct Struct<'a, B: ?Sized + 'a> where - B: ToOwned, + B: ToOwned<()>, { pub a: &'a B, pub b: u32, @@ -53,7 +54,7 @@ where // @has 'foo/struct.Struct2.html' // @snapshot struct2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub struct Struct2<'a, B: ?Sized + ToOwned + 'a> { +pub struct Struct2<'a, B: ?Sized + ToOwned<()> + 'a> { pub a: &'a B, pub b: u32, } @@ -62,7 +63,7 @@ pub struct Struct2<'a, B: ?Sized + ToOwned + 'a> { // @snapshot union - '//*[@class="rust item-decl"]' pub union Union<'a, B: ?Sized + 'a> where - B: ToOwned, + B: ToOwned<()>, { a: &'a B, b: u32, @@ -71,7 +72,7 @@ where // @has 'foo/union.Union2.html' // @snapshot union2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub union Union2<'a, B: ?Sized + ToOwned + 'a> { +pub union Union2<'a, B: ?Sized + ToOwned<()> + 'a> { a: &'a B, b: u32, } diff --git a/tests/rustdoc/whitespace-after-where-clause.struct.html b/tests/rustdoc/whitespace-after-where-clause.struct.html index 948ddc499..ca6853586 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct.html @@ -1,5 +1,5 @@
pub struct Struct<'a, B>where
-    B: ToOwned<dyn Clone> + ?Sized + 'a,{
+    B: ToOwned<()> + ?Sized + 'a,{
     pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct2.html b/tests/rustdoc/whitespace-after-where-clause.struct2.html index c647e8d71..5aa8110c1 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct2.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@ -
pub struct Struct2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
+
pub struct Struct2<'a, B: ?Sized + ToOwned<()> + 'a> {
     pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.union.html b/tests/rustdoc/whitespace-after-where-clause.union.html index 38b6cb8b5..40b0c6712 100644 --- a/tests/rustdoc/whitespace-after-where-clause.union.html +++ b/tests/rustdoc/whitespace-after-where-clause.union.html @@ -1,4 +1,4 @@
pub union Union<'a, B>where
-    B: ToOwned<dyn Clone> + ?Sized + 'a,{
+    B: ToOwned<()> + ?Sized + 'a,{
     /* private fields */
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.union2.html b/tests/rustdoc/whitespace-after-where-clause.union2.html index 66ad30c92..177a161b8 100644 --- a/tests/rustdoc/whitespace-after-where-clause.union2.html +++ b/tests/rustdoc/whitespace-after-where-clause.union2.html @@ -1,3 +1,3 @@ -
pub union Union2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
+
pub union Union2<'a, B: ?Sized + ToOwned<()> + 'a> {
     /* private fields */
 }
\ No newline at end of file -- cgit v1.2.3
pub enum Cow<'a, B>where
-    B: ToOwned<dyn Clone> + ?Sized + 'a,{
+    B: ToOwned<()> + ?Sized + 'a,{
     Borrowed(&'a B),
     Whatever(u32),
 }