From b84f4cc39e99f801dcd37125dffa67eb796c85b8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:01:08 +0200 Subject: Created `tests/rustdoc/impl` subfolder to limit number of files at the top level --- tests/rustdoc/assoc-consts-underscore.rs | 30 ------ tests/rustdoc/assoc-consts-version.rs | 15 --- tests/rustdoc/assoc-consts.rs | 103 ------------------ tests/rustdoc/associated-consts.rs | 51 --------- .../auxiliary/cross-crate-hidden-impl-parameter.rs | 5 - tests/rustdoc/auxiliary/extern-impl-trait.rs | 27 ----- tests/rustdoc/auxiliary/incoherent-impl-types.rs | 7 -- tests/rustdoc/auxiliary/issue-100204-aux.rs | 13 --- tests/rustdoc/auxiliary/issue-17476.rs | 7 -- tests/rustdoc/auxiliary/issue-21092.rs | 12 --- tests/rustdoc/auxiliary/issue-22025.rs | 10 -- tests/rustdoc/auxiliary/issue-53689.rs | 1 - tests/rustdoc/auxiliary/precise-capturing.rs | 7 -- tests/rustdoc/auxiliary/real_gimli.rs | 13 --- tests/rustdoc/auxiliary/realcore.rs | 15 --- tests/rustdoc/auxiliary/rustdoc-default-impl.rs | 23 ---- .../auxiliary/rustdoc-impl-parts-crosscrate.rs | 3 - tests/rustdoc/blanket-impl-29503.rs | 21 ---- tests/rustdoc/blanket-impl-78673.rs | 25 ----- tests/rustdoc/const-display.rs | 92 ---------------- tests/rustdoc/const-doc.rs | 19 ---- tests/rustdoc/const-effect-param.rs | 14 --- tests/rustdoc/const-underscore.rs | 7 -- tests/rustdoc/const-value-display.rs | 9 -- tests/rustdoc/const.rs | 10 -- tests/rustdoc/constant/assoc-consts-underscore.rs | 30 ++++++ tests/rustdoc/constant/assoc-consts-version.rs | 15 +++ tests/rustdoc/constant/assoc-consts.rs | 103 ++++++++++++++++++ tests/rustdoc/constant/associated-consts.rs | 51 +++++++++ tests/rustdoc/constant/const-display.rs | 92 ++++++++++++++++ tests/rustdoc/constant/const-doc.rs | 19 ++++ tests/rustdoc/constant/const-effect-param.rs | 14 +++ tests/rustdoc/constant/const-underscore.rs | 7 ++ tests/rustdoc/constant/const-value-display.rs | 9 ++ tests/rustdoc/constant/const.rs | 10 ++ ...t-item-with-associated-const-in-where-clause.rs | 17 +++ tests/rustdoc/constant/generic-const-items.rs | 38 +++++++ tests/rustdoc/constant/generic_const_exprs.rs | 24 +++++ tests/rustdoc/constant/glob-shadowing-const.rs | 20 ++++ .../hide-complex-unevaluated-const-arguments.rs | 91 ++++++++++++++++ .../constant/hide-complex-unevaluated-consts.rs | 71 +++++++++++++ .../ice-associated-const-equality-105952.rs | 15 +++ tests/rustdoc/constant/legacy-const-generic.rs | 16 +++ tests/rustdoc/constant/link-assoc-const.rs | 16 +++ tests/rustdoc/constant/redirect-const.rs | 13 +++ .../rustdoc/constant/rfc-2632-const-trait-impl.rs | 73 +++++++++++++ tests/rustdoc/constant/show-const-contents.rs | 68 ++++++++++++ tests/rustdoc/cross-crate-hidden-impl-parameter.rs | 35 ------ .../rustdoc/deduplicate-glob-import-impl-21474.rs | 14 --- tests/rustdoc/deduplicate-trait-impl-22025.rs | 9 -- tests/rustdoc/default-impl.rs | 9 -- tests/rustdoc/deprecated-impls.rs | 118 --------------------- .../rustdoc/doc-hidden-trait-implementors-33069.rs | 13 --- tests/rustdoc/doc_auto_cfg_nested_impl.rs | 24 ----- ...t-item-with-associated-const-in-where-clause.rs | 17 --- tests/rustdoc/duplicated_impl.rs | 14 --- tests/rustdoc/empty-impl-block.rs | 20 ---- tests/rustdoc/empty-impls.rs | 19 ---- tests/rustdoc/extern-impl-trait.rs | 11 -- tests/rustdoc/extern-impl.rs | 27 ----- tests/rustdoc/foreign-implementors-js-43701.rs | 6 -- tests/rustdoc/generic-const-items.rs | 38 ------- tests/rustdoc/generic-impl.rs | 16 --- tests/rustdoc/generic_const_exprs.rs | 24 ----- tests/rustdoc/glob-shadowing-const.rs | 20 ---- tests/rustdoc/hidden-implementors-90781.rs | 78 -------------- tests/rustdoc/hidden-impls.rs | 17 --- tests/rustdoc/hidden-trait-struct-impls.rs | 22 ---- .../hide-complex-unevaluated-const-arguments.rs | 91 ---------------- tests/rustdoc/hide-complex-unevaluated-consts.rs | 71 ------------- .../hide-mut-methods-if-no-derefmut-impl-74083.rs | 24 ----- .../ice-associated-const-equality-105952.rs | 15 --- tests/rustdoc/impl-alias-substituted.rs | 9 -- tests/rustdoc/impl-assoc-type-21092.rs | 11 -- tests/rustdoc/impl-associated-items-order.rs | 42 -------- tests/rustdoc/impl-associated-items-sidebar.rs | 42 -------- tests/rustdoc/impl-blanket-53689.rs | 17 --- tests/rustdoc/impl-box.rs | 16 --- tests/rustdoc/impl-disambiguation.rs | 30 ------ tests/rustdoc/impl-everywhere.rs | 30 ------ tests/rustdoc/impl-in-const-block.rs | 43 -------- tests/rustdoc/impl-on-ty-alias-issue-119015.rs | 27 ----- tests/rustdoc/impl-parts-crosscrate.rs | 20 ---- tests/rustdoc/impl-parts.rs | 12 --- tests/rustdoc/impl-ref-20175.rs | 14 --- tests/rustdoc/impl-trait-43869.rs | 75 ------------- tests/rustdoc/impl-trait-alias.rs | 14 --- tests/rustdoc/impl-trait-precise-capturing.rs | 26 ----- tests/rustdoc/impl-type-parameter-33592.rs | 14 --- .../auxiliary/cross-crate-hidden-impl-parameter.rs | 5 + tests/rustdoc/impl/auxiliary/extern-impl-trait.rs | 27 +++++ .../impl/auxiliary/incoherent-impl-types.rs | 7 ++ tests/rustdoc/impl/auxiliary/issue-100204-aux.rs | 13 +++ tests/rustdoc/impl/auxiliary/issue-17476.rs | 7 ++ tests/rustdoc/impl/auxiliary/issue-21092.rs | 12 +++ tests/rustdoc/impl/auxiliary/issue-22025.rs | 10 ++ tests/rustdoc/impl/auxiliary/issue-53689.rs | 1 + tests/rustdoc/impl/auxiliary/precise-capturing.rs | 7 ++ tests/rustdoc/impl/auxiliary/real_gimli.rs | 13 +++ tests/rustdoc/impl/auxiliary/realcore.rs | 15 +++ .../rustdoc/impl/auxiliary/rustdoc-default-impl.rs | 23 ++++ .../auxiliary/rustdoc-impl-parts-crosscrate.rs | 3 + tests/rustdoc/impl/blanket-impl-29503.rs | 21 ++++ tests/rustdoc/impl/blanket-impl-78673.rs | 25 +++++ .../impl/cross-crate-hidden-impl-parameter.rs | 35 ++++++ .../impl/deduplicate-glob-import-impl-21474.rs | 14 +++ tests/rustdoc/impl/deduplicate-trait-impl-22025.rs | 9 ++ tests/rustdoc/impl/default-impl.rs | 9 ++ tests/rustdoc/impl/deprecated-impls.rs | 118 +++++++++++++++++++++ .../impl/doc-hidden-trait-implementors-33069.rs | 13 +++ tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs | 24 +++++ tests/rustdoc/impl/duplicated_impl.rs | 14 +++ tests/rustdoc/impl/empty-impl-block.rs | 20 ++++ tests/rustdoc/impl/empty-impls.rs | 19 ++++ tests/rustdoc/impl/extern-impl-trait.rs | 11 ++ tests/rustdoc/impl/extern-impl.rs | 27 +++++ .../rustdoc/impl/foreign-implementors-js-43701.rs | 6 ++ tests/rustdoc/impl/generic-impl.rs | 16 +++ tests/rustdoc/impl/hidden-implementors-90781.rs | 78 ++++++++++++++ tests/rustdoc/impl/hidden-impls.rs | 17 +++ tests/rustdoc/impl/hidden-trait-struct-impls.rs | 22 ++++ .../hide-mut-methods-if-no-derefmut-impl-74083.rs | 24 +++++ tests/rustdoc/impl/impl-alias-substituted.rs | 9 ++ tests/rustdoc/impl/impl-assoc-type-21092.rs | 11 ++ tests/rustdoc/impl/impl-associated-items-order.rs | 42 ++++++++ .../rustdoc/impl/impl-associated-items-sidebar.rs | 42 ++++++++ tests/rustdoc/impl/impl-blanket-53689.rs | 17 +++ tests/rustdoc/impl/impl-box.rs | 16 +++ tests/rustdoc/impl/impl-disambiguation.rs | 30 ++++++ tests/rustdoc/impl/impl-everywhere.rs | 30 ++++++ tests/rustdoc/impl/impl-in-const-block.rs | 43 ++++++++ .../rustdoc/impl/impl-on-ty-alias-issue-119015.rs | 27 +++++ tests/rustdoc/impl/impl-parts-crosscrate.rs | 20 ++++ tests/rustdoc/impl/impl-parts.rs | 12 +++ tests/rustdoc/impl/impl-ref-20175.rs | 14 +++ tests/rustdoc/impl/impl-trait-43869.rs | 75 +++++++++++++ tests/rustdoc/impl/impl-trait-alias.rs | 14 +++ tests/rustdoc/impl/impl-trait-precise-capturing.rs | 26 +++++ tests/rustdoc/impl/impl-type-parameter-33592.rs | 14 +++ tests/rustdoc/impl/implementor-stable-version.rs | 21 ++++ tests/rustdoc/impl/implementors-unstable-75588.rs | 18 ++++ .../impl/inline-impl-through-glob-import-100204.rs | 15 +++ tests/rustdoc/impl/manual_impl.rs | 77 ++++++++++++++ .../impl/method-link-foreign-trait-impl-17476.rs | 14 +++ tests/rustdoc/impl/module-impls.rs | 5 + tests/rustdoc/impl/must_implement_one_of.rs | 10 ++ tests/rustdoc/impl/negative-impl-no-items.rs | 26 +++++ tests/rustdoc/impl/negative-impl-sidebar.rs | 9 ++ tests/rustdoc/impl/negative-impl.rs | 14 +++ tests/rustdoc/impl/return-impl-trait.rs | 15 +++ tests/rustdoc/impl/rustc-incoherent-impls.rs | 28 +++++ .../impl/same-crate-hidden-impl-parameter.rs | 36 +++++++ .../impl/sidebar-trait-impl-disambiguate-78701.rs | 21 ++++ tests/rustdoc/impl/struct-implementations-title.rs | 9 ++ tests/rustdoc/impl/trait-impl.rs | 45 ++++++++ .../trait-implementations-duplicate-self-45584.rs | 17 +++ .../impl/underscore-type-in-trait-impl-96381.rs | 17 +++ tests/rustdoc/impl/universal-impl-trait.rs | 55 ++++++++++ .../impl/unneeded-trait-implementations-title.rs | 5 + tests/rustdoc/implementor-stable-version.rs | 21 ---- tests/rustdoc/implementors-unstable-75588.rs | 18 ---- .../inline-impl-through-glob-import-100204.rs | 15 --- tests/rustdoc/legacy-const-generic.rs | 16 --- tests/rustdoc/link-assoc-const.rs | 16 --- tests/rustdoc/manual_impl.rs | 77 -------------- .../method-link-foreign-trait-impl-17476.rs | 14 --- tests/rustdoc/module-impls.rs | 5 - tests/rustdoc/must_implement_one_of.rs | 10 -- tests/rustdoc/negative-impl-no-items.rs | 26 ----- tests/rustdoc/negative-impl-sidebar.rs | 9 -- tests/rustdoc/negative-impl.rs | 14 --- tests/rustdoc/redirect-const.rs | 13 --- tests/rustdoc/return-impl-trait.rs | 15 --- tests/rustdoc/rfc-2632-const-trait-impl.rs | 73 ------------- tests/rustdoc/rustc-incoherent-impls.rs | 28 ----- tests/rustdoc/same-crate-hidden-impl-parameter.rs | 36 ------- tests/rustdoc/show-const-contents.rs | 68 ------------ .../sidebar-trait-impl-disambiguate-78701.rs | 21 ---- tests/rustdoc/struct-implementations-title.rs | 9 -- tests/rustdoc/trait-impl.rs | 45 -------- .../trait-implementations-duplicate-self-45584.rs | 17 --- .../rustdoc/underscore-type-in-trait-impl-96381.rs | 17 --- tests/rustdoc/universal-impl-trait.rs | 55 ---------- .../unneeded-trait-implementations-title.rs | 5 - 184 files changed, 2376 insertions(+), 2376 deletions(-) delete mode 100644 tests/rustdoc/assoc-consts-underscore.rs delete mode 100644 tests/rustdoc/assoc-consts-version.rs delete mode 100644 tests/rustdoc/assoc-consts.rs delete mode 100644 tests/rustdoc/associated-consts.rs delete mode 100644 tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/auxiliary/extern-impl-trait.rs delete mode 100644 tests/rustdoc/auxiliary/incoherent-impl-types.rs delete mode 100644 tests/rustdoc/auxiliary/issue-100204-aux.rs delete mode 100644 tests/rustdoc/auxiliary/issue-17476.rs delete mode 100644 tests/rustdoc/auxiliary/issue-21092.rs delete mode 100644 tests/rustdoc/auxiliary/issue-22025.rs delete mode 100644 tests/rustdoc/auxiliary/issue-53689.rs delete mode 100644 tests/rustdoc/auxiliary/precise-capturing.rs delete mode 100644 tests/rustdoc/auxiliary/real_gimli.rs delete mode 100644 tests/rustdoc/auxiliary/realcore.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-default-impl.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs delete mode 100644 tests/rustdoc/blanket-impl-29503.rs delete mode 100644 tests/rustdoc/blanket-impl-78673.rs delete mode 100644 tests/rustdoc/const-display.rs delete mode 100644 tests/rustdoc/const-doc.rs delete mode 100644 tests/rustdoc/const-effect-param.rs delete mode 100644 tests/rustdoc/const-underscore.rs delete mode 100644 tests/rustdoc/const-value-display.rs delete mode 100644 tests/rustdoc/const.rs create mode 100644 tests/rustdoc/constant/assoc-consts-underscore.rs create mode 100644 tests/rustdoc/constant/assoc-consts-version.rs create mode 100644 tests/rustdoc/constant/assoc-consts.rs create mode 100644 tests/rustdoc/constant/associated-consts.rs create mode 100644 tests/rustdoc/constant/const-display.rs create mode 100644 tests/rustdoc/constant/const-doc.rs create mode 100644 tests/rustdoc/constant/const-effect-param.rs create mode 100644 tests/rustdoc/constant/const-underscore.rs create mode 100644 tests/rustdoc/constant/const-value-display.rs create mode 100644 tests/rustdoc/constant/const.rs create mode 100644 tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs create mode 100644 tests/rustdoc/constant/generic-const-items.rs create mode 100644 tests/rustdoc/constant/generic_const_exprs.rs create mode 100644 tests/rustdoc/constant/glob-shadowing-const.rs create mode 100644 tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs create mode 100644 tests/rustdoc/constant/hide-complex-unevaluated-consts.rs create mode 100644 tests/rustdoc/constant/ice-associated-const-equality-105952.rs create mode 100644 tests/rustdoc/constant/legacy-const-generic.rs create mode 100644 tests/rustdoc/constant/link-assoc-const.rs create mode 100644 tests/rustdoc/constant/redirect-const.rs create mode 100644 tests/rustdoc/constant/rfc-2632-const-trait-impl.rs create mode 100644 tests/rustdoc/constant/show-const-contents.rs delete mode 100644 tests/rustdoc/cross-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/deduplicate-glob-import-impl-21474.rs delete mode 100644 tests/rustdoc/deduplicate-trait-impl-22025.rs delete mode 100644 tests/rustdoc/default-impl.rs delete mode 100644 tests/rustdoc/deprecated-impls.rs delete mode 100644 tests/rustdoc/doc-hidden-trait-implementors-33069.rs delete mode 100644 tests/rustdoc/doc_auto_cfg_nested_impl.rs delete mode 100644 tests/rustdoc/document-item-with-associated-const-in-where-clause.rs delete mode 100644 tests/rustdoc/duplicated_impl.rs delete mode 100644 tests/rustdoc/empty-impl-block.rs delete mode 100644 tests/rustdoc/empty-impls.rs delete mode 100644 tests/rustdoc/extern-impl-trait.rs delete mode 100644 tests/rustdoc/extern-impl.rs delete mode 100644 tests/rustdoc/foreign-implementors-js-43701.rs delete mode 100644 tests/rustdoc/generic-const-items.rs delete mode 100644 tests/rustdoc/generic-impl.rs delete mode 100644 tests/rustdoc/generic_const_exprs.rs delete mode 100644 tests/rustdoc/glob-shadowing-const.rs delete mode 100644 tests/rustdoc/hidden-implementors-90781.rs delete mode 100644 tests/rustdoc/hidden-impls.rs delete mode 100644 tests/rustdoc/hidden-trait-struct-impls.rs delete mode 100644 tests/rustdoc/hide-complex-unevaluated-const-arguments.rs delete mode 100644 tests/rustdoc/hide-complex-unevaluated-consts.rs delete mode 100644 tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs delete mode 100644 tests/rustdoc/ice-associated-const-equality-105952.rs delete mode 100644 tests/rustdoc/impl-alias-substituted.rs delete mode 100644 tests/rustdoc/impl-assoc-type-21092.rs delete mode 100644 tests/rustdoc/impl-associated-items-order.rs delete mode 100644 tests/rustdoc/impl-associated-items-sidebar.rs delete mode 100644 tests/rustdoc/impl-blanket-53689.rs delete mode 100644 tests/rustdoc/impl-box.rs delete mode 100644 tests/rustdoc/impl-disambiguation.rs delete mode 100644 tests/rustdoc/impl-everywhere.rs delete mode 100644 tests/rustdoc/impl-in-const-block.rs delete mode 100644 tests/rustdoc/impl-on-ty-alias-issue-119015.rs delete mode 100644 tests/rustdoc/impl-parts-crosscrate.rs delete mode 100644 tests/rustdoc/impl-parts.rs delete mode 100644 tests/rustdoc/impl-ref-20175.rs delete mode 100644 tests/rustdoc/impl-trait-43869.rs delete mode 100644 tests/rustdoc/impl-trait-alias.rs delete mode 100644 tests/rustdoc/impl-trait-precise-capturing.rs delete mode 100644 tests/rustdoc/impl-type-parameter-33592.rs create mode 100644 tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/auxiliary/extern-impl-trait.rs create mode 100644 tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-100204-aux.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-17476.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-21092.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-22025.rs create mode 100644 tests/rustdoc/impl/auxiliary/issue-53689.rs create mode 100644 tests/rustdoc/impl/auxiliary/precise-capturing.rs create mode 100644 tests/rustdoc/impl/auxiliary/real_gimli.rs create mode 100644 tests/rustdoc/impl/auxiliary/realcore.rs create mode 100644 tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs create mode 100644 tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs create mode 100644 tests/rustdoc/impl/blanket-impl-29503.rs create mode 100644 tests/rustdoc/impl/blanket-impl-78673.rs create mode 100644 tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs create mode 100644 tests/rustdoc/impl/deduplicate-trait-impl-22025.rs create mode 100644 tests/rustdoc/impl/default-impl.rs create mode 100644 tests/rustdoc/impl/deprecated-impls.rs create mode 100644 tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs create mode 100644 tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs create mode 100644 tests/rustdoc/impl/duplicated_impl.rs create mode 100644 tests/rustdoc/impl/empty-impl-block.rs create mode 100644 tests/rustdoc/impl/empty-impls.rs create mode 100644 tests/rustdoc/impl/extern-impl-trait.rs create mode 100644 tests/rustdoc/impl/extern-impl.rs create mode 100644 tests/rustdoc/impl/foreign-implementors-js-43701.rs create mode 100644 tests/rustdoc/impl/generic-impl.rs create mode 100644 tests/rustdoc/impl/hidden-implementors-90781.rs create mode 100644 tests/rustdoc/impl/hidden-impls.rs create mode 100644 tests/rustdoc/impl/hidden-trait-struct-impls.rs create mode 100644 tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs create mode 100644 tests/rustdoc/impl/impl-alias-substituted.rs create mode 100644 tests/rustdoc/impl/impl-assoc-type-21092.rs create mode 100644 tests/rustdoc/impl/impl-associated-items-order.rs create mode 100644 tests/rustdoc/impl/impl-associated-items-sidebar.rs create mode 100644 tests/rustdoc/impl/impl-blanket-53689.rs create mode 100644 tests/rustdoc/impl/impl-box.rs create mode 100644 tests/rustdoc/impl/impl-disambiguation.rs create mode 100644 tests/rustdoc/impl/impl-everywhere.rs create mode 100644 tests/rustdoc/impl/impl-in-const-block.rs create mode 100644 tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs create mode 100644 tests/rustdoc/impl/impl-parts-crosscrate.rs create mode 100644 tests/rustdoc/impl/impl-parts.rs create mode 100644 tests/rustdoc/impl/impl-ref-20175.rs create mode 100644 tests/rustdoc/impl/impl-trait-43869.rs create mode 100644 tests/rustdoc/impl/impl-trait-alias.rs create mode 100644 tests/rustdoc/impl/impl-trait-precise-capturing.rs create mode 100644 tests/rustdoc/impl/impl-type-parameter-33592.rs create mode 100644 tests/rustdoc/impl/implementor-stable-version.rs create mode 100644 tests/rustdoc/impl/implementors-unstable-75588.rs create mode 100644 tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs create mode 100644 tests/rustdoc/impl/manual_impl.rs create mode 100644 tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs create mode 100644 tests/rustdoc/impl/module-impls.rs create mode 100644 tests/rustdoc/impl/must_implement_one_of.rs create mode 100644 tests/rustdoc/impl/negative-impl-no-items.rs create mode 100644 tests/rustdoc/impl/negative-impl-sidebar.rs create mode 100644 tests/rustdoc/impl/negative-impl.rs create mode 100644 tests/rustdoc/impl/return-impl-trait.rs create mode 100644 tests/rustdoc/impl/rustc-incoherent-impls.rs create mode 100644 tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs create mode 100644 tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs create mode 100644 tests/rustdoc/impl/struct-implementations-title.rs create mode 100644 tests/rustdoc/impl/trait-impl.rs create mode 100644 tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs create mode 100644 tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs create mode 100644 tests/rustdoc/impl/universal-impl-trait.rs create mode 100644 tests/rustdoc/impl/unneeded-trait-implementations-title.rs delete mode 100644 tests/rustdoc/implementor-stable-version.rs delete mode 100644 tests/rustdoc/implementors-unstable-75588.rs delete mode 100644 tests/rustdoc/inline-impl-through-glob-import-100204.rs delete mode 100644 tests/rustdoc/legacy-const-generic.rs delete mode 100644 tests/rustdoc/link-assoc-const.rs delete mode 100644 tests/rustdoc/manual_impl.rs delete mode 100644 tests/rustdoc/method-link-foreign-trait-impl-17476.rs delete mode 100644 tests/rustdoc/module-impls.rs delete mode 100644 tests/rustdoc/must_implement_one_of.rs delete mode 100644 tests/rustdoc/negative-impl-no-items.rs delete mode 100644 tests/rustdoc/negative-impl-sidebar.rs delete mode 100644 tests/rustdoc/negative-impl.rs delete mode 100644 tests/rustdoc/redirect-const.rs delete mode 100644 tests/rustdoc/return-impl-trait.rs delete mode 100644 tests/rustdoc/rfc-2632-const-trait-impl.rs delete mode 100644 tests/rustdoc/rustc-incoherent-impls.rs delete mode 100644 tests/rustdoc/same-crate-hidden-impl-parameter.rs delete mode 100644 tests/rustdoc/show-const-contents.rs delete mode 100644 tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs delete mode 100644 tests/rustdoc/struct-implementations-title.rs delete mode 100644 tests/rustdoc/trait-impl.rs delete mode 100644 tests/rustdoc/trait-implementations-duplicate-self-45584.rs delete mode 100644 tests/rustdoc/underscore-type-in-trait-impl-96381.rs delete mode 100644 tests/rustdoc/universal-impl-trait.rs delete mode 100644 tests/rustdoc/unneeded-trait-implementations-title.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/assoc-consts-underscore.rs b/tests/rustdoc/assoc-consts-underscore.rs deleted file mode 100644 index f48098094db..00000000000 --- a/tests/rustdoc/assoc-consts-underscore.rs +++ /dev/null @@ -1,30 +0,0 @@ -pub struct Struct { - _private: (), -} - -pub trait Trait { - //@ has assoc_consts_underscore/trait.Trait.html '//pre[@class="rust item-decl"]' \ - // 'const REQUIRED: Struct;' - //@ !has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct = _' - //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' - const REQUIRED: Struct; - //@ has - '//pre[@class="rust item-decl"]' 'const OPTIONAL: Struct = _;' - //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' - const OPTIONAL: Struct = Struct { _private: () }; -} - -impl Trait for Struct { - //@ !has assoc_consts_underscore/struct.Struct.html '//*[@id="associatedconstant.REQUIRED"]' \ - // 'const REQUIRED: Struct = _' - //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' - const REQUIRED: Struct = Struct { _private: () }; - //@ !has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' - //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct' - const OPTIONAL: Struct = Struct { _private: () }; -} - -impl Struct { - //@ !has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct = _' - //@ has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct' - pub const INHERENT: Struct = Struct { _private: () }; -} diff --git a/tests/rustdoc/assoc-consts-version.rs b/tests/rustdoc/assoc-consts-version.rs deleted file mode 100644 index db4d759acab..00000000000 --- a/tests/rustdoc/assoc-consts-version.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![crate_name = "foo"] - -#![feature(staged_api)] - -#![stable(since="1.1.1", feature="rust1")] - -#[stable(since="1.1.1", feature="rust1")] -pub struct SomeStruct; - -impl SomeStruct { - //@ has 'foo/struct.SomeStruct.html' \ - // '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2' - #[stable(since="1.1.2", feature="rust2")] - pub const SOME_CONST: usize = 0; -} diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs deleted file mode 100644 index 247b5b180a8..00000000000 --- a/tests/rustdoc/assoc-consts.rs +++ /dev/null @@ -1,103 +0,0 @@ -pub trait Foo { - //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ - // 'const FOO: usize = 13usize;' - //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' - const FOO: usize = 12 + 1; - //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' - const FOO_NO_DEFAULT: bool; - //@ !hasraw - FOO_HIDDEN - #[doc(hidden)] - const FOO_HIDDEN: u8 = 0; -} - -pub struct Bar; - -impl Foo for Bar { - //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' - //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' - const FOO: usize = 12; - //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' - const FOO_NO_DEFAULT: bool = false; - //@ !hasraw - FOO_HIDDEN - #[doc(hidden)] - const FOO_HIDDEN: u8 = 0; -} - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ - // 'const BAR: usize' - pub const BAR: usize = 3; - - //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ - // "const BAR_ESCAPED: &'static str = \"markup\"" - pub const BAR_ESCAPED: &'static str = "markup"; -} - -pub struct Baz<'a, U: 'a, T>(T, &'a [U]); - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ - // "const BAZ: Baz<'static, u8, u32>" - pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]); -} - -pub fn f(_: &(ToString + 'static)) {} - -impl Bar { - //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ - // "const F: fn(&(dyn ToString + 'static))" - pub const F: fn(_: &(ToString + 'static)) = f; -} - -impl Bar { - //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' - const BAR_PRIVATE: char = 'a'; - //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' - #[doc(hidden)] - pub const BAR_HIDDEN: &'static str = "a"; -} - -//@ has assoc_consts/trait.Qux.html -pub trait Qux { - //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." - /// Docs for QUX0 in trait. - const QUX0: u8; - //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait." - /// Docs for QUX1 in trait. - const QUX1: i8; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." - /// Docs for QUX_DEFAULT12 in trait. - const QUX_DEFAULT0: u16 = 1; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." - /// Docs for QUX_DEFAULT1 in trait. - const QUX_DEFAULT1: i16 = 2; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." - /// Docs for QUX_DEFAULT2 in trait. - const QUX_DEFAULT2: u32 = 3; -} - -//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' -impl Qux for Bar { - //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." - /// Docs for QUX0 in trait. - const QUX0: u8 = 4; - //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl." - /// Docs for QUX1 in impl. - const QUX1: i8 = 5; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." - const QUX_DEFAULT0: u16 = 6; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." - /// Docs for QUX_DEFAULT1 in impl. - const QUX_DEFAULT1: i16 = 7; - //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." -} diff --git a/tests/rustdoc/associated-consts.rs b/tests/rustdoc/associated-consts.rs deleted file mode 100644 index 2a7269a89be..00000000000 --- a/tests/rustdoc/associated-consts.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![crate_name = "foo"] - -pub trait Trait { - const FOO: u32 = 12; - - fn foo(); -} - -pub struct Bar; - -//@ has 'foo/struct.Bar.html' -//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Trait for Bar { - const FOO: u32 = 1; - - fn foo() {} -} - -pub enum Foo { - A, -} - -//@ has 'foo/enum.Foo.html' -//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Trait for Foo { - const FOO: u32 = 1; - - fn foo() {} -} - -pub struct Baz; - -//@ has 'foo/struct.Baz.html' -//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Baz { - pub const FOO: u32 = 42; -} - -pub enum Quux { - B, -} - -//@ has 'foo/enum.Quux.html' -//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' -impl Quux { - pub const FOO: u32 = 42; -} diff --git a/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs deleted file mode 100644 index 15953122280..00000000000 --- a/tests/rustdoc/auxiliary/cross-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[doc(hidden)] -pub enum HiddenType {} - -#[doc(hidden)] -pub trait HiddenTrait {} diff --git a/tests/rustdoc/auxiliary/extern-impl-trait.rs b/tests/rustdoc/auxiliary/extern-impl-trait.rs deleted file mode 100644 index dbd54393098..00000000000 --- a/tests/rustdoc/auxiliary/extern-impl-trait.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub trait Foo { - type Associated; -} - -pub struct X; -pub struct Y; - - -impl Foo for X { - type Associated = (); -} - -impl Foo for Y { - type Associated = (); -} - -impl X { - pub fn returns_sized<'a>(&'a self) -> impl Foo + 'a { - X - } -} - -impl Y { - pub fn returns_unsized<'a>(&'a self) -> Box + 'a> { - Box::new(X) - } -} diff --git a/tests/rustdoc/auxiliary/incoherent-impl-types.rs b/tests/rustdoc/auxiliary/incoherent-impl-types.rs deleted file mode 100644 index fc51e42e500..00000000000 --- a/tests/rustdoc/auxiliary/incoherent-impl-types.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_has_incoherent_inherent_impls] -pub trait FooTrait {} - -#[rustc_has_incoherent_inherent_impls] -pub struct FooStruct; diff --git a/tests/rustdoc/auxiliary/issue-100204-aux.rs b/tests/rustdoc/auxiliary/issue-100204-aux.rs deleted file mode 100644 index df1b59069be..00000000000 --- a/tests/rustdoc/auxiliary/issue-100204-aux.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_name="first"] - -pub mod prelude { - pub use crate::Bot; -} - -pub struct Bot; - -impl Bot { - pub fn new() -> Bot { - Bot - } -} diff --git a/tests/rustdoc/auxiliary/issue-17476.rs b/tests/rustdoc/auxiliary/issue-17476.rs deleted file mode 100644 index 0a63b893fff..00000000000 --- a/tests/rustdoc/auxiliary/issue-17476.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -#![doc(html_root_url = "http://example.com")] - -pub trait Foo { - fn foo(&self) {} -} diff --git a/tests/rustdoc/auxiliary/issue-21092.rs b/tests/rustdoc/auxiliary/issue-21092.rs deleted file mode 100644 index 49522e0d4b5..00000000000 --- a/tests/rustdoc/auxiliary/issue-21092.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub trait Foo { - type Bar; - fn foo(&self) {} -} - -pub struct Bar; - -impl Foo for Bar { - type Bar = i32; -} diff --git a/tests/rustdoc/auxiliary/issue-22025.rs b/tests/rustdoc/auxiliary/issue-22025.rs deleted file mode 100644 index 6bc55073283..00000000000 --- a/tests/rustdoc/auxiliary/issue-22025.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Cmetadata=aux - -pub mod foo { - - pub trait Foo {} - pub struct Bar; - - impl Foo for Bar {} - -} diff --git a/tests/rustdoc/auxiliary/issue-53689.rs b/tests/rustdoc/auxiliary/issue-53689.rs deleted file mode 100644 index 5003c2c00f4..00000000000 --- a/tests/rustdoc/auxiliary/issue-53689.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct MyStruct; diff --git a/tests/rustdoc/auxiliary/precise-capturing.rs b/tests/rustdoc/auxiliary/precise-capturing.rs deleted file mode 100644 index 531d4dfdccc..00000000000 --- a/tests/rustdoc/auxiliary/precise-capturing.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(precise_capturing)] - -pub fn cross_crate_empty() -> impl Sized + use<> {} - -pub fn cross_crate_missing() -> impl Sized {} - -pub fn cross_crate_args<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} diff --git a/tests/rustdoc/auxiliary/real_gimli.rs b/tests/rustdoc/auxiliary/real_gimli.rs deleted file mode 100644 index 871d9b31be9..00000000000 --- a/tests/rustdoc/auxiliary/real_gimli.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:realcore.rs - -#![crate_name = "real_gimli"] -#![feature(staged_api, extremely_unstable)] -#![unstable(feature = "rustc_private", issue = "none")] - -extern crate realcore; - -#[unstable(feature = "rustc_private", issue = "none")] -pub struct EndianSlice; - -#[unstable(feature = "rustc_private", issue = "none")] -impl realcore::Deref for EndianSlice {} diff --git a/tests/rustdoc/auxiliary/realcore.rs b/tests/rustdoc/auxiliary/realcore.rs deleted file mode 100644 index e0a906df002..00000000000 --- a/tests/rustdoc/auxiliary/realcore.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![crate_name = "realcore"] -#![feature(staged_api)] -#![unstable(feature = "extremely_unstable", issue = "none")] - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -pub struct Foo {} - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -pub trait Join {} - -#[unstable(feature = "extremely_unstable_foo", issue = "none")] -impl Join for Foo {} - -#[stable(feature = "faked_deref", since = "1.47.0")] -pub trait Deref {} diff --git a/tests/rustdoc/auxiliary/rustdoc-default-impl.rs b/tests/rustdoc/auxiliary/rustdoc-default-impl.rs deleted file mode 100644 index 032db3b25e6..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-default-impl.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(auto_traits)] - -pub mod bar { - use std::marker; - - pub auto trait Bar {} - - pub trait Foo { - fn foo(&self) {} - } - - impl Foo { - pub fn test(&self) {} - } - - pub struct TypeId; - - impl TypeId { - pub fn of() -> TypeId { - panic!() - } - } -} diff --git a/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs b/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs deleted file mode 100644 index 135987fc00d..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![feature(auto_traits)] - -pub auto trait AnAutoTrait {} diff --git a/tests/rustdoc/blanket-impl-29503.rs b/tests/rustdoc/blanket-impl-29503.rs deleted file mode 100644 index f43fe79ca58..00000000000 --- a/tests/rustdoc/blanket-impl-29503.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/29503 -#![crate_name="issue_29503"] - -use std::fmt; - -//@ has issue_29503/trait.MyTrait.html -pub trait MyTrait { - fn my_string(&self) -> String; -} - -//@ has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl MyTrait for Twhere T: Debug" -impl MyTrait for T -where - T: fmt::Debug, -{ - fn my_string(&self) -> String { - format!("{:?}", self) - } -} - -pub fn main() {} diff --git a/tests/rustdoc/blanket-impl-78673.rs b/tests/rustdoc/blanket-impl-78673.rs deleted file mode 100644 index 412d4057406..00000000000 --- a/tests/rustdoc/blanket-impl-78673.rs +++ /dev/null @@ -1,25 +0,0 @@ -// https://github.com/rust-lang/rust/issues/78673 -#![crate_name = "issue_78673"] - -pub trait Something {} - -pub trait AnAmazingTrait {} - -impl AnAmazingTrait for T {} - -//@ has 'issue_78673/struct.MyStruct.html' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' -//@ !has - '//*[@class="impl"]' 'AnAmazingTrait for T' -pub struct MyStruct; - -impl AnAmazingTrait for MyStruct {} - -// generic structs may have _both_ specific and blanket impls that apply - -//@ has 'issue_78673/struct.AnotherStruct.html' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' -//@ has - '//*[@class="impl"]' 'AnAmazingTrait for T' -pub struct AnotherStruct(T); - -impl Something for AnotherStruct {} -impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/const-display.rs b/tests/rustdoc/const-display.rs deleted file mode 100644 index bc4270c421d..00000000000 --- a/tests/rustdoc/const-display.rs +++ /dev/null @@ -1,92 +0,0 @@ -#![crate_name = "foo"] - -#![stable(feature = "rust1", since = "1.0.0")] - -#![feature(foo, foo2)] -#![feature(staged_api)] - -//@ has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature="foo", issue = "none")] -pub const fn foo() -> u32 { 42 } - -//@ has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature="foo", issue = "none")] -pub const unsafe fn foo_unsafe() -> u32 { 42 } - -//@ has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "humans", issue = "none")] -pub const fn foo2() -> u32 { 42 } - -//@ has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "humans", issue = "none")] -#[rustc_const_unstable(feature = "humans", issue = "none")] -pub const fn foo3() -> u32 { 42 } - -//@ has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' -//@ has - //span '1.0.0 (const: 1.0.0)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(feature = "rust1", since = "1.0.0")] -pub const fn bar2() -> u32 { 42 } - - -//@ has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' -//@ !hasraw - '//span[@class="since"]' -#[unstable(feature = "foo2", issue = "none")] -pub const unsafe fn foo2_gated() -> u32 { 42 } - -//@ has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' -//@ has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(feature = "rust1", since = "1.0.0")] -pub const unsafe fn bar2_gated() -> u32 { 42 } - -#[unstable( - feature = "humans", - reason = "who ever let humans program computers, we're apparently really bad at it", - issue = "none", -)] -pub mod unstable { - //@ has 'foo/unstable/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' - //@ !hasraw - '//span[@class="since"]' - pub const unsafe fn bar_not_gated() -> u32 { 42 } -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Foo; - -impl Foo { - //@ has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="foo", issue = "none")] - pub const fn gated() -> u32 { 42 } - - //@ has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="foo", issue = "none")] - pub const unsafe fn gated_unsafe() -> u32 { 42 } - - //@ has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' - //@ has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const2", since = "1.2.0")] - pub const fn stable_impl() -> u32 { 42 } -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Bar; - -impl Bar { - // Show non-const stabilities that are the same as the enclosing item. - //@ has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const2", since = "1.2.0")] - pub const fn stable_impl() -> u32 { 42 } -} diff --git a/tests/rustdoc/const-doc.rs b/tests/rustdoc/const-doc.rs deleted file mode 100644 index f33083a267c..00000000000 --- a/tests/rustdoc/const-doc.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::marker::PhantomData; - -pub struct Foo<'a> { - f: PhantomData<&'a u32>, -} - -pub struct ContentType { - pub ttype: Foo<'static>, - pub subtype: Foo<'static>, - pub params: Option>, -} - -impl ContentType { - //@ has const_doc/struct.ContentType.html - //@ has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' - pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, }, - subtype: Foo { f: PhantomData, }, - params: None, }; -} diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs deleted file mode 100644 index cceb0adac30..00000000000 --- a/tests/rustdoc/const-effect-param.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check that we don't render host effect parameters & arguments. - -#![crate_name = "foo"] -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Tr { - fn f(); -} - -//@ has foo/fn.g.html -//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g()' -/// foo -pub const fn g() {} diff --git a/tests/rustdoc/const-underscore.rs b/tests/rustdoc/const-underscore.rs deleted file mode 100644 index fafc4b4e25c..00000000000 --- a/tests/rustdoc/const-underscore.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags: --document-private-items - -//@ !has const_underscore/constant._.html -const _: () = { - #[no_mangle] - extern "C" fn implementation_detail() {} -}; diff --git a/tests/rustdoc/const-value-display.rs b/tests/rustdoc/const-value-display.rs deleted file mode 100644 index 658978a3490..00000000000 --- a/tests/rustdoc/const-value-display.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/constant.HOUR_IN_SECONDS.html' -//@ has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' -pub const HOUR_IN_SECONDS: u64 = 60 * 60; - -//@ has 'foo/constant.NEGATIVE.html' -//@ has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' -pub const NEGATIVE: i64 = -60 * 60; diff --git a/tests/rustdoc/const.rs b/tests/rustdoc/const.rs deleted file mode 100644 index fe6a828505a..00000000000 --- a/tests/rustdoc/const.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type="lib"] - -pub struct Foo; - -impl Foo { - //@ has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' - pub const unsafe fn new() -> Foo { - Foo - } -} diff --git a/tests/rustdoc/constant/assoc-consts-underscore.rs b/tests/rustdoc/constant/assoc-consts-underscore.rs new file mode 100644 index 00000000000..f48098094db --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts-underscore.rs @@ -0,0 +1,30 @@ +pub struct Struct { + _private: (), +} + +pub trait Trait { + //@ has assoc_consts_underscore/trait.Trait.html '//pre[@class="rust item-decl"]' \ + // 'const REQUIRED: Struct;' + //@ !has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct = _' + //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' + const REQUIRED: Struct; + //@ has - '//pre[@class="rust item-decl"]' 'const OPTIONAL: Struct = _;' + //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' + const OPTIONAL: Struct = Struct { _private: () }; +} + +impl Trait for Struct { + //@ !has assoc_consts_underscore/struct.Struct.html '//*[@id="associatedconstant.REQUIRED"]' \ + // 'const REQUIRED: Struct = _' + //@ has - '//*[@id="associatedconstant.REQUIRED"]' 'const REQUIRED: Struct' + const REQUIRED: Struct = Struct { _private: () }; + //@ !has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct = _' + //@ has - '//*[@id="associatedconstant.OPTIONAL"]' 'const OPTIONAL: Struct' + const OPTIONAL: Struct = Struct { _private: () }; +} + +impl Struct { + //@ !has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct = _' + //@ has - '//*[@id="associatedconstant.INHERENT"]' 'const INHERENT: Struct' + pub const INHERENT: Struct = Struct { _private: () }; +} diff --git a/tests/rustdoc/constant/assoc-consts-version.rs b/tests/rustdoc/constant/assoc-consts-version.rs new file mode 100644 index 00000000000..db4d759acab --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts-version.rs @@ -0,0 +1,15 @@ +#![crate_name = "foo"] + +#![feature(staged_api)] + +#![stable(since="1.1.1", feature="rust1")] + +#[stable(since="1.1.1", feature="rust1")] +pub struct SomeStruct; + +impl SomeStruct { + //@ has 'foo/struct.SomeStruct.html' \ + // '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2' + #[stable(since="1.1.2", feature="rust2")] + pub const SOME_CONST: usize = 0; +} diff --git a/tests/rustdoc/constant/assoc-consts.rs b/tests/rustdoc/constant/assoc-consts.rs new file mode 100644 index 00000000000..247b5b180a8 --- /dev/null +++ b/tests/rustdoc/constant/assoc-consts.rs @@ -0,0 +1,103 @@ +pub trait Foo { + //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ + // 'const FOO: usize = 13usize;' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + const FOO: usize = 12 + 1; + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + const FOO_NO_DEFAULT: bool; + //@ !hasraw - FOO_HIDDEN + #[doc(hidden)] + const FOO_HIDDEN: u8 = 0; +} + +pub struct Bar; + +impl Foo for Bar { + //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + const FOO: usize = 12; + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + const FOO_NO_DEFAULT: bool = false; + //@ !hasraw - FOO_HIDDEN + #[doc(hidden)] + const FOO_HIDDEN: u8 = 0; +} + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ + // 'const BAR: usize' + pub const BAR: usize = 3; + + //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ + // "const BAR_ESCAPED: &'static str = \"markup\"" + pub const BAR_ESCAPED: &'static str = "markup"; +} + +pub struct Baz<'a, U: 'a, T>(T, &'a [U]); + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ + // "const BAZ: Baz<'static, u8, u32>" + pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]); +} + +pub fn f(_: &(ToString + 'static)) {} + +impl Bar { + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ + // "const F: fn(&(dyn ToString + 'static))" + pub const F: fn(_: &(ToString + 'static)) = f; +} + +impl Bar { + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' + const BAR_PRIVATE: char = 'a'; + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' + #[doc(hidden)] + pub const BAR_HIDDEN: &'static str = "a"; +} + +//@ has assoc_consts/trait.Qux.html +pub trait Qux { + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + /// Docs for QUX0 in trait. + const QUX0: u8; + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait." + /// Docs for QUX1 in trait. + const QUX1: i8; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + /// Docs for QUX_DEFAULT12 in trait. + const QUX_DEFAULT0: u16 = 1; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." + /// Docs for QUX_DEFAULT1 in trait. + const QUX_DEFAULT1: i16 = 2; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." + /// Docs for QUX_DEFAULT2 in trait. + const QUX_DEFAULT2: u32 = 3; +} + +//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' +impl Qux for Bar { + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + /// Docs for QUX0 in trait. + const QUX0: u8 = 4; + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl." + /// Docs for QUX1 in impl. + const QUX1: i8 = 5; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + const QUX_DEFAULT0: u16 = 6; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." + /// Docs for QUX_DEFAULT1 in impl. + const QUX_DEFAULT1: i16 = 7; + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." +} diff --git a/tests/rustdoc/constant/associated-consts.rs b/tests/rustdoc/constant/associated-consts.rs new file mode 100644 index 00000000000..2a7269a89be --- /dev/null +++ b/tests/rustdoc/constant/associated-consts.rs @@ -0,0 +1,51 @@ +#![crate_name = "foo"] + +pub trait Trait { + const FOO: u32 = 12; + + fn foo(); +} + +pub struct Bar; + +//@ has 'foo/struct.Bar.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Trait for Bar { + const FOO: u32 = 1; + + fn foo() {} +} + +pub enum Foo { + A, +} + +//@ has 'foo/enum.Foo.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Trait for Foo { + const FOO: u32 = 1; + + fn foo() {} +} + +pub struct Baz; + +//@ has 'foo/struct.Baz.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Baz { + pub const FOO: u32 = 42; +} + +pub enum Quux { + B, +} + +//@ has 'foo/enum.Quux.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' +impl Quux { + pub const FOO: u32 = 42; +} diff --git a/tests/rustdoc/constant/const-display.rs b/tests/rustdoc/constant/const-display.rs new file mode 100644 index 00000000000..bc4270c421d --- /dev/null +++ b/tests/rustdoc/constant/const-display.rs @@ -0,0 +1,92 @@ +#![crate_name = "foo"] + +#![stable(feature = "rust1", since = "1.0.0")] + +#![feature(foo, foo2)] +#![feature(staged_api)] + +//@ has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature="foo", issue = "none")] +pub const fn foo() -> u32 { 42 } + +//@ has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature="foo", issue = "none")] +pub const unsafe fn foo_unsafe() -> u32 { 42 } + +//@ has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "humans", issue = "none")] +pub const fn foo2() -> u32 { 42 } + +//@ has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "humans", issue = "none")] +#[rustc_const_unstable(feature = "humans", issue = "none")] +pub const fn foo3() -> u32 { 42 } + +//@ has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' +//@ has - //span '1.0.0 (const: 1.0.0)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "rust1", since = "1.0.0")] +pub const fn bar2() -> u32 { 42 } + + +//@ has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' +//@ !hasraw - '//span[@class="since"]' +#[unstable(feature = "foo2", issue = "none")] +pub const unsafe fn foo2_gated() -> u32 { 42 } + +//@ has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "rust1", since = "1.0.0")] +pub const unsafe fn bar2_gated() -> u32 { 42 } + +#[unstable( + feature = "humans", + reason = "who ever let humans program computers, we're apparently really bad at it", + issue = "none", +)] +pub mod unstable { + //@ has 'foo/unstable/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' + //@ !hasraw - '//span[@class="since"]' + pub const unsafe fn bar_not_gated() -> u32 { 42 } +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Foo; + +impl Foo { + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature="foo", issue = "none")] + pub const fn gated() -> u32 { 42 } + + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature="foo", issue = "none")] + pub const unsafe fn gated_unsafe() -> u32 { 42 } + + //@ has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const2", since = "1.2.0")] + pub const fn stable_impl() -> u32 { 42 } +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Bar; + +impl Bar { + // Show non-const stabilities that are the same as the enclosing item. + //@ has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const2", since = "1.2.0")] + pub const fn stable_impl() -> u32 { 42 } +} diff --git a/tests/rustdoc/constant/const-doc.rs b/tests/rustdoc/constant/const-doc.rs new file mode 100644 index 00000000000..f33083a267c --- /dev/null +++ b/tests/rustdoc/constant/const-doc.rs @@ -0,0 +1,19 @@ +use std::marker::PhantomData; + +pub struct Foo<'a> { + f: PhantomData<&'a u32>, +} + +pub struct ContentType { + pub ttype: Foo<'static>, + pub subtype: Foo<'static>, + pub params: Option>, +} + +impl ContentType { + //@ has const_doc/struct.ContentType.html + //@ has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' + pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, }, + subtype: Foo { f: PhantomData, }, + params: None, }; +} diff --git a/tests/rustdoc/constant/const-effect-param.rs b/tests/rustdoc/constant/const-effect-param.rs new file mode 100644 index 00000000000..cceb0adac30 --- /dev/null +++ b/tests/rustdoc/constant/const-effect-param.rs @@ -0,0 +1,14 @@ +// Check that we don't render host effect parameters & arguments. + +#![crate_name = "foo"] +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Tr { + fn f(); +} + +//@ has foo/fn.g.html +//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g()' +/// foo +pub const fn g() {} diff --git a/tests/rustdoc/constant/const-underscore.rs b/tests/rustdoc/constant/const-underscore.rs new file mode 100644 index 00000000000..fafc4b4e25c --- /dev/null +++ b/tests/rustdoc/constant/const-underscore.rs @@ -0,0 +1,7 @@ +//@ compile-flags: --document-private-items + +//@ !has const_underscore/constant._.html +const _: () = { + #[no_mangle] + extern "C" fn implementation_detail() {} +}; diff --git a/tests/rustdoc/constant/const-value-display.rs b/tests/rustdoc/constant/const-value-display.rs new file mode 100644 index 00000000000..658978a3490 --- /dev/null +++ b/tests/rustdoc/constant/const-value-display.rs @@ -0,0 +1,9 @@ +#![crate_name = "foo"] + +//@ has 'foo/constant.HOUR_IN_SECONDS.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' +pub const HOUR_IN_SECONDS: u64 = 60 * 60; + +//@ has 'foo/constant.NEGATIVE.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' +pub const NEGATIVE: i64 = -60 * 60; diff --git a/tests/rustdoc/constant/const.rs b/tests/rustdoc/constant/const.rs new file mode 100644 index 00000000000..fe6a828505a --- /dev/null +++ b/tests/rustdoc/constant/const.rs @@ -0,0 +1,10 @@ +#![crate_type="lib"] + +pub struct Foo; + +impl Foo { + //@ has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' + pub const unsafe fn new() -> Foo { + Foo + } +} diff --git a/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs new file mode 100644 index 00000000000..c9408ef3360 --- /dev/null +++ b/tests/rustdoc/constant/document-item-with-associated-const-in-where-clause.rs @@ -0,0 +1,17 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Enumerable { + const N: usize; +} + +#[derive(Clone)] +pub struct SymmetricGroup +where + S: Enumerable, + [(); S::N]: Sized, +{ + _phantom: std::marker::PhantomData, +} + +fn main() {} diff --git a/tests/rustdoc/constant/generic-const-items.rs b/tests/rustdoc/constant/generic-const-items.rs new file mode 100644 index 00000000000..31c300f2ff1 --- /dev/null +++ b/tests/rustdoc/constant/generic-const-items.rs @@ -0,0 +1,38 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +//@ has 'generic_const_items/constant.K.html' +//@ has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +//@ has generic_const_items/trait.Trait.html +pub trait Trait { + //@ has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a T \ + // where \ + // T: 'a + Eq" + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +//@ has generic_const_items/struct.Implementor.html +//@ has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +impl Trait for Implementor { + //@ has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a str = \"C\" \ + // where \ + // str: 'a" + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/constant/generic_const_exprs.rs b/tests/rustdoc/constant/generic_const_exprs.rs new file mode 100644 index 00000000000..44f7bf5b24c --- /dev/null +++ b/tests/rustdoc/constant/generic_const_exprs.rs @@ -0,0 +1,24 @@ +// Regression test for . + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +#![crate_name = "foo"] + +//@ has 'foo/trait.Foo.html' + +pub trait Foo: Sized { + const WIDTH: usize; + + fn arrayify(self) -> [Self; Self::WIDTH]; +} + +impl Foo for T { + const WIDTH: usize = 1; + + //@ has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ + // 'fn arrayify(self) -> [Self; Self::WIDTH]' + fn arrayify(self) -> [Self; Self::WIDTH] { + [self] + } +} diff --git a/tests/rustdoc/constant/glob-shadowing-const.rs b/tests/rustdoc/constant/glob-shadowing-const.rs new file mode 100644 index 00000000000..fbc22dbccaa --- /dev/null +++ b/tests/rustdoc/constant/glob-shadowing-const.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/pull/83872#issuecomment-820101008 +#![crate_name="foo"] + +mod sub4 { + /// 0 + pub const X: usize = 0; + pub mod inner { + pub use super::*; + /// 1 + pub const X: usize = 1; + } +} + +#[doc(inline)] +pub use sub4::inner::*; + +//@ has 'foo/index.html' +//@ has - '//dd' '1' +//@ !has - '//dd' '0' +fn main() { assert_eq!(X, 1); } diff --git a/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs new file mode 100644 index 00000000000..e94c1ea5c61 --- /dev/null +++ b/tests/rustdoc/constant/hide-complex-unevaluated-const-arguments.rs @@ -0,0 +1,91 @@ +// Test that certain unevaluated constant expression arguments that are +// deemed too verbose or complex and that may leak private or +// `doc(hidden)` struct fields are not displayed in the documentation. +// +// Read the documentation of `rustdoc::clean::utils::print_const_expr` +// for further details. +#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +//@ has hide_complex_unevaluated_const_arguments/trait.Stage.html +pub trait Stage { + // A helper constant that prevents const expressions containing it + // from getting fully evaluated since it doesn't have a body and + // thus is non-reducible. This allows us to specifically test the + // pretty-printing of *unevaluated* consts. + const ABSTRACT: usize; + + // Currently considered "overly complex" by the `generic_const_exprs` + // feature. If / once this expression kind gets supported, this + // unevaluated const expression could leak the private struct field. + // + // FIXME: Once the line below compiles, make this a test that + // ensures that the private field is not printed. + // + //const ARRAY0: [u8; Struct { private: () } + Self::ABSTRACT]; + + // This assoc. const could leak the private assoc. function `Struct::new`. + // Ensure that this does not happen. + // + //@ has - '//*[@id="associatedconstant.ARRAY1"]' \ + // 'const ARRAY1: [u8; { _ }]' + const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] + where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; + + //@ has - '//*[@id="associatedconstant.VERBOSE"]' \ + // 'const VERBOSE: [u16; { _ }]' + const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] + where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; + + // Check that we do not leak the private struct field contained within + // the path. The output could definitely be improved upon + // (e.g. printing sth. akin to `>::OUT`) but + // right now “safe is safe”. + // + //@ has - '//*[@id="associatedconstant.PATH"]' \ + // 'const PATH: usize = _' + const PATH: usize = >::OUT; +} + +const fn compute(input: &str, extra: usize) -> usize { + input.len() + extra +} + +pub trait Helper { + const OUT: usize; +} + +impl Helper for St { + const OUT: usize = St::ABSTRACT; +} + +// Currently in rustdoc, const arguments are not evaluated in this position +// and therefore they fall under the realm of `print_const_expr`. +// If rustdoc gets patched to evaluate const arguments, it is fine to replace +// this test as long as one can ensure that private fields are not leaked! +// +//@ has hide_complex_unevaluated_const_arguments/trait.Sub.html \ +// '//pre[@class="rust item-decl"]' \ +// 'pub trait Sub: Sup<{ _ }, { _ }> { }' +pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} + +pub trait Sup {} + +#[derive(ConstParamTy, PartialEq, Eq)] +pub struct Struct { private: () } + +impl Struct { + const fn new() -> Self { Self { private: () } } + const fn do_something(self, x: usize) -> usize { + x + } +} +/* FIXME(const-trait): readd this +impl const std::ops::Add for Struct { + type Output = usize; + + fn add(self, _: usize) -> usize { 0 } +} +*/ diff --git a/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs b/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs new file mode 100644 index 00000000000..61ae8c801dd --- /dev/null +++ b/tests/rustdoc/constant/hide-complex-unevaluated-consts.rs @@ -0,0 +1,71 @@ +// Regression test for issue #97933. +// +// Test that certain unevaluated constant expressions that are +// deemed too verbose or complex and that may leak private or +// `doc(hidden)` struct fields are not displayed in the documentation. +// +// Read the documentation of `rustdoc::clean::utils::print_const_expr` +// for further details. + +//@ has hide_complex_unevaluated_consts/trait.Container.html +pub trait Container { + // A helper constant that prevents const expressions containing it + // from getting fully evaluated since it doesn't have a body and + // thus is non-reducible. This allows us to specifically test the + // pretty-printing of *unevaluated* consts. + const ABSTRACT: i32; + + // Ensure that the private field does not get leaked: + // + //@ has - '//*[@id="associatedconstant.STRUCT0"]' \ + // 'const STRUCT0: Struct = _' + const STRUCT0: Struct = Struct { private: () }; + + //@ has - '//*[@id="associatedconstant.STRUCT1"]' \ + // 'const STRUCT1: (Struct,) = _' + const STRUCT1: (Struct,) = (Struct{private: /**/()},); + + // Although the struct field is public here, check that it is not + // displayed. In a future version of rustdoc, we definitely want to + // show it. However for the time being, the printing logic is a bit + // conservative. + // + //@ has - '//*[@id="associatedconstant.STRUCT2"]' \ + // 'const STRUCT2: Record = _' + const STRUCT2: Record = Record { public: 5 }; + + // Test that we do not show the incredibly verbose match expr: + // + //@ has - '//*[@id="associatedconstant.MATCH0"]' \ + // 'const MATCH0: i32 = _' + const MATCH0: i32 = match 234 { + 0 => 1, + _ => Self::ABSTRACT, + }; + + //@ has - '//*[@id="associatedconstant.MATCH1"]' \ + // 'const MATCH1: bool = _' + const MATCH1: bool = match Self::ABSTRACT { + _ => true, + }; + + // Check that we hide complex (arithmetic) operations. + // In this case, it is a bit unfortunate since the expression + // is not *that* verbose and it might be quite useful to the reader. + // + // However in general, the expression might be quite large and + // contain match expressions and structs with private fields. + // We would need to recurse over the whole expression and even more + // importantly respect operator precedence when pretty-printing + // the potentially partially censored expression. + // For now, the implementation is quite simple and the choices + // rather conservative. + // + //@ has - '//*[@id="associatedconstant.ARITH_OPS"]' \ + // 'const ARITH_OPS: i32 = _' + const ARITH_OPS: i32 = Self::ABSTRACT * 2 + 1; +} + +pub struct Struct { private: () } + +pub struct Record { pub public: i32 } diff --git a/tests/rustdoc/constant/ice-associated-const-equality-105952.rs b/tests/rustdoc/constant/ice-associated-const-equality-105952.rs new file mode 100644 index 00000000000..1bcdfac7342 --- /dev/null +++ b/tests/rustdoc/constant/ice-associated-const-equality-105952.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/105952 +#![crate_name = "foo"] + +#![feature(associated_const_equality)] +pub enum ParseMode { + Raw, +} +pub trait Parse { + const PARSE_MODE: ParseMode; +} +pub trait RenderRaw {} + +//@ hasraw foo/trait.RenderRaw.html 'impl' +//@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' +impl> RenderRaw for T {} diff --git a/tests/rustdoc/constant/legacy-const-generic.rs b/tests/rustdoc/constant/legacy-const-generic.rs new file mode 100644 index 00000000000..41df535f3e0 --- /dev/null +++ b/tests/rustdoc/constant/legacy-const-generic.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +//@ has 'foo/fn.foo.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' +#[rustc_legacy_const_generics(1)] +pub fn foo(x: usize, z: usize) -> [usize; 3] { + [x, Y, z] +} + +//@ has 'foo/fn.bar.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' +#[rustc_legacy_const_generics(1, 2)] +pub fn bar(x: usize) -> [usize; 3] { + [x, Y, z] +} diff --git a/tests/rustdoc/constant/link-assoc-const.rs b/tests/rustdoc/constant/link-assoc-const.rs new file mode 100644 index 00000000000..56b82fb2d39 --- /dev/null +++ b/tests/rustdoc/constant/link-assoc-const.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +//@ has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' +//@ has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' + +//! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`]. + +pub mod foo { + pub const FIRSTCONST: u32 = 42; +} + +pub struct Bar; + +impl Bar { + pub const CONST: u32 = 42; +} diff --git a/tests/rustdoc/constant/redirect-const.rs b/tests/rustdoc/constant/redirect-const.rs new file mode 100644 index 00000000000..e636a915f30 --- /dev/null +++ b/tests/rustdoc/constant/redirect-const.rs @@ -0,0 +1,13 @@ +#![crate_name="foo"] + +pub use hidden::STATIC_FOO; +pub use hidden::CONST_FOO; + +mod hidden { + //@ has foo/hidden/static.STATIC_FOO.html + //@ has - '//p/a' '../../foo/static.STATIC_FOO.html' + pub static STATIC_FOO: u64 = 0; + //@ has foo/hidden/constant.CONST_FOO.html + //@ has - '//p/a' '../../foo/constant.CONST_FOO.html' + pub const CONST_FOO: u64 = 0; +} diff --git a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs new file mode 100644 index 00000000000..8a86e3e5e97 --- /dev/null +++ b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs @@ -0,0 +1,73 @@ +// Test that we do not currently display `~const` in rustdoc +// as that syntax is currently provisional; `~const Destruct` has +// no effect on stable code so it should be hidden as well. +// +// To future blessers: make sure that `const_trait_impl` is +// stabilized when changing `@!has` to `@has`, and please do +// not remove this test. +// +// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const` +// FIXME(const_trait_impl) restore `const_trait` to `Destruct` +#![feature(const_trait_impl)] +#![crate_name = "foo"] + +use std::marker::Destruct; + +pub struct S(T); + +//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' +#[const_trait] +pub trait Tr { + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + fn a() + where + Option: /* ~const */ Fn() /* + ~const Destruct */, + { + } +} + +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' +impl const Tr for T +where + Option: /* ~const */ Fn() /* + ~const Destruct */, +{ + fn a() + where + Option: /* ~const */ Fn() /* + ~const Destruct */, + { + } +} + +//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' +pub const fn foo() +where + Option: /* ~const */ Fn() /* + ~const Destruct */, +{ + F::a() +} + +impl S { + //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + pub const fn foo() + where + B: /* ~const */ Fn() /* + ~const Destruct */, + { + B::a() + } +} diff --git a/tests/rustdoc/constant/show-const-contents.rs b/tests/rustdoc/constant/show-const-contents.rs new file mode 100644 index 00000000000..6d2701693ce --- /dev/null +++ b/tests/rustdoc/constant/show-const-contents.rs @@ -0,0 +1,68 @@ +// Test that the contents of constants are displayed as part of the +// documentation. + +//@ hasraw show_const_contents/constant.CONST_S.html 'show this' +//@ !hasraw show_const_contents/constant.CONST_S.html '; //' +pub const CONST_S: &'static str = "show this"; + +//@ hasraw show_const_contents/constant.CONST_I32.html '= 42;' +//@ !hasraw show_const_contents/constant.CONST_I32.html '; //' +pub const CONST_I32: i32 = 42; + +//@ hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' +//@ !hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' +pub const CONST_I32_HEX: i32 = 0x42; + +//@ hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' +//@ !hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' +pub const CONST_NEG_I32: i32 = -42; + +//@ hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' +//@ !hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' +pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; + +//@ hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' +pub const CONST_CALC_I32: i32 = 42 + 1; + +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '; //' +pub const CONST_REF_I32: &'static i32 = &42; + +//@ hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' +pub const CONST_I32_MAX: i32 = i32::MAX; + +//@ !hasraw show_const_contents/constant.UNIT.html '= ();' +//@ !hasraw show_const_contents/constant.UNIT.html '; //' +pub const UNIT: () = (); + +pub struct MyType(i32); + +//@ !hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' +//@ !hasraw show_const_contents/constant.MY_TYPE.html '; //' +pub const MY_TYPE: MyType = MyType(42); + +pub struct MyTypeWithStr(&'static str); + +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' +pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); + +//@ hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' +//@ hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' +pub use std::f32::consts::PI; + +//@ hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' +#[allow(deprecated, deprecated_in_future)] +pub use std::i32::MAX; + +macro_rules! int_module { + ($T:ident) => ( + pub const MIN: $T = $T::MIN; + ) +} + +//@ hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' +int_module!(i16); + +//@ has show_const_contents/constant.ESCAPE.html //pre '= r#""#;' +pub const ESCAPE: &str = r#""#; diff --git a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/cross-crate-hidden-impl-parameter.rs deleted file mode 100644 index ebfe251134a..00000000000 --- a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Issue #86448: test for cross-crate `doc(hidden)` -#![crate_name = "foo"] - -//@ aux-build:cross-crate-hidden-impl-parameter.rs -extern crate cross_crate_hidden_impl_parameter; - -pub use ::cross_crate_hidden_impl_parameter::{HiddenType, HiddenTrait}; // OK, not re-exported - -pub enum MyLibType {} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' -impl From for MyLibType { - fn from(it: HiddenType) -> MyLibType { - match it {} - } -} - -pub struct T(T); - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' -impl From>>>> for MyLibType { - fn from(it: T>>>) -> MyLibType { - todo!() - } -} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' -impl HiddenTrait for MyLibType {} - -//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' -impl From for T>>> { - fn from(it: MyLibType) -> T>>> { - match it {} - } -} diff --git a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs deleted file mode 100644 index 5812d414997..00000000000 --- a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/21474 -#![crate_name="issue_21474"] - -pub use inner::*; - -mod inner { - impl super::Blah for super::What { } -} - -pub trait Blah { } - -//@ count issue_21474/struct.What.html \ -// '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -pub struct What; diff --git a/tests/rustdoc/deduplicate-trait-impl-22025.rs b/tests/rustdoc/deduplicate-trait-impl-22025.rs deleted file mode 100644 index 7b1648a56ac..00000000000 --- a/tests/rustdoc/deduplicate-trait-impl-22025.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:issue-22025.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/22025 -#![crate_name="issue_22025"] - -extern crate issue_22025; - -pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/default-impl.rs b/tests/rustdoc/default-impl.rs deleted file mode 100644 index 2ba9c4ab5ad..00000000000 --- a/tests/rustdoc/default-impl.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:rustdoc-default-impl.rs -//@ ignore-cross-compile - -extern crate rustdoc_default_impl as foo; - -pub use foo::bar; - -pub fn wut() { -} diff --git a/tests/rustdoc/deprecated-impls.rs b/tests/rustdoc/deprecated-impls.rs deleted file mode 100644 index a57f26ec7fd..00000000000 --- a/tests/rustdoc/deprecated-impls.rs +++ /dev/null @@ -1,118 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo0.html -pub struct Foo0; - -impl Foo0 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' - //@ hasraw - 'fn_with_doc short' - //@ hasraw - 'fn_with_doc full' - /// fn_with_doc short - /// - /// fn_with_doc full - #[deprecated(since = "1.0.1", note = "fn_with_doc")] - pub fn fn_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' - #[deprecated(since = "1.0.2", note = "fn_without_doc")] - pub fn fn_without_doc() {} -} - -pub trait Bar { - /// fn_empty_with_doc short - /// - /// fn_empty_with_doc full - #[deprecated(since = "1.0.3", note = "fn_empty_with_doc")] - fn fn_empty_with_doc(); - - #[deprecated(since = "1.0.4", note = "fn_empty_without_doc")] - fn fn_empty_without_doc(); - - /// fn_def_with_doc short - /// - /// fn_def_with_doc full - #[deprecated(since = "1.0.5", note = "fn_def_with_doc")] - fn fn_def_with_doc() {} - - #[deprecated(since = "1.0.6", note = "fn_def_without_doc")] - fn fn_def_without_doc() {} - - /// fn_def_def_with_doc short - /// - /// fn_def_def_with_doc full - #[deprecated(since = "1.0.7", note = "fn_def_def_with_doc")] - fn fn_def_def_with_doc() {} - - #[deprecated(since = "1.0.8", note = "fn_def_def_without_doc")] - fn fn_def_def_without_doc() {} -} - -//@ has foo/struct.Foo1.html -pub struct Foo1; - -impl Bar for Foo1 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - //@ hasraw - 'fn_empty_with_doc_impl short' - //@ hasraw - 'fn_empty_with_doc_impl full' - /// fn_empty_with_doc_impl short - /// - /// fn_empty_with_doc_impl full - fn fn_empty_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - fn fn_empty_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - //@ hasraw - 'fn_def_with_doc_impl short' - //@ hasraw - 'fn_def_with_doc_impl full' - /// fn_def_with_doc_impl short - /// - /// fn_def_with_doc_impl full - fn fn_def_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - fn fn_def_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - //@ hasraw - 'fn_def_def_with_doc short' - //@ !hasraw - 'fn_def_def_with_doc full' - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' -} - -//@ has foo/struct.Foo2.html -pub struct Foo2; - -impl Bar for Foo2 { - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - //@ hasraw - 'fn_empty_with_doc short' - //@ !hasraw - 'fn_empty_with_doc full' - fn fn_empty_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - //@ hasraw - 'fn_empty_without_doc_impl short' - //@ hasraw - 'fn_empty_without_doc_impl full' - /// fn_empty_without_doc_impl short - /// - /// fn_empty_without_doc_impl full - fn fn_empty_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - //@ hasraw - 'fn_def_with_doc short' - //@ !hasraw - 'fn_def_with_doc full' - fn fn_def_with_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - //@ hasraw - 'fn_def_without_doc_impl short' - //@ hasraw - 'fn_def_without_doc_impl full' - /// fn_def_without_doc_impl short - /// - /// fn_def_without_doc_impl full - fn fn_def_without_doc() {} - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - //@ hasraw - 'fn_def_def_with_doc short' - //@ !hasraw - 'fn_def_def_with_doc full' - - //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' -} diff --git a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs deleted file mode 100644 index d5ee3d09276..00000000000 --- a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/33069 -#![crate_name="issue_33069"] - -pub trait Bar {} - -#[doc(hidden)] -pub mod hidden { - pub struct Foo; -} - -//@ has issue_33069/trait.Bar.html -//@ !has - '//code' 'impl Bar for Foo' -impl Bar for hidden::Foo {} diff --git a/tests/rustdoc/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/doc_auto_cfg_nested_impl.rs deleted file mode 100644 index f85d7b23637..00000000000 --- a/tests/rustdoc/doc_auto_cfg_nested_impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for . - -#![feature(doc_auto_cfg)] -#![crate_type = "lib"] -#![crate_name = "foo"] - -pub struct S; -pub trait MyTrait1 {} -pub trait MyTrait2 {} - -//@ has foo/struct.S.html -//@ has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ -// 'Available on non-crate feature coolstuff only.' -#[cfg(not(feature = "coolstuff"))] -impl MyTrait1 for S {} - -#[cfg(not(feature = "coolstuff"))] -mod submod { - use crate::{S, MyTrait2}; - // This impl should also have the `not(feature = "coolstuff")`. - //@ has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ - // 'Available on non-crate feature coolstuff only.' - impl MyTrait2 for S {} -} diff --git a/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs deleted file mode 100644 index c9408ef3360..00000000000 --- a/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -pub trait Enumerable { - const N: usize; -} - -#[derive(Clone)] -pub struct SymmetricGroup -where - S: Enumerable, - [(); S::N]: Sized, -{ - _phantom: std::marker::PhantomData, -} - -fn main() {} diff --git a/tests/rustdoc/duplicated_impl.rs b/tests/rustdoc/duplicated_impl.rs deleted file mode 100644 index e7828885cc1..00000000000 --- a/tests/rustdoc/duplicated_impl.rs +++ /dev/null @@ -1,14 +0,0 @@ -// This test ensures that the same implementation doesn't show more than once. -// It's a regression test for https://github.com/rust-lang/rust/issues/96036. - -#![crate_name = "foo"] - -// We check that there is only one "impl Something for T" listed in the -// blanket implementations. - -//@ has 'foo/struct.Whatever.html' -//@ count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 - -pub trait Something { } -pub struct Whatever; -impl Something for T {} diff --git a/tests/rustdoc/empty-impl-block.rs b/tests/rustdoc/empty-impl-block.rs deleted file mode 100644 index 91fd4a64ef9..00000000000 --- a/tests/rustdoc/empty-impl-block.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/struct.Foo.html' -pub struct Foo; - -//@ has - '//*[@class="docblock"]' 'Hello empty impl block!' -//@ has - '//*[@class="item-info"]' 'This impl block contains no items.' -/// Hello empty impl block! -impl Foo {} -// We ensure that this empty impl block without doc isn't rendered. -//@ count - '//*[@class="impl"]' 'impl Foo' 1 -impl Foo {} - -// Just to ensure that empty trait impl blocks are rendered. -pub struct Another; -pub trait Bar {} - -//@ has 'foo/struct.Another.html' -//@ has - '//h3[@class="code-header"]' 'impl Bar for Another' -impl Bar for Another {} diff --git a/tests/rustdoc/empty-impls.rs b/tests/rustdoc/empty-impls.rs deleted file mode 100644 index 912a8d3d913..00000000000 --- a/tests/rustdoc/empty-impls.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo.html -//@ has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' -pub struct Foo; - -pub trait EmptyTrait {} - -//@ has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' -impl EmptyTrait for Foo {} - -pub trait NotEmpty { - fn foo(&self); -} - -//@ has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' -impl NotEmpty for Foo { - fn foo(&self) {} -} diff --git a/tests/rustdoc/extern-impl-trait.rs b/tests/rustdoc/extern-impl-trait.rs deleted file mode 100644 index 65b7a8cef49..00000000000 --- a/tests/rustdoc/extern-impl-trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:extern-impl-trait.rs - -#![crate_name = "foo"] - -extern crate extern_impl_trait; - -//@ has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" -pub use extern_impl_trait::X; - -//@ has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" -pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/extern-impl.rs b/tests/rustdoc/extern-impl.rs deleted file mode 100644 index 4fc31393988..00000000000 --- a/tests/rustdoc/extern-impl.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/struct.Foo.html -pub struct Foo; - -impl Foo { - //@ has - '//h4[@class="code-header"]' 'fn rust0()' - pub fn rust0() {} - //@ has - '//h4[@class="code-header"]' 'fn rust1()' - pub extern "Rust" fn rust1() {} - //@ has - '//h4[@class="code-header"]' 'extern "C" fn c0()' - pub extern fn c0() {} - //@ has - '//h4[@class="code-header"]' 'extern "C" fn c1()' - pub extern "C" fn c1() {} - //@ has - '//h4[@class="code-header"]' 'extern "system" fn system0()' - pub extern "system" fn system0() {} -} - -//@ has foo/trait.Bar.html -pub trait Bar {} - -//@ has - '//h3[@class="code-header"]' 'impl Bar for fn()' -impl Bar for fn() {} -//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' -impl Bar for extern fn() {} -//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' -impl Bar for extern "system" fn() {} diff --git a/tests/rustdoc/foreign-implementors-js-43701.rs b/tests/rustdoc/foreign-implementors-js-43701.rs deleted file mode 100644 index 03147da02c2..00000000000 --- a/tests/rustdoc/foreign-implementors-js-43701.rs +++ /dev/null @@ -1,6 +0,0 @@ -// https://github.com/rust-lang/rust/issues/43701 -#![crate_name = "foo"] - -pub use std::vec::Vec; - -//@ !has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/generic-const-items.rs b/tests/rustdoc/generic-const-items.rs deleted file mode 100644 index 31c300f2ff1..00000000000 --- a/tests/rustdoc/generic-const-items.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![feature(generic_const_items)] -#![allow(incomplete_features)] - -//@ has 'generic_const_items/constant.K.html' -//@ has - '//*[@class="rust item-decl"]//code' \ -// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ -// where \ -// String: From;" -pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None -where - String: From; - -//@ has generic_const_items/trait.Trait.html -pub trait Trait { - //@ has - '//*[@id="associatedconstant.C"]' \ - // "const C<'a>: &'a T \ - // where \ - // T: 'a + Eq" - const C<'a>: &'a T - where - T: 'a + Eq; -} - -pub struct Implementor; - -//@ has generic_const_items/struct.Implementor.html -//@ has - '//h3[@class="code-header"]' 'impl Trait for Implementor' -impl Trait for Implementor { - //@ has - '//*[@id="associatedconstant.C"]' \ - // "const C<'a>: &'a str = \"C\" \ - // where \ - // str: 'a" - const C<'a>: &'a str = "C" - // In real code we could've left off this bound but adding it explicitly allows us to test if - // we render where-clauses on associated consts inside impl blocks correctly. - where - str: 'a; -} diff --git a/tests/rustdoc/generic-impl.rs b/tests/rustdoc/generic-impl.rs deleted file mode 100644 index 9d15d0fff77..00000000000 --- a/tests/rustdoc/generic-impl.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] - -use std::fmt; - -//@ !has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' -pub struct Bar; - -//@ has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl ToString for T' -pub struct Foo; -//@ has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' - -impl fmt::Display for Foo { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Foo") - } -} diff --git a/tests/rustdoc/generic_const_exprs.rs b/tests/rustdoc/generic_const_exprs.rs deleted file mode 100644 index 44f7bf5b24c..00000000000 --- a/tests/rustdoc/generic_const_exprs.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for . - -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - -#![crate_name = "foo"] - -//@ has 'foo/trait.Foo.html' - -pub trait Foo: Sized { - const WIDTH: usize; - - fn arrayify(self) -> [Self; Self::WIDTH]; -} - -impl Foo for T { - const WIDTH: usize = 1; - - //@ has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ - // 'fn arrayify(self) -> [Self; Self::WIDTH]' - fn arrayify(self) -> [Self; Self::WIDTH] { - [self] - } -} diff --git a/tests/rustdoc/glob-shadowing-const.rs b/tests/rustdoc/glob-shadowing-const.rs deleted file mode 100644 index fbc22dbccaa..00000000000 --- a/tests/rustdoc/glob-shadowing-const.rs +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/rust-lang/rust/pull/83872#issuecomment-820101008 -#![crate_name="foo"] - -mod sub4 { - /// 0 - pub const X: usize = 0; - pub mod inner { - pub use super::*; - /// 1 - pub const X: usize = 1; - } -} - -#[doc(inline)] -pub use sub4::inner::*; - -//@ has 'foo/index.html' -//@ has - '//dd' '1' -//@ !has - '//dd' '0' -fn main() { assert_eq!(X, 1); } diff --git a/tests/rustdoc/hidden-implementors-90781.rs b/tests/rustdoc/hidden-implementors-90781.rs deleted file mode 100644 index 960a85b91f0..00000000000 --- a/tests/rustdoc/hidden-implementors-90781.rs +++ /dev/null @@ -1,78 +0,0 @@ -//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items - -// regression test for https://github.com/rust-lang/rust/issues/90781 -#![crate_name = "foo"] - -//@ has foo/trait.TPubVis.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -pub trait TPubVis {} - -//@ has foo/trait.TPubHidden.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -#[doc(hidden)] -pub trait TPubHidden {} - -//@ has foo/trait.TPrivVis.html -//@ has - '//*[@id="implementors-list"]' 'HidPriv' -//@ has - '//*[@id="implementors-list"]' 'HidPub' -//@ has - '//*[@id="implementors-list"]' 'VisPriv' -//@ has - '//*[@id="implementors-list"]' 'VisPub' -trait TPrivVis {} - -#[doc(hidden)] -//@ has foo/trait.TPrivHidden.html -//@ has - '//*[@id="impl-TPrivHidden-for-HidPriv"]' 'HidPriv' -//@ has - '//*[@id="impl-TPrivHidden-for-HidPub"]' 'HidPub' -//@ has - '//*[@id="impl-TPrivHidden-for-VisPriv"]' 'VisPriv' -//@ has - '//*[@id="impl-TPrivHidden-for-VisPub"]' 'VisPub' -trait TPrivHidden {} - -//@ has foo/struct.VisPub.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -pub struct VisPub; - -//@ has foo/struct.VisPriv.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -struct VisPriv; - -//@ has foo/struct.HidPub.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -#[doc(hidden)] -pub struct HidPub; - -//@ has foo/struct.HidPriv.html -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' -//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' -#[doc(hidden)] -struct HidPriv; - -macro_rules! implement { - ($trait:ident - $($struct:ident)+) => { - $( - impl $trait for $struct {} - )+ - } -} - - -implement!(TPubVis - VisPub VisPriv HidPub HidPriv); -implement!(TPubHidden - VisPub VisPriv HidPub HidPriv); -implement!(TPrivVis - VisPub VisPriv HidPub HidPriv); -implement!(TPrivHidden - VisPub VisPriv HidPub HidPriv); diff --git a/tests/rustdoc/hidden-impls.rs b/tests/rustdoc/hidden-impls.rs deleted file mode 100644 index 73deeed9e90..00000000000 --- a/tests/rustdoc/hidden-impls.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_name = "foo"] - -mod hidden { - #[derive(Clone)] - pub struct Foo; -} - -#[doc(hidden)] -pub mod __hidden { - pub use hidden::Foo; -} - -//@ has foo/trait.Clone.html -//@ !hasraw - 'Foo' -//@ has trait.impl/core/clone/trait.Clone.js -//@ !hasraw - 'Foo' -pub use std::clone::Clone; diff --git a/tests/rustdoc/hidden-trait-struct-impls.rs b/tests/rustdoc/hidden-trait-struct-impls.rs deleted file mode 100644 index 1010cb45960..00000000000 --- a/tests/rustdoc/hidden-trait-struct-impls.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![crate_name = "foo"] - -#[doc(hidden)] -pub trait Foo {} - -trait Dark {} - -pub trait Bam {} - -pub struct Bar; - -struct Hidden; - -//@ !has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' -impl Foo for Bar {} -//@ !has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' -impl Dark for Bar {} -//@ has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' -//@ has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' -impl Bam for Bar {} -//@ !has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' -impl Bam for Hidden {} diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs deleted file mode 100644 index e94c1ea5c61..00000000000 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Test that certain unevaluated constant expression arguments that are -// deemed too verbose or complex and that may leak private or -// `doc(hidden)` struct fields are not displayed in the documentation. -// -// Read the documentation of `rustdoc::clean::utils::print_const_expr` -// for further details. -#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)] -#![allow(incomplete_features)] - -use std::marker::ConstParamTy; - -//@ has hide_complex_unevaluated_const_arguments/trait.Stage.html -pub trait Stage { - // A helper constant that prevents const expressions containing it - // from getting fully evaluated since it doesn't have a body and - // thus is non-reducible. This allows us to specifically test the - // pretty-printing of *unevaluated* consts. - const ABSTRACT: usize; - - // Currently considered "overly complex" by the `generic_const_exprs` - // feature. If / once this expression kind gets supported, this - // unevaluated const expression could leak the private struct field. - // - // FIXME: Once the line below compiles, make this a test that - // ensures that the private field is not printed. - // - //const ARRAY0: [u8; Struct { private: () } + Self::ABSTRACT]; - - // This assoc. const could leak the private assoc. function `Struct::new`. - // Ensure that this does not happen. - // - //@ has - '//*[@id="associatedconstant.ARRAY1"]' \ - // 'const ARRAY1: [u8; { _ }]' - const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] - where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; - - //@ has - '//*[@id="associatedconstant.VERBOSE"]' \ - // 'const VERBOSE: [u16; { _ }]' - const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] - where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; - - // Check that we do not leak the private struct field contained within - // the path. The output could definitely be improved upon - // (e.g. printing sth. akin to `>::OUT`) but - // right now “safe is safe”. - // - //@ has - '//*[@id="associatedconstant.PATH"]' \ - // 'const PATH: usize = _' - const PATH: usize = >::OUT; -} - -const fn compute(input: &str, extra: usize) -> usize { - input.len() + extra -} - -pub trait Helper { - const OUT: usize; -} - -impl Helper for St { - const OUT: usize = St::ABSTRACT; -} - -// Currently in rustdoc, const arguments are not evaluated in this position -// and therefore they fall under the realm of `print_const_expr`. -// If rustdoc gets patched to evaluate const arguments, it is fine to replace -// this test as long as one can ensure that private fields are not leaked! -// -//@ has hide_complex_unevaluated_const_arguments/trait.Sub.html \ -// '//pre[@class="rust item-decl"]' \ -// 'pub trait Sub: Sup<{ _ }, { _ }> { }' -pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} - -pub trait Sup {} - -#[derive(ConstParamTy, PartialEq, Eq)] -pub struct Struct { private: () } - -impl Struct { - const fn new() -> Self { Self { private: () } } - const fn do_something(self, x: usize) -> usize { - x - } -} -/* FIXME(const-trait): readd this -impl const std::ops::Add for Struct { - type Output = usize; - - fn add(self, _: usize) -> usize { 0 } -} -*/ diff --git a/tests/rustdoc/hide-complex-unevaluated-consts.rs b/tests/rustdoc/hide-complex-unevaluated-consts.rs deleted file mode 100644 index 61ae8c801dd..00000000000 --- a/tests/rustdoc/hide-complex-unevaluated-consts.rs +++ /dev/null @@ -1,71 +0,0 @@ -// Regression test for issue #97933. -// -// Test that certain unevaluated constant expressions that are -// deemed too verbose or complex and that may leak private or -// `doc(hidden)` struct fields are not displayed in the documentation. -// -// Read the documentation of `rustdoc::clean::utils::print_const_expr` -// for further details. - -//@ has hide_complex_unevaluated_consts/trait.Container.html -pub trait Container { - // A helper constant that prevents const expressions containing it - // from getting fully evaluated since it doesn't have a body and - // thus is non-reducible. This allows us to specifically test the - // pretty-printing of *unevaluated* consts. - const ABSTRACT: i32; - - // Ensure that the private field does not get leaked: - // - //@ has - '//*[@id="associatedconstant.STRUCT0"]' \ - // 'const STRUCT0: Struct = _' - const STRUCT0: Struct = Struct { private: () }; - - //@ has - '//*[@id="associatedconstant.STRUCT1"]' \ - // 'const STRUCT1: (Struct,) = _' - const STRUCT1: (Struct,) = (Struct{private: /**/()},); - - // Although the struct field is public here, check that it is not - // displayed. In a future version of rustdoc, we definitely want to - // show it. However for the time being, the printing logic is a bit - // conservative. - // - //@ has - '//*[@id="associatedconstant.STRUCT2"]' \ - // 'const STRUCT2: Record = _' - const STRUCT2: Record = Record { public: 5 }; - - // Test that we do not show the incredibly verbose match expr: - // - //@ has - '//*[@id="associatedconstant.MATCH0"]' \ - // 'const MATCH0: i32 = _' - const MATCH0: i32 = match 234 { - 0 => 1, - _ => Self::ABSTRACT, - }; - - //@ has - '//*[@id="associatedconstant.MATCH1"]' \ - // 'const MATCH1: bool = _' - const MATCH1: bool = match Self::ABSTRACT { - _ => true, - }; - - // Check that we hide complex (arithmetic) operations. - // In this case, it is a bit unfortunate since the expression - // is not *that* verbose and it might be quite useful to the reader. - // - // However in general, the expression might be quite large and - // contain match expressions and structs with private fields. - // We would need to recurse over the whole expression and even more - // importantly respect operator precedence when pretty-printing - // the potentially partially censored expression. - // For now, the implementation is quite simple and the choices - // rather conservative. - // - //@ has - '//*[@id="associatedconstant.ARITH_OPS"]' \ - // 'const ARITH_OPS: i32 = _' - const ARITH_OPS: i32 = Self::ABSTRACT * 2 + 1; -} - -pub struct Struct { private: () } - -pub struct Record { pub public: i32 } diff --git a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs b/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs deleted file mode 100644 index 995121a8455..00000000000 --- a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs +++ /dev/null @@ -1,24 +0,0 @@ -// https://github.com/rust-lang/rust/issues/74083 -#![crate_name="foo"] - -use std::ops::Deref; - -pub struct Foo; - -impl Foo { - pub fn foo(&mut self) {} -} - -//@ has foo/struct.Bar.html -//@ !has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' -pub struct Bar { - foo: Foo, -} - -impl Deref for Bar { - type Target = Foo; - - fn deref(&self) -> &Foo { - &self.foo - } -} diff --git a/tests/rustdoc/ice-associated-const-equality-105952.rs b/tests/rustdoc/ice-associated-const-equality-105952.rs deleted file mode 100644 index 1bcdfac7342..00000000000 --- a/tests/rustdoc/ice-associated-const-equality-105952.rs +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/rust-lang/rust/issues/105952 -#![crate_name = "foo"] - -#![feature(associated_const_equality)] -pub enum ParseMode { - Raw, -} -pub trait Parse { - const PARSE_MODE: ParseMode; -} -pub trait RenderRaw {} - -//@ hasraw foo/trait.RenderRaw.html 'impl' -//@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' -impl> RenderRaw for T {} diff --git a/tests/rustdoc/impl-alias-substituted.rs b/tests/rustdoc/impl-alias-substituted.rs deleted file mode 100644 index 02efcd88df8..00000000000 --- a/tests/rustdoc/impl-alias-substituted.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub struct Matrix([[T; N]; M]); - -pub type Vector = Matrix; - -//@ has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl Matrix" -impl Vector { - pub fn test() {} -} diff --git a/tests/rustdoc/impl-assoc-type-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs deleted file mode 100644 index c350456195d..00000000000 --- a/tests/rustdoc/impl-assoc-type-21092.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ aux-build:issue-21092.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/21092 -#![crate_name="issue_21092"] - -extern crate issue_21092; - -//@ has issue_21092/struct.Bar.html -//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' -pub use issue_21092::{Foo, Bar}; diff --git a/tests/rustdoc/impl-associated-items-order.rs b/tests/rustdoc/impl-associated-items-order.rs deleted file mode 100644 index 759e0f0b400..00000000000 --- a/tests/rustdoc/impl-associated-items-order.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This test ensures that impl associated items always follow this order: -// -// 1. Consts -// 2. Types -// 3. Functions - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Bar.html' -pub struct Bar; - -impl Bar { - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ - // 'pub fn foo()' - pub fn foo() {} - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ - // 'pub const X: u8 = 12u8' - pub const X: u8 = 12; - //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ - // 'pub type Y = u8' - pub type Y = u8; -} - -pub trait Foo { - const W: u32; - fn yeay(); - type Z; -} - -impl Foo for Bar { - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ - // 'type Z = u8' - type Z = u8; - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ - // 'const W: u32 = 12u32' - const W: u32 = 12; - //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ - // 'fn yeay()' - fn yeay() {} -} diff --git a/tests/rustdoc/impl-associated-items-sidebar.rs b/tests/rustdoc/impl-associated-items-sidebar.rs deleted file mode 100644 index d393a577e50..00000000000 --- a/tests/rustdoc/impl-associated-items-sidebar.rs +++ /dev/null @@ -1,42 +0,0 @@ -// This test ensures that impl/trait associated items are listed in the sidebar. - -// ignore-tidy-linelength - -#![feature(inherent_associated_types)] -#![feature(associated_type_defaults)] -#![allow(incomplete_features)] -#![crate_name = "foo"] - -//@ has 'foo/struct.Bar.html' -pub struct Bar; - -impl Bar { - //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedconstant"]/li/a[@href="#associatedconstant.X"]' 'X' - pub const X: u8 = 12; - //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedtype"]/li/a[@href="#associatedtype.Y"]' 'Y' - pub type Y = u8; -} - -//@ has 'foo/trait.Foo.html' -pub trait Foo { - //@ has - '//*[@class="sidebar-elems"]//h3[5]' 'Required Methods' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][5]/li/a[@href="#tymethod.yeay"]' 'yeay' - fn yeay(); - //@ has - '//*[@class="sidebar-elems"]//h3[6]' 'Provided Methods' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][6]/li/a[@href="#method.boo"]' 'boo' - fn boo() {} - //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Required Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][1]/li/a[@href="#associatedconstant.W"]' 'W' - const W: u32; - //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Provided Associated Constants' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][2]/li/a[@href="#associatedconstant.U"]' 'U' - const U: u32 = 0; - //@ has - '//*[@class="sidebar-elems"]//h3[3]' 'Required Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][3]/li/a[@href="#associatedtype.Z"]' 'Z' - type Z; - //@ has - '//*[@class="sidebar-elems"]//h3[4]' 'Provided Associated Types' - //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][4]/li/a[@href="#associatedtype.T"]' 'T' - type T = u32; -} diff --git a/tests/rustdoc/impl-blanket-53689.rs b/tests/rustdoc/impl-blanket-53689.rs deleted file mode 100644 index 4b1697349f2..00000000000 --- a/tests/rustdoc/impl-blanket-53689.rs +++ /dev/null @@ -1,17 +0,0 @@ -// https://github.com/rust-lang/rust/issues/53689 -//@ aux-build:issue-53689.rs - -#![crate_name = "foo"] - -extern crate issue_53689; - -//@ has foo/trait.MyTrait.html -//@ !hasraw - 'MyStruct' -//@ count - '//*[h3="impl MyTrait for T"]' 1 -pub trait MyTrait {} - -impl MyTrait for T {} - -mod a { - pub use issue_53689::MyStruct; -} diff --git a/tests/rustdoc/impl-box.rs b/tests/rustdoc/impl-box.rs deleted file mode 100644 index 1fb63e21685..00000000000 --- a/tests/rustdoc/impl-box.rs +++ /dev/null @@ -1,16 +0,0 @@ -// https://github.com/rust-lang/rust/issues/92940 -// -// Show traits implemented on fundamental types that wrap local ones. - -pub struct MyType; - -//@ has 'impl_box/struct.MyType.html' -//@ has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box' - -impl Iterator for Box { - type Item = (); - - fn next(&mut self) -> Option { - todo!() - } -} diff --git a/tests/rustdoc/impl-disambiguation.rs b/tests/rustdoc/impl-disambiguation.rs deleted file mode 100644 index cfd5013964b..00000000000 --- a/tests/rustdoc/impl-disambiguation.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![crate_name = "foo"] - -pub trait Foo {} - -pub struct Bar { field: T } - -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for Bar" -impl Foo for Bar {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for Bar" -impl Foo for Bar {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl<'a> Foo for &'a Bar" -impl<'a> Foo for &'a Bar {} - -pub mod mod1 { - pub struct Baz {} -} - -pub mod mod2 { - pub enum Baz {} -} - -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl Foo for foo::mod1::Baz" -impl Foo for mod1::Baz {} -//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl<'a> Foo for &'a foo::mod2::Baz" -impl<'a> Foo for &'a mod2::Baz {} diff --git a/tests/rustdoc/impl-everywhere.rs b/tests/rustdoc/impl-everywhere.rs deleted file mode 100644 index d1a4e901bad..00000000000 --- a/tests/rustdoc/impl-everywhere.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![crate_name = "foo"] - -pub trait Foo {} -pub trait Foo2 {} - -pub struct Bar; - -impl Foo for Bar {} -impl Foo2 for Bar {} - -//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" -pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo { - x -} - -//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' -pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 { - Bar -} - -//@ has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' -pub fn foo_foo() -> impl Foo + Foo2 { - Bar -} - -//@ has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" -pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { -} diff --git a/tests/rustdoc/impl-in-const-block.rs b/tests/rustdoc/impl-in-const-block.rs deleted file mode 100644 index 3f757fa9566..00000000000 --- a/tests/rustdoc/impl-in-const-block.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Regression test for #83026. -// The goal of this test is to ensure that impl blocks inside -// const expressions are documented as well. - -#![crate_name = "foo"] - -//@ has 'foo/struct.A.html' -//@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' -//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' -//@ has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' -//@ has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' -//@ has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' -pub struct A; - -const _: () = { - impl A { - const FOO: () = { - impl A { - pub fn woo(&self) {} - } - }; - - pub fn new() -> A { - A - } - } -}; -pub const X: () = { - impl A { - pub fn bar(&self) {} - } -}; - -fn foo() { - impl A { - pub fn yoo() {} - } - const _: () = { - impl A { - pub fn yuu() {} - } - }; -} diff --git a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs deleted file mode 100644 index a514bc35bfc..00000000000 --- a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![crate_name = "foo"] - -//@ has 'foo/index.html' -// There should be only `type A`. -//@ count - '//*[@class="item-table"]//dt' 1 -//@ has - '//dt/a[@href="type.A.html"]' 'A' - -mod foo { - pub struct S; -} - -use foo::S; - -pub type A = S; - -//@ has 'foo/type.A.html' -//@ has - '//*[@id="method.default"]/h4' 'fn default() -> Self' -impl Default for A { - fn default() -> Self { - S - } -} - -//@ has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' -impl A { - pub fn a(&self) {} -} diff --git a/tests/rustdoc/impl-parts-crosscrate.rs b/tests/rustdoc/impl-parts-crosscrate.rs deleted file mode 100644 index 631c8bb3eb3..00000000000 --- a/tests/rustdoc/impl-parts-crosscrate.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build:rustdoc-impl-parts-crosscrate.rs -//@ ignore-cross-compile - -#![feature(negative_impls)] - -extern crate rustdoc_impl_parts_crosscrate; - -pub struct Bar { t: T } - -// The output file is html embedded in javascript, so the html tags -// aren't stripped by the processing script and we can't check for the -// full impl string. Instead, just make sure something from each part -// is mentioned. - -//@ hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar -//@ hasraw - Send -//@ hasraw - !AnAutoTrait -//@ hasraw - Copy -impl !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar - where T: Copy {} diff --git a/tests/rustdoc/impl-parts.rs b/tests/rustdoc/impl-parts.rs deleted file mode 100644 index 4f281bfd63c..00000000000 --- a/tests/rustdoc/impl-parts.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(negative_impls)] -#![feature(auto_traits)] - -pub auto trait AnAutoTrait {} - -pub struct Foo { field: T } - -//@ has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !AnAutoTrait for Foowhere T: Sync + Clone," -//@ has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ -// "impl !AnAutoTrait for Foowhere T: Sync + Clone," -impl !AnAutoTrait for Foo where T: Sync {} diff --git a/tests/rustdoc/impl-ref-20175.rs b/tests/rustdoc/impl-ref-20175.rs deleted file mode 100644 index b1a9286fd41..00000000000 --- a/tests/rustdoc/impl-ref-20175.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/20175 - -#![crate_name="issue_20175"] - -pub trait Foo { - fn foo(&self) {} -} - -pub struct Bar; - -//@ has issue_20175/struct.Bar.html \ -// '//*[@id="method.foo"]' \ -// 'fn foo' -impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/impl-trait-43869.rs b/tests/rustdoc/impl-trait-43869.rs deleted file mode 100644 index 89176f59ca1..00000000000 --- a/tests/rustdoc/impl-trait-43869.rs +++ /dev/null @@ -1,75 +0,0 @@ -// https://github.com/rust-lang/rust/issues/43869 -#![crate_name="foo"] - -pub fn g() -> impl Iterator { - Some(1u8).into_iter() -} - -#[allow(unused_parens)] -pub fn h() -> (impl Iterator) { - Some(1u8).into_iter() -} - -pub fn i() -> impl Iterator + 'static { - Some(1u8).into_iter() -} - -pub fn j() -> impl Iterator + Clone { - Some(1u8).into_iter() -} - -pub fn k() -> [impl Clone; 2] { - [123u32, 456u32] -} - -pub fn l() -> (impl Clone, impl Default) { - (789u32, -123i32) -} - -pub fn m() -> &'static impl Clone { - &1u8 -} - -pub fn n() -> *const impl Clone { - &1u8 -} - -pub fn o() -> &'static [impl Clone] { - b":)" -} - -// issue #44731 -pub fn test_44731_0() -> Box> { - Box::new(g()) -} - -pub fn test_44731_1() -> Result, ()> { - Ok(Box::new(j())) -} - -// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 -// -//pub fn test_44731_2() -> Box { -// Box::new(|_: u32| {}) -//} -// -//pub fn test_44731_3() -> Box impl Clone> { -// Box::new(|| 0u32) -//} - -pub fn test_44731_4() -> Box> { - Box::new(g()) -} - -//@ has foo/fn.g.html -//@ has foo/fn.h.html -//@ has foo/fn.i.html -//@ has foo/fn.j.html -//@ has foo/fn.k.html -//@ has foo/fn.l.html -//@ has foo/fn.m.html -//@ has foo/fn.n.html -//@ has foo/fn.o.html -//@ has foo/fn.test_44731_0.html -//@ has foo/fn.test_44731_1.html -//@ has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/impl-trait-alias.rs b/tests/rustdoc/impl-trait-alias.rs deleted file mode 100644 index f7ecfffbf46..00000000000 --- a/tests/rustdoc/impl-trait-alias.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(type_alias_impl_trait)] - -trait MyTrait {} -impl MyTrait for i32 {} - -//@ hasraw impl_trait_alias/type.Foo.html 'Foo' -/// debug type -pub type Foo = impl MyTrait; - -//@ hasraw impl_trait_alias/fn.foo.html 'foo' -/// debug function -pub fn foo() -> Foo { - 1 -} diff --git a/tests/rustdoc/impl-trait-precise-capturing.rs b/tests/rustdoc/impl-trait-precise-capturing.rs deleted file mode 100644 index 3ec8c578013..00000000000 --- a/tests/rustdoc/impl-trait-precise-capturing.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ aux-build:precise-capturing.rs - -#![crate_name = "foo"] - -extern crate precise_capturing; - -//@ has foo/fn.two.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'b, 'a>" -pub fn two<'a, 'b, 'c>() -> impl Sized + use<'b, 'a /* no 'c */> {} - -//@ has foo/fn.params.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" -pub fn params<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} - -//@ has foo/fn.none.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" -pub fn none() -> impl Sized + use<> {} - -//@ has foo/fn.first.html '//section[@id="main-content"]//pre' "-> impl use<> + Sized" -pub fn first() -> impl use<> + Sized {} - -//@ has foo/fn.cross_crate_empty.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" -pub use precise_capturing::cross_crate_empty; - -//@ matches foo/fn.cross_crate_missing.html '//section[@id="main-content"]//pre' "-> impl Sized$" -pub use precise_capturing::cross_crate_missing; - -//@ has foo/fn.cross_crate_args.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" -pub use precise_capturing::cross_crate_args; diff --git a/tests/rustdoc/impl-type-parameter-33592.rs b/tests/rustdoc/impl-type-parameter-33592.rs deleted file mode 100644 index ac5df460925..00000000000 --- a/tests/rustdoc/impl-type-parameter-33592.rs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/rust-lang/rust/issues/33592 -#![crate_name = "foo"] - -pub trait Foo {} - -pub struct Bar; - -pub struct Baz; - -//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Bar' -impl Foo for Bar {} - -//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Baz' -impl Foo for Baz {} diff --git a/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..15953122280 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/cross-crate-hidden-impl-parameter.rs @@ -0,0 +1,5 @@ +#[doc(hidden)] +pub enum HiddenType {} + +#[doc(hidden)] +pub trait HiddenTrait {} diff --git a/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs b/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs new file mode 100644 index 00000000000..dbd54393098 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/extern-impl-trait.rs @@ -0,0 +1,27 @@ +pub trait Foo { + type Associated; +} + +pub struct X; +pub struct Y; + + +impl Foo for X { + type Associated = (); +} + +impl Foo for Y { + type Associated = (); +} + +impl X { + pub fn returns_sized<'a>(&'a self) -> impl Foo + 'a { + X + } +} + +impl Y { + pub fn returns_unsized<'a>(&'a self) -> Box + 'a> { + Box::new(X) + } +} diff --git a/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs b/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs new file mode 100644 index 00000000000..fc51e42e500 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/incoherent-impl-types.rs @@ -0,0 +1,7 @@ +#![feature(rustc_attrs)] + +#[rustc_has_incoherent_inherent_impls] +pub trait FooTrait {} + +#[rustc_has_incoherent_inherent_impls] +pub struct FooStruct; diff --git a/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs b/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs new file mode 100644 index 00000000000..df1b59069be --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-100204-aux.rs @@ -0,0 +1,13 @@ +#![crate_name="first"] + +pub mod prelude { + pub use crate::Bot; +} + +pub struct Bot; + +impl Bot { + pub fn new() -> Bot { + Bot + } +} diff --git a/tests/rustdoc/impl/auxiliary/issue-17476.rs b/tests/rustdoc/impl/auxiliary/issue-17476.rs new file mode 100644 index 00000000000..0a63b893fff --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-17476.rs @@ -0,0 +1,7 @@ +//@ compile-flags: -Cmetadata=aux + +#![doc(html_root_url = "http://example.com")] + +pub trait Foo { + fn foo(&self) {} +} diff --git a/tests/rustdoc/impl/auxiliary/issue-21092.rs b/tests/rustdoc/impl/auxiliary/issue-21092.rs new file mode 100644 index 00000000000..49522e0d4b5 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-21092.rs @@ -0,0 +1,12 @@ +//@ compile-flags: -Cmetadata=aux + +pub trait Foo { + type Bar; + fn foo(&self) {} +} + +pub struct Bar; + +impl Foo for Bar { + type Bar = i32; +} diff --git a/tests/rustdoc/impl/auxiliary/issue-22025.rs b/tests/rustdoc/impl/auxiliary/issue-22025.rs new file mode 100644 index 00000000000..6bc55073283 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-22025.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -Cmetadata=aux + +pub mod foo { + + pub trait Foo {} + pub struct Bar; + + impl Foo for Bar {} + +} diff --git a/tests/rustdoc/impl/auxiliary/issue-53689.rs b/tests/rustdoc/impl/auxiliary/issue-53689.rs new file mode 100644 index 00000000000..5003c2c00f4 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/issue-53689.rs @@ -0,0 +1 @@ +pub struct MyStruct; diff --git a/tests/rustdoc/impl/auxiliary/precise-capturing.rs b/tests/rustdoc/impl/auxiliary/precise-capturing.rs new file mode 100644 index 00000000000..531d4dfdccc --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/precise-capturing.rs @@ -0,0 +1,7 @@ +#![feature(precise_capturing)] + +pub fn cross_crate_empty() -> impl Sized + use<> {} + +pub fn cross_crate_missing() -> impl Sized {} + +pub fn cross_crate_args<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} diff --git a/tests/rustdoc/impl/auxiliary/real_gimli.rs b/tests/rustdoc/impl/auxiliary/real_gimli.rs new file mode 100644 index 00000000000..871d9b31be9 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/real_gimli.rs @@ -0,0 +1,13 @@ +//@ aux-build:realcore.rs + +#![crate_name = "real_gimli"] +#![feature(staged_api, extremely_unstable)] +#![unstable(feature = "rustc_private", issue = "none")] + +extern crate realcore; + +#[unstable(feature = "rustc_private", issue = "none")] +pub struct EndianSlice; + +#[unstable(feature = "rustc_private", issue = "none")] +impl realcore::Deref for EndianSlice {} diff --git a/tests/rustdoc/impl/auxiliary/realcore.rs b/tests/rustdoc/impl/auxiliary/realcore.rs new file mode 100644 index 00000000000..e0a906df002 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/realcore.rs @@ -0,0 +1,15 @@ +#![crate_name = "realcore"] +#![feature(staged_api)] +#![unstable(feature = "extremely_unstable", issue = "none")] + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +pub struct Foo {} + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +pub trait Join {} + +#[unstable(feature = "extremely_unstable_foo", issue = "none")] +impl Join for Foo {} + +#[stable(feature = "faked_deref", since = "1.47.0")] +pub trait Deref {} diff --git a/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs b/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs new file mode 100644 index 00000000000..032db3b25e6 --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/rustdoc-default-impl.rs @@ -0,0 +1,23 @@ +#![feature(auto_traits)] + +pub mod bar { + use std::marker; + + pub auto trait Bar {} + + pub trait Foo { + fn foo(&self) {} + } + + impl Foo { + pub fn test(&self) {} + } + + pub struct TypeId; + + impl TypeId { + pub fn of() -> TypeId { + panic!() + } + } +} diff --git a/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs b/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs new file mode 100644 index 00000000000..135987fc00d --- /dev/null +++ b/tests/rustdoc/impl/auxiliary/rustdoc-impl-parts-crosscrate.rs @@ -0,0 +1,3 @@ +#![feature(auto_traits)] + +pub auto trait AnAutoTrait {} diff --git a/tests/rustdoc/impl/blanket-impl-29503.rs b/tests/rustdoc/impl/blanket-impl-29503.rs new file mode 100644 index 00000000000..f43fe79ca58 --- /dev/null +++ b/tests/rustdoc/impl/blanket-impl-29503.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/29503 +#![crate_name="issue_29503"] + +use std::fmt; + +//@ has issue_29503/trait.MyTrait.html +pub trait MyTrait { + fn my_string(&self) -> String; +} + +//@ has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl MyTrait for Twhere T: Debug" +impl MyTrait for T +where + T: fmt::Debug, +{ + fn my_string(&self) -> String { + format!("{:?}", self) + } +} + +pub fn main() {} diff --git a/tests/rustdoc/impl/blanket-impl-78673.rs b/tests/rustdoc/impl/blanket-impl-78673.rs new file mode 100644 index 00000000000..412d4057406 --- /dev/null +++ b/tests/rustdoc/impl/blanket-impl-78673.rs @@ -0,0 +1,25 @@ +// https://github.com/rust-lang/rust/issues/78673 +#![crate_name = "issue_78673"] + +pub trait Something {} + +pub trait AnAmazingTrait {} + +impl AnAmazingTrait for T {} + +//@ has 'issue_78673/struct.MyStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' +//@ !has - '//*[@class="impl"]' 'AnAmazingTrait for T' +pub struct MyStruct; + +impl AnAmazingTrait for MyStruct {} + +// generic structs may have _both_ specific and blanket impls that apply + +//@ has 'issue_78673/struct.AnotherStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for T' +pub struct AnotherStruct(T); + +impl Something for AnotherStruct {} +impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..ebfe251134a --- /dev/null +++ b/tests/rustdoc/impl/cross-crate-hidden-impl-parameter.rs @@ -0,0 +1,35 @@ +// Issue #86448: test for cross-crate `doc(hidden)` +#![crate_name = "foo"] + +//@ aux-build:cross-crate-hidden-impl-parameter.rs +extern crate cross_crate_hidden_impl_parameter; + +pub use ::cross_crate_hidden_impl_parameter::{HiddenType, HiddenTrait}; // OK, not re-exported + +pub enum MyLibType {} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' +impl From for MyLibType { + fn from(it: HiddenType) -> MyLibType { + match it {} + } +} + +pub struct T(T); + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' +impl From>>>> for MyLibType { + fn from(it: T>>>) -> MyLibType { + todo!() + } +} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +impl HiddenTrait for MyLibType {} + +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' +impl From for T>>> { + fn from(it: MyLibType) -> T>>> { + match it {} + } +} diff --git a/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs new file mode 100644 index 00000000000..5812d414997 --- /dev/null +++ b/tests/rustdoc/impl/deduplicate-glob-import-impl-21474.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/21474 +#![crate_name="issue_21474"] + +pub use inner::*; + +mod inner { + impl super::Blah for super::What { } +} + +pub trait Blah { } + +//@ count issue_21474/struct.What.html \ +// '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +pub struct What; diff --git a/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs b/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs new file mode 100644 index 00000000000..7b1648a56ac --- /dev/null +++ b/tests/rustdoc/impl/deduplicate-trait-impl-22025.rs @@ -0,0 +1,9 @@ +//@ aux-build:issue-22025.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/22025 +#![crate_name="issue_22025"] + +extern crate issue_22025; + +pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/impl/default-impl.rs b/tests/rustdoc/impl/default-impl.rs new file mode 100644 index 00000000000..2ba9c4ab5ad --- /dev/null +++ b/tests/rustdoc/impl/default-impl.rs @@ -0,0 +1,9 @@ +//@ aux-build:rustdoc-default-impl.rs +//@ ignore-cross-compile + +extern crate rustdoc_default_impl as foo; + +pub use foo::bar; + +pub fn wut() { +} diff --git a/tests/rustdoc/impl/deprecated-impls.rs b/tests/rustdoc/impl/deprecated-impls.rs new file mode 100644 index 00000000000..a57f26ec7fd --- /dev/null +++ b/tests/rustdoc/impl/deprecated-impls.rs @@ -0,0 +1,118 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo0.html +pub struct Foo0; + +impl Foo0 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' + //@ hasraw - 'fn_with_doc short' + //@ hasraw - 'fn_with_doc full' + /// fn_with_doc short + /// + /// fn_with_doc full + #[deprecated(since = "1.0.1", note = "fn_with_doc")] + pub fn fn_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' + #[deprecated(since = "1.0.2", note = "fn_without_doc")] + pub fn fn_without_doc() {} +} + +pub trait Bar { + /// fn_empty_with_doc short + /// + /// fn_empty_with_doc full + #[deprecated(since = "1.0.3", note = "fn_empty_with_doc")] + fn fn_empty_with_doc(); + + #[deprecated(since = "1.0.4", note = "fn_empty_without_doc")] + fn fn_empty_without_doc(); + + /// fn_def_with_doc short + /// + /// fn_def_with_doc full + #[deprecated(since = "1.0.5", note = "fn_def_with_doc")] + fn fn_def_with_doc() {} + + #[deprecated(since = "1.0.6", note = "fn_def_without_doc")] + fn fn_def_without_doc() {} + + /// fn_def_def_with_doc short + /// + /// fn_def_def_with_doc full + #[deprecated(since = "1.0.7", note = "fn_def_def_with_doc")] + fn fn_def_def_with_doc() {} + + #[deprecated(since = "1.0.8", note = "fn_def_def_without_doc")] + fn fn_def_def_without_doc() {} +} + +//@ has foo/struct.Foo1.html +pub struct Foo1; + +impl Bar for Foo1 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc_impl short' + //@ hasraw - 'fn_empty_with_doc_impl full' + /// fn_empty_with_doc_impl short + /// + /// fn_empty_with_doc_impl full + fn fn_empty_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + fn fn_empty_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc_impl short' + //@ hasraw - 'fn_def_with_doc_impl full' + /// fn_def_with_doc_impl short + /// + /// fn_def_with_doc_impl full + fn fn_def_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + fn fn_def_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' +} + +//@ has foo/struct.Foo2.html +pub struct Foo2; + +impl Bar for Foo2 { + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc short' + //@ !hasraw - 'fn_empty_with_doc full' + fn fn_empty_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + //@ hasraw - 'fn_empty_without_doc_impl short' + //@ hasraw - 'fn_empty_without_doc_impl full' + /// fn_empty_without_doc_impl short + /// + /// fn_empty_without_doc_impl full + fn fn_empty_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc short' + //@ !hasraw - 'fn_def_with_doc full' + fn fn_def_with_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + //@ hasraw - 'fn_def_without_doc_impl short' + //@ hasraw - 'fn_def_without_doc_impl full' + /// fn_def_without_doc_impl short + /// + /// fn_def_without_doc_impl full + fn fn_def_without_doc() {} + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' + + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' +} diff --git a/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs new file mode 100644 index 00000000000..d5ee3d09276 --- /dev/null +++ b/tests/rustdoc/impl/doc-hidden-trait-implementors-33069.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/33069 +#![crate_name="issue_33069"] + +pub trait Bar {} + +#[doc(hidden)] +pub mod hidden { + pub struct Foo; +} + +//@ has issue_33069/trait.Bar.html +//@ !has - '//code' 'impl Bar for Foo' +impl Bar for hidden::Foo {} diff --git a/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs new file mode 100644 index 00000000000..f85d7b23637 --- /dev/null +++ b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs @@ -0,0 +1,24 @@ +// Regression test for . + +#![feature(doc_auto_cfg)] +#![crate_type = "lib"] +#![crate_name = "foo"] + +pub struct S; +pub trait MyTrait1 {} +pub trait MyTrait2 {} + +//@ has foo/struct.S.html +//@ has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ +// 'Available on non-crate feature coolstuff only.' +#[cfg(not(feature = "coolstuff"))] +impl MyTrait1 for S {} + +#[cfg(not(feature = "coolstuff"))] +mod submod { + use crate::{S, MyTrait2}; + // This impl should also have the `not(feature = "coolstuff")`. + //@ has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ + // 'Available on non-crate feature coolstuff only.' + impl MyTrait2 for S {} +} diff --git a/tests/rustdoc/impl/duplicated_impl.rs b/tests/rustdoc/impl/duplicated_impl.rs new file mode 100644 index 00000000000..e7828885cc1 --- /dev/null +++ b/tests/rustdoc/impl/duplicated_impl.rs @@ -0,0 +1,14 @@ +// This test ensures that the same implementation doesn't show more than once. +// It's a regression test for https://github.com/rust-lang/rust/issues/96036. + +#![crate_name = "foo"] + +// We check that there is only one "impl Something for T" listed in the +// blanket implementations. + +//@ has 'foo/struct.Whatever.html' +//@ count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 + +pub trait Something { } +pub struct Whatever; +impl Something for T {} diff --git a/tests/rustdoc/impl/empty-impl-block.rs b/tests/rustdoc/impl/empty-impl-block.rs new file mode 100644 index 00000000000..91fd4a64ef9 --- /dev/null +++ b/tests/rustdoc/impl/empty-impl-block.rs @@ -0,0 +1,20 @@ +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +pub struct Foo; + +//@ has - '//*[@class="docblock"]' 'Hello empty impl block!' +//@ has - '//*[@class="item-info"]' 'This impl block contains no items.' +/// Hello empty impl block! +impl Foo {} +// We ensure that this empty impl block without doc isn't rendered. +//@ count - '//*[@class="impl"]' 'impl Foo' 1 +impl Foo {} + +// Just to ensure that empty trait impl blocks are rendered. +pub struct Another; +pub trait Bar {} + +//@ has 'foo/struct.Another.html' +//@ has - '//h3[@class="code-header"]' 'impl Bar for Another' +impl Bar for Another {} diff --git a/tests/rustdoc/impl/empty-impls.rs b/tests/rustdoc/impl/empty-impls.rs new file mode 100644 index 00000000000..912a8d3d913 --- /dev/null +++ b/tests/rustdoc/impl/empty-impls.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo.html +//@ has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' +pub struct Foo; + +pub trait EmptyTrait {} + +//@ has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' +impl EmptyTrait for Foo {} + +pub trait NotEmpty { + fn foo(&self); +} + +//@ has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' +impl NotEmpty for Foo { + fn foo(&self) {} +} diff --git a/tests/rustdoc/impl/extern-impl-trait.rs b/tests/rustdoc/impl/extern-impl-trait.rs new file mode 100644 index 00000000000..65b7a8cef49 --- /dev/null +++ b/tests/rustdoc/impl/extern-impl-trait.rs @@ -0,0 +1,11 @@ +//@ aux-build:extern-impl-trait.rs + +#![crate_name = "foo"] + +extern crate extern_impl_trait; + +//@ has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" +pub use extern_impl_trait::X; + +//@ has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" +pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/impl/extern-impl.rs b/tests/rustdoc/impl/extern-impl.rs new file mode 100644 index 00000000000..4fc31393988 --- /dev/null +++ b/tests/rustdoc/impl/extern-impl.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +//@ has foo/struct.Foo.html +pub struct Foo; + +impl Foo { + //@ has - '//h4[@class="code-header"]' 'fn rust0()' + pub fn rust0() {} + //@ has - '//h4[@class="code-header"]' 'fn rust1()' + pub extern "Rust" fn rust1() {} + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c0()' + pub extern fn c0() {} + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c1()' + pub extern "C" fn c1() {} + //@ has - '//h4[@class="code-header"]' 'extern "system" fn system0()' + pub extern "system" fn system0() {} +} + +//@ has foo/trait.Bar.html +pub trait Bar {} + +//@ has - '//h3[@class="code-header"]' 'impl Bar for fn()' +impl Bar for fn() {} +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' +impl Bar for extern fn() {} +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' +impl Bar for extern "system" fn() {} diff --git a/tests/rustdoc/impl/foreign-implementors-js-43701.rs b/tests/rustdoc/impl/foreign-implementors-js-43701.rs new file mode 100644 index 00000000000..03147da02c2 --- /dev/null +++ b/tests/rustdoc/impl/foreign-implementors-js-43701.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/43701 +#![crate_name = "foo"] + +pub use std::vec::Vec; + +//@ !has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/impl/generic-impl.rs b/tests/rustdoc/impl/generic-impl.rs new file mode 100644 index 00000000000..9d15d0fff77 --- /dev/null +++ b/tests/rustdoc/impl/generic-impl.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +use std::fmt; + +//@ !has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' +pub struct Bar; + +//@ has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl ToString for T' +pub struct Foo; +//@ has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' + +impl fmt::Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Foo") + } +} diff --git a/tests/rustdoc/impl/hidden-implementors-90781.rs b/tests/rustdoc/impl/hidden-implementors-90781.rs new file mode 100644 index 00000000000..960a85b91f0 --- /dev/null +++ b/tests/rustdoc/impl/hidden-implementors-90781.rs @@ -0,0 +1,78 @@ +//@ compile-flags: -Z unstable-options --document-hidden-items --document-private-items + +// regression test for https://github.com/rust-lang/rust/issues/90781 +#![crate_name = "foo"] + +//@ has foo/trait.TPubVis.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +pub trait TPubVis {} + +//@ has foo/trait.TPubHidden.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +#[doc(hidden)] +pub trait TPubHidden {} + +//@ has foo/trait.TPrivVis.html +//@ has - '//*[@id="implementors-list"]' 'HidPriv' +//@ has - '//*[@id="implementors-list"]' 'HidPub' +//@ has - '//*[@id="implementors-list"]' 'VisPriv' +//@ has - '//*[@id="implementors-list"]' 'VisPub' +trait TPrivVis {} + +#[doc(hidden)] +//@ has foo/trait.TPrivHidden.html +//@ has - '//*[@id="impl-TPrivHidden-for-HidPriv"]' 'HidPriv' +//@ has - '//*[@id="impl-TPrivHidden-for-HidPub"]' 'HidPub' +//@ has - '//*[@id="impl-TPrivHidden-for-VisPriv"]' 'VisPriv' +//@ has - '//*[@id="impl-TPrivHidden-for-VisPub"]' 'VisPub' +trait TPrivHidden {} + +//@ has foo/struct.VisPub.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +pub struct VisPub; + +//@ has foo/struct.VisPriv.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +struct VisPriv; + +//@ has foo/struct.HidPub.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +#[doc(hidden)] +pub struct HidPub; + +//@ has foo/struct.HidPriv.html +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPrivVis' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubHidden' +//@ has - '//*[@id="trait-implementations-list"]' 'TPubVis' +#[doc(hidden)] +struct HidPriv; + +macro_rules! implement { + ($trait:ident - $($struct:ident)+) => { + $( + impl $trait for $struct {} + )+ + } +} + + +implement!(TPubVis - VisPub VisPriv HidPub HidPriv); +implement!(TPubHidden - VisPub VisPriv HidPub HidPriv); +implement!(TPrivVis - VisPub VisPriv HidPub HidPriv); +implement!(TPrivHidden - VisPub VisPriv HidPub HidPriv); diff --git a/tests/rustdoc/impl/hidden-impls.rs b/tests/rustdoc/impl/hidden-impls.rs new file mode 100644 index 00000000000..73deeed9e90 --- /dev/null +++ b/tests/rustdoc/impl/hidden-impls.rs @@ -0,0 +1,17 @@ +#![crate_name = "foo"] + +mod hidden { + #[derive(Clone)] + pub struct Foo; +} + +#[doc(hidden)] +pub mod __hidden { + pub use hidden::Foo; +} + +//@ has foo/trait.Clone.html +//@ !hasraw - 'Foo' +//@ has trait.impl/core/clone/trait.Clone.js +//@ !hasraw - 'Foo' +pub use std::clone::Clone; diff --git a/tests/rustdoc/impl/hidden-trait-struct-impls.rs b/tests/rustdoc/impl/hidden-trait-struct-impls.rs new file mode 100644 index 00000000000..1010cb45960 --- /dev/null +++ b/tests/rustdoc/impl/hidden-trait-struct-impls.rs @@ -0,0 +1,22 @@ +#![crate_name = "foo"] + +#[doc(hidden)] +pub trait Foo {} + +trait Dark {} + +pub trait Bam {} + +pub struct Bar; + +struct Hidden; + +//@ !has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' +impl Foo for Bar {} +//@ !has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' +impl Dark for Bar {} +//@ has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' +//@ has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' +impl Bam for Bar {} +//@ !has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' +impl Bam for Hidden {} diff --git a/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs b/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs new file mode 100644 index 00000000000..995121a8455 --- /dev/null +++ b/tests/rustdoc/impl/hide-mut-methods-if-no-derefmut-impl-74083.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/74083 +#![crate_name="foo"] + +use std::ops::Deref; + +pub struct Foo; + +impl Foo { + pub fn foo(&mut self) {} +} + +//@ has foo/struct.Bar.html +//@ !has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +pub struct Bar { + foo: Foo, +} + +impl Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &self.foo + } +} diff --git a/tests/rustdoc/impl/impl-alias-substituted.rs b/tests/rustdoc/impl/impl-alias-substituted.rs new file mode 100644 index 00000000000..02efcd88df8 --- /dev/null +++ b/tests/rustdoc/impl/impl-alias-substituted.rs @@ -0,0 +1,9 @@ +pub struct Matrix([[T; N]; M]); + +pub type Vector = Matrix; + +//@ has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl Matrix" +impl Vector { + pub fn test() {} +} diff --git a/tests/rustdoc/impl/impl-assoc-type-21092.rs b/tests/rustdoc/impl/impl-assoc-type-21092.rs new file mode 100644 index 00000000000..c350456195d --- /dev/null +++ b/tests/rustdoc/impl/impl-assoc-type-21092.rs @@ -0,0 +1,11 @@ +//@ aux-build:issue-21092.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/21092 +#![crate_name="issue_21092"] + +extern crate issue_21092; + +//@ has issue_21092/struct.Bar.html +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' +pub use issue_21092::{Foo, Bar}; diff --git a/tests/rustdoc/impl/impl-associated-items-order.rs b/tests/rustdoc/impl/impl-associated-items-order.rs new file mode 100644 index 00000000000..759e0f0b400 --- /dev/null +++ b/tests/rustdoc/impl/impl-associated-items-order.rs @@ -0,0 +1,42 @@ +// This test ensures that impl associated items always follow this order: +// +// 1. Consts +// 2. Types +// 3. Functions + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Bar.html' +pub struct Bar; + +impl Bar { + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ + // 'pub fn foo()' + pub fn foo() {} + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ + // 'pub const X: u8 = 12u8' + pub const X: u8 = 12; + //@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ + // 'pub type Y = u8' + pub type Y = u8; +} + +pub trait Foo { + const W: u32; + fn yeay(); + type Z; +} + +impl Foo for Bar { + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[2]/h4' \ + // 'type Z = u8' + type Z = u8; + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[1]/h4' \ + // 'const W: u32 = 12u32' + const W: u32 = 12; + //@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[3]/h4' \ + // 'fn yeay()' + fn yeay() {} +} diff --git a/tests/rustdoc/impl/impl-associated-items-sidebar.rs b/tests/rustdoc/impl/impl-associated-items-sidebar.rs new file mode 100644 index 00000000000..d393a577e50 --- /dev/null +++ b/tests/rustdoc/impl/impl-associated-items-sidebar.rs @@ -0,0 +1,42 @@ +// This test ensures that impl/trait associated items are listed in the sidebar. + +// ignore-tidy-linelength + +#![feature(inherent_associated_types)] +#![feature(associated_type_defaults)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +//@ has 'foo/struct.Bar.html' +pub struct Bar; + +impl Bar { + //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedconstant"]/li/a[@href="#associatedconstant.X"]' 'X' + pub const X: u8 = 12; + //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block associatedtype"]/li/a[@href="#associatedtype.Y"]' 'Y' + pub type Y = u8; +} + +//@ has 'foo/trait.Foo.html' +pub trait Foo { + //@ has - '//*[@class="sidebar-elems"]//h3[5]' 'Required Methods' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][5]/li/a[@href="#tymethod.yeay"]' 'yeay' + fn yeay(); + //@ has - '//*[@class="sidebar-elems"]//h3[6]' 'Provided Methods' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][6]/li/a[@href="#method.boo"]' 'boo' + fn boo() {} + //@ has - '//*[@class="sidebar-elems"]//h3[1]' 'Required Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][1]/li/a[@href="#associatedconstant.W"]' 'W' + const W: u32; + //@ has - '//*[@class="sidebar-elems"]//h3[2]' 'Provided Associated Constants' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][2]/li/a[@href="#associatedconstant.U"]' 'U' + const U: u32 = 0; + //@ has - '//*[@class="sidebar-elems"]//h3[3]' 'Required Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][3]/li/a[@href="#associatedtype.Z"]' 'Z' + type Z; + //@ has - '//*[@class="sidebar-elems"]//h3[4]' 'Provided Associated Types' + //@ has - '//*[@class="sidebar-elems"]//ul[@class="block"][4]/li/a[@href="#associatedtype.T"]' 'T' + type T = u32; +} diff --git a/tests/rustdoc/impl/impl-blanket-53689.rs b/tests/rustdoc/impl/impl-blanket-53689.rs new file mode 100644 index 00000000000..4b1697349f2 --- /dev/null +++ b/tests/rustdoc/impl/impl-blanket-53689.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/53689 +//@ aux-build:issue-53689.rs + +#![crate_name = "foo"] + +extern crate issue_53689; + +//@ has foo/trait.MyTrait.html +//@ !hasraw - 'MyStruct' +//@ count - '//*[h3="impl MyTrait for T"]' 1 +pub trait MyTrait {} + +impl MyTrait for T {} + +mod a { + pub use issue_53689::MyStruct; +} diff --git a/tests/rustdoc/impl/impl-box.rs b/tests/rustdoc/impl/impl-box.rs new file mode 100644 index 00000000000..1fb63e21685 --- /dev/null +++ b/tests/rustdoc/impl/impl-box.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/92940 +// +// Show traits implemented on fundamental types that wrap local ones. + +pub struct MyType; + +//@ has 'impl_box/struct.MyType.html' +//@ has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box' + +impl Iterator for Box { + type Item = (); + + fn next(&mut self) -> Option { + todo!() + } +} diff --git a/tests/rustdoc/impl/impl-disambiguation.rs b/tests/rustdoc/impl/impl-disambiguation.rs new file mode 100644 index 00000000000..cfd5013964b --- /dev/null +++ b/tests/rustdoc/impl/impl-disambiguation.rs @@ -0,0 +1,30 @@ +#![crate_name = "foo"] + +pub trait Foo {} + +pub struct Bar { field: T } + +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for Bar" +impl Foo for Bar {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for Bar" +impl Foo for Bar {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<'a> Foo for &'a Bar" +impl<'a> Foo for &'a Bar {} + +pub mod mod1 { + pub struct Baz {} +} + +pub mod mod2 { + pub enum Baz {} +} + +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl Foo for foo::mod1::Baz" +impl Foo for mod1::Baz {} +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<'a> Foo for &'a foo::mod2::Baz" +impl<'a> Foo for &'a mod2::Baz {} diff --git a/tests/rustdoc/impl/impl-everywhere.rs b/tests/rustdoc/impl/impl-everywhere.rs new file mode 100644 index 00000000000..d1a4e901bad --- /dev/null +++ b/tests/rustdoc/impl/impl-everywhere.rs @@ -0,0 +1,30 @@ +#![crate_name = "foo"] + +pub trait Foo {} +pub trait Foo2 {} + +pub struct Bar; + +impl Foo for Bar {} +impl Foo2 for Bar {} + +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" +pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo { + x +} + +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' +pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 { + Bar +} + +//@ has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' +pub fn foo_foo() -> impl Foo + Foo2 { + Bar +} + +//@ has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" +pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { +} diff --git a/tests/rustdoc/impl/impl-in-const-block.rs b/tests/rustdoc/impl/impl-in-const-block.rs new file mode 100644 index 00000000000..3f757fa9566 --- /dev/null +++ b/tests/rustdoc/impl/impl-in-const-block.rs @@ -0,0 +1,43 @@ +// Regression test for #83026. +// The goal of this test is to ensure that impl blocks inside +// const expressions are documented as well. + +#![crate_name = "foo"] + +//@ has 'foo/struct.A.html' +//@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' +//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' +//@ has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' +//@ has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' +//@ has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' +pub struct A; + +const _: () = { + impl A { + const FOO: () = { + impl A { + pub fn woo(&self) {} + } + }; + + pub fn new() -> A { + A + } + } +}; +pub const X: () = { + impl A { + pub fn bar(&self) {} + } +}; + +fn foo() { + impl A { + pub fn yoo() {} + } + const _: () = { + impl A { + pub fn yuu() {} + } + }; +} diff --git a/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs new file mode 100644 index 00000000000..a514bc35bfc --- /dev/null +++ b/tests/rustdoc/impl/impl-on-ty-alias-issue-119015.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +//@ has 'foo/index.html' +// There should be only `type A`. +//@ count - '//*[@class="item-table"]//dt' 1 +//@ has - '//dt/a[@href="type.A.html"]' 'A' + +mod foo { + pub struct S; +} + +use foo::S; + +pub type A = S; + +//@ has 'foo/type.A.html' +//@ has - '//*[@id="method.default"]/h4' 'fn default() -> Self' +impl Default for A { + fn default() -> Self { + S + } +} + +//@ has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' +impl A { + pub fn a(&self) {} +} diff --git a/tests/rustdoc/impl/impl-parts-crosscrate.rs b/tests/rustdoc/impl/impl-parts-crosscrate.rs new file mode 100644 index 00000000000..631c8bb3eb3 --- /dev/null +++ b/tests/rustdoc/impl/impl-parts-crosscrate.rs @@ -0,0 +1,20 @@ +//@ aux-build:rustdoc-impl-parts-crosscrate.rs +//@ ignore-cross-compile + +#![feature(negative_impls)] + +extern crate rustdoc_impl_parts_crosscrate; + +pub struct Bar { t: T } + +// The output file is html embedded in javascript, so the html tags +// aren't stripped by the processing script and we can't check for the +// full impl string. Instead, just make sure something from each part +// is mentioned. + +//@ hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar +//@ hasraw - Send +//@ hasraw - !AnAutoTrait +//@ hasraw - Copy +impl !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar + where T: Copy {} diff --git a/tests/rustdoc/impl/impl-parts.rs b/tests/rustdoc/impl/impl-parts.rs new file mode 100644 index 00000000000..4f281bfd63c --- /dev/null +++ b/tests/rustdoc/impl/impl-parts.rs @@ -0,0 +1,12 @@ +#![feature(negative_impls)] +#![feature(auto_traits)] + +pub auto trait AnAutoTrait {} + +pub struct Foo { field: T } + +//@ has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !AnAutoTrait for Foowhere T: Sync + Clone," +//@ has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl !AnAutoTrait for Foowhere T: Sync + Clone," +impl !AnAutoTrait for Foo where T: Sync {} diff --git a/tests/rustdoc/impl/impl-ref-20175.rs b/tests/rustdoc/impl/impl-ref-20175.rs new file mode 100644 index 00000000000..b1a9286fd41 --- /dev/null +++ b/tests/rustdoc/impl/impl-ref-20175.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/20175 + +#![crate_name="issue_20175"] + +pub trait Foo { + fn foo(&self) {} +} + +pub struct Bar; + +//@ has issue_20175/struct.Bar.html \ +// '//*[@id="method.foo"]' \ +// 'fn foo' +impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/impl/impl-trait-43869.rs b/tests/rustdoc/impl/impl-trait-43869.rs new file mode 100644 index 00000000000..89176f59ca1 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-43869.rs @@ -0,0 +1,75 @@ +// https://github.com/rust-lang/rust/issues/43869 +#![crate_name="foo"] + +pub fn g() -> impl Iterator { + Some(1u8).into_iter() +} + +#[allow(unused_parens)] +pub fn h() -> (impl Iterator) { + Some(1u8).into_iter() +} + +pub fn i() -> impl Iterator + 'static { + Some(1u8).into_iter() +} + +pub fn j() -> impl Iterator + Clone { + Some(1u8).into_iter() +} + +pub fn k() -> [impl Clone; 2] { + [123u32, 456u32] +} + +pub fn l() -> (impl Clone, impl Default) { + (789u32, -123i32) +} + +pub fn m() -> &'static impl Clone { + &1u8 +} + +pub fn n() -> *const impl Clone { + &1u8 +} + +pub fn o() -> &'static [impl Clone] { + b":)" +} + +// issue #44731 +pub fn test_44731_0() -> Box> { + Box::new(g()) +} + +pub fn test_44731_1() -> Result, ()> { + Ok(Box::new(j())) +} + +// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 +// +//pub fn test_44731_2() -> Box { +// Box::new(|_: u32| {}) +//} +// +//pub fn test_44731_3() -> Box impl Clone> { +// Box::new(|| 0u32) +//} + +pub fn test_44731_4() -> Box> { + Box::new(g()) +} + +//@ has foo/fn.g.html +//@ has foo/fn.h.html +//@ has foo/fn.i.html +//@ has foo/fn.j.html +//@ has foo/fn.k.html +//@ has foo/fn.l.html +//@ has foo/fn.m.html +//@ has foo/fn.n.html +//@ has foo/fn.o.html +//@ has foo/fn.test_44731_0.html +//@ has foo/fn.test_44731_1.html +//@ has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/impl/impl-trait-alias.rs b/tests/rustdoc/impl/impl-trait-alias.rs new file mode 100644 index 00000000000..f7ecfffbf46 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-alias.rs @@ -0,0 +1,14 @@ +#![feature(type_alias_impl_trait)] + +trait MyTrait {} +impl MyTrait for i32 {} + +//@ hasraw impl_trait_alias/type.Foo.html 'Foo' +/// debug type +pub type Foo = impl MyTrait; + +//@ hasraw impl_trait_alias/fn.foo.html 'foo' +/// debug function +pub fn foo() -> Foo { + 1 +} diff --git a/tests/rustdoc/impl/impl-trait-precise-capturing.rs b/tests/rustdoc/impl/impl-trait-precise-capturing.rs new file mode 100644 index 00000000000..3ec8c578013 --- /dev/null +++ b/tests/rustdoc/impl/impl-trait-precise-capturing.rs @@ -0,0 +1,26 @@ +//@ aux-build:precise-capturing.rs + +#![crate_name = "foo"] + +extern crate precise_capturing; + +//@ has foo/fn.two.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'b, 'a>" +pub fn two<'a, 'b, 'c>() -> impl Sized + use<'b, 'a /* no 'c */> {} + +//@ has foo/fn.params.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" +pub fn params<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {} + +//@ has foo/fn.none.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" +pub fn none() -> impl Sized + use<> {} + +//@ has foo/fn.first.html '//section[@id="main-content"]//pre' "-> impl use<> + Sized" +pub fn first() -> impl use<> + Sized {} + +//@ has foo/fn.cross_crate_empty.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>" +pub use precise_capturing::cross_crate_empty; + +//@ matches foo/fn.cross_crate_missing.html '//section[@id="main-content"]//pre' "-> impl Sized$" +pub use precise_capturing::cross_crate_missing; + +//@ has foo/fn.cross_crate_args.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>" +pub use precise_capturing::cross_crate_args; diff --git a/tests/rustdoc/impl/impl-type-parameter-33592.rs b/tests/rustdoc/impl/impl-type-parameter-33592.rs new file mode 100644 index 00000000000..ac5df460925 --- /dev/null +++ b/tests/rustdoc/impl/impl-type-parameter-33592.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/33592 +#![crate_name = "foo"] + +pub trait Foo {} + +pub struct Bar; + +pub struct Baz; + +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Bar' +impl Foo for Bar {} + +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo for Baz' +impl Foo for Baz {} diff --git a/tests/rustdoc/impl/implementor-stable-version.rs b/tests/rustdoc/impl/implementor-stable-version.rs new file mode 100644 index 00000000000..cd4fa93f803 --- /dev/null +++ b/tests/rustdoc/impl/implementor-stable-version.rs @@ -0,0 +1,21 @@ +#![stable(feature = "bar", since = "3.3.3")] +#![crate_name = "foo"] + +#![feature(staged_api)] + +#[stable(feature = "bar", since = "3.3.3")] +pub trait Bar {} + +#[stable(feature = "baz", since = "3.3.3")] +pub trait Baz {} + +#[stable(feature = "baz", since = "3.3.3")] +pub struct Foo; + +//@ has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' +#[stable(feature = "foobar", since = "4.4.4")] +impl Bar for Foo {} + +//@ has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' +#[stable(feature = "foobaz", since = "3.3.3")] +impl Baz for Foo {} diff --git a/tests/rustdoc/impl/implementors-unstable-75588.rs b/tests/rustdoc/impl/implementors-unstable-75588.rs new file mode 100644 index 00000000000..44a785c4ad9 --- /dev/null +++ b/tests/rustdoc/impl/implementors-unstable-75588.rs @@ -0,0 +1,18 @@ +//@ aux-build:realcore.rs +//@ aux-build:real_gimli.rs + +// Ensure unstably exported traits have their Implementors sections. +// https://github.com/rust-lang/rust/issues/75588 + +#![crate_name = "foo"] +#![feature(extremely_unstable_foo)] + +extern crate realcore; +extern crate real_gimli; + +// issue #74672 +//@ !has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' +pub use realcore::Deref; + +//@ has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' +pub use realcore::Join; diff --git a/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs b/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs new file mode 100644 index 00000000000..ba6ed427871 --- /dev/null +++ b/tests/rustdoc/impl/inline-impl-through-glob-import-100204.rs @@ -0,0 +1,15 @@ +//@ aux-build:issue-100204-aux.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/100204 +#![crate_name="second"] + +extern crate first; + +pub mod prelude {} + +//@ has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +//@ has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +#[doc(inline)] +pub use first::*; diff --git a/tests/rustdoc/impl/manual_impl.rs b/tests/rustdoc/impl/manual_impl.rs new file mode 100644 index 00000000000..281262bb40a --- /dev/null +++ b/tests/rustdoc/impl/manual_impl.rs @@ -0,0 +1,77 @@ +//@ has manual_impl/trait.T.html +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' +/// Docs associated with the trait definition. +pub trait T { + /// Docs associated with the trait a_method definition. + fn a_method(&self) -> usize; + + /// Docs associated with the trait b_method definition. + fn b_method(&self) -> usize { + self.a_method() + } + + /// Docs associated with the trait c_method definition. + /// + /// There is another line + fn c_method(&self) -> usize { + self.a_method() + } +} + +//@ has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' +//@ !has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' +//@ !has - '//*[@class="docblock"]' 'There is another line' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' +pub struct S1(usize); + +/// Docs associated with the S1 trait implementation. +impl T for S1 { + /// Docs associated with the S1 trait a_method implementation. + fn a_method(&self) -> usize { + self.0 + } +} + +//@ has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +pub struct S2(usize); + +/// Docs associated with the S2 trait implementation. +impl T for S2 { + /// Docs associated with the S2 trait a_method implementation. + fn a_method(&self) -> usize { + self.0 + } + + /// Docs associated with the S2 trait c_method implementation. + fn c_method(&self) -> usize { + 5 + } +} + +//@ has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' +pub struct S3(usize); + +/// Docs associated with the S3 trait implementation. +impl T for S3 { + fn a_method(&self) -> usize { + self.0 + } + + /// Docs associated with the S3 trait b_method implementation. + fn b_method(&self) -> usize { + 5 + } +} diff --git a/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs new file mode 100644 index 00000000000..cda828d3967 --- /dev/null +++ b/tests/rustdoc/impl/method-link-foreign-trait-impl-17476.rs @@ -0,0 +1,14 @@ +//@ aux-build:issue-17476.rs +//@ ignore-cross-compile +// https://github.com/rust-lang/rust/issues/17476 + +#![crate_name="issue_17476"] + +extern crate issue_17476; + +pub struct Foo; + +//@ has issue_17476/struct.Foo.html \ +// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ +// 'foo' +impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/impl/module-impls.rs b/tests/rustdoc/impl/module-impls.rs new file mode 100644 index 00000000000..b66721ecb13 --- /dev/null +++ b/tests/rustdoc/impl/module-impls.rs @@ -0,0 +1,5 @@ +#![crate_name = "foo"] + +pub use std::marker::Send; + +//@ !hasraw foo/index.html 'Implementations' diff --git a/tests/rustdoc/impl/must_implement_one_of.rs b/tests/rustdoc/impl/must_implement_one_of.rs new file mode 100644 index 00000000000..ab965bab356 --- /dev/null +++ b/tests/rustdoc/impl/must_implement_one_of.rs @@ -0,0 +1,10 @@ +#![crate_name = "c"] +#![feature(rustc_attrs)] + +#[rustc_must_implement_one_of(a, b)] +//@ matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ +// 'At least one of the `a`, `b` methods is required.$' +pub trait Trait { + fn a() {} + fn b() {} +} diff --git a/tests/rustdoc/impl/negative-impl-no-items.rs b/tests/rustdoc/impl/negative-impl-no-items.rs new file mode 100644 index 00000000000..c628e542033 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl-no-items.rs @@ -0,0 +1,26 @@ +// This test ensures that negative impls don't have items listed inside them. + +#![feature(negative_impls)] +#![crate_name = "foo"] + +pub struct Thing; + +//@ has 'foo/struct.Thing.html' +// We check the full path to ensure there is no `
` element. +//@ has - '//div[@id="trait-implementations-list"]/section[@id="impl-Iterator-for-Thing"]/h3' \ +// 'impl !Iterator for Thing' +impl !Iterator for Thing {} + +// This struct will allow us to compare both paths. +pub struct Witness; + +//@ has 'foo/struct.Witness.html' +//@ has - '//div[@id="trait-implementations-list"]/details//section[@id="impl-Iterator-for-Witness"]/h3' \ +// 'impl Iterator for Witness' +impl Iterator for Witness { + type Item = u8; + + fn next(&mut self) -> Option { + None + } +} diff --git a/tests/rustdoc/impl/negative-impl-sidebar.rs b/tests/rustdoc/impl/negative-impl-sidebar.rs new file mode 100644 index 00000000000..1742dce1945 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl-sidebar.rs @@ -0,0 +1,9 @@ +#![feature(negative_impls)] +#![crate_name = "foo"] + +pub struct Foo; + +//@ has foo/struct.Foo.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' +//@ has - '//*[@class="sidebar-elems"]//section//a' '!Sync' +impl !Sync for Foo {} diff --git a/tests/rustdoc/impl/negative-impl.rs b/tests/rustdoc/impl/negative-impl.rs new file mode 100644 index 00000000000..f057a749b72 --- /dev/null +++ b/tests/rustdoc/impl/negative-impl.rs @@ -0,0 +1,14 @@ +#![feature(negative_impls)] + +//@ matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" +pub struct Alpha; +//@ matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo" +pub struct Bravo(B); + +//@ matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Send for Alpha" +impl !Send for Alpha {} + +//@ matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ +// impl !Send for Bravo" +impl !Send for Bravo {} diff --git a/tests/rustdoc/impl/return-impl-trait.rs b/tests/rustdoc/impl/return-impl-trait.rs new file mode 100644 index 00000000000..175867d2204 --- /dev/null +++ b/tests/rustdoc/impl/return-impl-trait.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +pub trait Backend {} + +impl Backend for () {} + +pub struct Module(T); + +pub type BackendImpl = impl Backend; + +//@ has return_impl_trait/fn.make_module.html +/// Documentation +pub fn make_module() -> Module { + Module(()) +} diff --git a/tests/rustdoc/impl/rustc-incoherent-impls.rs b/tests/rustdoc/impl/rustc-incoherent-impls.rs new file mode 100644 index 00000000000..81a7025906b --- /dev/null +++ b/tests/rustdoc/impl/rustc-incoherent-impls.rs @@ -0,0 +1,28 @@ +//@ aux-build:incoherent-impl-types.rs +//@ build-aux-docs + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +extern crate incoherent_impl_types; + +// The only way this actually shows up is if the type gets inlined. +#[doc(inline)] +pub use incoherent_impl_types::FooTrait; + +//@ has foo/trait.FooTrait.html +//@ count - '//section[@id="method.do_something"]' 1 +impl dyn FooTrait { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} + +#[doc(inline)] +pub use incoherent_impl_types::FooStruct; + +//@ has foo/struct.FooStruct.html +//@ count - '//section[@id="method.do_something"]' 1 +impl FooStruct { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} diff --git a/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs b/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs new file mode 100644 index 00000000000..b0beb1bdfa0 --- /dev/null +++ b/tests/rustdoc/impl/same-crate-hidden-impl-parameter.rs @@ -0,0 +1,36 @@ +// test for `doc(hidden)` with impl parameters in the same crate. +#![crate_name = "foo"] + +#[doc(hidden)] +pub enum HiddenType {} + +#[doc(hidden)] +pub trait HiddenTrait {} + +pub enum MyLibType {} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' +impl From for MyLibType { + fn from(it: HiddenType) -> MyLibType { + match it {} + } +} + +pub struct T(T); + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' +impl From>>>> for MyLibType { + fn from(it: T>>>) -> MyLibType { + todo!() + } +} + +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +impl HiddenTrait for MyLibType {} + +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' +impl From for T>>> { + fn from(it: MyLibType) -> T>>> { + match it {} + } +} diff --git a/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs b/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs new file mode 100644 index 00000000000..b1bf029cf84 --- /dev/null +++ b/tests/rustdoc/impl/sidebar-trait-impl-disambiguate-78701.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/78701 +#![crate_name = "foo"] + +// This test ensures that if a blanket impl has the same ID as another impl, it'll +// link to the blanket impl and not the other impl. Basically, we're checking if +// the ID is correctly derived. + +//@ has 'foo/struct.AnotherStruct.html' +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 + +pub trait Something {} + +pub trait AnAmazingTrait {} + +impl AnAmazingTrait for T {} + +pub struct AnotherStruct(T); + +impl Something for AnotherStruct {} +impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/impl/struct-implementations-title.rs b/tests/rustdoc/impl/struct-implementations-title.rs new file mode 100644 index 00000000000..ca5b5c0ee20 --- /dev/null +++ b/tests/rustdoc/impl/struct-implementations-title.rs @@ -0,0 +1,9 @@ +#![crate_name = "foo"] + +pub struct Struc; + +//@ has foo/struct.Struc.html +//@ has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" +impl Struc { + pub const S: u64 = 0; +} diff --git a/tests/rustdoc/impl/trait-impl.rs b/tests/rustdoc/impl/trait-impl.rs new file mode 100644 index 00000000000..c65eecc4edf --- /dev/null +++ b/tests/rustdoc/impl/trait-impl.rs @@ -0,0 +1,45 @@ +pub trait Trait { + /// Some long docs here. + /// + /// These docs are long enough that a link will be added to the end. + fn a(); + + /// These docs contain a [reference link]. + /// + /// [reference link]: https://example.com + fn b(); + + /// ``` + /// This code block should not be in the output, but a Read more link should be generated + /// ``` + fn c(); + + /// Escaped formatting a\*b\*c\* works + fn d(); +} + +pub struct Struct; + +impl Trait for Struct { + //@ has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' + //@ !has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' + fn a() {} + + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' + fn b() {} + + //@ !has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' + fn c() {} + + //@ has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' + //@ !has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' + fn d() {} + + //@ has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' +} diff --git a/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs b/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs new file mode 100644 index 00000000000..8eb6d007525 --- /dev/null +++ b/tests/rustdoc/impl/trait-implementations-duplicate-self-45584.rs @@ -0,0 +1,17 @@ +#![crate_name = "foo"] + +// https://github.com/rust-lang/rust/issues/45584 + +pub trait Bar {} + +//@ has 'foo/struct.Foo1.html' +pub struct Foo1; +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar for Foo1" +impl Bar for Foo1 {} + +//@ has 'foo/struct.Foo2.html' +pub struct Foo2; +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" +impl Bar<&'static Foo2, Foo2> for u8 {} diff --git a/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs b/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs new file mode 100644 index 00000000000..6d6e5e0a839 --- /dev/null +++ b/tests/rustdoc/impl/underscore-type-in-trait-impl-96381.rs @@ -0,0 +1,17 @@ +//@ should-fail +// https://github.com/rust-lang/rust/issues/96381 + +#![allow(unused)] + +trait Foo: Sized { + fn bar(i: i32, t: T, s: &Self) -> (T, i32); +} + +impl Foo for () { + fn bar(i: _, t: _, s: _) -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + (1, 2) + } +} + +fn main() {} diff --git a/tests/rustdoc/impl/universal-impl-trait.rs b/tests/rustdoc/impl/universal-impl-trait.rs new file mode 100644 index 00000000000..b78d69c0690 --- /dev/null +++ b/tests/rustdoc/impl/universal-impl-trait.rs @@ -0,0 +1,55 @@ +#![crate_name = "foo"] + +use std::io::Read; +use std::borrow::Borrow; + +//@ has foo/fn.foo.html +//@ has - //pre 'foo(' +//@ matchesraw - '_x: impl (' + //@ matchesraw - '_x: impl (T); + +impl S { + //@ has foo/struct.S.html + //@ hasraw - 'bar(' + //@ matchesraw - '_bar: impl (' + //@ matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' + pub fn baz(_baz: S) { + } + + //@ hasraw - 'qux(' + //@ matchesraw - 'trait\.Read\.html' + pub fn qux(_qux: impl IntoIterator>) { + } +} + +//@ hasraw - 'method(' +//@ matchesraw - '_x: impl Trait for S {} + +//@ has foo/fn.much_universe.html +//@ matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' +//@ matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' +//@ matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' +pub fn much_universe< + T: Borrow, + U: IntoIterator>, +>( + _: impl Read + Clone, +) { +} diff --git a/tests/rustdoc/impl/unneeded-trait-implementations-title.rs b/tests/rustdoc/impl/unneeded-trait-implementations-title.rs new file mode 100644 index 00000000000..f7a97dfaaef --- /dev/null +++ b/tests/rustdoc/impl/unneeded-trait-implementations-title.rs @@ -0,0 +1,5 @@ +#![crate_name = "foo"] + +pub struct Bar; + +//@ count foo/struct.Bar.html '//*[@id="implementations"]' 0 diff --git a/tests/rustdoc/implementor-stable-version.rs b/tests/rustdoc/implementor-stable-version.rs deleted file mode 100644 index cd4fa93f803..00000000000 --- a/tests/rustdoc/implementor-stable-version.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![stable(feature = "bar", since = "3.3.3")] -#![crate_name = "foo"] - -#![feature(staged_api)] - -#[stable(feature = "bar", since = "3.3.3")] -pub trait Bar {} - -#[stable(feature = "baz", since = "3.3.3")] -pub trait Baz {} - -#[stable(feature = "baz", since = "3.3.3")] -pub struct Foo; - -//@ has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' -#[stable(feature = "foobar", since = "4.4.4")] -impl Bar for Foo {} - -//@ has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' -#[stable(feature = "foobaz", since = "3.3.3")] -impl Baz for Foo {} diff --git a/tests/rustdoc/implementors-unstable-75588.rs b/tests/rustdoc/implementors-unstable-75588.rs deleted file mode 100644 index 44a785c4ad9..00000000000 --- a/tests/rustdoc/implementors-unstable-75588.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ aux-build:realcore.rs -//@ aux-build:real_gimli.rs - -// Ensure unstably exported traits have their Implementors sections. -// https://github.com/rust-lang/rust/issues/75588 - -#![crate_name = "foo"] -#![feature(extremely_unstable_foo)] - -extern crate realcore; -extern crate real_gimli; - -// issue #74672 -//@ !has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' -pub use realcore::Deref; - -//@ has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' -pub use realcore::Join; diff --git a/tests/rustdoc/inline-impl-through-glob-import-100204.rs b/tests/rustdoc/inline-impl-through-glob-import-100204.rs deleted file mode 100644 index ba6ed427871..00000000000 --- a/tests/rustdoc/inline-impl-through-glob-import-100204.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:issue-100204-aux.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/100204 -#![crate_name="second"] - -extern crate first; - -pub mod prelude {} - -//@ has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' -//@ has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' -#[doc(inline)] -pub use first::*; diff --git a/tests/rustdoc/legacy-const-generic.rs b/tests/rustdoc/legacy-const-generic.rs deleted file mode 100644 index 41df535f3e0..00000000000 --- a/tests/rustdoc/legacy-const-generic.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -//@ has 'foo/fn.foo.html' -//@ has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' -#[rustc_legacy_const_generics(1)] -pub fn foo(x: usize, z: usize) -> [usize; 3] { - [x, Y, z] -} - -//@ has 'foo/fn.bar.html' -//@ has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' -#[rustc_legacy_const_generics(1, 2)] -pub fn bar(x: usize) -> [usize; 3] { - [x, Y, z] -} diff --git a/tests/rustdoc/link-assoc-const.rs b/tests/rustdoc/link-assoc-const.rs deleted file mode 100644 index 56b82fb2d39..00000000000 --- a/tests/rustdoc/link-assoc-const.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_name = "foo"] - -//@ has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' -//@ has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' - -//! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`]. - -pub mod foo { - pub const FIRSTCONST: u32 = 42; -} - -pub struct Bar; - -impl Bar { - pub const CONST: u32 = 42; -} diff --git a/tests/rustdoc/manual_impl.rs b/tests/rustdoc/manual_impl.rs deleted file mode 100644 index 281262bb40a..00000000000 --- a/tests/rustdoc/manual_impl.rs +++ /dev/null @@ -1,77 +0,0 @@ -//@ has manual_impl/trait.T.html -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' -/// Docs associated with the trait definition. -pub trait T { - /// Docs associated with the trait a_method definition. - fn a_method(&self) -> usize; - - /// Docs associated with the trait b_method definition. - fn b_method(&self) -> usize { - self.a_method() - } - - /// Docs associated with the trait c_method definition. - /// - /// There is another line - fn c_method(&self) -> usize { - self.a_method() - } -} - -//@ has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' -//@ !has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' -//@ !has - '//*[@class="docblock"]' 'There is another line' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' -pub struct S1(usize); - -/// Docs associated with the S1 trait implementation. -impl T for S1 { - /// Docs associated with the S1 trait a_method implementation. - fn a_method(&self) -> usize { - self.0 - } -} - -//@ has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' -//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' -pub struct S2(usize); - -/// Docs associated with the S2 trait implementation. -impl T for S2 { - /// Docs associated with the S2 trait a_method implementation. - fn a_method(&self) -> usize { - self.0 - } - - /// Docs associated with the S2 trait c_method implementation. - fn c_method(&self) -> usize { - 5 - } -} - -//@ has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' -//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' -//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' -//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' -pub struct S3(usize); - -/// Docs associated with the S3 trait implementation. -impl T for S3 { - fn a_method(&self) -> usize { - self.0 - } - - /// Docs associated with the S3 trait b_method implementation. - fn b_method(&self) -> usize { - 5 - } -} diff --git a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs deleted file mode 100644 index cda828d3967..00000000000 --- a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ aux-build:issue-17476.rs -//@ ignore-cross-compile -// https://github.com/rust-lang/rust/issues/17476 - -#![crate_name="issue_17476"] - -extern crate issue_17476; - -pub struct Foo; - -//@ has issue_17476/struct.Foo.html \ -// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ -// 'foo' -impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/module-impls.rs b/tests/rustdoc/module-impls.rs deleted file mode 100644 index b66721ecb13..00000000000 --- a/tests/rustdoc/module-impls.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "foo"] - -pub use std::marker::Send; - -//@ !hasraw foo/index.html 'Implementations' diff --git a/tests/rustdoc/must_implement_one_of.rs b/tests/rustdoc/must_implement_one_of.rs deleted file mode 100644 index ab965bab356..00000000000 --- a/tests/rustdoc/must_implement_one_of.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_name = "c"] -#![feature(rustc_attrs)] - -#[rustc_must_implement_one_of(a, b)] -//@ matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ -// 'At least one of the `a`, `b` methods is required.$' -pub trait Trait { - fn a() {} - fn b() {} -} diff --git a/tests/rustdoc/negative-impl-no-items.rs b/tests/rustdoc/negative-impl-no-items.rs deleted file mode 100644 index c628e542033..00000000000 --- a/tests/rustdoc/negative-impl-no-items.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This test ensures that negative impls don't have items listed inside them. - -#![feature(negative_impls)] -#![crate_name = "foo"] - -pub struct Thing; - -//@ has 'foo/struct.Thing.html' -// We check the full path to ensure there is no `
` element. -//@ has - '//div[@id="trait-implementations-list"]/section[@id="impl-Iterator-for-Thing"]/h3' \ -// 'impl !Iterator for Thing' -impl !Iterator for Thing {} - -// This struct will allow us to compare both paths. -pub struct Witness; - -//@ has 'foo/struct.Witness.html' -//@ has - '//div[@id="trait-implementations-list"]/details//section[@id="impl-Iterator-for-Witness"]/h3' \ -// 'impl Iterator for Witness' -impl Iterator for Witness { - type Item = u8; - - fn next(&mut self) -> Option { - None - } -} diff --git a/tests/rustdoc/negative-impl-sidebar.rs b/tests/rustdoc/negative-impl-sidebar.rs deleted file mode 100644 index 1742dce1945..00000000000 --- a/tests/rustdoc/negative-impl-sidebar.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(negative_impls)] -#![crate_name = "foo"] - -pub struct Foo; - -//@ has foo/struct.Foo.html -//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' -//@ has - '//*[@class="sidebar-elems"]//section//a' '!Sync' -impl !Sync for Foo {} diff --git a/tests/rustdoc/negative-impl.rs b/tests/rustdoc/negative-impl.rs deleted file mode 100644 index f057a749b72..00000000000 --- a/tests/rustdoc/negative-impl.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(negative_impls)] - -//@ matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" -pub struct Alpha; -//@ matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo" -pub struct Bravo(B); - -//@ matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ -// "impl !Send for Alpha" -impl !Send for Alpha {} - -//@ matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ -// impl !Send for Bravo" -impl !Send for Bravo {} diff --git a/tests/rustdoc/redirect-const.rs b/tests/rustdoc/redirect-const.rs deleted file mode 100644 index e636a915f30..00000000000 --- a/tests/rustdoc/redirect-const.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_name="foo"] - -pub use hidden::STATIC_FOO; -pub use hidden::CONST_FOO; - -mod hidden { - //@ has foo/hidden/static.STATIC_FOO.html - //@ has - '//p/a' '../../foo/static.STATIC_FOO.html' - pub static STATIC_FOO: u64 = 0; - //@ has foo/hidden/constant.CONST_FOO.html - //@ has - '//p/a' '../../foo/constant.CONST_FOO.html' - pub const CONST_FOO: u64 = 0; -} diff --git a/tests/rustdoc/return-impl-trait.rs b/tests/rustdoc/return-impl-trait.rs deleted file mode 100644 index 175867d2204..00000000000 --- a/tests/rustdoc/return-impl-trait.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(type_alias_impl_trait)] - -pub trait Backend {} - -impl Backend for () {} - -pub struct Module(T); - -pub type BackendImpl = impl Backend; - -//@ has return_impl_trait/fn.make_module.html -/// Documentation -pub fn make_module() -> Module { - Module(()) -} diff --git a/tests/rustdoc/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs deleted file mode 100644 index 8a86e3e5e97..00000000000 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Test that we do not currently display `~const` in rustdoc -// as that syntax is currently provisional; `~const Destruct` has -// no effect on stable code so it should be hidden as well. -// -// To future blessers: make sure that `const_trait_impl` is -// stabilized when changing `@!has` to `@has`, and please do -// not remove this test. -// -// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const` -// FIXME(const_trait_impl) restore `const_trait` to `Destruct` -#![feature(const_trait_impl)] -#![crate_name = "foo"] - -use std::marker::Destruct; - -pub struct S(T); - -//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' -#[const_trait] -pub trait Tr { - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' - //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' - //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - fn a() - where - Option: /* ~const */ Fn() /* + ~const Destruct */, - { - } -} - -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' -//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' -impl const Tr for T -where - Option: /* ~const */ Fn() /* + ~const Destruct */, -{ - fn a() - where - Option: /* ~const */ Fn() /* + ~const Destruct */, - { - } -} - -//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' -//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' -pub const fn foo() -where - Option: /* ~const */ Fn() /* + ~const Destruct */, -{ - F::a() -} - -impl S { - //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' - //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' - //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - pub const fn foo() - where - B: /* ~const */ Fn() /* + ~const Destruct */, - { - B::a() - } -} diff --git a/tests/rustdoc/rustc-incoherent-impls.rs b/tests/rustdoc/rustc-incoherent-impls.rs deleted file mode 100644 index 81a7025906b..00000000000 --- a/tests/rustdoc/rustc-incoherent-impls.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ aux-build:incoherent-impl-types.rs -//@ build-aux-docs - -#![crate_name = "foo"] -#![feature(rustc_attrs)] - -extern crate incoherent_impl_types; - -// The only way this actually shows up is if the type gets inlined. -#[doc(inline)] -pub use incoherent_impl_types::FooTrait; - -//@ has foo/trait.FooTrait.html -//@ count - '//section[@id="method.do_something"]' 1 -impl dyn FooTrait { - #[rustc_allow_incoherent_impl] - pub fn do_something() {} -} - -#[doc(inline)] -pub use incoherent_impl_types::FooStruct; - -//@ has foo/struct.FooStruct.html -//@ count - '//section[@id="method.do_something"]' 1 -impl FooStruct { - #[rustc_allow_incoherent_impl] - pub fn do_something() {} -} diff --git a/tests/rustdoc/same-crate-hidden-impl-parameter.rs b/tests/rustdoc/same-crate-hidden-impl-parameter.rs deleted file mode 100644 index b0beb1bdfa0..00000000000 --- a/tests/rustdoc/same-crate-hidden-impl-parameter.rs +++ /dev/null @@ -1,36 +0,0 @@ -// test for `doc(hidden)` with impl parameters in the same crate. -#![crate_name = "foo"] - -#[doc(hidden)] -pub enum HiddenType {} - -#[doc(hidden)] -pub trait HiddenTrait {} - -pub enum MyLibType {} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From for MyLibType' -impl From for MyLibType { - fn from(it: HiddenType) -> MyLibType { - match it {} - } -} - -pub struct T(T); - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From>>>> for MyLibType' -impl From>>>> for MyLibType { - fn from(it: T>>>) -> MyLibType { - todo!() - } -} - -//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' -impl HiddenTrait for MyLibType {} - -//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From for T>>>' -impl From for T>>> { - fn from(it: MyLibType) -> T>>> { - match it {} - } -} diff --git a/tests/rustdoc/show-const-contents.rs b/tests/rustdoc/show-const-contents.rs deleted file mode 100644 index 6d2701693ce..00000000000 --- a/tests/rustdoc/show-const-contents.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Test that the contents of constants are displayed as part of the -// documentation. - -//@ hasraw show_const_contents/constant.CONST_S.html 'show this' -//@ !hasraw show_const_contents/constant.CONST_S.html '; //' -pub const CONST_S: &'static str = "show this"; - -//@ hasraw show_const_contents/constant.CONST_I32.html '= 42;' -//@ !hasraw show_const_contents/constant.CONST_I32.html '; //' -pub const CONST_I32: i32 = 42; - -//@ hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' -//@ !hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' -pub const CONST_I32_HEX: i32 = 0x42; - -//@ hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' -//@ !hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' -pub const CONST_NEG_I32: i32 = -42; - -//@ hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' -//@ !hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' -pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; - -//@ hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' -pub const CONST_CALC_I32: i32 = 42 + 1; - -//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' -//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '; //' -pub const CONST_REF_I32: &'static i32 = &42; - -//@ hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' -pub const CONST_I32_MAX: i32 = i32::MAX; - -//@ !hasraw show_const_contents/constant.UNIT.html '= ();' -//@ !hasraw show_const_contents/constant.UNIT.html '; //' -pub const UNIT: () = (); - -pub struct MyType(i32); - -//@ !hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' -//@ !hasraw show_const_contents/constant.MY_TYPE.html '; //' -pub const MY_TYPE: MyType = MyType(42); - -pub struct MyTypeWithStr(&'static str); - -//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' -//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' -pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); - -//@ hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' -//@ hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' -pub use std::f32::consts::PI; - -//@ hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' -#[allow(deprecated, deprecated_in_future)] -pub use std::i32::MAX; - -macro_rules! int_module { - ($T:ident) => ( - pub const MIN: $T = $T::MIN; - ) -} - -//@ hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' -int_module!(i16); - -//@ has show_const_contents/constant.ESCAPE.html //pre '= r#""#;' -pub const ESCAPE: &str = r#""#; diff --git a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs b/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs deleted file mode 100644 index b1bf029cf84..00000000000 --- a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/rust-lang/rust/issues/78701 -#![crate_name = "foo"] - -// This test ensures that if a blanket impl has the same ID as another impl, it'll -// link to the blanket impl and not the other impl. Basically, we're checking if -// the ID is correctly derived. - -//@ has 'foo/struct.AnotherStruct.html' -//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 -//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 - -pub trait Something {} - -pub trait AnAmazingTrait {} - -impl AnAmazingTrait for T {} - -pub struct AnotherStruct(T); - -impl Something for AnotherStruct {} -impl AnAmazingTrait for AnotherStruct<()> {} diff --git a/tests/rustdoc/struct-implementations-title.rs b/tests/rustdoc/struct-implementations-title.rs deleted file mode 100644 index ca5b5c0ee20..00000000000 --- a/tests/rustdoc/struct-implementations-title.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_name = "foo"] - -pub struct Struc; - -//@ has foo/struct.Struc.html -//@ has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" -impl Struc { - pub const S: u64 = 0; -} diff --git a/tests/rustdoc/trait-impl.rs b/tests/rustdoc/trait-impl.rs deleted file mode 100644 index c65eecc4edf..00000000000 --- a/tests/rustdoc/trait-impl.rs +++ /dev/null @@ -1,45 +0,0 @@ -pub trait Trait { - /// Some long docs here. - /// - /// These docs are long enough that a link will be added to the end. - fn a(); - - /// These docs contain a [reference link]. - /// - /// [reference link]: https://example.com - fn b(); - - /// ``` - /// This code block should not be in the output, but a Read more link should be generated - /// ``` - fn c(); - - /// Escaped formatting a\*b\*c\* works - fn d(); -} - -pub struct Struct; - -impl Trait for Struct { - //@ has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' - //@ !has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' - //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' - //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' - fn a() {} - - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' - //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' - fn b() {} - - //@ !has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' - //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' - //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' - fn c() {} - - //@ has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' - //@ !has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' - fn d() {} - - //@ has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' -} diff --git a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs b/tests/rustdoc/trait-implementations-duplicate-self-45584.rs deleted file mode 100644 index 8eb6d007525..00000000000 --- a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_name = "foo"] - -// https://github.com/rust-lang/rust/issues/45584 - -pub trait Bar {} - -//@ has 'foo/struct.Foo1.html' -pub struct Foo1; -//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -//@ has - '//*[@class="impl"]' "impl Bar for Foo1" -impl Bar for Foo1 {} - -//@ has 'foo/struct.Foo2.html' -pub struct Foo2; -//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -//@ has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" -impl Bar<&'static Foo2, Foo2> for u8 {} diff --git a/tests/rustdoc/underscore-type-in-trait-impl-96381.rs b/tests/rustdoc/underscore-type-in-trait-impl-96381.rs deleted file mode 100644 index 6d6e5e0a839..00000000000 --- a/tests/rustdoc/underscore-type-in-trait-impl-96381.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ should-fail -// https://github.com/rust-lang/rust/issues/96381 - -#![allow(unused)] - -trait Foo: Sized { - fn bar(i: i32, t: T, s: &Self) -> (T, i32); -} - -impl Foo for () { - fn bar(i: _, t: _, s: _) -> _ { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - (1, 2) - } -} - -fn main() {} diff --git a/tests/rustdoc/universal-impl-trait.rs b/tests/rustdoc/universal-impl-trait.rs deleted file mode 100644 index b78d69c0690..00000000000 --- a/tests/rustdoc/universal-impl-trait.rs +++ /dev/null @@ -1,55 +0,0 @@ -#![crate_name = "foo"] - -use std::io::Read; -use std::borrow::Borrow; - -//@ has foo/fn.foo.html -//@ has - //pre 'foo(' -//@ matchesraw - '_x: impl (' - //@ matchesraw - '_x: impl (T); - -impl S { - //@ has foo/struct.S.html - //@ hasraw - 'bar(' - //@ matchesraw - '_bar: impl (' - //@ matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' - pub fn baz(_baz: S) { - } - - //@ hasraw - 'qux(' - //@ matchesraw - 'trait\.Read\.html' - pub fn qux(_qux: impl IntoIterator>) { - } -} - -//@ hasraw - 'method(' -//@ matchesraw - '_x: impl Trait for S {} - -//@ has foo/fn.much_universe.html -//@ matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' -//@ matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' -//@ matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' -pub fn much_universe< - T: Borrow, - U: IntoIterator>, ->( - _: impl Read + Clone, -) { -} diff --git a/tests/rustdoc/unneeded-trait-implementations-title.rs b/tests/rustdoc/unneeded-trait-implementations-title.rs deleted file mode 100644 index f7a97dfaaef..00000000000 --- a/tests/rustdoc/unneeded-trait-implementations-title.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "foo"] - -pub struct Bar; - -//@ count foo/struct.Bar.html '//*[@id="implementations"]' 0 -- cgit 1.4.1-3-g733a5