diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/rustdoc | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
243 files changed, 2471 insertions, 864 deletions
diff --git a/tests/rustdoc-gui/anchor-navigable.goml b/tests/rustdoc-gui/anchor-navigable.goml index 9d5c55a1e..61d7c89d4 100644 --- a/tests/rustdoc-gui/anchor-navigable.goml +++ b/tests/rustdoc-gui/anchor-navigable.goml @@ -4,7 +4,7 @@ // anchor and the `impl Foo`. If there were a gap, this would cause an annoying // problem: you hover `impl Foo` to see the anchor, then when you move your // mouse to the left, the anchor disappears before you reach it. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // We check that ".item-info" is bigger than its content. move-cursor-to: ".impl" assert-property: (".impl > a.anchor", {"offsetWidth": "8"}) diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml index 85cb72274..0904aa90e 100644 --- a/tests/rustdoc-gui/anchors.goml +++ b/tests/rustdoc-gui/anchors.goml @@ -4,12 +4,12 @@ define-function: ( "check-colors", (theme, main_color, title_color, main_heading_color, main_heading_type_color, src_link_color, sidebar_link_color), block { - goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" + go-to: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" // This is needed to ensure that the text color is computed. show-text: true // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: @@ -48,9 +48,9 @@ define-function: ( {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, ) - goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" // Since we changed page, we need to set the theme again. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: diff --git a/tests/rustdoc-gui/auto-hide-trait-implementations.goml b/tests/rustdoc-gui/auto-hide-trait-implementations.goml deleted file mode 100644 index 0a619c352..000000000 --- a/tests/rustdoc-gui/auto-hide-trait-implementations.goml +++ /dev/null @@ -1,13 +0,0 @@ -// Checks that the setting "auto hide trait implementations" is working as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" - -// By default, the trait implementations are not collapsed. -assert-attribute: ("#trait-implementations-list > details", {"open": ""}, ALL) - -// We now set the setting to auto hide all trait implementations. -local-storage: {"rustdoc-auto-hide-trait-implementations": "true" } -// We reload to ensure the trait implementations are collapsed as expected. -reload: - -// We now check that all matching elements don't have the open attributes. -assert-attribute-false: ("#trait-implementations-list > details", {"open": ""}, ALL) diff --git a/tests/rustdoc-gui/basic-code.goml b/tests/rustdoc-gui/basic-code.goml index 971c2f948..e372f7119 100644 --- a/tests/rustdoc-gui/basic-code.goml +++ b/tests/rustdoc-gui/basic-code.goml @@ -1,6 +1,6 @@ // Small test to ensure the "src-line-numbers" element is only present once on // the page. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" wait-for: ".src-line-numbers" assert-count: (".src-line-numbers", 1) diff --git a/tests/rustdoc-gui/check-code-blocks-margin.goml b/tests/rustdoc-gui/check-code-blocks-margin.goml index c2cec0020..8c2cbc4d9 100644 --- a/tests/rustdoc-gui/check-code-blocks-margin.goml +++ b/tests/rustdoc-gui/check-code-blocks-margin.goml @@ -1,5 +1,5 @@ // This test ensures that the docblock elements have the appropriate left margin. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // The top docblock elements shouldn't have left margin... assert-css: ("#main-content .item-decl", {"margin-left": "0px"}) // ... but all the others should! diff --git a/tests/rustdoc-gui/check-stab-in-docblock.goml b/tests/rustdoc-gui/check-stab-in-docblock.goml index 266fa9997..2f6263621 100644 --- a/tests/rustdoc-gui/check-stab-in-docblock.goml +++ b/tests/rustdoc-gui/check-stab-in-docblock.goml @@ -1,9 +1,9 @@ // This test checks that using `.stab` attributes in `.docblock` elements doesn't // create scrollable paragraphs. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // Needs the text to be display to check for scrollable content. show-text: true -size: (786, 600) +set-window-size: (786, 600) // Confirms that there 3 paragraphs. assert-count: (".top-doc .docblock p", 3) // Checking that there is no scrollable content. diff --git a/tests/rustdoc-gui/check_info_sign_position.goml b/tests/rustdoc-gui/check_info_sign_position.goml index f36e73fc5..c9a4ea94c 100644 --- a/tests/rustdoc-gui/check_info_sign_position.goml +++ b/tests/rustdoc-gui/check_info_sign_position.goml @@ -1,7 +1,7 @@ // This test checks the position of the information on the code blocks (like // `compile_fail` or `ignore`). -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -goto: "./fn.check_list_code_block.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "./fn.check_list_code_block.html" // If the codeblock is the first element of the docblock, the information tooltip must have // have some top margin to avoid going over the toggle (the "[+]"). assert-css: (".docblock > .example-wrap.compile_fail .tooltip", { "margin-top": "16px" }) diff --git a/tests/rustdoc-gui/code-blocks-overflow.goml b/tests/rustdoc-gui/code-blocks-overflow.goml index fbf0e890b..a23136f4b 100644 --- a/tests/rustdoc-gui/code-blocks-overflow.goml +++ b/tests/rustdoc-gui/code-blocks-overflow.goml @@ -1,6 +1,6 @@ // This test ensures that codeblocks content don't overflow. -goto: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" -size: (1080, 600) +go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" +set-window-size: (1080, 600) // There should be two codeblocks: a rust one and a non-rust one. assert-count: (".docblock > .example-wrap", 2) assert: ".docblock > .example-wrap > .language-txt" diff --git a/tests/rustdoc-gui/code-color.goml b/tests/rustdoc-gui/code-color.goml index cb550a457..833fa05db 100644 --- a/tests/rustdoc-gui/code-color.goml +++ b/tests/rustdoc-gui/code-color.goml @@ -2,7 +2,7 @@ // check that the rule isn't applied on other "<code>" elements. // // While we're at it, we also check it for the other themes. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true @@ -11,7 +11,7 @@ define-function: ( (theme, doc_code_color, doc_inline_code_color), block { // Set the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL) diff --git a/tests/rustdoc-gui/code-sidebar-toggle.goml b/tests/rustdoc-gui/code-sidebar-toggle.goml index df665bd46..28c3712f3 100644 --- a/tests/rustdoc-gui/code-sidebar-toggle.goml +++ b/tests/rustdoc-gui/code-sidebar-toggle.goml @@ -1,7 +1,7 @@ // This test checks that the source code pages sidebar toggle is working as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" wait-for: "#src-sidebar-toggle" click: "#src-sidebar-toggle" -fail: true +expect-failure: true assert-css: ("#source-sidebar", { "left": "-300px" }) diff --git a/tests/rustdoc-gui/code-tags.goml b/tests/rustdoc-gui/code-tags.goml index ca337cbc3..3405d3295 100644 --- a/tests/rustdoc-gui/code-tags.goml +++ b/tests/rustdoc-gui/code-tags.goml @@ -3,22 +3,22 @@ // We need to disable this check because `implementors/test_docs/trait.AnotherOne.js` // doesn't exist. fail-on-request-error: false -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" -size: (1080, 600) +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +set-window-size: (1080, 600) // There should be four doc codeblocks. // Check that their content is inside <pre><code> assert-count: (".example-wrap pre > code", 4) // Check that function signature is inside <pre><code> assert: "pre.rust.item-decl > code" -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert: "pre.rust.item-decl > code" -goto: "file://" + |DOC_PATH| + "/test_docs/enum.AnEnum.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/enum.AnEnum.html" assert: "pre.rust.item-decl > code" -goto: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" assert: "pre.rust.item-decl > code" -goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" assert: "pre.rust.item-decl > code" diff --git a/tests/rustdoc-gui/codeblock-sub.goml b/tests/rustdoc-gui/codeblock-sub.goml index cbd314d27..03575cc6a 100644 --- a/tests/rustdoc-gui/codeblock-sub.goml +++ b/tests/rustdoc-gui/codeblock-sub.goml @@ -1,5 +1,5 @@ // Test that code blocks nested within <sub> do not have a line height of 0. -goto: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html" store-property: (codeblock_sub_1, "#codeblock-sub-1", "offsetHeight") assert-property-false: ("#codeblock-sub-3", { "offsetHeight": |codeblock_sub_1| }) diff --git a/tests/rustdoc-gui/codeblock-tooltip.goml b/tests/rustdoc-gui/codeblock-tooltip.goml index 36b67073a..2ed0579d3 100644 --- a/tests/rustdoc-gui/codeblock-tooltip.goml +++ b/tests/rustdoc-gui/codeblock-tooltip.goml @@ -1,5 +1,5 @@ // Checking the colors of the codeblocks tooltips. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" show-text: true define-function: ( @@ -7,7 +7,7 @@ define-function: ( (theme, background, color, border), block { // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: // compile_fail block diff --git a/tests/rustdoc-gui/cursor.goml b/tests/rustdoc-gui/cursor.goml index 59b139797..f318b05ce 100644 --- a/tests/rustdoc-gui/cursor.goml +++ b/tests/rustdoc-gui/cursor.goml @@ -1,5 +1,5 @@ // This test ensures that several clickable items actually have the pointer cursor. -goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" // the `[+]/[-]` button assert-css: ("#toggle-all-docs", {"cursor": "pointer"}) @@ -16,9 +16,9 @@ wait-for: "#search-tabs" assert-css: ("#search-tabs > button", {"cursor": "pointer"}) // mobile sidebar toggle button -size: (500, 700) +set-window-size: (500, 700) assert-css: (".sidebar-menu-toggle", {"cursor": "pointer"}) // the sidebar toggle button on the source code pages -goto: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html" assert-css: ("#src-sidebar-toggle > button", {"cursor": "pointer"}) diff --git a/tests/rustdoc-gui/default-settings.goml b/tests/rustdoc-gui/default-settings.goml index ab27b001e..3466f3693 100644 --- a/tests/rustdoc-gui/default-settings.goml +++ b/tests/rustdoc-gui/default-settings.goml @@ -2,7 +2,7 @@ // // The "settings" crate uses "ayu" as default setting, which is what we will // check. -goto: "file://" + |DOC_PATH| + "/settings/index.html" +go-to: "file://" + |DOC_PATH| + "/settings/index.html" // Wait a bit to be sure the default theme is applied. // If the theme isn't applied, the command will time out. wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"}) diff --git a/tests/rustdoc-gui/docblock-big-code-mobile.goml b/tests/rustdoc-gui/docblock-big-code-mobile.goml index 3ce921c2c..6fc683476 100644 --- a/tests/rustdoc-gui/docblock-big-code-mobile.goml +++ b/tests/rustdoc-gui/docblock-big-code-mobile.goml @@ -1,7 +1,7 @@ // If we have a long `<code>`, we need to ensure that it'll be fully displayed on mobile, meaning // that it'll be on two lines. emulate: "iPhone 8" // it has the following size: (375, 667) -goto: "file://" + |DOC_PATH| + "/test_docs/long_code_block/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/long_code_block/index.html" // We now check that the block is on two lines: show-text: true // We need to enable text draw to be able to have the "real" size // Little explanations for this test: if the text wasn't displayed on two lines, it would take @@ -9,5 +9,5 @@ show-text: true // We need to enable text draw to be able to have the "real" siz assert-property: (".docblock p > code", {"offsetHeight": "44"}) // Same check, but where the long code block is also a link -goto: "file://" + |DOC_PATH| + "/test_docs/long_code_block_link/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/long_code_block_link/index.html" assert-property: (".docblock p > a > code", {"offsetHeight": "44"}) diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index 69bcf5339..4c36394a3 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -1,5 +1,5 @@ // Checks that the setting "line numbers" is working as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // Otherwise, we can't check text color show-text: true @@ -13,7 +13,7 @@ define-function: ( (theme, color), block { // We now set the setting to show the line numbers on code examples. - local-storage: { + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", "rustdoc-line-numbers": "true" diff --git a/tests/rustdoc-gui/docblock-details.goml b/tests/rustdoc-gui/docblock-details.goml index 9ae571efb..58ff17619 100644 --- a/tests/rustdoc-gui/docblock-details.goml +++ b/tests/rustdoc-gui/docblock-details.goml @@ -1,7 +1,7 @@ // This ensures that the `<details>`/`<summary>` elements are displayed as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html" show-text: true -local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} +set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: // We first check that the headers in the `.top-doc` doc block still have their diff --git a/tests/rustdoc-gui/docblock-table-overflow.goml b/tests/rustdoc-gui/docblock-table-overflow.goml index d8670089a..1ca919d1e 100644 --- a/tests/rustdoc-gui/docblock-table-overflow.goml +++ b/tests/rustdoc-gui/docblock-table-overflow.goml @@ -1,7 +1,7 @@ // This test ensures that the type declaration content overflow is handled inside the <pre> directly. -goto: "file://" + |DOC_PATH| + "/lib2/long_table/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/long_table/struct.Foo.html" // We set a fixed size so there is no chance of "random" resize. -size: (1100, 800) +set-window-size: (1100, 800) // Logically, the ".docblock" and the "<p>" should have the same scroll width. compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["scrollWidth"]) assert-property: (".top-doc .docblock", {"scrollWidth": "816"}) diff --git a/tests/rustdoc-gui/docblock-table.goml b/tests/rustdoc-gui/docblock-table.goml index 3dcb8abd4..011451ef4 100644 --- a/tests/rustdoc-gui/docblock-table.goml +++ b/tests/rustdoc-gui/docblock-table.goml @@ -1,5 +1,5 @@ // This test checks the appearance of the tables in the doc comments. -goto: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func" +go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func" compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"]) compare-elements-css: (".impl-items .docblock table td", ".top-doc .docblock table td", ["border"]) @@ -8,7 +8,7 @@ define-function: ( "check-colors", (theme, border_color, zebra_stripe_color), block { - local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} reload: assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", { "background-color": "rgba(0, 0, 0, 0)", diff --git a/tests/rustdoc-gui/duplicate-macro-reexport.goml b/tests/rustdoc-gui/duplicate-macro-reexport.goml index 496203c12..7d01c88f3 100644 --- a/tests/rustdoc-gui/duplicate-macro-reexport.goml +++ b/tests/rustdoc-gui/duplicate-macro-reexport.goml @@ -1,5 +1,5 @@ // This test ensures that there is no macro duplicates in the sidebar. -goto: "file://" + |DOC_PATH| + "/test_docs/macro.a.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/macro.a.html" // Waiting for the elements in the sidebar to be rendered. wait-for: ".sidebar-elems .macro" // Check there is only one macro named "a" listed in the sidebar. diff --git a/tests/rustdoc-gui/enum-variants.goml b/tests/rustdoc-gui/enum-variants.goml index 8dfc49285..a1f60986a 100644 --- a/tests/rustdoc-gui/enum-variants.goml +++ b/tests/rustdoc-gui/enum-variants.goml @@ -1,5 +1,5 @@ // Verifies that there is non-zero margin on variants and their docblocks. -goto: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html" assert-css: (".variants > .variant", {"margin": "0px 0px 12px"}) assert-css: (".variants > .docblock", {"margin": "0px 0px 32px 24px"}) diff --git a/tests/rustdoc-gui/escape-key.goml b/tests/rustdoc-gui/escape-key.goml index 5d80d2496..3ea20fd11 100644 --- a/tests/rustdoc-gui/escape-key.goml +++ b/tests/rustdoc-gui/escape-key.goml @@ -1,6 +1,6 @@ // This test ensures that the "Escape" shortcut is handled correctly based on the // current content displayed. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // First, we check that the search results are hidden when the Escape key is pressed. write: (".search-input", "test") // To be SURE that the search will be run. diff --git a/tests/rustdoc-gui/extend-css.goml b/tests/rustdoc-gui/extend-css.goml new file mode 100644 index 000000000..fb34469df --- /dev/null +++ b/tests/rustdoc-gui/extend-css.goml @@ -0,0 +1,5 @@ +// Test to ensure that the `--extend-css` option is working as expected. +go-to: "file://" + |DOC_PATH| + "/extend_css/index.html" +show-text: true +// The text from the `.extend` element should be red. +assert-css: (".extend", {"color": "rgb(255, 0, 0)"}) diff --git a/tests/rustdoc-gui/font-weight.goml b/tests/rustdoc-gui/font-weight.goml index aad334d2b..6fad128da 100644 --- a/tests/rustdoc-gui/font-weight.goml +++ b/tests/rustdoc-gui/font-weight.goml @@ -1,5 +1,5 @@ // This test checks that the font weight is correctly applied. -goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" assert-css: ("//*[@class='rust item-decl']//a[text()='Alias']", {"font-weight": "400"}) assert-css: ( "//*[@class='structfield small-section-header']//a[text()='Alias']", @@ -9,13 +9,13 @@ assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"}) assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"}) assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"}) -goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" assert-css: (".top-doc .docblock p", {"font-weight": "400"}, ALL) -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-css: (".impl-items .method > .code-header", {"font-weight": "600"}, ALL) -goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" +go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // This is a complex selector, so here's how it works: // diff --git a/tests/rustdoc-gui/go-to-collapsed-elem.goml b/tests/rustdoc-gui/go-to-collapsed-elem.goml new file mode 100644 index 000000000..80e979177 --- /dev/null +++ b/tests/rustdoc-gui/go-to-collapsed-elem.goml @@ -0,0 +1,40 @@ +// This test ensures that when clicking on a link which leads to an item inside a collapsed element, +// the collapsed element will be expanded. +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +// We check that the implementors block is expanded. +assert-property: ("#implementations-list .implementors-toggle", {"open": "true"}) +// We now collapse the implementors block. +set-property: ("#implementations-list .implementors-toggle", {"open": "false"}) +// And now we click on the link to the method to ensure it'll expand the implementors block. +click: "//*[@class='sidebar']//a[@href='#method.must_use']" +assert-property: ("#implementations-list .implementors-toggle", {"open": "true"}) + +define-function: ("collapsed-from-search", (), block { + // Now we do the same through search result. + // First we reload the page without the anchor in the URL. + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" + // Then we collapse the section again... + set-property: ("#implementations-list .implementors-toggle", {"open": "false"}) + // Then we run the search. + write: (".search-input", "foo::must_use") + wait-for: "//*[@id='search']//a[@href='../test_docs/struct.Foo.html#method.must_use']" + click: "//*[@id='search']//a[@href='../test_docs/struct.Foo.html#method.must_use']" + assert-property: ("#implementations-list .implementors-toggle", {"open": "true"}) +}) + +call-function: ("collapsed-from-search", {}) + +// Now running the same check but with mobile. +set-window-size: (600, 600) +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +// We check that the implementors block is expanded. +assert-property: ("#implementations-list .implementors-toggle", {"open": "true"}) +// We now collapse the implementors block. +set-property: ("#implementations-list .implementors-toggle", {"open": "false"}) +// First we expand the mobile menu. +click: ".sidebar-menu-toggle" +// Then we click on the link to the method to ensure it'll expand the implementors block. +click: "//*[@class='sidebar shown']//a[@href='#method.must_use']" +assert-property: ("#implementations-list .implementors-toggle", {"open": "true"}) + +call-function: ("collapsed-from-search", {}) diff --git a/tests/rustdoc-gui/hash-item-expansion.goml b/tests/rustdoc-gui/hash-item-expansion.goml index 3cf94f624..a7a5c3cb4 100644 --- a/tests/rustdoc-gui/hash-item-expansion.goml +++ b/tests/rustdoc-gui/hash-item-expansion.goml @@ -1,5 +1,5 @@ // This test ensures that the element corresponding to the hash is displayed. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.borrow" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.borrow" // In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)". assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"open": ""}) // We first check that the impl block is open by default. diff --git a/tests/rustdoc-gui/headers-color.goml b/tests/rustdoc-gui/headers-color.goml index 92cf050a5..7d83833a8 100644 --- a/tests/rustdoc-gui/headers-color.goml +++ b/tests/rustdoc-gui/headers-color.goml @@ -4,10 +4,10 @@ define-function: ( "check-colors", (theme, color, code_header_color, focus_background_color, headings_color), block { - goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // This is needed so that the text color is computed. show-text: true - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: ( ".impl", @@ -19,20 +19,20 @@ define-function: ( {"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"}, ALL, ) - goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" assert-css: ( "#impl-Foo", {"color": |color|, "background-color": |focus_background_color|}, ) - goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" assert-css: ( "#method\.must_use", {"color": |color|, "background-color": |focus_background_color|}, ALL, ) - goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-css: (".small-section-header a", {"color": |color|}, ALL) - goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" // We select headings (h2, h3, h...). assert-css: (".docblock > :not(p) > a", {"color": |headings_color|}, ALL) }, diff --git a/tests/rustdoc-gui/headings.goml b/tests/rustdoc-gui/headings.goml index e4ba5f124..089e2203a 100644 --- a/tests/rustdoc-gui/headings.goml +++ b/tests/rustdoc-gui/headings.goml @@ -11,7 +11,7 @@ // 18px 1.125em // 16px 1rem // 14px 0.875rem -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" assert-css: (".main-heading h1", {"font-size": "24px"}) @@ -50,7 +50,7 @@ assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"border-bottom-width": "0px"}) assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) -goto: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html" assert-css: (".main-heading h1", {"font-size": "24px"}) @@ -109,7 +109,7 @@ assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width" assert-text: ("//ul[@class='block mod']/preceding-sibling::h3", "Modules") assert-css: ("//ul[@class='block mod']/preceding-sibling::h3", {"border-bottom-width": "0px"}, ALL) -goto: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html" assert-css: (".main-heading h1", {"font-size": "24px"}) @@ -141,7 +141,7 @@ assert-css: ("h5#title-for-union-impl-item-doc", {"border-bottom-width": "0px"}) assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "0px"}) -goto: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html" assert-css: (".main-heading h1", {"font-size": "24px"}) @@ -152,13 +152,13 @@ assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) // Needed to check colors show-text: true -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" define-function: ( "check-colors", (theme, heading_color, small_heading_color, heading_border_color), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: ( ".top-doc .docblock h2", @@ -222,13 +222,13 @@ define-function: ( "check-since-color", (theme), block { - local-storage: {"rustdoc-theme": |theme|} + set-local-storage: {"rustdoc-theme": |theme|} reload: assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) }, ) -goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" call-function: ("check-since-color", ("ayu")) call-function: ("check-since-color", ("dark")) call-function: ("check-since-color", ("light")) diff --git a/tests/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml index 6e2321a69..1a1c1b28f 100644 --- a/tests/rustdoc-gui/help-page.goml +++ b/tests/rustdoc-gui/help-page.goml @@ -1,6 +1,6 @@ // This test ensures that opening the help page in its own tab works. -goto: "file://" + |DOC_PATH| + "/help.html" -size: (1000, 1000) // Try desktop size first. +go-to: "file://" + |DOC_PATH| + "/help.html" +set-window-size: (1000, 1000) // Try desktop size first. wait-for: "#help" assert-css: ("#help", {"display": "block"}) assert-css: ("#help dd", {"font-size": "16px"}) @@ -8,7 +8,7 @@ click: "#help-button > a" assert-css: ("#help", {"display": "block"}) compare-elements-property: (".sub", "#help", ["offsetWidth"]) compare-elements-position: (".sub", "#help", ("x")) -size: (500, 1000) // Try mobile next. +set-window-size: (500, 1000) // Try mobile next. assert-css: ("#help", {"display": "block"}) compare-elements-property: (".sub", "#help", ["offsetWidth"]) compare-elements-position: (".sub", "#help", ("x")) @@ -20,7 +20,7 @@ define-function: ( (theme, color, background, box_shadow), block { // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: assert-css: ("#help kbd", { @@ -51,8 +51,8 @@ call-function: ("check-colors", { }) // This test ensures that opening the help popover without switching pages works. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -size: (1000, 1000) // Only supported on desktop. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (1000, 1000) // Only supported on desktop. assert-false: "#help" click: "#help-button > a" assert-css: ("#help", {"display": "block"}) @@ -63,8 +63,8 @@ compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) compare-elements-position-false: (".sub", "#help", ("x")) // This test ensures that the "the rustdoc book" anchor link within the help popover works. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -size: (1000, 1000) // Popover only appears when the screen width is >700px. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (1000, 1000) // Popover only appears when the screen width is >700px. assert-false: "#help" click: "#help-button > a" click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" diff --git a/tests/rustdoc-gui/highlight-colors.goml b/tests/rustdoc-gui/highlight-colors.goml index b182150a5..4f5e1c110 100644 --- a/tests/rustdoc-gui/highlight-colors.goml +++ b/tests/rustdoc-gui/highlight-colors.goml @@ -1,5 +1,5 @@ // This test checks the highlight colors in the source code pages. -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" show-text: true define-function: ( @@ -22,7 +22,7 @@ define-function: ( doc_comment, ), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: ("pre.rust .kw", {"color": |kw|}, ALL) assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL) diff --git a/tests/rustdoc-gui/huge-collection-of-constants.goml b/tests/rustdoc-gui/huge-collection-of-constants.goml index 636382a91..387aca6f6 100644 --- a/tests/rustdoc-gui/huge-collection-of-constants.goml +++ b/tests/rustdoc-gui/huge-collection-of-constants.goml @@ -1,6 +1,6 @@ // Make sure that the last two entries are more than 12 pixels apart and not stacked on each other. -goto: "file://" + |DOC_PATH| + "/test_docs/huge_amount_of_consts/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/huge_amount_of_consts/index.html" compare-elements-position-near-false: ( "//ul[@class='item-table']/li[last()-1]", diff --git a/tests/rustdoc-gui/huge-logo.goml b/tests/rustdoc-gui/huge-logo.goml index 01f06771c..6d3eb6606 100644 --- a/tests/rustdoc-gui/huge-logo.goml +++ b/tests/rustdoc-gui/huge-logo.goml @@ -1,21 +1,23 @@ // huge_logo crate has a custom 712x860 logo // test to ensure the maximum size in the layout works correctly -goto: "file://" + |DOC_PATH| + "/huge_logo/index.html" +go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html" -size: (1280, 1024) +set-window-size: (1280, 1024) // offsetWidth = width of sidebar assert-property: (".sidebar .logo-container", {"offsetWidth": "200", "offsetHeight": 100}) assert-property: (".sidebar .logo-container img", {"offsetWidth": "100", "offsetHeight": 100}) -size: (400, 600) +set-window-size: (400, 600) // offset = size + margin assert-property: (".mobile-topbar .logo-container", {"offsetWidth": "55", "offsetHeight": 45}) assert-property: (".mobile-topbar .logo-container img", {"offsetWidth": "35", "offsetHeight": 35}) -goto: "file://" + |DOC_PATH| + "/src/huge_logo/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/huge_logo/lib.rs.html" -size: (1280, 1024) +set-window-size: (1280, 1024) assert-property: (".sub-logo-container", {"offsetWidth": "60", "offsetHeight": 60}) -size: (400, 600) -assert-property: (".sub-logo-container", {"offsetWidth": "35", "offsetHeight": 35}) +set-window-size: (400, 600) +// 43 because 35px + 8px of margin +assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"}) +assert-property: (".sub-logo-container", {"offsetWidth": "35", "offsetHeight": 43}) diff --git a/tests/rustdoc-gui/impl-default-expansion.goml b/tests/rustdoc-gui/impl-default-expansion.goml index c3f9240cc..45bd7beb6 100644 --- a/tests/rustdoc-gui/impl-default-expansion.goml +++ b/tests/rustdoc-gui/impl-default-expansion.goml @@ -1,3 +1,3 @@ // This test ensures that the impl blocks are open by default. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-attribute: ("#implementations-list details.implementors-toggle", {"open": ""}) diff --git a/tests/rustdoc-gui/impl-doc.goml b/tests/rustdoc-gui/impl-doc.goml index 6caffb9c3..4ec46de40 100644 --- a/tests/rustdoc-gui/impl-doc.goml +++ b/tests/rustdoc-gui/impl-doc.goml @@ -1,5 +1,5 @@ // A docblock on an impl must have a margin to separate it from the contents. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html" // The text is about 24px tall, so if there's a margin, then their position will be >24px apart compare-elements-position-near-false: ( diff --git a/tests/rustdoc-gui/implementors.goml b/tests/rustdoc-gui/implementors.goml index 997c0ed8f..b39b95c1a 100644 --- a/tests/rustdoc-gui/implementors.goml +++ b/tests/rustdoc-gui/implementors.goml @@ -1,6 +1,6 @@ // The goal of this test is to check that the external trait implementors, generated with JS, // have the same display than the "local" ones. -goto: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" +go-to: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" assert: "#implementors-list" // There are supposed to be two implementors listed. assert-count: ("#implementors-list .impl", 2) @@ -15,7 +15,7 @@ assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whateve assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"}) assert: "#implementors-list .impl:nth-child(2) > .code-header" -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HasEmptyTraits.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HasEmptyTraits.html" compare-elements-position-near-false: ( "#impl-EmptyTrait1-for-HasEmptyTraits", "#impl-EmptyTrait2-for-HasEmptyTraits", @@ -29,13 +29,13 @@ compare-elements-position-near: ( // Now check that re-exports work correctly. // There should be exactly one impl shown on both of these pages. -goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" +go-to: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) -goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" +go-to: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) // Now check that the link is properly rewritten for a crate called `http`. // An older version of rustdoc had a buggy check for absolute links. -goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html" +go-to: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html" assert-count: ("#implementors-list .impl", 1) assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"}) diff --git a/tests/rustdoc-gui/item-decl-colors.goml b/tests/rustdoc-gui/item-decl-colors.goml index c58e3eb7c..5732dd8ee 100644 --- a/tests/rustdoc-gui/item-decl-colors.goml +++ b/tests/rustdoc-gui/item-decl-colors.goml @@ -18,9 +18,9 @@ define-function: ( assoc_type_color, ), block { - goto: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html" show-text: true - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL) assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL) @@ -29,7 +29,7 @@ define-function: ( assert-css: (".item-decl .enum", {"color": |enum_color|}, ALL) assert-css: (".item-decl .primitive", {"color": |primitive_color|}, ALL) - goto: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html" assert-css: (".item-decl .constant", {"color": |constant_color|}, ALL) assert-css: (".item-decl .fn", {"color": |fn_color|}, ALL) assert-css: (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL) diff --git a/tests/rustdoc-gui/item-info-alignment.goml b/tests/rustdoc-gui/item-info-alignment.goml index 94b52f005..6fc365d1f 100644 --- a/tests/rustdoc-gui/item-info-alignment.goml +++ b/tests/rustdoc-gui/item-info-alignment.goml @@ -1,10 +1,10 @@ // This test ensures that the "item-info" looks about the same // whether or not it's inside a toggle. -goto: "file://" + |DOC_PATH| + "/lib2/struct.ItemInfoAlignmentTest.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.ItemInfoAlignmentTest.html" // First, we try it in "desktop" mode. -size: (1200, 870) +set-window-size: (1200, 870) compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) // Next, we try it in "mobile" mode (max-width: 700px). -size: (650, 650) +set-window-size: (650, 650) compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) diff --git a/tests/rustdoc-gui/item-info-overflow.goml b/tests/rustdoc-gui/item-info-overflow.goml index 8ea14621c..23c53c037 100644 --- a/tests/rustdoc-gui/item-info-overflow.goml +++ b/tests/rustdoc-gui/item-info-overflow.goml @@ -1,7 +1,7 @@ // This test ensures that the "item-info" elements don't overflow. -goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo.html" // We set a fixed size so there is no chance of "random" resize. -size: (1200, 870) +set-window-size: (1200, 870) // Logically, the "item-decl" and the "item-info" should have the same scroll width. compare-elements-property: (".item-decl", ".item-info", ["scrollWidth"]) assert-property: (".item-info", {"scrollWidth": "940"}) @@ -13,7 +13,7 @@ assert-text: ( ) // Checking the "item-info" on an impl block as well: -goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo2.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo2.html" compare-elements-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", "#impl-SimpleTrait-for-LongItemInfo2 + .docblock", diff --git a/tests/rustdoc-gui/item-info.goml b/tests/rustdoc-gui/item-info.goml index 6780dfca6..60fd7c4e1 100644 --- a/tests/rustdoc-gui/item-info.goml +++ b/tests/rustdoc-gui/item-info.goml @@ -1,15 +1,15 @@ // This test ensures a few things for item info elements. -goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" // Ensuring that the item information don't take 100% of the width if unnecessary. // We set a fixed size so there is no chance of "random" resize. -size: (1100, 800) +set-window-size: (1100, 800) // We check that ".item-info" is bigger than its content. assert-css: (".item-info", {"width": "840px"}) assert-css: (".item-info .stab", {"width": "289px"}) assert-position: (".item-info .stab", {"x": 245}) // Now we ensure that they're not rendered on the same line. -goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" +go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // We first ensure that there are two item info on the trait. assert-count: ("#main-content > .item-info .stab", 2) // They should not have the same `y` position! diff --git a/tests/rustdoc-gui/item-summary-table.goml b/tests/rustdoc-gui/item-summary-table.goml index 7a219bd54..893060303 100644 --- a/tests/rustdoc-gui/item-summary-table.goml +++ b/tests/rustdoc-gui/item-summary-table.goml @@ -1,5 +1,5 @@ // This test ensures that <table> elements aren't display in items summary. -goto: "file://" + |DOC_PATH| + "/lib2/summary_table/index.html" +go-to: "file://" + |DOC_PATH| + "/lib2/summary_table/index.html" // We check that we picked the right item first. assert-text: (".item-table .item-name", "Foo") // Then we check that its summary is empty. diff --git a/tests/rustdoc-gui/javascript-disabled.goml b/tests/rustdoc-gui/javascript-disabled.goml index edf179d0d..a0872d553 100644 --- a/tests/rustdoc-gui/javascript-disabled.goml +++ b/tests/rustdoc-gui/javascript-disabled.goml @@ -2,5 +2,5 @@ // can't be used without JS. javascript: false -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-css: (".sub", {"display": "none"}) diff --git a/tests/rustdoc-gui/jump-to-def-background.goml b/tests/rustdoc-gui/jump-to-def-background.goml index 8ee3ccf4a..3a7d48284 100644 --- a/tests/rustdoc-gui/jump-to-def-background.goml +++ b/tests/rustdoc-gui/jump-to-def-background.goml @@ -1,12 +1,12 @@ // We check the background color on the jump to definition links in the source code page. -goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" define-function: ( "check-background-color", (theme, background_color), block { // Set the theme. - local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } // We reload the page so the local storage settings are being used. reload: assert-css: ( diff --git a/tests/rustdoc-gui/label-next-to-symbol.goml b/tests/rustdoc-gui/label-next-to-symbol.goml index 412e475dc..6c6380256 100644 --- a/tests/rustdoc-gui/label-next-to-symbol.goml +++ b/tests/rustdoc-gui/label-next-to-symbol.goml @@ -1,9 +1,9 @@ // These tests verify that labels like "UNIX" and "Deprecated" stay on the same line as their symbol. // It also verifies the staggered layout on mobile. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // Desktop view -size: (1080, 600) +set-window-size: (1080, 600) assert: (".stab.deprecated") assert: (".stab.portability") @@ -39,7 +39,7 @@ compare-elements-position: ( // Mobile view -size: (600, 600) +set-window-size: (600, 600) // staggered layout with 2em spacing assert-css: (".desc.docblock-short", { "padding-left": "32px" }) compare-elements-position-near: ( diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index 14f7d9935..2ee4bce10 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -1,5 +1,5 @@ // This test checks links colors. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // This is needed so that the text color is computed. show-text: true @@ -9,7 +9,7 @@ define-function: ( (theme, mod, macro, struct, enum, trait, fn, type, union, keyword, sidebar, sidebar_current, sidebar_current_background), block { - local-storage: { + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } diff --git a/tests/rustdoc-gui/list_code_block.goml b/tests/rustdoc-gui/list_code_block.goml index 4c477d70c..25ddea319 100644 --- a/tests/rustdoc-gui/list_code_block.goml +++ b/tests/rustdoc-gui/list_code_block.goml @@ -1,4 +1,4 @@ // This test checks that code blocks in list are supported. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -goto: "./fn.check_list_code_block.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "./fn.check_list_code_block.html" assert: ("pre.rust.item-decl") diff --git a/tests/rustdoc-gui/method-margins.goml b/tests/rustdoc-gui/method-margins.goml index 720268a9e..ac3caeb23 100644 --- a/tests/rustdoc-gui/method-margins.goml +++ b/tests/rustdoc-gui/method-margins.goml @@ -1,5 +1,5 @@ // This test ensures that the margins on methods are coherent inside an impl block. -goto: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait" +go-to: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait" assert-count: ("#trait-implementations-list > .toggle", 1) diff --git a/tests/rustdoc-gui/mobile.goml b/tests/rustdoc-gui/mobile.goml index 8c8516ebf..e576385cd 100644 --- a/tests/rustdoc-gui/mobile.goml +++ b/tests/rustdoc-gui/mobile.goml @@ -1,8 +1,8 @@ // Test various properties of the mobile UI -goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" -size: (400, 600) +go-to: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" +set-window-size: (400, 600) -font-size: 18 +set-font-size: 18 wait-for: 100 // wait a bit for the resize and the font-size change to be fully taken into account. // The out-of-band info (source, stable version, collapse) should be below the @@ -18,14 +18,14 @@ assert-property: (".mobile-topbar h2", {"offsetHeight": 33}) // is therefore not part of the DOM. assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" }) -size: (1000, 1000) +set-window-size: (1000, 1000) wait-for: 100 // wait a bit for the resize to be fully taken into account. assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" }) // On the settings page, the theme buttons should not line-wrap. Instead, they should // all be placed as a group on a line below the setting name "Theme." -goto: "file://" + |DOC_PATH| + "/settings.html" -size: (400, 600) +go-to: "file://" + |DOC_PATH| + "/settings.html" +set-window-size: (400, 600) // Ignored for now https://github.com/rust-lang/rust/issues/93784. // compare-elements-position-near-false: ( // "#preferred-light-theme .setting-radio-name", diff --git a/tests/rustdoc-gui/module-items-font.goml b/tests/rustdoc-gui/module-items-font.goml index 23823f8b6..54c8131c3 100644 --- a/tests/rustdoc-gui/module-items-font.goml +++ b/tests/rustdoc-gui/module-items-font.goml @@ -1,5 +1,5 @@ // This test checks that the correct font is used on module items (in index.html pages). -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-css: ( ".item-table .item-name > a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, diff --git a/tests/rustdoc-gui/no-docblock.goml b/tests/rustdoc-gui/no-docblock.goml index 17a955064..1b4638ef0 100644 --- a/tests/rustdoc-gui/no-docblock.goml +++ b/tests/rustdoc-gui/no-docblock.goml @@ -4,10 +4,10 @@ // doesn't exist. fail-on-request-error: false -goto: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithNoDocblocks.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithNoDocblocks.html" // Check that the two methods are more than 24px apart. compare-elements-position-near-false: ("//*[@id='tymethod.first_fn']", "//*[@id='tymethod.second_fn']", {"y": 24}) -goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithNoDocblocks.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithNoDocblocks.html" // Check that the two methods are more than 24px apart. compare-elements-position-near-false: ("//*[@id='method.first_fn']", "//*[@id='method.second_fn']", {"y": 24}) diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 207289151..f65da5774 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -1,8 +1,8 @@ // This test checks the position of the `i` for the notable traits. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" show-text: true // We start with a wide screen. -size: (1100, 600) +set-window-size: (1100, 600) // Checking they have the same y position. compare-elements-position: ( "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", @@ -44,7 +44,7 @@ move-cursor-to: "//h1" assert-count: ("//*[@class='tooltip popover']", 0) // Now only the `i` should be on the next line. -size: (1055, 600) +set-window-size: (1055, 600) compare-elements-position-false: ( "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", @@ -52,7 +52,7 @@ compare-elements-position-false: ( ) // Now both the `i` and the struct name should be on the next line. -size: (980, 600) +set-window-size: (980, 600) // Checking they have the same y position. compare-elements-position: ( "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", @@ -76,7 +76,7 @@ assert-position: ( ) // Checking on mobile now. -size: (650, 600) +set-window-size: (650, 600) // Checking they have the same y position. compare-elements-position: ( "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", @@ -124,12 +124,12 @@ define-function: ( "check-colors", (theme, header_color, content_color, type_color, trait_color), block { - goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" // This is needed to ensure that the text color is computed. show-text: true // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: @@ -253,7 +253,7 @@ press-key: "Escape" assert-window-property-false: {"scrollY": |scroll|} // Opening the mobile sidebar should close the popover. -size: (650, 600) +set-window-size: (650, 600) click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" assert-count: ("//*[@class='tooltip popover']", 1) click: ".sidebar-menu-toggle" @@ -266,7 +266,7 @@ assert-count: ("//*[@class='tooltip popover']", 1) assert-false: "//*[@class='sidebar shown']" // Also check the focus handling for the help button. -size: (1100, 600) +set-window-size: (1100, 600) reload: assert-count: ("//*[@class='tooltip popover']", 0) click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" diff --git a/tests/rustdoc-gui/overflow-tooltip-information.goml b/tests/rustdoc-gui/overflow-tooltip-information.goml index 09ad6cdd7..ab7ffc24c 100644 --- a/tests/rustdoc-gui/overflow-tooltip-information.goml +++ b/tests/rustdoc-gui/overflow-tooltip-information.goml @@ -1,7 +1,7 @@ // The goal of this test is to ensure that the tooltip `.information` class doesn't // have overflow and max-width CSS rules set because they create a bug in firefox on // mac. For more information: https://github.com/rust-lang/rust/issues/89185 -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" assert-css: (".docblock > .example-wrap .tooltip", { "overflow-x": "visible", "max-width": "none" diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml index c3649dc7b..4bdf31ecb 100644 --- a/tests/rustdoc-gui/pocket-menu.goml +++ b/tests/rustdoc-gui/pocket-menu.goml @@ -1,5 +1,5 @@ // This test ensures that the "pocket menus" are working as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // First we check that the help menu doesn't exist yet. assert-false: "#help-button .popover" // Then we display the help menu. @@ -32,7 +32,7 @@ assert-css: ("#settings-menu .popover", {"display": "none"}) // We check the borders color now: // Ayu theme -local-storage: { +set-local-storage: { "rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false", } @@ -47,7 +47,7 @@ compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-co compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) // Dark theme -local-storage: { +set-local-storage: { "rustdoc-theme": "dark", "rustdoc-use-system-theme": "false", } @@ -62,7 +62,7 @@ compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-co compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) // Light theme -local-storage: { +set-local-storage: { "rustdoc-theme": "light", "rustdoc-use-system-theme": "false", } @@ -77,7 +77,7 @@ compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-co compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) // Opening the mobile sidebar should close the settings popover. -size: (650, 600) +set-window-size: (650, 600) click: "#settings-menu a" assert-css: ("#settings-menu .popover", {"display": "block"}) click: ".sidebar-menu-toggle" diff --git a/tests/rustdoc-gui/run-on-hover.goml b/tests/rustdoc-gui/run-on-hover.goml index 8dcb62c10..b5fc49eac 100644 --- a/tests/rustdoc-gui/run-on-hover.goml +++ b/tests/rustdoc-gui/run-on-hover.goml @@ -2,14 +2,14 @@ // Playground. That button is hidden until the user hovers over the code block. // This test checks that it is hidden, and that it shows on hover. It also // checks for its color. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" show-text: true define-function: ( "check-run-button", (theme, color, background, hover_color, hover_background), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".test-arrow", {"visibility": "hidden"}) move-cursor-to: ".example-wrap" diff --git a/tests/rustdoc-gui/rust-logo.goml b/tests/rustdoc-gui/rust-logo.goml index 2d15e8b96..640ed152b 100644 --- a/tests/rustdoc-gui/rust-logo.goml +++ b/tests/rustdoc-gui/rust-logo.goml @@ -1,26 +1,26 @@ // This test ensures that the correct style is applied to the rust logo in the sidebar. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" define-function: ( "check-logo", (theme, filter), block { // Going to the doc page. - goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // Changing theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".rust-logo", {"filter": |filter|}) // Going to the source code page. - goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" + go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // Changing theme (since it's local files, the local storage works by folder). - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".rust-logo", {"filter": |filter|}) // Now we check that the non-rust logos don't have a CSS filter set. - goto: "file://" + |DOC_PATH| + "/huge_logo/index.html" + go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html" // Changing theme on the new page (again...). - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: // Check there is no rust logo assert-false: ".rust-logo" diff --git a/tests/rustdoc-gui/scrape-examples-button-focus.goml b/tests/rustdoc-gui/scrape-examples-button-focus.goml index 1b5c3a0d2..77061ea2a 100644 --- a/tests/rustdoc-gui/scrape-examples-button-focus.goml +++ b/tests/rustdoc-gui/scrape-examples-button-focus.goml @@ -1,6 +1,6 @@ // This test ensures that the scraped examples buttons are working as expecting // when 'Enter' key is pressed when they're focused. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" // The next/prev buttons vertically scroll the code viewport between examples store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre", "scrollTop") @@ -8,24 +8,24 @@ focus: ".scraped-example-list > .scraped-example .next" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { "scrollTop": |initialScrollTop| -}) +}, NEAR) focus: ".scraped-example-list > .scraped-example .prev" press-key: "Enter" assert-property: (".scraped-example-list > .scraped-example pre", { "scrollTop": |initialScrollTop| -}) +}, NEAR) // The expand button increases the scrollHeight of the minimized code viewport store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property-false: (".scraped-example-list > .scraped-example pre", { "scrollHeight": |smallOffsetHeight| -}) +}, NEAR) focus: ".scraped-example-list > .scraped-example .expand" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { "offsetHeight": |smallOffsetHeight| -}) +}, NEAR) store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property: (".scraped-example-list > .scraped-example pre", { "scrollHeight": |fullOffsetHeight| -}) +}, NEAR) diff --git a/tests/rustdoc-gui/scrape-examples-color.goml b/tests/rustdoc-gui/scrape-examples-color.goml index 67c58826e..8ddb06fcc 100644 --- a/tests/rustdoc-gui/scrape-examples-color.goml +++ b/tests/rustdoc-gui/scrape-examples-color.goml @@ -1,5 +1,5 @@ // Check that scrape example code blocks have the expected colors. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" show-text: true define-function: ( @@ -7,7 +7,7 @@ define-function: ( (theme, highlight, highlight_focus, help_border, help_color, help_hover_border, help_hover_color), block { - local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } reload: wait-for: ".more-examples-toggle" assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", { @@ -60,13 +60,13 @@ call-function: ("check-colors", { }) // Now testing the top and bottom background in case there is only one scraped examples. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" define-function: ( "check-background", (theme, background_color_start, background_color_end), block { - local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } reload: assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", { "background-image": "linear-gradient(" + |background_color_start| + ", " + diff --git a/tests/rustdoc-gui/scrape-examples-fonts.goml b/tests/rustdoc-gui/scrape-examples-fonts.goml index 142f337cb..4c325bace 100644 --- a/tests/rustdoc-gui/scrape-examples-fonts.goml +++ b/tests/rustdoc-gui/scrape-examples-fonts.goml @@ -1,5 +1,5 @@ // This test ensures that the correct font is used in scraped examples. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" store-value: (font, '"Fira Sans", Arial, NanumBarunGothic, sans-serif') diff --git a/tests/rustdoc-gui/scrape-examples-layout.goml b/tests/rustdoc-gui/scrape-examples-layout.goml index dad727c77..160056d6d 100644 --- a/tests/rustdoc-gui/scrape-examples-layout.goml +++ b/tests/rustdoc-gui/scrape-examples-layout.goml @@ -1,5 +1,5 @@ // Check that the line number column has the correct layout. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" // Check that it's not zero. assert-property-false: ( @@ -44,6 +44,6 @@ assert-position: (".scraped-example .code-wrapper", {"y": 253}) assert-position: (".scraped-example .code-wrapper .prev", {"y": 253 + |offset_y|}) // Then with mobile -size: (600, 600) +set-window-size: (600, 600) assert-position: (".scraped-example .code-wrapper", {"y": 308}) assert-position: (".scraped-example .code-wrapper .prev", {"y": 308 + |offset_y|}) diff --git a/tests/rustdoc-gui/scrape-examples-toggle.goml b/tests/rustdoc-gui/scrape-examples-toggle.goml index 2d5df6a5d..9cec6d2bb 100644 --- a/tests/rustdoc-gui/scrape-examples-toggle.goml +++ b/tests/rustdoc-gui/scrape-examples-toggle.goml @@ -1,5 +1,5 @@ // This tests checks that the "scraped examples" toggle is working as expected. -goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" +go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" // Checking the color of the toggle line. show-text: true @@ -7,7 +7,7 @@ define-function: ( "check-color", (theme, toggle_line_color, toggle_line_hover_color), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: // Clicking "More examples..." will open additional examples diff --git a/tests/rustdoc-gui/search-error.goml b/tests/rustdoc-gui/search-error.goml index 2a10a647b..d21905e90 100644 --- a/tests/rustdoc-gui/search-error.goml +++ b/tests/rustdoc-gui/search-error.goml @@ -1,5 +1,5 @@ // Checks that the crate search filtering is handled correctly and changes the results. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds" show-text: true define-function: ( @@ -7,7 +7,7 @@ define-function: ( (theme, error_background), block { // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: diff --git a/tests/rustdoc-gui/search-filter.goml b/tests/rustdoc-gui/search-filter.goml index 5bc6e87d6..d739471a6 100644 --- a/tests/rustdoc-gui/search-filter.goml +++ b/tests/rustdoc-gui/search-filter.goml @@ -1,5 +1,5 @@ // Checks that the crate search filtering is handled correctly and changes the results. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true write: (".search-input", "test") // To be SURE that the search will be run. @@ -16,6 +16,7 @@ press-key: "ArrowDown" press-key: "ArrowDown" press-key: "ArrowDown" press-key: "ArrowDown" +press-key: "ArrowDown" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" @@ -41,13 +42,14 @@ press-key: "ArrowUp" press-key: "ArrowUp" press-key: "ArrowUp" press-key: "ArrowUp" +press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" assert-property: ("#crate-search", {"value": "all crates"}) // Checking that the URL parameter is taken into account for crate filtering. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test&filter-crate=lib2" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test&filter-crate=lib2" wait-for: "#crate-search" assert-property: ("#crate-search", {"value": "lib2"}) assert-false: "#results .externcrate" @@ -57,10 +59,10 @@ assert-text: (".search-results-title", "Results in all crates", STARTS_WITH) // Checking the display of the crate filter. // We start with the light theme. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: -timeout: 2000 +set-timeout: 2000 wait-for: "#crate-search" assert-css: ("#crate-search", { "border": "1px solid rgb(224, 224, 224)", diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index 542db348c..83c698090 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -1,9 +1,9 @@ // This test ensures that the elements in ".search-form" have the expected display. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true // Ayu theme -local-storage: { +set-local-storage: { "rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false", } @@ -89,7 +89,7 @@ assert-css: ( ) // Dark theme -local-storage: { +set-local-storage: { "rustdoc-theme": "dark", "rustdoc-use-system-theme": "false", } @@ -176,7 +176,7 @@ assert-css: ( ) // Light theme -local-storage: { +set-local-storage: { "rustdoc-theme": "light", "rustdoc-use-system-theme": "false", } diff --git a/tests/rustdoc-gui/search-input-mobile.goml b/tests/rustdoc-gui/search-input-mobile.goml index ce0cef77c..adcb3658a 100644 --- a/tests/rustdoc-gui/search-input-mobile.goml +++ b/tests/rustdoc-gui/search-input-mobile.goml @@ -1,11 +1,11 @@ // Test to ensure that you can click on the search input, whatever the width. // The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592 -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -size: (463, 700) +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (463, 700) // We first check that the search input isn't already focused. assert-false: ("input.search-input:focus") click: "input.search-input" reload: -size: (750, 700) +set-window-size: (750, 700) click: "input.search-input" assert: ("input.search-input:focus") diff --git a/tests/rustdoc-gui/search-keyboard.goml b/tests/rustdoc-gui/search-keyboard.goml index ed975664c..f1d802461 100644 --- a/tests/rustdoc-gui/search-keyboard.goml +++ b/tests/rustdoc-gui/search-keyboard.goml @@ -1,6 +1,6 @@ // Checks that the search tab results work correctly with function signature syntax // First, try a search-by-name -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "Foo") // To be SURE that the search will be run. press-key: 'Enter' diff --git a/tests/rustdoc-gui/search-no-result.goml b/tests/rustdoc-gui/search-no-result.goml index b76a44fa9..46d1856b4 100644 --- a/tests/rustdoc-gui/search-no-result.goml +++ b/tests/rustdoc-gui/search-no-result.goml @@ -1,5 +1,5 @@ // The goal of this test is to check the color of the "no result" links. -goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks" +go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks" show-text: true define-function: ( @@ -7,7 +7,7 @@ define-function: ( (theme, link, link_hover), block { // Changing theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: wait-for: "#results" assert: ".search-failed.active" diff --git a/tests/rustdoc-gui/search-reexport.goml b/tests/rustdoc-gui/search-reexport.goml index dd19f03bd..fd817b589 100644 --- a/tests/rustdoc-gui/search-reexport.goml +++ b/tests/rustdoc-gui/search-reexport.goml @@ -1,7 +1,7 @@ // Checks that the reexports are present in the search index, can have // doc aliases and are highligted when their ID is the hash of the page. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: // First we check that the reexport has the correct ID and no background color. assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;") diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index d6d54ec4b..da46a90df 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -31,13 +31,13 @@ define-function: ( }, ) -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" // This is needed so that the text color is computed. show-text: true // Ayu theme -local-storage: { +set-local-storage: { "rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false", } @@ -154,7 +154,7 @@ assert-css: ( ) // Dark theme -local-storage: { +set-local-storage: { "rustdoc-theme": "dark", "rustdoc-use-system-theme": "false", } @@ -259,7 +259,7 @@ assert-css: ( ) // Light theme -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: // Waiting for the search results to appear... @@ -361,7 +361,7 @@ assert-css: ( ) // Check the alias. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true @@ -369,7 +369,7 @@ define-function: ( "check-alias", (theme, alias, grey), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: write: (".search-input", "thisisanalias") // To be SURE that the search will be run. diff --git a/tests/rustdoc-gui/search-result-description.goml b/tests/rustdoc-gui/search-result-description.goml index 9fa210804..745ef31e6 100644 --- a/tests/rustdoc-gui/search-result-description.goml +++ b/tests/rustdoc-gui/search-result-description.goml @@ -1,5 +1,5 @@ // This test is to ensure that the codeblocks are correctly rendered in the search results. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=some_more_function" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=some_more_function" // Waiting for the search results to appear... wait-for: "#search-tabs" assert-text: (".search-results .desc code", "format!") diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index 20a88c36e..93c71f23f 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -1,6 +1,6 @@ // Checks that the search results have the expected width. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -size: (900, 1000) +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (900, 1000) write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' @@ -8,7 +8,7 @@ wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... assert-css: (".search-results div.desc", {"width": "310px"}) -size: (600, 100) +set-window-size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. assert-css: (".search-results div.desc", {"width": "566px"}) @@ -18,7 +18,7 @@ assert-css: (".search-results .result-name > span", {"display": "inline"}) // Check that the crate filter `<select>` is correctly handled when it goes to next line. // To do so we need to update the length of one of its `<option>`. -size: (900, 900) +set-window-size: (900, 900) // First we check the current width, height and position. assert-css: ("#crate-search", {"width": "223px"}) @@ -26,7 +26,7 @@ assert-css: (".search-results-title", {"height": "50px", "width": "640px"}) assert-css: ("#search", {"width": "640px"}) // Then we update the text of one of the `<option>`. -text: ( +set-text: ( "#crate-search option", "sdjfaksdjfaksjdbfkadsbfkjsadbfkdsbkfbsadkjfbkdsabfkadsfkjdsafa", ) @@ -43,7 +43,7 @@ define-function: ( "check-filter", (theme, border, filter, hover_border, hover_filter), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: wait-for: "#crate-search" assert-css: ("#crate-search", {"border": "1px solid " + |border|}) diff --git a/tests/rustdoc-gui/search-result-go-to-first.goml b/tests/rustdoc-gui/search-result-go-to-first.goml index f444baa6c..a0bc2bb16 100644 --- a/tests/rustdoc-gui/search-result-go-to-first.goml +++ b/tests/rustdoc-gui/search-result-go-to-first.goml @@ -2,11 +2,11 @@ // First, we check that the first page doesn't have the string we're looking for to ensure // that the feature is changing page as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-text-false: (".main-heading h1", "Struct test_docs::Foo") // We now check that we land on the search result page if "go_to_first" isn't set. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo" // Waiting for the search results to appear... wait-for: "#search-tabs" assert-text-false: (".main-heading h1", "Struct test_docs::Foo") @@ -14,6 +14,6 @@ assert-text-false: (".main-heading h1", "Struct test_docs::Foo") assert-css: ("#main-content", {"display": "none"}) // Now we can check that the feature is working as expected! -goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo&go_to_first=true" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo&go_to_first=true" // Waiting for the page to load... wait-for-text: (".main-heading h1", "Struct test_docs::Foo") diff --git a/tests/rustdoc-gui/search-result-keyword.goml b/tests/rustdoc-gui/search-result-keyword.goml index 8c3577d9f..5d56e9d9c 100644 --- a/tests/rustdoc-gui/search-result-keyword.goml +++ b/tests/rustdoc-gui/search-result-keyword.goml @@ -1,5 +1,5 @@ // Checks that the "keyword" results have the expected text alongside them. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "CookieMonster") // To be SURE that the search will be run. press-key: 'Enter' diff --git a/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml index 1433dc4d7..b3f9ae928 100644 --- a/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml +++ b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml @@ -1,6 +1,6 @@ // Checks that the search tab results work correctly with function signature syntax // First, try a search-by-name -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "Foo") // To be SURE that the search will be run. press-key: 'Enter' @@ -22,7 +22,7 @@ press-key: "ArrowLeft" wait-for-attribute: ("#search-tabs > button:nth-of-type(3)", {"class": "selected"}) // Now try search-by-return -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "-> String") // To be SURE that the search will be run. press-key: 'Enter' @@ -44,7 +44,7 @@ press-key: "ArrowLeft" wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) // Try with a search-by-return with no results -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "-> Something") // To be SURE that the search will be run. press-key: 'Enter' @@ -54,7 +54,7 @@ assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"} assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Return Types", STARTS_WITH) // Try with a search-by-parameter -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "usize pattern") // To be SURE that the search will be run. press-key: 'Enter' @@ -64,7 +64,7 @@ assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"} assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Parameters", STARTS_WITH) // Try with a search-by-parameter-and-return -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "pattern -> str") // To be SURE that the search will be run. press-key: 'Enter' diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml index 36958f700..2223598f0 100644 --- a/tests/rustdoc-gui/search-tab.goml +++ b/tests/rustdoc-gui/search-tab.goml @@ -1,5 +1,5 @@ // Checking the colors of the search tab headers. -goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=something" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=something" show-text: true define-function: ( @@ -9,7 +9,7 @@ define-function: ( border_top_hover), block { // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: // These two commands are used to be sure the search will be run. diff --git a/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml b/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml new file mode 100644 index 000000000..6cd725043 --- /dev/null +++ b/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml @@ -0,0 +1,51 @@ +// This test ensures that the "Auto-hide item contents for large items" setting is working as +// expected. + +// We need to disable this check because `implementors/test_docs/trait.Iterator.js` doesn't exist. +fail-on-request-error: false + +define-function: ( + "check-setting", + (storage_value, setting_attribute_value, toggle_attribute_value), + block { + assert-local-storage: {"rustdoc-auto-hide-large-items": |storage_value|} + click: "#settings-menu" + wait-for: "#settings" + assert-property: ("#auto-hide-large-items", {"checked": |setting_attribute_value|}) + assert-attribute: (".item-decl .type-contents-toggle", {"open": |toggle_attribute_value|}) + } +) + +go-to: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html" + +// We check that the setting is enabled by default and is working. +call-function: ("check-setting", { + "storage_value": null, + "setting_attribute_value": "true", + "toggle_attribute_value": null, +}) + +// Now we change its value. +click: "#auto-hide-large-items" +assert-local-storage: {"rustdoc-auto-hide-large-items": "false"} + +// We check that the changes were applied as expected. +reload: + +call-function: ("check-setting", { + "storage_value": "false", + "setting_attribute_value": "false", + "toggle_attribute_value": "", +}) + +// And now we re-enable the setting. +click: "#auto-hide-large-items" +assert-local-storage: {"rustdoc-auto-hide-large-items": "true"} + +// And we check everything is back the way it was before. +reload: +call-function: ("check-setting", { + "storage_value": "true", + "setting_attribute_value": "true", + "toggle_attribute_value": null, +}) diff --git a/tests/rustdoc-gui/setting-auto-hide-item-methods-docs.goml b/tests/rustdoc-gui/setting-auto-hide-item-methods-docs.goml new file mode 100644 index 000000000..5210ad8f7 --- /dev/null +++ b/tests/rustdoc-gui/setting-auto-hide-item-methods-docs.goml @@ -0,0 +1,48 @@ +// This test ensures that the "Auto-hide item methods' documentation" setting is working as +// expected. + +define-function: ( + "check-setting", + (storage_value, setting_attribute_value, toggle_attribute_value), + block { + assert-local-storage: {"rustdoc-auto-hide-method-docs": |storage_value|} + click: "#settings-menu" + wait-for: "#settings" + assert-property: ("#auto-hide-method-docs", {"checked": |setting_attribute_value|}) + assert-attribute: (".toggle.method-toggle", {"open": |toggle_attribute_value|}) + } +) + +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" + +// We check that the setting is disabled by default. +call-function: ("check-setting", { + "storage_value": null, + "setting_attribute_value": "false", + "toggle_attribute_value": "", +}) + +// Now we change its value. +click: "#auto-hide-method-docs" +assert-local-storage: {"rustdoc-auto-hide-method-docs": "true"} + +// We check that the changes were applied as expected. +reload: + +call-function: ("check-setting", { + "storage_value": "true", + "setting_attribute_value": "true", + "toggle_attribute_value": null, +}) + +// And now we re-disable the setting. +click: "#auto-hide-method-docs" +assert-local-storage: {"rustdoc-auto-hide-method-docs": "false"} + +// And we check everything is back the way it was before. +reload: +call-function: ("check-setting", { + "storage_value": "false", + "setting_attribute_value": "false", + "toggle_attribute_value": "", +}) diff --git a/tests/rustdoc-gui/setting-auto-hide-trait-implementations.goml b/tests/rustdoc-gui/setting-auto-hide-trait-implementations.goml new file mode 100644 index 000000000..ecadd8fa8 --- /dev/null +++ b/tests/rustdoc-gui/setting-auto-hide-trait-implementations.goml @@ -0,0 +1,47 @@ +// Checks that the setting "auto hide trait implementations" is working as expected. + +define-function: ( + "check-setting", + (storage_value, setting_attribute_value, toggle_attribute_value), + block { + assert-local-storage: {"rustdoc-auto-hide-trait-implementations": |storage_value|} + click: "#settings-menu" + wait-for: "#settings" + assert-property: ("#auto-hide-trait-implementations", {"checked": |setting_attribute_value|}) + assert-attribute: ("#trait-implementations-list > details", {"open": |toggle_attribute_value|}, ALL) + } +) + +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" + +// By default, the trait implementations are not collapsed. +call-function: ("check-setting", { + "storage_value": null, + "setting_attribute_value": "false", + "toggle_attribute_value": "", +}) + +// Now we change its value. +click: "#auto-hide-trait-implementations" +assert-local-storage: {"rustdoc-auto-hide-trait-implementations": "true"} + +// We check that the changes were applied as expected. +reload: + +call-function: ("check-setting", { + "storage_value": "true", + "setting_attribute_value": "true", + "toggle_attribute_value": null, +}) + +// And now we re-disable the setting. +click: "#auto-hide-trait-implementations" +assert-local-storage: {"rustdoc-auto-hide-trait-implementations": "false"} + +// And we check everything is back the way it was before. +reload: +call-function: ("check-setting", { + "storage_value": "false", + "setting_attribute_value": "false", + "toggle_attribute_value": "", +}) diff --git a/tests/rustdoc-gui/setting-go-to-only-result.goml b/tests/rustdoc-gui/setting-go-to-only-result.goml new file mode 100644 index 000000000..c5720b4bf --- /dev/null +++ b/tests/rustdoc-gui/setting-go-to-only-result.goml @@ -0,0 +1,63 @@ +// Checks that the setting "Directly go to item in search if there is only one result " is working as expected. + +define-function: ( + "check-setting", + (storage_value, setting_attribute_value), + block { + assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|} + click: "#settings-menu" + wait-for: "#settings" + assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|}) + } +) + +go-to: "file://" + |DOC_PATH| + "/lib2/index.html" + +call-function: ("check-setting", { + "storage_value": null, + "setting_attribute_value": "false", +}) + +// By default, the search doesn't automatically go to the page if there is only one result. +go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" +// It will timeout if the setting isn't working. +wait-for: "#search" +assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS) + +// Now we change its value. +click: "#settings-menu" +wait-for: "#settings" +click: "#go-to-only-result" +assert-local-storage: {"rustdoc-go-to-only-result": "true"} + +go-to: "file://" + |DOC_PATH| + "/lib2/index.html" +// We enter it into the search. +write: (".search-input", "HasALongTraitWithParams") +wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} +assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) + +// We try again to see if it goes to the only result +go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" +wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} +assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) + +// We check the settings +call-function: ("check-setting", { + "storage_value": "true", + "setting_attribute_value": "true", +}) + +// And now we re-disable the setting. +click: "#go-to-only-result" +assert-local-storage: {"rustdoc-go-to-only-result": "false"} + +go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" +// It will timeout if the setting isn't working. +wait-for: "#search" +assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS) + +// And we check everything is back the way it was before. +call-function: ("check-setting", { + "storage_value": "false", + "setting_attribute_value": "false", +}) diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index a84172885..733be9beb 100644 --- a/tests/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -1,6 +1,6 @@ // This test ensures that the settings menu display is working as expected and that // the settings page is also rendered as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true // needed when we check for colors below. // First, we check that the settings page doesn't exist. assert-false: "#settings" @@ -35,7 +35,7 @@ wait-for: "#alternative-display #search" assert: "#main-content.hidden" // Now let's check the content of the settings menu. -local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} +set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: click: "#settings-menu" wait-for: "#settings" @@ -56,11 +56,12 @@ move-cursor-to: "#settings-menu > a" assert-css: ( "#theme-dark", { - "border-color": "rgb(221, 221, 221)", + "border-color": "rgb(153, 153, 153)", "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-width": "2px", }, ) -assert-css: ("#theme-light", {"border-color": "rgb(221, 221, 221)", "box-shadow": "none"}) +assert-css: ("#theme-light", {"border-color": "rgb(153, 153, 153)", "box-shadow": "none"}) // Let's start with the hover for radio buttons. move-cursor-to: "#theme-dark" assert-css: ( @@ -68,26 +69,36 @@ assert-css: ( { "border-color": "rgb(33, 150, 243)", "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-width": "2px", }, ) move-cursor-to: "#theme-light" -assert-css: ("#theme-light", {"border-color": "rgb(33, 150, 243)", "box-shadow": "none"}) +assert-css: ( + "#theme-light", + { + "border-color": "rgb(33, 150, 243)", + "box-shadow": "none", + "border-width": "2px", + } +) move-cursor-to: "#theme-ayu" // Let's now check with the focus for radio buttons. focus: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(221, 221, 221)", + "border-color": "rgb(153, 153, 153)", "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-width": "2px", }, ) focus: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(221, 221, 221)", + "border-color": "rgb(153, 153, 153)", "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-width": "2px", }, ) // Now we check we both focus and hover for radio buttons. @@ -98,6 +109,7 @@ assert-css: ( { "border-color": "rgb(33, 150, 243)", "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-width": "2px", }, ) move-cursor-to: "#theme-light" @@ -107,6 +119,7 @@ assert-css: ( { "border-color": "rgb(33, 150, 243)", "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-width": "2px", }, ) // Now we check the setting-radio-name is on a different line than the label. @@ -142,7 +155,18 @@ assert-css: ( "#auto-hide-large-items", { "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(221, 221, 221)", + "border-color": "rgb(153, 153, 153)", + // 1px border when checked + "border-width": "1px", + }, +) +assert-css: ( + "#auto-hide-method-docs", + { + "background-color": "rgba(0, 0, 0, 0)", + "border-color": "rgb(153, 153, 153)", + // 2px border when unchecked + "border-width": "2px", }, ) // Let's start with the hover for toggles. @@ -152,6 +176,18 @@ assert-css: ( { "background-color": "rgb(33, 150, 243)", "border-color": "rgb(33, 150, 243)", + // 1px border when checked + "border-width": "1px", + }, +) +move-cursor-to: "#auto-hide-method-docs" +assert-css: ( + "#auto-hide-method-docs", + { + "background-color": "rgba(0, 0, 0, 0)", + "border-color": "rgb(33, 150, 243)", + // 2px border when unchecked + "border-width": "2px", }, ) move-cursor-to: "#settings-menu > a" @@ -161,8 +197,21 @@ assert-css: ( "#auto-hide-large-items", { "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(221, 221, 221)", + "border-color": "rgb(153, 153, 153)", + "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + // 1px border when checked + "border-width": "1px", + }, +) +focus: "#auto-hide-method-docs" +assert-css: ( + "#auto-hide-method-docs", + { + "background-color": "rgba(0, 0, 0, 0)", + "border-color": "rgb(153, 153, 153)", "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + // 2px border when unchecked + "border-width": "2px", }, ) // Now we check we both focus and hover for toggles. @@ -174,6 +223,20 @@ assert-css: ( "background-color": "rgb(33, 150, 243)", "border-color": "rgb(33, 150, 243)", "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + // 1px border when checked + "border-width": "1px", + }, +) +move-cursor-to: "#auto-hide-method-docs" +focus: "#auto-hide-method-docs" +assert-css: ( + "#auto-hide-method-docs", + { + "background-color": "rgba(0, 0, 0, 0)", + "border-color": "rgb(33, 150, 243)", + "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + // 2px border when unchecked + "border-width": "2px", }, ) @@ -189,7 +252,7 @@ assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light the // We now check that clicking on the toggles' text is like clicking on the checkbox. // To test it, we use the "Disable keyboard shortcuts". -local-storage: {"rustdoc-disable-shortcuts": "false"} +set-local-storage: {"rustdoc-disable-shortcuts": "false"} click: ".setting-line:last-child .setting-check span" assert-local-storage: {"rustdoc-disable-shortcuts": "true"} @@ -227,7 +290,7 @@ wait-for-css: ("#settings-menu .popover", {"display": "none"}) wait-for-css: ("#help-button .popover", {"display": "block"}) // Now we go to the settings page to check that the CSS is loaded as expected. -goto: "file://" + |DOC_PATH| + "/settings.html" +go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" assert-css: (".setting-line", {"position": "relative"}) @@ -247,7 +310,7 @@ javascript: true // Check for the display on small screen show-text: true reload: -size: (300, 1000) +set-window-size: (300, 1000) click: "#settings-menu" wait-for: "#settings" assert-css: (".setting-line", {"position": "relative"}) diff --git a/tests/rustdoc-gui/shortcuts.goml b/tests/rustdoc-gui/shortcuts.goml index 9068680d6..667df89ec 100644 --- a/tests/rustdoc-gui/shortcuts.goml +++ b/tests/rustdoc-gui/shortcuts.goml @@ -1,5 +1,5 @@ // Check that the various shortcuts are working. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // We first check that the search input isn't already focused. assert-false: "input.search-input:focus" press-key: "s" diff --git a/tests/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index 1d5fdb7a4..cec1a7999 100644 --- a/tests/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -1,5 +1,5 @@ // This test checks links colors in sidebar before and after hover. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // This is needed so that the text color is computed. show-text: true @@ -13,7 +13,7 @@ define-function: ( type_hover_background, keyword, keyword_hover, keyword_hover_background, ), block { - local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } reload: // Struct assert-css: ( diff --git a/tests/rustdoc-gui/sidebar-macro-reexport.goml b/tests/rustdoc-gui/sidebar-macro-reexport.goml index b5c1b6a43..0f7ef6c35 100644 --- a/tests/rustdoc-gui/sidebar-macro-reexport.goml +++ b/tests/rustdoc-gui/sidebar-macro-reexport.goml @@ -1,5 +1,5 @@ // This test ensures that the reexport of a macro doesn't make the original macro // displayed twice in the sidebar. -goto: "file://" + |DOC_PATH| + "/test_docs/macro.repro.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/macro.repro.html" wait-for: ".sidebar-elems .block.macro a" assert-count: ("//*[@class='sidebar-elems']//*[@class='block macro']//a[text()='repro']", 1) diff --git a/tests/rustdoc-gui/sidebar-mobile-scroll.goml b/tests/rustdoc-gui/sidebar-mobile-scroll.goml index 4442b263e..d58d1d487 100644 --- a/tests/rustdoc-gui/sidebar-mobile-scroll.goml +++ b/tests/rustdoc-gui/sidebar-mobile-scroll.goml @@ -1,31 +1,12 @@ -// This test ensures that the mobile sidebar preserves scroll position. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" -// Switching to "mobile view" by reducing the width to 600px. -size: (700, 600) -assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) - -// Scroll down. -scroll-to: "//h2[@id='blanket-implementations']" -assert-window-property: {"pageYOffset": "622"} - -// Open the sidebar menu. -click: ".sidebar-menu-toggle" -wait-for-css: (".sidebar", {"left": "0px"}) - -// We are no longer "scrolled". It's important that the user can't -// scroll the body at all, but these test scripts are run only in Chrome, -// and we need to use a more complicated solution to this problem because -// of Mobile Safari... -assert-window-property: {"pageYOffset": "0"} - -// Close the sidebar menu. Make sure the scroll position gets restored. -click: ".sidebar-menu-toggle" -wait-for-css: (".sidebar", {"left": "-1000px"}) -assert-window-property: {"pageYOffset": "622"} - -// Now test that scrollability returns when the browser window is just resized. -click: ".sidebar-menu-toggle" -wait-for-css: (".sidebar", {"left": "0px"}) -assert-window-property: {"pageYOffset": "0"} -size: (900, 600) -assert-window-property: {"pageYOffset": "622"} +// This test ensures that the mobile disables scrolling the page. +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +set-window-size: (1280, 800) // desktop +assert-css: (".sidebar", {"overscroll-behavior": "contain"}) +set-window-size: (700, 600) // mobile +assert-css: (".sidebar", {"overscroll-behavior": "contain"}) + +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +set-window-size: (1280, 800) // desktop +assert-css: (".sidebar", {"overscroll-behavior": "contain"}) +set-window-size: (700, 600) // mobile +assert-css: (".sidebar", {"overscroll-behavior": "contain"}) diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index cc6267c3d..3b022c7e9 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -1,9 +1,9 @@ // This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport. // This is especially important for devices for "text-first" content (like for users with // sight issues). -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // Switching to "mobile view" by reducing the width to 600px. -size: (600, 600) +set-window-size: (600, 600) assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) // Opening the sidebar menu. click: ".sidebar-menu-toggle" @@ -59,7 +59,7 @@ define-function: ( "check-colors", (theme, color, background), block { - local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} reload: // Open the sidebar menu. diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml index f3eb8ff76..20bf0596f 100644 --- a/tests/rustdoc-gui/sidebar-source-code-display.goml +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -1,6 +1,6 @@ // This test ensures that the elements in the sidebar are displayed correctly. javascript: false -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // Since the javascript is disabled, there shouldn't be a toggle. assert-false: "#src-sidebar-toggle" wait-for-css: (".sidebar", {"display": "none"}) @@ -22,7 +22,7 @@ wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) wait-for-css: (".sidebar", {"width": "300px"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} click: ".sidebar a.selected" -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" wait-for-css: (".sidebar", {"width": "300px"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} @@ -36,7 +36,7 @@ define-function: ( background_toggle_hover, ), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) assert-css: ( @@ -148,7 +148,7 @@ call-function: ("check-colors", { }) // Now checking on mobile devices. -size: (500, 700) +set-window-size: (500, 700) reload: // Waiting for the sidebar to be displayed... wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) @@ -183,31 +183,21 @@ wait-for-css: (".sidebar", {"left": "-1000px"}) // The "scrollTop" property should be the same. assert-window-property: {"pageYOffset": "2542"} -// We now check that the scroll position is restored if the window is resized. -size: (500, 700) -click: "#src-sidebar-toggle" -wait-for-css: ("#source-sidebar", {"visibility": "visible"}) -assert-window-property: {"pageYOffset": "0"} -size: (900, 900) -assert-window-property: {"pageYOffset": "2542"} -size: (500, 700) -click: "#src-sidebar-toggle" -wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) - // We now check that opening the sidebar and clicking a link will close it. // The behavior here on mobile is different than the behavior on desktop, // but common sense dictates that if you have a list of files that fills the entire screen, and // you click one of them, you probably want to actually see the file's contents, and not just // make it the current selection. +set-window-size: (500, 700) click: "#src-sidebar-toggle" wait-for-css: ("#source-sidebar", {"visibility": "visible"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} click: ".sidebar a.selected" -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) assert-local-storage: {"rustdoc-source-sidebar-show": "false"} // Resize back to desktop size, to check that the sidebar doesn't spontaneously open. -size: (1000, 1000) +set-window-size: (1000, 1000) wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) assert-local-storage: {"rustdoc-source-sidebar-show": "false"} click: "#src-sidebar-toggle" diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index c8a29b58d..520b2c59b 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -1,6 +1,6 @@ // The goal of this test is to ensure that the sidebar is working as expected in the source // code pages. -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" show-text: true // First, check the sidebar colors. @@ -8,7 +8,7 @@ define-function: ( "check-colors", (theme, color, background_color), block { - local-storage: { + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } @@ -47,7 +47,7 @@ call-function: ( ) // Next, desktop mode layout. -size: (1100, 800) +set-window-size: (1100, 800) // We check that the sidebar isn't expanded and has the expected width. assert-css: ("nav.sidebar", {"width": "50px"}) // We now click on the button to expand the sidebar. @@ -62,7 +62,7 @@ wait-for: "html:not(.expanded)" assert: "nav.sidebar" // Checking that only the path to the current file is "open". -goto: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html" // First we expand the sidebar again. click: (10, 10) // We wait for the sidebar to be expanded. @@ -73,10 +73,10 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8) +assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9) // We now switch to mobile mode. -size: (600, 600) +set-window-size: (600, 600) wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) // We collapse the sidebar. click: (10, 10) diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index a6d517090..3c1ed009a 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -1,5 +1,5 @@ // Checks multiple things on the sidebar display (width of its elements, colors, etc). -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) show-text: true @@ -8,7 +8,7 @@ define-function: ( "check-colors", (theme, color, background_color), block { - local-storage: { + set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } @@ -46,7 +46,7 @@ call-function: ( } ) -local-storage: {"rustdoc-theme": "light"} +set-local-storage: {"rustdoc-theme": "light"} // We reload the page so the local storage settings are being used. reload: @@ -86,13 +86,13 @@ click: ".sidebar h2.location a" assert-property: ("html", {"scrollTop": "0"}) // We now go back to the crate page to click on the "lib2" crate link. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"}) click: ".sidebar-elems ul.crate > li:first-child > a" // PAGE: lib2/index.html -goto: "file://" + |DOC_PATH| + "/lib2/index.html" +go-to: "file://" + |DOC_PATH| + "/lib2/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Crate lib2") // We check that we have the crates list and that the "current" on is now "lib2". @@ -115,13 +115,13 @@ assert-text: (".sidebar .sidebar-elems h2", "In lib2") // We check that we don't have the crate list. assert-false: ".sidebar-elems > .crate" -goto: "./module/index.html" +go-to: "./module/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Module module") // We check that we don't have the crate list. assert-false: ".sidebar-elems > .crate" -goto: "./sub_module/sub_sub_module/index.html" +go-to: "./sub_module/sub_sub_module/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Module sub_sub_module") // We check that we don't have the crate list. @@ -130,13 +130,13 @@ assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-name > a", "foo") // Links to trait implementations in the sidebar should not wrap even if they are long. -goto: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html" assert-property: (".sidebar", {"clientWidth": "200"}) assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29}) // Test that clicking on of the "In <module>" headings in the sidebar links to the // appropriate anchor in index.html. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-property: (".sidebar", {"clientWidth": "200"}) click: "//ul[@class='block mod']/preceding-sibling::h3/a" // PAGE: index.html @@ -149,3 +149,17 @@ assert-property: (".sidebar", {"clientWidth": "200"}) click: "#toggle-all-docs" assert-text: ("#toggle-all-docs", "[−]") assert-property: (".sidebar", {"clientWidth": "200"}) + +// Checks that all.html and index.html have their sidebar link in the same place. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +store-property: (index_sidebar_width, ".sidebar .location a", "clientWidth") +store-property: (index_sidebar_height, ".sidebar .location a", "clientHeight") +store-property: (index_sidebar_x, ".sidebar .location a", "offsetTop") +store-property: (index_sidebar_y, ".sidebar .location a", "offsetLeft") +go-to: "file://" + |DOC_PATH| + "/test_docs/all.html" +assert-property: (".sidebar .location a", { + "clientWidth": |index_sidebar_width|, + "clientHeight": |index_sidebar_height|, + "offsetTop": |index_sidebar_x|, + "offsetLeft": |index_sidebar_y|, +}) diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index ddfe0c3d1..3d88d5619 100644 --- a/tests/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml @@ -1,9 +1,9 @@ // We check that when the anchor changes and is output of the displayed content, // the page is scrolled to it. -goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" // We reduce the window size to make it easier to make an element "out of the page". -size: (600, 800) +set-window-size: (600, 800) // We check that the scroll is at the top first. assert-property: ("html", {"scrollTop": "0"}) diff --git a/tests/rustdoc-gui/source-code-page-code-scroll.goml b/tests/rustdoc-gui/source-code-page-code-scroll.goml new file mode 100644 index 000000000..35f338ea3 --- /dev/null +++ b/tests/rustdoc-gui/source-code-page-code-scroll.goml @@ -0,0 +1,8 @@ +// Checks that the scrollbar is visible on the page rather than the code block. +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +set-window-size: (800, 1000) +// "scrollWidth" should be superior than "clientWidth". +assert-property: ("body", {"scrollWidth": 1047, "clientWidth": 800}) + +// Both properties should be equal (ie, no scroll on the code block). +assert-property: (".example-wrap .rust", {"scrollWidth": 933, "clientWidth": 933}) diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index 7c35119e6..42f3200e9 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -1,5 +1,5 @@ // Checks that the interactions with the source code pages are working as expected. -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" show-text: true // Check that we can click on the line number. click: ".src-line-numbers > a:nth-child(4)" // This is the anchor for line 4. @@ -12,7 +12,7 @@ reload: assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) assert-css: ("//*[@id='4']", {"border-right-width": "0px"}) // We now check that the good anchors are highlighted -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" assert-attribute-false: (".src-line-numbers > a:nth-child(3)", {"class": "line-highlighted"}) assert-attribute: (".src-line-numbers > a:nth-child(4)", {"class": "line-highlighted"}) assert-attribute: (".src-line-numbers > a:nth-child(5)", {"class": "line-highlighted"}) @@ -23,7 +23,7 @@ define-function: ( "check-colors", (theme, color, background_color, highlight_color, highlight_background_color), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: ( ".src-line-numbers > a:not(.line-highlighted)", @@ -87,7 +87,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"}) // Now let's check that clicking on something else than the line number doesn't // do anything (and certainly not add a `#NaN` to the URL!). -goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // We use this assert-position to know where we will click. assert-position: ("//*[@id='1']", {"x": 88, "y": 112}) // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`. @@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded" // We check that the first entry of the sidebar is collapsed assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) -assert-text: ("#source-sidebar details:first-of-type > summary", "http") +assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css") // We now click on it. click: "#source-sidebar details:first-of-type > summary" assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) @@ -175,7 +175,7 @@ assert-property: ("#main-content", {"offsetTop": 90}) // 28 = 90 - 34 - 28 // Now do the same check on moderately-sized, tablet mobile. -size: (700, 700) +set-window-size: (700, 700) assert-css: ("nav.sub", {"flex-direction": "row"}) assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34}) assert-property: ("#main-content", {"offsetTop": 76}) @@ -198,7 +198,7 @@ call-function: ("check-sidebar-dir-entry", { }) // Tiny, phone mobile gets a different display where the logo is stacked on top. -size: (450, 700) +set-window-size: (450, 700) assert-css: ("nav.sub", {"flex-direction": "column"}) // Check the sidebar directory entries have a marker and spacing (phone). @@ -216,3 +216,8 @@ call-function: ("check-sidebar-dir-entry", { "x": 0, "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, }) + +// Now we check that the logo has a bottom margin so it's not stuck to the search input. +assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"}) +store-property: (logo_height, ".sub-logo-container", "clientHeight") +assert-position: (".search-form", {"y": |logo_height| + 8}) diff --git a/tests/rustdoc-gui/src-font-size.goml b/tests/rustdoc-gui/src-font-size.goml index bab66dae7..790aeba52 100644 --- a/tests/rustdoc-gui/src-font-size.goml +++ b/tests/rustdoc-gui/src-font-size.goml @@ -1,7 +1,7 @@ // This test ensures that the "[src]" have the same font size as their headers // to avoid having some weird height difference in the background when the element // is selected. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" show-text: true // Check the impl headers. assert-css: (".impl .srclink", {"font-size": "16px", "font-weight": 400}, ALL) diff --git a/tests/rustdoc-gui/src/extend_css/Cargo.lock b/tests/rustdoc-gui/src/extend_css/Cargo.lock new file mode 100644 index 000000000..7101a6f0f --- /dev/null +++ b/tests/rustdoc-gui/src/extend_css/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "extend_css" +version = "0.1.0" diff --git a/tests/rustdoc-gui/src/extend_css/Cargo.toml b/tests/rustdoc-gui/src/extend_css/Cargo.toml new file mode 100644 index 000000000..91683fe89 --- /dev/null +++ b/tests/rustdoc-gui/src/extend_css/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "extend_css" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/tests/rustdoc-gui/src/extend_css/extra.css b/tests/rustdoc-gui/src/extend_css/extra.css new file mode 100644 index 000000000..ee7062d96 --- /dev/null +++ b/tests/rustdoc-gui/src/extend_css/extra.css @@ -0,0 +1,3 @@ +.extend { + color: red !important; +} diff --git a/tests/rustdoc-gui/src/extend_css/lib.rs b/tests/rustdoc-gui/src/extend_css/lib.rs new file mode 100644 index 000000000..3a3babf89 --- /dev/null +++ b/tests/rustdoc-gui/src/extend_css/lib.rs @@ -0,0 +1 @@ +//! <div class="extend">text in red</div> diff --git a/tests/rustdoc-gui/stab-badge.goml b/tests/rustdoc-gui/stab-badge.goml index 50ba1ba62..e23404188 100644 --- a/tests/rustdoc-gui/stab-badge.goml +++ b/tests/rustdoc-gui/stab-badge.goml @@ -1,12 +1,12 @@ // All stability badges should have rounded corners and colored backgrounds. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true define-function: ( "check-badge", (theme, background, color), block { - local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} - goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert: ".docblock .stab" assert: ".item-table .stab" assert-css: (".stab", { @@ -14,7 +14,7 @@ define-function: ( "color": |color|, "background-color": |background|, }) - goto: "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html" + go-to: "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html" assert: (".item-info .stab") assert-css: (".stab", { "border-radius": "3px", diff --git a/tests/rustdoc-gui/struct-fields.goml b/tests/rustdoc-gui/struct-fields.goml index fa3e16cb8..da0467de1 100644 --- a/tests/rustdoc-gui/struct-fields.goml +++ b/tests/rustdoc-gui/struct-fields.goml @@ -1,5 +1,5 @@ // This test ensures that each field is on its own line (In other words, they have display: block). -goto: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" store-property: (first_top, "//*[@id='structfield.first']", "offsetTop") assert-property-false: ("//*[@id='structfield.second']", { "offsetTop": |first_top| }) diff --git a/tests/rustdoc-gui/target.goml b/tests/rustdoc-gui/target.goml index ca393ee58..0c514fc68 100644 --- a/tests/rustdoc-gui/target.goml +++ b/tests/rustdoc-gui/target.goml @@ -1,5 +1,5 @@ // Check that the targetted element has the expected styles. -goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method" show-text: true // Confirming that the method is the target. @@ -9,7 +9,7 @@ define-function: ( "check-style", (theme, background, border), block { - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: ("#method\.a_method:target", { "background-color": |background|, diff --git a/tests/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml index 31c9d99aa..ae6947213 100644 --- a/tests/rustdoc-gui/theme-change.goml +++ b/tests/rustdoc-gui/theme-change.goml @@ -1,6 +1,6 @@ // Ensures that the theme change is working as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} reload: store-value: (background_light, "rgb(255, 255, 255)") @@ -22,11 +22,11 @@ click: "#theme-dark" wait-for-css: ("body", { "background-color": |background_dark| }) assert-local-storage: { "rustdoc-theme": "dark" } -local-storage: { +set-local-storage: { "rustdoc-preferred-light-theme": "light", "rustdoc-preferred-dark-theme": "light", } -goto: "file://" + |DOC_PATH| + "/settings.html" +go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" click: "#theme-light" diff --git a/tests/rustdoc-gui/theme-defaults.goml b/tests/rustdoc-gui/theme-defaults.goml new file mode 100644 index 000000000..2cc5d716c --- /dev/null +++ b/tests/rustdoc-gui/theme-defaults.goml @@ -0,0 +1,24 @@ +// Ensure that the theme picker always starts with the actual defaults. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +click: "#settings-menu" +wait-for: "#theme-system-preference" +assert: "#theme-system-preference:checked" +assert: "#preferred-light-theme-light:checked" +assert: "#preferred-dark-theme-dark:checked" +assert-false: "#preferred-dark-theme-ayu:checked" + +// Test legacy migration from old theme setup without system-preference matching. +// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732 +set-local-storage: { + "rustdoc-preferred-light-theme": null, + "rustdoc-preferred-dark-theme": null, + "rustdoc-use-system-theme": null, + "rustdoc-theme": "ayu" +} +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +click: "#settings-menu" +wait-for: "#theme-system-preference" +assert: "#theme-system-preference:checked" +assert: "#preferred-light-theme-light:checked" +assert-false: "#preferred-dark-theme-dark:checked" +assert: "#preferred-dark-theme-ayu:checked" diff --git a/tests/rustdoc-gui/theme-in-history.goml b/tests/rustdoc-gui/theme-in-history.goml index 10508e86a..8fcd0ecd3 100644 --- a/tests/rustdoc-gui/theme-in-history.goml +++ b/tests/rustdoc-gui/theme-in-history.goml @@ -1,7 +1,7 @@ // Ensures that the theme is working when going back in history. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // Set the theme to dark. -local-storage: { +set-local-storage: { "rustdoc-theme": "dark", "rustdoc-use-system-theme": "false", } @@ -11,7 +11,7 @@ assert-css: ("body", { "background-color": "rgb(53, 53, 53)" }) assert-local-storage: { "rustdoc-theme": "dark" } // Now we go to the settings page. -goto: "file://" + |DOC_PATH| + "/settings.html" +go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" // We change the theme to "light". click: "#theme-light" diff --git a/tests/rustdoc-gui/toggle-click-deadspace.goml b/tests/rustdoc-gui/toggle-click-deadspace.goml index ac346f25b..f115f63ab 100644 --- a/tests/rustdoc-gui/toggle-click-deadspace.goml +++ b/tests/rustdoc-gui/toggle-click-deadspace.goml @@ -1,6 +1,6 @@ // This test ensures that clicking on a method summary, but not on the "[-]", // doesn't toggle the <details>. -goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" assert-attribute: (".impl-items .toggle", {"open": ""}) click: "h4.code-header" // This is the position of "pub" in "pub fn a_method" assert-attribute: (".impl-items .toggle", {"open": ""}) diff --git a/tests/rustdoc-gui/toggle-docs-mobile.goml b/tests/rustdoc-gui/toggle-docs-mobile.goml index 6ce24a81b..b69aa6e30 100644 --- a/tests/rustdoc-gui/toggle-docs-mobile.goml +++ b/tests/rustdoc-gui/toggle-docs-mobile.goml @@ -1,7 +1,7 @@ // Checks that the documentation toggles on mobile have the correct position, style and work // as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" -size: (433, 600) +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +set-window-size: (433, 600) assert-attribute: (".top-doc", {"open": ""}) click: (4, 270) // This is the position of the top doc comment toggle assert-attribute-false: (".top-doc", {"open": ""}) @@ -22,7 +22,7 @@ assert-position: ( ) // Now we do the same but with a little bigger width -size: (600, 600) +set-window-size: (600, 600) assert-attribute: (".top-doc", {"open": ""}) click: (4, 270) // New Y position since all search elements are back on one line. assert-attribute-false: (".top-doc", {"open": ""}) diff --git a/tests/rustdoc-gui/toggle-docs.goml b/tests/rustdoc-gui/toggle-docs.goml index c9d236e9b..9ea6d9b18 100644 --- a/tests/rustdoc-gui/toggle-docs.goml +++ b/tests/rustdoc-gui/toggle-docs.goml @@ -1,5 +1,5 @@ // Checks that the documentation toggles have the correct position, style and work as expected. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-attribute: ("#main-content > details.top-doc", {"open": ""}) assert-text: ("#toggle-all-docs", "[−]") click: "#toggle-all-docs" @@ -17,7 +17,7 @@ wait-for-attribute: ("#main-content > details.top-doc", {"open": ""}) assert-text: ("#toggle-all-docs", "[−]") // Check that it works on non-module pages as well. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // We first check that everything is visible. assert-text: ("#toggle-all-docs", "[−]") assert-attribute: ("#implementations-list details.toggle", {"open": ""}, ALL) @@ -52,7 +52,7 @@ define-function: ( (theme, filter), block { // Setting the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: diff --git a/tests/rustdoc-gui/toggle-implementors.goml b/tests/rustdoc-gui/toggle-implementors.goml index 8ff5b91af..c4056275d 100644 --- a/tests/rustdoc-gui/toggle-implementors.goml +++ b/tests/rustdoc-gui/toggle-implementors.goml @@ -1,4 +1,4 @@ // This test ensures that the implementors toggle are not open by default. -goto: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" +go-to: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" assert-attribute-false: ("#implementors-list > details", {"open": ""}, ALL) diff --git a/tests/rustdoc-gui/toggled-open-implementations.goml b/tests/rustdoc-gui/toggled-open-implementations.goml index 000293b55..238205dd4 100644 --- a/tests/rustdoc-gui/toggled-open-implementations.goml +++ b/tests/rustdoc-gui/toggled-open-implementations.goml @@ -1,5 +1,5 @@ // This tests that the "implementations" section on struct/enum pages // has all the implementations toggled open by default, so users can // find method names in those implementations with Ctrl-F. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-attribute: (".toggle.implementors-toggle", {"open": ""}) diff --git a/tests/rustdoc-gui/trait-sidebar-item-order.goml b/tests/rustdoc-gui/trait-sidebar-item-order.goml index e5d023544..9330ef040 100644 --- a/tests/rustdoc-gui/trait-sidebar-item-order.goml +++ b/tests/rustdoc-gui/trait-sidebar-item-order.goml @@ -4,7 +4,7 @@ // doesn't exist. fail-on-request-error: false -goto: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" assert-text: (".sidebar-elems section .block li:nth-of-type(1) > a", "another") assert-text: (".sidebar-elems section .block li:nth-of-type(2) > a", "func1") assert-text: (".sidebar-elems section .block li:nth-of-type(3) > a", "func2") diff --git a/tests/rustdoc-gui/type-declation-overflow.goml b/tests/rustdoc-gui/type-declation-overflow.goml index 708e9dca0..e8e42e400 100644 --- a/tests/rustdoc-gui/type-declation-overflow.goml +++ b/tests/rustdoc-gui/type-declation-overflow.goml @@ -6,20 +6,20 @@ // doesn't exist. fail-on-request-error: false -goto: "file://" + |DOC_PATH| + "/lib2/long_trait/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.html" +go-to: "file://" + |DOC_PATH| + "/lib2/long_trait/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.html" // We set a fixed size so there is no chance of "random" resize. -size: (1100, 800) +set-window-size: (1100, 800) // Logically, the <body> scroll width should be the width of the window. assert-property: ("body", {"scrollWidth": "1100"}) // However, since there is overflow in the type declaration, its scroll width is bigger. assert-property: ("pre.item-decl", {"scrollWidth": "1324"}) // In the table-ish view on the module index, the name should not be wrapped more than necessary. -goto: "file://" + |DOC_PATH| + "/lib2/too_long/index.html" +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/index.html" assert-property: (".item-table .struct", {"offsetWidth": "684"}) // We now make the same check on type declaration... -goto: "file://" + |DOC_PATH| + "/lib2/too_long/type.ReallyLongTypeNameLongLongLong.html" +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/type.ReallyLongTypeNameLongLongLong.html" assert-property: ("body", {"scrollWidth": "1100"}) // We now check that the section width hasn't grown because of it. assert-property: ("#main-content", {"scrollWidth": "840"}) @@ -28,7 +28,7 @@ assert-property: ("pre.item-decl", {"scrollWidth": "1103"}) // ... and constant. // On a sidenote, it also checks that the (very) long title isn't changing the docblock width. -goto: "file://" + |DOC_PATH| + "/lib2/too_long/constant.ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong.html" +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/constant.ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong.html" assert-property: ("body", {"scrollWidth": "1100"}) // We now check that the section width hasn't grown because of it. assert-property: ("#main-content", {"scrollWidth": "840"}) @@ -36,8 +36,8 @@ assert-property: ("#main-content", {"scrollWidth": "840"}) assert-property: ("pre.item-decl", {"scrollWidth": "950"}) // On mobile: -size: (600, 600) -goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" +set-window-size: (600, 600) +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" // It shouldn't have an overflow in the topbar either. store-property: (scrollWidth, ".mobile-topbar h2", "scrollWidth") assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|}) @@ -45,24 +45,24 @@ assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"}) // Check wrapping for top main-heading h1 and out-of-band. // On desktop, they wrap when too big. -size: (1100, 800) -goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" +set-window-size: (1100, 800) +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y")) -goto: "file://" + |DOC_PATH| + "/lib2/index.html" +go-to: "file://" + |DOC_PATH| + "/lib2/index.html" compare-elements-position: (".main-heading h1", ".main-heading .out-of-band", ("y")) // make sure there is a gap between them compare-elements-position-near-false: (".main-heading h1", ".main-heading .out-of-band", {"x": 550}) // On mobile, they always wrap. -size: (600, 600) -goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" +set-window-size: (600, 600) +go-to: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y")) -goto: "file://" + |DOC_PATH| + "/lib2/index.html" +go-to: "file://" + |DOC_PATH| + "/lib2/index.html" compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y")) // Now we will check that the scrolling is working. // First on an item with "hidden methods". -goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html" +go-to: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html" click: ".item-decl .type-contents-toggle" assert-property: ("pre.item-decl", {"scrollLeft": 0}) @@ -70,7 +70,7 @@ scroll-to: "//*[@class='rust item-decl']//details/a[text()='String']" assert-property-false: ("pre.item-decl", {"scrollLeft": 0}) // Then on an item without "hidden methods". -goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.TraitWithLongItemsName.html" +go-to: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.TraitWithLongItemsName.html" assert-property: ("pre.item-decl", {"scrollLeft": 0}) scroll-to: "//*[@class='rust item-decl']//code/a[text()='String']" assert-property-false: ("pre.item-decl", {"scrollLeft": 0}) diff --git a/tests/rustdoc-gui/unsafe-fn.goml b/tests/rustdoc-gui/unsafe-fn.goml index 9d2577178..51007b653 100644 --- a/tests/rustdoc-gui/unsafe-fn.goml +++ b/tests/rustdoc-gui/unsafe-fn.goml @@ -1,5 +1,5 @@ // Check position and color of the `<sup>` for unsafe elements. -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true @@ -16,7 +16,7 @@ define-function: ( (theme, color), block { // Set the theme. - local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: assert-css: (".item-name sup", {"color": |color|}) diff --git a/tests/rustdoc-gui/where-whitespace.goml b/tests/rustdoc-gui/where-whitespace.goml index 41596a9bc..69e6c3356 100644 --- a/tests/rustdoc-gui/where-whitespace.goml +++ b/tests/rustdoc-gui/where-whitespace.goml @@ -1,5 +1,5 @@ // This test ensures that the where conditions are correctly displayed. -goto: "file://" + |DOC_PATH| + "/lib2/trait.Whitespace.html" +go-to: "file://" + |DOC_PATH| + "/lib2/trait.Whitespace.html" show-text: true // First, we check in the trait definition if the where clause is "on its own" (not on the same // line than "pub trait Whitespace<Idx>"). @@ -7,9 +7,9 @@ compare-elements-position-false: (".item-decl code", ".where.fmt-newline", ("y") // And that the code following it isn't on the same line either. compare-elements-position-false: (".item-decl .fn", ".where.fmt-newline", ("y")) -goto: "file://" + |DOC_PATH| + "/lib2/struct.WhereWhitespace.html" +go-to: "file://" + |DOC_PATH| + "/lib2/struct.WhereWhitespace.html" // We make the screen a bit wider to ensure that the trait impl is on one line. -size: (915, 915) +set-window-size: (915, 915) compare-elements-position-false: ("#method\.new .fn", "#method\.new .where.fmt-newline", ("y")) // We ensure that both the trait name and the struct name are on the same line in diff --git a/tests/rustdoc-js-std/option-type-signatures.js b/tests/rustdoc-js-std/option-type-signatures.js new file mode 100644 index 000000000..6bf421a21 --- /dev/null +++ b/tests/rustdoc-js-std/option-type-signatures.js @@ -0,0 +1,18 @@ +const QUERY = [ + 'option, fnonce -> option', + 'option -> default', +]; + +const EXPECTED = [ + { + 'others': [ + { 'path': 'std::option::Option', 'name': 'map' }, + ], + }, + { + 'others': [ + { 'path': 'std::option::Option', 'name': 'unwrap_or_default' }, + { 'path': 'std::option::Option', 'name': 'get_or_insert_default' }, + ], + }, +]; diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js index 98c6f27ca..d1aa840ab 100644 --- a/tests/rustdoc-js-std/parser-errors.js +++ b/tests/rustdoc-js-std/parser-errors.js @@ -17,6 +17,7 @@ const QUERY = [ "a b:", "a (b:", "_:", + "_:a", "a-bb", "a>bb", "ab'", @@ -48,7 +49,6 @@ const PARSED = [ foundElems: 0, original: "<P>", returned: [], - typeFilter: -1, userQuery: "<p>", error: "Found generics without a path", }, @@ -57,7 +57,6 @@ const PARSED = [ foundElems: 0, original: "-> <P>", returned: [], - typeFilter: -1, userQuery: "-> <p>", error: "Found generics without a path", }, @@ -66,7 +65,6 @@ const PARSED = [ foundElems: 0, original: "a<\"P\">", returned: [], - typeFilter: -1, userQuery: "a<\"p\">", error: "Unexpected `\"` in generics", }, @@ -75,7 +73,6 @@ const PARSED = [ foundElems: 0, original: "\"P\" \"P\"", returned: [], - typeFilter: -1, userQuery: "\"p\" \"p\"", error: "Cannot have more than one literal search element", }, @@ -84,7 +81,6 @@ const PARSED = [ foundElems: 0, original: "P \"P\"", returned: [], - typeFilter: -1, userQuery: "p \"p\"", error: "Cannot use literal search when there is more than one element", }, @@ -93,7 +89,6 @@ const PARSED = [ foundElems: 0, original: "\"p\" p", returned: [], - typeFilter: -1, userQuery: "\"p\" p", error: "You cannot have more than one element if you use quotes", }, @@ -102,7 +97,6 @@ const PARSED = [ foundElems: 0, original: "\"const\": p", returned: [], - typeFilter: -1, userQuery: "\"const\": p", error: "You cannot use quotes on type filter", }, @@ -111,16 +105,14 @@ const PARSED = [ foundElems: 0, original: "a<:a>", returned: [], - typeFilter: -1, userQuery: "a<:a>", - error: "Unexpected `:` after `<`", + error: "Expected type filter before `:`", }, { elems: [], foundElems: 0, original: "a<::a>", returned: [], - typeFilter: -1, userQuery: "a<::a>", error: "Unexpected `::`: paths cannot start with `::`", }, @@ -129,7 +121,6 @@ const PARSED = [ foundElems: 0, original: "((a))", returned: [], - typeFilter: -1, userQuery: "((a))", error: "Unexpected `(`", }, @@ -138,7 +129,6 @@ const PARSED = [ foundElems: 0, original: "(p -> p", returned: [], - typeFilter: -1, userQuery: "(p -> p", error: "Unexpected `(`", }, @@ -147,7 +137,6 @@ const PARSED = [ foundElems: 0, original: "::a::b", returned: [], - typeFilter: -1, userQuery: "::a::b", error: "Paths cannot start with `::`", }, @@ -156,7 +145,6 @@ const PARSED = [ foundElems: 0, original: "a::::b", returned: [], - typeFilter: -1, userQuery: "a::::b", error: "Unexpected `::::`", }, @@ -165,7 +153,6 @@ const PARSED = [ foundElems: 0, original: "a::b::", returned: [], - typeFilter: -1, userQuery: "a::b::", error: "Paths cannot end with `::`", }, @@ -174,7 +161,6 @@ const PARSED = [ foundElems: 0, original: ":a", returned: [], - typeFilter: -1, userQuery: ":a", error: "Expected type filter before `:`", }, @@ -183,16 +169,14 @@ const PARSED = [ foundElems: 0, original: "a b:", returned: [], - typeFilter: -1, userQuery: "a b:", - error: "Unexpected `:`", + error: "Unexpected `:` (expected path after type filter)", }, { elems: [], foundElems: 0, original: "a (b:", returned: [], - typeFilter: -1, userQuery: "a (b:", error: "Unexpected `(`", }, @@ -201,8 +185,15 @@ const PARSED = [ foundElems: 0, original: "_:", returned: [], - typeFilter: -1, userQuery: "_:", + error: "Unexpected `:` (expected path after type filter)", + }, + { + elems: [], + foundElems: 0, + original: "_:a", + returned: [], + userQuery: "_:a", error: "Unknown type filter `_`", }, { @@ -210,7 +201,6 @@ const PARSED = [ foundElems: 0, original: "a-bb", returned: [], - typeFilter: -1, userQuery: "a-bb", error: "Unexpected `-` (did you mean `->`?)", }, @@ -219,7 +209,6 @@ const PARSED = [ foundElems: 0, original: "a>bb", returned: [], - typeFilter: -1, userQuery: "a>bb", error: "Unexpected `>` (did you mean `->`?)", }, @@ -228,7 +217,6 @@ const PARSED = [ foundElems: 0, original: "ab'", returned: [], - typeFilter: -1, userQuery: "ab'", error: "Unexpected `'`", }, @@ -237,7 +225,6 @@ const PARSED = [ foundElems: 0, original: "a->", returned: [], - typeFilter: -1, userQuery: "a->", error: "Expected at least one item after `->`", }, @@ -246,7 +233,6 @@ const PARSED = [ foundElems: 0, original: '"p" <a>', returned: [], - typeFilter: -1, userQuery: '"p" <a>', error: "Found generics without a path", }, @@ -255,7 +241,6 @@ const PARSED = [ foundElems: 0, original: '"p" a<a>', returned: [], - typeFilter: -1, userQuery: '"p" a<a>', error: "You cannot have more than one element if you use quotes", }, @@ -264,7 +249,6 @@ const PARSED = [ foundElems: 0, original: 'a,<', returned: [], - typeFilter: -1, userQuery: 'a,<', error: 'Found generics without a path', }, @@ -273,7 +257,6 @@ const PARSED = [ foundElems: 0, original: 'aaaaa<>b', returned: [], - typeFilter: -1, userQuery: 'aaaaa<>b', error: 'Expected `,`, ` `, `:` or `->`, found `b`', }, @@ -282,16 +265,14 @@ const PARSED = [ foundElems: 0, original: 'fn:aaaaa<>b', returned: [], - typeFilter: -1, userQuery: 'fn:aaaaa<>b', - error: 'Expected `,`, ` ` or `->`, found `b`', + error: 'Expected `,`, ` `, `:` or `->`, found `b`', }, { elems: [], foundElems: 0, original: '->a<>b', returned: [], - typeFilter: -1, userQuery: '->a<>b', error: 'Expected `,` or ` `, found `b`', }, @@ -300,7 +281,6 @@ const PARSED = [ foundElems: 0, original: 'a<->', returned: [], - typeFilter: -1, userQuery: 'a<->', error: 'Unexpected `-` after `<`', }, @@ -309,7 +289,6 @@ const PARSED = [ foundElems: 0, original: 'a:: a', returned: [], - typeFilter: -1, userQuery: 'a:: a', error: 'Paths cannot end with `::`', }, @@ -318,7 +297,6 @@ const PARSED = [ foundElems: 0, original: 'a ::a', returned: [], - typeFilter: -1, userQuery: 'a ::a', error: 'Paths cannot start with `::`', }, @@ -327,16 +305,14 @@ const PARSED = [ foundElems: 0, original: "a<a>:", returned: [], - typeFilter: -1, userQuery: "a<a>:", - error: 'Unexpected `:`', + error: 'Unexpected `<` in type filter', }, { elems: [], foundElems: 0, original: "a<>:", returned: [], - typeFilter: -1, userQuery: "a<>:", error: 'Unexpected `<` in type filter', }, @@ -345,7 +321,6 @@ const PARSED = [ foundElems: 0, original: "a,:", returned: [], - typeFilter: -1, userQuery: "a,:", error: 'Unexpected `,` in type filter', }, @@ -354,7 +329,6 @@ const PARSED = [ foundElems: 0, original: "a<> :", returned: [], - typeFilter: -1, userQuery: "a<> :", error: 'Unexpected `<` in type filter', }, @@ -363,7 +337,6 @@ const PARSED = [ foundElems: 0, original: "mod : :", returned: [], - typeFilter: -1, userQuery: "mod : :", error: 'Unexpected `:`', }, @@ -372,7 +345,6 @@ const PARSED = [ foundElems: 0, original: "a!a", returned: [], - typeFilter: -1, userQuery: "a!a", error: 'Unexpected `!`: it can only be at the end of an ident', }, @@ -381,7 +353,6 @@ const PARSED = [ foundElems: 0, original: "a!!", returned: [], - typeFilter: -1, userQuery: "a!!", error: 'Cannot have more than one `!` in an ident', }, @@ -390,7 +361,6 @@ const PARSED = [ foundElems: 0, original: "mod:a!", returned: [], - typeFilter: -1, userQuery: "mod:a!", error: 'Invalid search type: macro `!` and `mod` both specified', }, @@ -399,7 +369,6 @@ const PARSED = [ foundElems: 0, original: "a!::a", returned: [], - typeFilter: -1, userQuery: "a!::a", error: 'Cannot have associated items in macros', }, @@ -408,7 +377,6 @@ const PARSED = [ foundElems: 0, original: "a<", returned: [], - typeFilter: -1, userQuery: "a<", error: "Unclosed `<`", }, diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js index 01f65b478..e23447ab7 100644 --- a/tests/rustdoc-js-std/parser-filter.js +++ b/tests/rustdoc-js-std/parser-filter.js @@ -1,4 +1,14 @@ -const QUERY = ['fn:foo', 'enum : foo', 'macro<f>:foo', 'macro!', 'macro:mac!', 'a::mac!']; +const QUERY = [ + 'fn:foo', + 'enum : foo', + 'macro<f>:foo', + 'macro!', + 'macro:mac!', + 'a::mac!', + '-> fn:foo', + '-> fn:foo<fn:bar>', + '-> fn:foo<fn:bar, enum : baz::fuzz>', +]; const PARSED = [ { @@ -8,11 +18,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "foo", generics: [], + typeFilter: 5, }], foundElems: 1, original: "fn:foo", returned: [], - typeFilter: 5, userQuery: "fn:foo", error: null, }, @@ -23,11 +33,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "foo", generics: [], + typeFilter: 4, }], foundElems: 1, original: "enum : foo", returned: [], - typeFilter: 4, userQuery: "enum : foo", error: null, }, @@ -36,9 +46,8 @@ const PARSED = [ foundElems: 0, original: "macro<f>:foo", returned: [], - typeFilter: -1, userQuery: "macro<f>:foo", - error: "Unexpected `:`", + error: "Unexpected `<` in type filter", }, { elems: [{ @@ -47,11 +56,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "macro", generics: [], + typeFilter: 14, }], foundElems: 1, original: "macro!", returned: [], - typeFilter: 14, userQuery: "macro!", error: null, }, @@ -62,11 +71,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "mac", generics: [], + typeFilter: 14, }], foundElems: 1, original: "macro:mac!", returned: [], - typeFilter: 14, userQuery: "macro:mac!", error: null, }, @@ -77,12 +86,83 @@ const PARSED = [ pathWithoutLast: ["a"], pathLast: "mac", generics: [], + typeFilter: 14, }], foundElems: 1, original: "a::mac!", returned: [], - typeFilter: 14, userQuery: "a::mac!", error: null, }, + { + elems: [], + foundElems: 1, + original: "-> fn:foo", + returned: [{ + name: "foo", + fullPath: ["foo"], + pathWithoutLast: [], + pathLast: "foo", + generics: [], + typeFilter: 5, + }], + userQuery: "-> fn:foo", + error: null, + }, + { + elems: [], + foundElems: 1, + original: "-> fn:foo<fn:bar>", + returned: [{ + name: "foo", + fullPath: ["foo"], + pathWithoutLast: [], + pathLast: "foo", + generics: [ + { + name: "bar", + fullPath: ["bar"], + pathWithoutLast: [], + pathLast: "bar", + generics: [], + typeFilter: 5, + } + ], + typeFilter: 5, + }], + userQuery: "-> fn:foo<fn:bar>", + error: null, + }, + { + elems: [], + foundElems: 1, + original: "-> fn:foo<fn:bar, enum : baz::fuzz>", + returned: [{ + name: "foo", + fullPath: ["foo"], + pathWithoutLast: [], + pathLast: "foo", + generics: [ + { + name: "bar", + fullPath: ["bar"], + pathWithoutLast: [], + pathLast: "bar", + generics: [], + typeFilter: 5, + }, + { + name: "baz::fuzz", + fullPath: ["baz", "fuzz"], + pathWithoutLast: ["baz"], + pathLast: "fuzz", + generics: [], + typeFilter: 4, + }, + ], + typeFilter: 5, + }], + userQuery: "-> fn:foo<fn:bar, enum : baz::fuzz>", + error: null, + }, ]; diff --git a/tests/rustdoc-js-std/parser-generics.js b/tests/rustdoc-js-std/parser-generics.js index 0cf7f5019..5a2266dbe 100644 --- a/tests/rustdoc-js-std/parser-generics.js +++ b/tests/rustdoc-js-std/parser-generics.js @@ -1,4 +1,11 @@ -const QUERY = ['A<B<C<D>, E>', 'p<> u8', '"p"<a>']; +const QUERY = [ + 'A<B<C<D>, E>', + 'p<> u8', + '"p"<a>', + 'p<u<x>>', + 'p<u<x>, r>', + 'p<u<x, r>>', +]; const PARSED = [ { @@ -6,9 +13,8 @@ const PARSED = [ foundElems: 0, original: 'A<B<C<D>, E>', returned: [], - typeFilter: -1, userQuery: 'a<b<c<d>, e>', - error: 'Unexpected `<` after `<`', + error: 'Unclosed `<`', }, { elems: [ @@ -18,6 +24,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "p", generics: [], + typeFilter: -1, }, { name: "u8", @@ -25,12 +32,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "u8", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "p<> u8", returned: [], - typeFilter: -1, userQuery: "p<> u8", error: null, }, @@ -50,13 +57,126 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }, ], foundElems: 1, original: '"p"<a>', returned: [], - typeFilter: -1, userQuery: '"p"<a>', error: null, }, + { + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [ + { + name: "u", + fullPath: ["u"], + pathWithoutLast: [], + pathLast: "u", + generics: [ + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + }, + ], + }, + ], + typeFilter: -1, + }, + ], + foundElems: 1, + original: 'p<u<x>>', + returned: [], + userQuery: 'p<u<x>>', + error: null, + }, + { + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [ + { + name: "u", + fullPath: ["u"], + pathWithoutLast: [], + pathLast: "u", + generics: [ + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + }, + ], + }, + { + name: "r", + fullPath: ["r"], + pathWithoutLast: [], + pathLast: "r", + generics: [], + }, + ], + typeFilter: -1, + }, + ], + foundElems: 1, + original: 'p<u<x>, r>', + returned: [], + userQuery: 'p<u<x>, r>', + error: null, + }, + { + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [ + { + name: "u", + fullPath: ["u"], + pathWithoutLast: [], + pathLast: "u", + generics: [ + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + }, + { + name: "r", + fullPath: ["r"], + pathWithoutLast: [], + pathLast: "r", + generics: [], + }, + ], + }, + ], + typeFilter: -1, + }, + ], + foundElems: 1, + original: 'p<u<x, r>>', + returned: [], + userQuery: 'p<u<x, r>>', + error: null, + }, ]; diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js index 6c17d00f1..be42b7aa4 100644 --- a/tests/rustdoc-js-std/parser-ident.js +++ b/tests/rustdoc-js-std/parser-ident.js @@ -23,11 +23,11 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }], foundElems: 1, original: "R<!>", returned: [], - typeFilter: -1, userQuery: "r<!>", error: null, }, @@ -38,11 +38,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "!", generics: [], + typeFilter: -1, }], foundElems: 1, original: "!", returned: [], - typeFilter: -1, userQuery: "!", error: null, }, @@ -53,11 +53,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: 14, }], foundElems: 1, original: "a!", returned: [], - typeFilter: 14, userQuery: "a!", error: null, }, @@ -66,7 +66,6 @@ const PARSED = [ foundElems: 0, original: "a!::b", returned: [], - typeFilter: -1, userQuery: "a!::b", error: "Cannot have associated items in macros", }, @@ -77,11 +76,11 @@ const PARSED = [ pathWithoutLast: ["!"], pathLast: "b", generics: [], + typeFilter: -1, }], foundElems: 1, original: "!::b", returned: [], - typeFilter: -1, userQuery: "!::b", error: null, }, @@ -90,7 +89,6 @@ const PARSED = [ foundElems: 0, original: "a!::b!", returned: [], - typeFilter: -1, userQuery: "a!::b!", error: "Cannot have associated items in macros", }, diff --git a/tests/rustdoc-js-std/parser-literal.js b/tests/rustdoc-js-std/parser-literal.js index 87b3baff1..3a31d1bdd 100644 --- a/tests/rustdoc-js-std/parser-literal.js +++ b/tests/rustdoc-js-std/parser-literal.js @@ -16,11 +16,11 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }], foundElems: 1, original: "R<P>", returned: [], - typeFilter: -1, userQuery: "r<p>", error: null, } diff --git a/tests/rustdoc-js-std/parser-paths.js b/tests/rustdoc-js-std/parser-paths.js index 9f823f933..f3e421f5f 100644 --- a/tests/rustdoc-js-std/parser-paths.js +++ b/tests/rustdoc-js-std/parser-paths.js @@ -8,11 +8,11 @@ const PARSED = [ pathWithoutLast: ["a"], pathLast: "b", generics: [], + typeFilter: -1, }], foundElems: 1, original: "A::B", returned: [], - typeFilter: -1, userQuery: "a::b", error: null, }, @@ -24,6 +24,7 @@ const PARSED = [ pathWithoutLast: ["a"], pathLast: "b", generics: [], + typeFilter: -1, }, { name: "c", @@ -31,12 +32,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "c", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: 'A::B,C', returned: [], - typeFilter: -1, userQuery: 'a::b,c', error: null, }, @@ -56,6 +57,7 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }, { name: "c", @@ -63,12 +65,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "c", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: 'A::B<f>,C', returned: [], - typeFilter: -1, userQuery: 'a::b<f>,c', error: null, }, @@ -79,11 +81,11 @@ const PARSED = [ pathWithoutLast: ["mod"], pathLast: "a", generics: [], + typeFilter: -1, }], foundElems: 1, original: "mod::a", returned: [], - typeFilter: -1, userQuery: "mod::a", error: null, }, diff --git a/tests/rustdoc-js-std/parser-quote.js b/tests/rustdoc-js-std/parser-quote.js index 1e16c90de..d5d67cac8 100644 --- a/tests/rustdoc-js-std/parser-quote.js +++ b/tests/rustdoc-js-std/parser-quote.js @@ -19,8 +19,8 @@ const PARSED = [ pathWithoutLast: [], pathLast: "p", generics: [], + typeFilter: -1, }], - typeFilter: -1, userQuery: '-> "p"', error: null, }, @@ -31,11 +31,11 @@ const PARSED = [ pathWithoutLast: [], pathLast: "p", generics: [], + typeFilter: -1, }], foundElems: 1, original: '"p",', returned: [], - typeFilter: -1, userQuery: '"p",', error: null, }, @@ -44,7 +44,6 @@ const PARSED = [ foundElems: 0, original: '"p" -> a', returned: [], - typeFilter: -1, userQuery: '"p" -> a', error: "You cannot have more than one element if you use quotes", }, @@ -53,7 +52,6 @@ const PARSED = [ foundElems: 0, original: '"a" -> "p"', returned: [], - typeFilter: -1, userQuery: '"a" -> "p"', error: "Cannot have more than one literal search element", }, @@ -62,7 +60,6 @@ const PARSED = [ foundElems: 0, original: '->"-"', returned: [], - typeFilter: -1, userQuery: '->"-"', error: 'Unexpected `-` in a string element', }, @@ -71,7 +68,6 @@ const PARSED = [ foundElems: 0, original: '"a', returned: [], - typeFilter: -1, userQuery: '"a', error: 'Unclosed `"`', }, @@ -80,7 +76,6 @@ const PARSED = [ foundElems: 0, original: '""', returned: [], - typeFilter: -1, userQuery: '""', error: 'Cannot have empty string element', }, diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js index 6fce17dca..c29813190 100644 --- a/tests/rustdoc-js-std/parser-returned.js +++ b/tests/rustdoc-js-std/parser-returned.js @@ -25,8 +25,8 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }], - typeFilter: -1, userQuery: "-> f<p>", error: null, }, @@ -40,8 +40,8 @@ const PARSED = [ pathWithoutLast: [], pathLast: "p", generics: [], + typeFilter: -1, }], - typeFilter: -1, userQuery: "-> p", error: null, }, @@ -55,8 +55,8 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: -1, }], - typeFilter: -1, userQuery: "->,a", error: null, }, @@ -67,6 +67,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "aaaaa", generics: [], + typeFilter: -1, }], foundElems: 2, original: "aaaaa->a", @@ -76,8 +77,8 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: -1, }], - typeFilter: -1, userQuery: "aaaaa->a", error: null, }, @@ -91,8 +92,8 @@ const PARSED = [ pathWithoutLast: [], pathLast: "!", generics: [], + typeFilter: -1, }], - typeFilter: -1, userQuery: "-> !", error: null, }, diff --git a/tests/rustdoc-js-std/parser-separators.js b/tests/rustdoc-js-std/parser-separators.js index 5b7abdfa8..fc8c5114c 100644 --- a/tests/rustdoc-js-std/parser-separators.js +++ b/tests/rustdoc-js-std/parser-separators.js @@ -19,6 +19,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'aaaaaa', generics: [], + typeFilter: -1, }, { name: 'b', @@ -26,12 +27,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'b', generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "aaaaaa b", returned: [], - typeFilter: -1, userQuery: "aaaaaa b", error: null, }, @@ -43,6 +44,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'a', generics: [], + typeFilter: -1, }, { name: 'b', @@ -50,12 +52,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'b', generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "a b", returned: [], - typeFilter: -1, userQuery: "a b", error: null, }, @@ -67,6 +69,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'a', generics: [], + typeFilter: -1, }, { name: 'b', @@ -74,12 +77,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'b', generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "a,b", returned: [], - typeFilter: -1, userQuery: "a,b", error: null, }, @@ -91,6 +94,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'a', generics: [], + typeFilter: -1, }, { name: 'b', @@ -98,12 +102,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: 'b', generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "a\tb", returned: [], - typeFilter: -1, userQuery: "a\tb", error: null, }, @@ -130,12 +134,12 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }, ], foundElems: 1, original: "a<b c>", returned: [], - typeFilter: -1, userQuery: "a<b c>", error: null, }, @@ -162,12 +166,12 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }, ], foundElems: 1, original: "a<b,c>", returned: [], - typeFilter: -1, userQuery: "a<b,c>", error: null, }, @@ -194,12 +198,12 @@ const PARSED = [ generics: [], }, ], + typeFilter: -1, }, ], foundElems: 1, original: "a<b\tc>", returned: [], - typeFilter: -1, userQuery: "a<b\tc>", error: null, }, diff --git a/tests/rustdoc-js-std/parser-weird-queries.js b/tests/rustdoc-js-std/parser-weird-queries.js index a3d85aeca..dc1049a70 100644 --- a/tests/rustdoc-js-std/parser-weird-queries.js +++ b/tests/rustdoc-js-std/parser-weird-queries.js @@ -20,6 +20,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: -1, }, { name: "b", @@ -27,12 +28,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "b", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "a b", returned: [], - typeFilter: -1, userQuery: "a b", error: null, }, @@ -44,6 +45,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: -1, }, { name: "b", @@ -51,12 +53,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "b", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "a b", returned: [], - typeFilter: -1, userQuery: "a b", error: null, }, @@ -65,7 +67,6 @@ const PARSED = [ foundElems: 0, original: "a,b(c)", returned: [], - typeFilter: -1, userQuery: "a,b(c)", error: "Unexpected `(`", }, @@ -77,6 +78,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "aaa", generics: [], + typeFilter: -1, }, { name: "a", @@ -84,12 +86,12 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], + typeFilter: -1, }, ], foundElems: 2, original: "aaa,a", returned: [], - typeFilter: -1, userQuery: "aaa,a", error: null, }, @@ -98,7 +100,6 @@ const PARSED = [ foundElems: 0, original: ",,,,", returned: [], - typeFilter: -1, userQuery: ",,,,", error: null, }, @@ -107,17 +108,15 @@ const PARSED = [ foundElems: 0, original: 'mod :', returned: [], - typeFilter: 0, userQuery: 'mod :', - error: null, + error: "Unexpected `:` (expected path after type filter)", }, { elems: [], foundElems: 0, original: 'mod\t:', returned: [], - typeFilter: 0, userQuery: 'mod\t:', - error: null, + error: "Unexpected `:` (expected path after type filter)", }, ]; diff --git a/tests/rustdoc-js-std/println-typo.js b/tests/rustdoc-js-std/println-typo.js new file mode 100644 index 000000000..7ca3ab8e5 --- /dev/null +++ b/tests/rustdoc-js-std/println-typo.js @@ -0,0 +1,12 @@ +// exact-check + +const QUERY = 'prinltn'; +const FILTER_CRATE = 'std'; + +const EXPECTED = { + 'others': [ + { 'path': 'std', 'name': 'println' }, + { 'path': 'std', 'name': 'print' }, + { 'path': 'std', 'name': 'eprintln' }, + ], +}; diff --git a/tests/rustdoc-js/generics-impl.js b/tests/rustdoc-js/generics-impl.js index bb6e0041d..5051743bd 100644 --- a/tests/rustdoc-js/generics-impl.js +++ b/tests/rustdoc-js/generics-impl.js @@ -5,6 +5,8 @@ const QUERY = [ 'Aaaaaaa -> bool', 'Aaaaaaa -> usize', 'Read -> u64', + 'trait:Read -> u64', + 'struct:Read -> u64', 'bool -> u64', 'Ddddddd -> u64', '-> Ddddddd' @@ -37,6 +39,17 @@ const EXPECTED = [ ], }, { + // trait:Read -> u64 + 'others': [ + { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' }, + { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, + ], + }, + { + // struct:Read -> u64 + 'others': [], + }, + { // bool -> u64 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'fffffff' }, diff --git a/tests/rustdoc-js/generics-nested.js b/tests/rustdoc-js/generics-nested.js new file mode 100644 index 000000000..8701f2d49 --- /dev/null +++ b/tests/rustdoc-js/generics-nested.js @@ -0,0 +1,33 @@ +// exact-check + +const QUERY = [ + '-> Out<First<Second>>', + '-> Out<Second<First>>', + '-> Out<First, Second>', + '-> Out<Second, First>', +]; + +const EXPECTED = [ + { + // -> Out<First<Second>> + 'others': [ + { 'path': 'generics_nested', 'name': 'alef' }, + ], + }, + { + // -> Out<Second<First>> + 'others': [], + }, + { + // -> Out<First, Second> + 'others': [ + { 'path': 'generics_nested', 'name': 'bet' }, + ], + }, + { + // -> Out<Second, First> + 'others': [ + { 'path': 'generics_nested', 'name': 'bet' }, + ], + }, +]; diff --git a/tests/rustdoc-js/generics-nested.rs b/tests/rustdoc-js/generics-nested.rs new file mode 100644 index 000000000..5140422e3 --- /dev/null +++ b/tests/rustdoc-js/generics-nested.rs @@ -0,0 +1,19 @@ +pub struct Out<A, B = ()> { + a: A, + b: B, +} + +pub struct First<In = ()> { + in_: In, +} + +pub struct Second; + +// Out<First<Second>> +pub fn alef() -> Out<First<Second>> { + loop {} +} + +pub fn bet() -> Out<First, Second> { + loop {} +} diff --git a/tests/rustdoc-js/generics.js b/tests/rustdoc-js/generics.js index 5e5ba7cd9..f79c709ad 100644 --- a/tests/rustdoc-js/generics.js +++ b/tests/rustdoc-js/generics.js @@ -2,6 +2,8 @@ const QUERY = [ 'R<P>', + 'R<struct:P>', + 'R<enum:P>', '"P"', 'P', 'ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>', @@ -21,6 +23,20 @@ const EXPECTED = [ ], }, { + // R<struct:P> + 'returned': [ + { 'path': 'generics', 'name': 'alef' }, + ], + 'in_args': [ + { 'path': 'generics', 'name': 'alpha' }, + ], + }, + { + // R<enum:P> + 'returned': [], + 'in_args': [], + }, + { // "P" 'others': [ { 'path': 'generics', 'name': 'P' }, diff --git a/tests/rustdoc-js/primitive.js b/tests/rustdoc-js/primitive.js index 918f70999..4aec98c34 100644 --- a/tests/rustdoc-js/primitive.js +++ b/tests/rustdoc-js/primitive.js @@ -3,6 +3,8 @@ const QUERY = [ "i32", "str", + "primitive:str", + "struct:str", "TotoIsSomewhere", ]; @@ -18,6 +20,14 @@ const EXPECTED = [ ], }, { + 'returned': [ + { 'path': 'primitive', 'name': 'foo' }, + ], + }, + { + 'returned': [], + }, + { 'others': [], 'in_args': [], 'returned': [], diff --git a/tests/rustdoc-js/search-bag-semantics.js b/tests/rustdoc-js/search-bag-semantics.js new file mode 100644 index 000000000..c56a3df5f --- /dev/null +++ b/tests/rustdoc-js/search-bag-semantics.js @@ -0,0 +1,20 @@ +// exact-check + +const QUERY = [ + 'P', + 'P, P', +]; + +const EXPECTED = [ + { + 'in_args': [ + { 'path': 'search_bag_semantics', 'name': 'alacazam' }, + { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, + ], + }, + { + 'others': [ + { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, + ], + }, +]; diff --git a/tests/rustdoc-js/search-bag-semantics.rs b/tests/rustdoc-js/search-bag-semantics.rs new file mode 100644 index 000000000..546572dc4 --- /dev/null +++ b/tests/rustdoc-js/search-bag-semantics.rs @@ -0,0 +1,4 @@ +pub struct P; + +pub fn abracadabra(a: P, b: P) {} +pub fn alacazam(a: P) {} diff --git a/tests/rustdoc-js/where-clause.js b/tests/rustdoc-js/where-clause.js new file mode 100644 index 000000000..86254a80e --- /dev/null +++ b/tests/rustdoc-js/where-clause.js @@ -0,0 +1,30 @@ +const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam', 'drizzel -> shazam']; + +const EXPECTED = [ + { + 'in_args': [ + { 'path': 'where_clause', 'name': 'abracadabra' }, + ], + }, + { + 'others': [ + { 'path': 'where_clause', 'name': 'alacazam' }, + ], + }, + { + 'others': [ + { 'path': 'where_clause', 'name': 'presto' }, + ], + }, + { + 'others': [ + { 'path': 'where_clause', 'name': 'bippety' }, + { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, + ], + }, + { + 'others': [ + { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, + ], + }, +]; diff --git a/tests/rustdoc-js/where-clause.rs b/tests/rustdoc-js/where-clause.rs new file mode 100644 index 000000000..56c01019f --- /dev/null +++ b/tests/rustdoc-js/where-clause.rs @@ -0,0 +1,30 @@ +pub struct Nested; + +pub trait Trait<T> { + fn thank_you(x: T); +} + +pub fn abracadabra<X>(_: X) where X: Trait<Nested> {} + +pub fn alacazam<X>() -> X where X: Trait<Nested> {} + +pub trait T1 {} +pub trait T2<'a, T> { + fn please(_: &'a T); +} + +pub fn presto<A, B>(_: A, _: B) where A: T1, B: for <'b> T2<'b, Nested> {} + +pub trait Shazam {} + +pub fn bippety<X>() -> &'static X where X: Shazam { + panic!() +} + +pub struct Drizzel<T>(T); + +impl<T> Drizzel<T> { + pub fn boppety(&self) -> &T where T: Shazam { + panic!(); + } +} diff --git a/tests/rustdoc-json/fns/extern_c_variadic.rs b/tests/rustdoc-json/fns/extern_c_variadic.rs new file mode 100644 index 000000000..33bebbab5 --- /dev/null +++ b/tests/rustdoc-json/fns/extern_c_variadic.rs @@ -0,0 +1,9 @@ +#![feature(no_core)] +#![no_core] + +extern "C" { + // @is "$.index[*][?(@.name == 'not_variadic')].inner.decl.c_variadic" false + pub fn not_variadic(_: i32); + // @is "$.index[*][?(@.name == 'variadic')].inner.decl.c_variadic" true + pub fn variadic(_: i32, ...); +} diff --git a/tests/rustdoc-json/impls/local_for_local_primitive.rs b/tests/rustdoc-json/impls/local_for_local_primitive.rs index 38e7e2658..8383dcc04 100644 --- a/tests/rustdoc-json/impls/local_for_local_primitive.rs +++ b/tests/rustdoc-json/impls/local_for_local_primitive.rs @@ -1,5 +1,5 @@ #![feature(no_core)] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![no_core] // @set Local = "$.index[*][?(@.name=='Local')].id" @@ -16,6 +16,6 @@ impl Local for bool {} // FIXME(#101695): Test bool's `impls` include "Local for bool" // @has "$.index[*][?(@.name=='bool')]" -#[doc(primitive = "bool")] +#[rustc_doc_primitive = "bool"] /// Boolean docs mod prim_bool {} diff --git a/tests/rustdoc-json/non_lifetime_binders.rs b/tests/rustdoc-json/non_lifetime_binders.rs new file mode 100644 index 000000000..ca5a00834 --- /dev/null +++ b/tests/rustdoc-json/non_lifetime_binders.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength + +#![feature(non_lifetime_binders)] +#![allow(incomplete_features)] + +#![no_core] +#![feature(lang_items, no_core)] + +#[lang = "sized"] +pub trait Sized {} + +pub trait Trait {} + +#[lang = "phantom_data"] +struct PhantomData<T_>; + +pub struct Wrapper<T_>(PhantomData<T_>); + +// @count "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[*]" 2 +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].name" \"T\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].kind" '{ "type": { "bounds": [], "default": null, "synthetic": false } }' +pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/rustdoc-json/primitives/local_primitive.rs b/tests/rustdoc-json/primitives/local_primitive.rs index f27e6a2ad..0cf479faf 100644 --- a/tests/rustdoc-json/primitives/local_primitive.rs +++ b/tests/rustdoc-json/primitives/local_primitive.rs @@ -8,7 +8,7 @@ //! Link to [i32][prim@i32] [i64][prim@i64] -#[doc(primitive = "i32")] +#[rustc_doc_primitive = "i32"] mod prim_i32 {} // @set local_i32 = "$.index[*][?(@.name=='i32')].id" diff --git a/tests/rustdoc-json/primitives/primitive_impls.rs b/tests/rustdoc-json/primitives/primitive_impls.rs index 1fc937406..85d179ee4 100644 --- a/tests/rustdoc-json/primitives/primitive_impls.rs +++ b/tests/rustdoc-json/primitives/primitive_impls.rs @@ -25,7 +25,7 @@ pub trait Trait {} impl Trait for i32 {} /// i32 -#[doc(primitive = "i32")] +#[rustc_doc_primitive = "i32"] mod prim_i32 {} // @set i32 = "$.index[*][?(@.docs=='i32')].id" diff --git a/tests/rustdoc-json/primitives/primitive_overloading.rs b/tests/rustdoc-json/primitives/primitive_overloading.rs index 56b35cd14..81e0acdc6 100644 --- a/tests/rustdoc-json/primitives/primitive_overloading.rs +++ b/tests/rustdoc-json/primitives/primitive_overloading.rs @@ -2,7 +2,7 @@ // Regression test for <https://github.com/rust-lang/rust/issues/98006>. -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![feature(no_core)] #![no_core] @@ -10,7 +10,7 @@ // @has "$.index[*][?(@.name=='usize')]" // @has "$.index[*][?(@.name=='prim')]" -#[doc(primitive = "usize")] +#[rustc_doc_primitive = "usize"] /// This is the built-in type `usize`. mod prim { } diff --git a/tests/rustdoc-json/primitives/use_primitive.rs b/tests/rustdoc-json/primitives/use_primitive.rs index e22927374..5180a804f 100644 --- a/tests/rustdoc-json/primitives/use_primitive.rs +++ b/tests/rustdoc-json/primitives/use_primitive.rs @@ -1,8 +1,8 @@ // edition:2018 -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] -#[doc(primitive = "usize")] +#[rustc_doc_primitive = "usize"] mod usize {} // @set local_crate_id = "$.index[*][?(@.name=='use_primitive')].crate_id" diff --git a/tests/rustdoc-ui/c-help.rs b/tests/rustdoc-ui/c-help.rs deleted file mode 100644 index e166edf8b..000000000 --- a/tests/rustdoc-ui/c-help.rs +++ /dev/null @@ -1,6 +0,0 @@ -// check-pass -// compile-flags: -Chelp -// check-stdout -// regex-error-pattern: -C\s+incremental - -pub struct Foo; diff --git a/tests/rustdoc-ui/c-help.stdout b/tests/rustdoc-ui/c-help.stdout deleted file mode 100644 index 75b2e2a2a..000000000 --- a/tests/rustdoc-ui/c-help.stdout +++ /dev/null @@ -1,51 +0,0 @@ - -C ar=val -- this option is deprecated and does nothing - -C code-model=val -- choose the code model to use (`rustc --print code-models` for details) - -C codegen-units=val -- divide crate into N units to optimize in parallel - -C control-flow-guard=val -- use Windows Control Flow Guard (default: no) - -C debug-assertions=val -- explicitly enable the `cfg(debug_assertions)` directive - -C debuginfo=val -- debug info emission level (0 = no debug info, 1 = line tables only, 2 = full debug info with variable and type information; default: 0) - -C default-linker-libraries=val -- allow the linker to link its default libraries (default: no) - -C embed-bitcode=val -- emit bitcode in rlibs (default: yes) - -C extra-filename=val -- extra data to put in each output filename - -C force-frame-pointers=val -- force use of the frame pointers - -C force-unwind-tables=val -- force use of unwind tables - -C incremental=val -- enable incremental compilation - -C inline-threshold=val -- set the threshold for inlining a function - -C instrument-coverage=val -- instrument the generated code to support LLVM source-based code coverage reports (note, the compiler build config must include `profiler = true`); implies `-C symbol-mangling-version=v0`. Optional values are: - `=all` (implicit value) - `=except-unused-generics` - `=except-unused-functions` - `=off` (default) - -C link-arg=val -- a single extra argument to append to the linker invocation (can be used several times) - -C link-args=val -- extra arguments to append to the linker invocation (space separated) - -C link-dead-code=val -- keep dead code at link time (useful for code coverage) (default: no) - -C link-self-contained=val -- control whether to link Rust provided C objects/libraries or rely - on C toolchain installed in the system - -C linker=val -- system linker to link outputs with - -C linker-flavor=val -- linker flavor - -C linker-plugin-lto=val -- generate build artifacts that are compatible with linker-based LTO - -C llvm-args=val -- a list of arguments to pass to LLVM (space separated) - -C lto=val -- perform LLVM link-time optimizations - -C metadata=val -- metadata to mangle symbol names with - -C no-prepopulate-passes=val -- give an empty list of passes to the pass manager - -C no-redzone=val -- disable the use of the redzone - -C no-stack-check=val -- this option is deprecated and does nothing - -C no-vectorize-loops=val -- disable loop vectorization optimization passes - -C no-vectorize-slp=val -- disable LLVM's SLP vectorization pass - -C opt-level=val -- optimization level (0-3, s, or z; default: 0) - -C overflow-checks=val -- use overflow checks for integer arithmetic - -C panic=val -- panic strategy to compile crate with - -C passes=val -- a list of extra LLVM passes to run (space separated) - -C prefer-dynamic=val -- prefer dynamic linking to static linking (default: no) - -C profile-generate=val -- compile the program with profiling instrumentation - -C profile-use=val -- use the given `.profdata` file for profile-guided optimization - -C relocation-model=val -- control generation of position-independent code (PIC) (`rustc --print relocation-models` for details) - -C remark=val -- print remarks for these optimization passes (space separated, or "all") - -C rpath=val -- set rpath values in libs/exes (default: no) - -C save-temps=val -- save all temporary output files during compilation (default: no) - -C soft-float=val -- use soft float ABI (*eabihf targets only) (default: no) - -C split-debuginfo=val -- how to handle split-debuginfo, a platform-specific option - -C strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`) - -C symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0') - -C target-cpu=val -- select target processor (`rustc --print target-cpus` for details) - -C target-feature=val -- target specific attributes. (`rustc --print target-features` for details). This feature is unsafe. diff --git a/tests/rustdoc-ui/const_arg_in_type_position.rs b/tests/rustdoc-ui/const_arg_in_type_position.rs new file mode 100644 index 000000000..4969e8d19 --- /dev/null +++ b/tests/rustdoc-ui/const_arg_in_type_position.rs @@ -0,0 +1,6 @@ +type Array<T, const N: usize> = [T; N]; + +fn foo<const N: usize>() -> Array<N, ()> { + //~^ ERROR constant provided when a type was expected + unimplemented!() +} diff --git a/tests/rustdoc-ui/const_arg_in_type_position.stderr b/tests/rustdoc-ui/const_arg_in_type_position.stderr new file mode 100644 index 000000000..ea05920de --- /dev/null +++ b/tests/rustdoc-ui/const_arg_in_type_position.stderr @@ -0,0 +1,9 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/const_arg_in_type_position.rs:3:35 + | +LL | fn foo<const N: usize>() -> Array<N, ()> { + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/rustdoc-ui/coverage/exotic.rs b/tests/rustdoc-ui/coverage/exotic.rs index 72b70d698..f45405fbf 100644 --- a/tests/rustdoc-ui/coverage/exotic.rs +++ b/tests/rustdoc-ui/coverage/exotic.rs @@ -2,12 +2,13 @@ // check-pass #![feature(rustdoc_internals)] +#![feature(rustc_attrs)] //! the features only used in std also have entries in the table, so make sure those get pulled out //! properly as well /// woo, check it out, we can write our own primitive docs lol -#[doc(primitive="unit")] +#[rustc_doc_primitive = "unit"] mod prim_unit {} /// keywords? sure, pile them on diff --git a/tests/rustdoc-ui/crate-reference-in-block-module.rs b/tests/rustdoc-ui/crate-reference-in-block-module.rs new file mode 100644 index 000000000..aede030e0 --- /dev/null +++ b/tests/rustdoc-ui/crate-reference-in-block-module.rs @@ -0,0 +1,5 @@ +// check-pass +fn main() { + /// [](crate) + struct X; +} diff --git a/tests/rustdoc-ui/crate-reference-in-block-module.stderr b/tests/rustdoc-ui/crate-reference-in-block-module.stderr new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/rustdoc-ui/crate-reference-in-block-module.stderr diff --git a/tests/rustdoc-ui/intra-doc/ambiguity.rs b/tests/rustdoc-ui/intra-doc/ambiguity.rs index 1f3dc722e..0290b8582 100644 --- a/tests/rustdoc-ui/intra-doc/ambiguity.rs +++ b/tests/rustdoc-ui/intra-doc/ambiguity.rs @@ -35,6 +35,6 @@ pub mod foo { /// Ambiguous non-implied shortcut link [`foo::bar`]. //~ERROR `foo::bar` pub struct Docs {} -/// [true] //~ ERROR `true` is both a module and a builtin type +/// [true] //~ ERROR `true` is both a module and a primitive type /// [primitive@true] pub mod r#true {} diff --git a/tests/rustdoc-ui/intra-doc/ambiguity.stderr b/tests/rustdoc-ui/intra-doc/ambiguity.stderr index 7974796e4..47853e0b5 100644 --- a/tests/rustdoc-ui/intra-doc/ambiguity.stderr +++ b/tests/rustdoc-ui/intra-doc/ambiguity.stderr @@ -1,4 +1,4 @@ -error: `true` is both a module and a builtin type +error: `true` is both a module and a primitive type --> $DIR/ambiguity.rs:38:6 | LL | /// [true] @@ -13,89 +13,89 @@ help: to link to the module, prefix with `mod@` | LL | /// [mod@true] | ++++ -help: to link to the builtin type, prefix with `prim@` +help: to link to the primitive type, prefix with `prim@` | LL | /// [prim@true] | +++++ -error: `ambiguous` is both a struct and a function +error: `ambiguous` is both a function and a struct --> $DIR/ambiguity.rs:27:7 | LL | /// [`ambiguous`] is ambiguous. | ^^^^^^^^^ ambiguous link | -help: to link to the struct, prefix with `struct@` - | -LL | /// [`struct@ambiguous`] is ambiguous. - | +++++++ help: to link to the function, add parentheses | LL | /// [`ambiguous()`] is ambiguous. | ++ +help: to link to the struct, prefix with `struct@` + | +LL | /// [`struct@ambiguous`] is ambiguous. + | +++++++ -error: `ambiguous` is both a struct and a function +error: `ambiguous` is both a function and a struct --> $DIR/ambiguity.rs:29:6 | LL | /// [ambiguous] is ambiguous. | ^^^^^^^^^ ambiguous link | -help: to link to the struct, prefix with `struct@` - | -LL | /// [struct@ambiguous] is ambiguous. - | +++++++ help: to link to the function, add parentheses | LL | /// [ambiguous()] is ambiguous. | ++ +help: to link to the struct, prefix with `struct@` + | +LL | /// [struct@ambiguous] is ambiguous. + | +++++++ -error: `multi_conflict` is a struct, a function, and a macro +error: `multi_conflict` is a function, a struct, and a macro --> $DIR/ambiguity.rs:31:7 | LL | /// [`multi_conflict`] is a three-way conflict. | ^^^^^^^^^^^^^^ ambiguous link | -help: to link to the struct, prefix with `struct@` - | -LL | /// [`struct@multi_conflict`] is a three-way conflict. - | +++++++ help: to link to the function, add parentheses | LL | /// [`multi_conflict()`] is a three-way conflict. | ++ +help: to link to the struct, prefix with `struct@` + | +LL | /// [`struct@multi_conflict`] is a three-way conflict. + | +++++++ help: to link to the macro, add an exclamation mark | LL | /// [`multi_conflict!`] is a three-way conflict. | + -error: `type_and_value` is both a module and a constant +error: `type_and_value` is both a constant and a module --> $DIR/ambiguity.rs:33:16 | LL | /// Ambiguous [type_and_value]. | ^^^^^^^^^^^^^^ ambiguous link | -help: to link to the module, prefix with `mod@` - | -LL | /// Ambiguous [mod@type_and_value]. - | ++++ help: to link to the constant, prefix with `const@` | LL | /// Ambiguous [const@type_and_value]. | ++++++ +help: to link to the module, prefix with `mod@` + | +LL | /// Ambiguous [mod@type_and_value]. + | ++++ -error: `foo::bar` is both an enum and a function +error: `foo::bar` is both a function and an enum --> $DIR/ambiguity.rs:35:43 | LL | /// Ambiguous non-implied shortcut link [`foo::bar`]. | ^^^^^^^^ ambiguous link | -help: to link to the enum, prefix with `enum@` - | -LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`]. - | +++++ help: to link to the function, add parentheses | LL | /// Ambiguous non-implied shortcut link [`foo::bar()`]. | ++ +help: to link to the enum, prefix with `enum@` + | +LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`]. + | +++++ error: aborting due to 6 previous errors diff --git a/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-doc.rs b/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-doc.rs new file mode 100644 index 000000000..15bf51e6f --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-doc.rs @@ -0,0 +1 @@ +//! Inner doc comment diff --git a/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs b/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs new file mode 100644 index 000000000..6c48f5aa0 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs @@ -0,0 +1,3 @@ +pub enum O { + L = -1, +} diff --git a/tests/rustdoc-ui/intra-doc/errors.rs b/tests/rustdoc-ui/intra-doc/errors.rs index 95dd2b98e..f37f49c24 100644 --- a/tests/rustdoc-ui/intra-doc/errors.rs +++ b/tests/rustdoc-ui/intra-doc/errors.rs @@ -54,11 +54,11 @@ /// [u8::not_found] //~^ ERROR unresolved link -//~| NOTE the builtin type `u8` has no associated item named `not_found` +//~| NOTE the primitive type `u8` has no associated item named `not_found` /// [std::primitive::u8::not_found] //~^ ERROR unresolved link -//~| NOTE the builtin type `u8` has no associated item named `not_found` +//~| NOTE the primitive type `u8` has no associated item named `not_found` /// [type@Vec::into_iter] //~^ ERROR unresolved link diff --git a/tests/rustdoc-ui/intra-doc/errors.stderr b/tests/rustdoc-ui/intra-doc/errors.stderr index 1b2416d7d..a982bba00 100644 --- a/tests/rustdoc-ui/intra-doc/errors.stderr +++ b/tests/rustdoc-ui/intra-doc/errors.stderr @@ -80,13 +80,13 @@ error: unresolved link to `u8::not_found` --> $DIR/errors.rs:55:6 | LL | /// [u8::not_found] - | ^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` + | ^^^^^^^^^^^^^ the primitive type `u8` has no associated item named `not_found` error: unresolved link to `std::primitive::u8::not_found` --> $DIR/errors.rs:59:6 | LL | /// [std::primitive::u8::not_found] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the primitive type `u8` has no associated item named `not_found` error: unresolved link to `Vec::into_iter` --> $DIR/errors.rs:63:6 diff --git a/tests/rustdoc-ui/intra-doc/import-inline-merge-module.rs b/tests/rustdoc-ui/intra-doc/import-inline-merge-module.rs new file mode 100644 index 000000000..4d6a32566 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/import-inline-merge-module.rs @@ -0,0 +1,10 @@ +// Test for issue #108501. +// Module parent scope doesn't hijack import's parent scope for the import's doc links. + +// check-pass +// aux-build: inner-crate-doc.rs +// compile-flags: --extern inner_crate_doc --edition 2018 + +/// Import doc comment [inner_crate_doc] +#[doc(inline)] +pub use inner_crate_doc; diff --git a/tests/rustdoc-ui/intra-doc/inline-external-enum.rs b/tests/rustdoc-ui/intra-doc/inline-external-enum.rs new file mode 100644 index 000000000..363dd7f64 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/inline-external-enum.rs @@ -0,0 +1,8 @@ +// check-pass +// aux-build: inner-crate-enum.rs +// compile-flags:-Z unstable-options --output-format json + +#[doc(inline)] +pub extern crate inner_crate_enum; + +fn main() {} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs new file mode 100644 index 000000000..464c5f0d5 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs @@ -0,0 +1,22 @@ +// This test ensures that this warning doesn't show up: +// warning: `PartialEq` is both a trait and a derive macro +// --> tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs:1:7 +// | +// 1 | //! [`PartialEq`] +// | ^^^^^^^^^ ambiguous link +// | +// = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default +// help: to link to the trait, prefix with `trait@` +// | +// 1 | //! [`trait@PartialEq`] +// | ++++++ +// help: to link to the derive macro, prefix with `derive@` +// | +// 1 | //! [`derive@PartialEq`] +// | +++++++ + +// check-pass + +#![deny(rustdoc::broken_intra_doc_links)] + +//! [`PartialEq`] diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs new file mode 100644 index 000000000..cbe60f746 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs @@ -0,0 +1,17 @@ +// This is ensuring that the UI output for associated items is as expected. + +#![deny(rustdoc::broken_intra_doc_links)] + +/// [`Trait::IDENT`] +//~^ ERROR both an associated constant and an associated type +pub trait Trait { + type IDENT; + const IDENT: usize; +} + +/// [`Trait2::IDENT`] +//~^ ERROR both an associated function and an associated type +pub trait Trait2 { + type IDENT; + fn IDENT() {} +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr new file mode 100644 index 000000000..952392548 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr @@ -0,0 +1,37 @@ +error: `Trait::IDENT` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items-2.rs:5:7 + | +LL | /// [`Trait::IDENT`] + | ^^^^^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-2.rs:3:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@Trait::IDENT`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Trait::IDENT`] + | +++++ + +error: `Trait2::IDENT` is both an associated function and an associated type + --> $DIR/issue-108653-associated-items-2.rs:12:7 + | +LL | /// [`Trait2::IDENT`] + | ^^^^^^^^^^^^^ ambiguous link + | +help: to link to the associated function, add parentheses + | +LL | /// [`Trait2::IDENT()`] + | ++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Trait2::IDENT`] + | +++++ + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs new file mode 100644 index 000000000..7ffd0a40e --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs @@ -0,0 +1,16 @@ +// This is ensuring that the UI output for associated items works when it's being documented +// from another item. + +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +pub trait Trait { + type Trait; + const Trait: usize; +} + +/// [`Trait`] +//~^ ERROR both a constant and a trait +/// [`Trait::Trait`] +//~^ ERROR both an associated constant and an associated type +pub const Trait: usize = 0; diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr new file mode 100644 index 000000000..6401dacb5 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr @@ -0,0 +1,37 @@ +error: `Trait` is both a constant and a trait + --> $DIR/issue-108653-associated-items-3.rs:12:7 + | +LL | /// [`Trait`] + | ^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-3.rs:4:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the constant, prefix with `const@` + | +LL | /// [`const@Trait`] + | ++++++ +help: to link to the trait, prefix with `trait@` + | +LL | /// [`trait@Trait`] + | ++++++ + +error: `Trait::Trait` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items-3.rs:14:7 + | +LL | /// [`Trait::Trait`] + | ^^^^^^^^^^^^ ambiguous link + | +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@Trait::Trait`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Trait::Trait`] + | +++++ + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs new file mode 100644 index 000000000..537d61364 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs @@ -0,0 +1,21 @@ +// This is ensuring that the UI output for associated items works when it's being documented +// from another item. + +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +pub trait Trait { + type Trait; +} + +/// [`Struct::Trait`] +//~^ ERROR both an associated constant and an associated type +pub struct Struct; + +impl Trait for Struct { + type Trait = Struct; +} + +impl Struct { + pub const Trait: usize = 0; +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr new file mode 100644 index 000000000..a8dc91204 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr @@ -0,0 +1,22 @@ +error: `Struct::Trait` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items-4.rs:11:7 + | +LL | /// [`Struct::Trait`] + | ^^^^^^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-4.rs:4:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@Struct::Trait`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Struct::Trait`] + | +++++ + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs new file mode 100644 index 000000000..bc28bc544 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs @@ -0,0 +1,8 @@ +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +/// [`u32::MAX`] +//~^ ERROR both an associated constant and a trait +pub mod u32 { + pub trait MAX {} +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr new file mode 100644 index 000000000..7430044ac --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr @@ -0,0 +1,22 @@ +error: `u32::MAX` is both an associated constant and a trait + --> $DIR/issue-108653-associated-items-5.rs:4:7 + | +LL | /// [`u32::MAX`] + | ^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-5.rs:1:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@u32::MAX`] + | ++++++ +help: to link to the trait, prefix with `trait@` + | +LL | /// [`trait@u32::MAX`] + | ++++++ + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs new file mode 100644 index 000000000..8fde74d0d --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs @@ -0,0 +1,8 @@ +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +/// [`u32::MAX`] +//~^ ERROR both an associated constant and a primitive type +pub mod u32 { + pub use std::primitive::u32 as MAX; +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr new file mode 100644 index 000000000..fe2d8cafa --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr @@ -0,0 +1,22 @@ +error: `u32::MAX` is both an associated constant and a primitive type + --> $DIR/issue-108653-associated-items-6.rs:4:7 + | +LL | /// [`u32::MAX`] + | ^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-6.rs:1:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@u32::MAX`] + | ++++++ +help: to link to the primitive type, prefix with `prim@` + | +LL | /// [`prim@u32::MAX`] + | +++++ + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs new file mode 100644 index 000000000..6e99f4365 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs @@ -0,0 +1,12 @@ +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +pub trait Trait { + type MAX; +} + +/// [`u32::MAX`] +//~^ ERROR both an associated constant and an associated type +impl Trait for u32 { + type MAX = u32; +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr new file mode 100644 index 000000000..1d302ff42 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr @@ -0,0 +1,22 @@ +error: `u32::MAX` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items-7.rs:8:7 + | +LL | /// [`u32::MAX`] + | ^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-7.rs:1:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@u32::MAX`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@u32::MAX`] + | +++++ + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs new file mode 100644 index 000000000..2f8ee1566 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs @@ -0,0 +1,12 @@ +#![deny(rustdoc::broken_intra_doc_links)] +#![allow(nonstandard_style)] + +/// [`u32::MAX`] +//~^ ERROR both an associated constant and an associated type +pub trait T { + type MAX; +} + +impl T for u32 { + type MAX = (); +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr new file mode 100644 index 000000000..efed0e2ce --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr @@ -0,0 +1,22 @@ +error: `u32::MAX` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items-8.rs:4:7 + | +LL | /// [`u32::MAX`] + | ^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items-8.rs:1:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@u32::MAX`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@u32::MAX`] + | +++++ + +error: aborting due to previous error + diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs new file mode 100644 index 000000000..3357ccf24 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs @@ -0,0 +1,11 @@ +// check-pass + +#![deny(warnings)] + +//! [usize::Item] + +pub trait Foo { type Item; } +pub trait Bar { type Item; } + +impl Foo for usize { type Item = u32; } +impl Bar for usize { type Item = i32; } diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs new file mode 100644 index 000000000..0a393e26d --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs @@ -0,0 +1,35 @@ +// This is ensuring that the UI output for associated items is as expected. + +#![deny(rustdoc::broken_intra_doc_links)] + +pub enum Enum { + IDENT, +} + +/// [`Self::IDENT`] +//~^ ERROR both an associated function and an associated type +pub trait Trait { + type IDENT; + fn IDENT(); +} + +/// [`Self::IDENT`] +//~^ ERROR both an associated function and a variant +impl Trait for Enum { + type IDENT = usize; + fn IDENT() {} +} + +/// [`Self::IDENT2`] +//~^ ERROR both an associated constant and an associated type +pub trait Trait2 { + type IDENT2; + const IDENT2: usize; +} + +/// [`Self::IDENT2`] +//~^ ERROR both an associated constant and an associated type +impl Trait2 for Enum { + type IDENT2 = usize; + const IDENT2: usize = 0; +} diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr new file mode 100644 index 000000000..ed89fa839 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr @@ -0,0 +1,67 @@ +error: `Self::IDENT` is both an associated function and an associated type + --> $DIR/issue-108653-associated-items.rs:9:7 + | +LL | /// [`Self::IDENT`] + | ^^^^^^^^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/issue-108653-associated-items.rs:3:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the associated function, add parentheses + | +LL | /// [`Self::IDENT()`] + | ++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Self::IDENT`] + | +++++ + +error: `Self::IDENT2` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items.rs:23:7 + | +LL | /// [`Self::IDENT2`] + | ^^^^^^^^^^^^ ambiguous link + | +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@Self::IDENT2`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Self::IDENT2`] + | +++++ + +error: `Self::IDENT` is both an associated function and a variant + --> $DIR/issue-108653-associated-items.rs:16:7 + | +LL | /// [`Self::IDENT`] + | ^^^^^^^^^^^ ambiguous link + | +help: to link to the associated function, add parentheses + | +LL | /// [`Self::IDENT()`] + | ++ +help: to link to the variant, prefix with `type@` + | +LL | /// [`type@Self::IDENT`] + | +++++ + +error: `Self::IDENT2` is both an associated constant and an associated type + --> $DIR/issue-108653-associated-items.rs:30:7 + | +LL | /// [`Self::IDENT2`] + | ^^^^^^^^^^^^ ambiguous link + | +help: to link to the associated constant, prefix with `const@` + | +LL | /// [`const@Self::IDENT2`] + | ++++++ +help: to link to the associated type, prefix with `type@` + | +LL | /// [`type@Self::IDENT2`] + | +++++ + +error: aborting due to 4 previous errors + diff --git a/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr b/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr index 8ec894d10..6e08a9239 100644 --- a/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr +++ b/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr @@ -39,25 +39,25 @@ error: unresolved link to `unit::eq` --> $DIR/non-path-primitives.rs:28:6 | LL | //! [unit::eq] - | ^^^^^^^^ the builtin type `unit` has no associated item named `eq` + | ^^^^^^^^ the primitive type `unit` has no associated item named `eq` error: unresolved link to `tuple::eq` --> $DIR/non-path-primitives.rs:29:6 | LL | //! [tuple::eq] - | ^^^^^^^^^ the builtin type `tuple` has no associated item named `eq` + | ^^^^^^^^^ the primitive type `tuple` has no associated item named `eq` error: unresolved link to `fn::eq` --> $DIR/non-path-primitives.rs:30:6 | LL | //! [fn::eq] - | ^^^^^^ the builtin type `fn` has no associated item named `eq` + | ^^^^^^ the primitive type `fn` has no associated item named `eq` error: unresolved link to `reference::deref` --> $DIR/non-path-primitives.rs:34:6 | LL | //! [reference::deref] - | ^^^^^^^^^^^^^^^^ the builtin type `reference` has no associated item named `deref` + | ^^^^^^^^^^^^^^^^ the primitive type `reference` has no associated item named `deref` error: aborting due to 8 previous errors diff --git a/tests/rustdoc-ui/intra-doc/prim-conflict.rs b/tests/rustdoc-ui/intra-doc/prim-conflict.rs index 2c1a8b535..e87ce095c 100644 --- a/tests/rustdoc-ui/intra-doc/prim-conflict.rs +++ b/tests/rustdoc-ui/intra-doc/prim-conflict.rs @@ -2,16 +2,16 @@ //~^ NOTE lint level is defined /// [char] -//~^ ERROR both a module and a builtin type +//~^ ERROR both a module and a primitive type //~| NOTE ambiguous link //~| HELP to link to the module -//~| HELP to link to the builtin type +//~| HELP to link to the primitive type /// [type@char] -//~^ ERROR both a module and a builtin type +//~^ ERROR both a module and a primitive type //~| NOTE ambiguous link //~| HELP to link to the module -//~| HELP to link to the builtin type +//~| HELP to link to the primitive type /// [mod@char] // ok /// [prim@char] // ok @@ -26,5 +26,5 @@ pub mod inner { //! [struct@char] //~^ ERROR incompatible link //~| HELP prefix with `prim@` - //~| NOTE resolved to a builtin type + //~| NOTE resolved to a primitive type } diff --git a/tests/rustdoc-ui/intra-doc/prim-conflict.stderr b/tests/rustdoc-ui/intra-doc/prim-conflict.stderr index 6ef3b7eab..03ce8f15f 100644 --- a/tests/rustdoc-ui/intra-doc/prim-conflict.stderr +++ b/tests/rustdoc-ui/intra-doc/prim-conflict.stderr @@ -1,4 +1,4 @@ -error: `char` is both a module and a builtin type +error: `char` is both a module and a primitive type --> $DIR/prim-conflict.rs:4:6 | LL | /// [char] @@ -13,12 +13,12 @@ help: to link to the module, prefix with `mod@` | LL | /// [mod@char] | ++++ -help: to link to the builtin type, prefix with `prim@` +help: to link to the primitive type, prefix with `prim@` | LL | /// [prim@char] | +++++ -error: `char` is both a module and a builtin type +error: `char` is both a module and a primitive type --> $DIR/prim-conflict.rs:10:6 | LL | /// [type@char] @@ -28,7 +28,7 @@ help: to link to the module, prefix with `mod@` | LL | /// [mod@char] | ~~~~ -help: to link to the builtin type, prefix with `prim@` +help: to link to the primitive type, prefix with `prim@` | LL | /// [prim@char] | ~~~~~ @@ -48,9 +48,9 @@ error: incompatible link kind for `char` --> $DIR/prim-conflict.rs:26:10 | LL | //! [struct@char] - | ^^^^^^^^^^^ this link resolved to a builtin type, which is not a struct + | ^^^^^^^^^^^ this link resolved to a primitive type, which is not a struct | -help: to link to the builtin type, prefix with `prim@` +help: to link to the primitive type, prefix with `prim@` | LL | //! [prim@char] | ~~~~~ diff --git a/tests/rustdoc-ui/intra-doc/reachable-non-exported.rs b/tests/rustdoc-ui/intra-doc/reachable-non-exported.rs new file mode 100644 index 000000000..6afcad4f9 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/reachable-non-exported.rs @@ -0,0 +1,13 @@ +// The structure is reachable, but not exported, so rustdoc +// doesn't attempt to request doc link resolutions on it. + +// check-pass + +mod private { + /// [core::str::FromStr] + pub struct ReachableButNotExported; +} + +pub fn foo() -> private::ReachableButNotExported { + private::ReachableButNotExported +} diff --git a/tests/rustdoc-ui/invalid_associated_const.rs b/tests/rustdoc-ui/invalid_associated_const.rs new file mode 100644 index 000000000..6ab8c36f7 --- /dev/null +++ b/tests/rustdoc-ui/invalid_associated_const.rs @@ -0,0 +1,10 @@ +#![feature(associated_const_equality)] + +trait T { + type A: S<C<X = 0i32> = 34>; + //~^ ERROR associated type bindings are not allowed here +} + +trait S { + const C: i32; +} diff --git a/tests/rustdoc-ui/invalid_associated_const.stderr b/tests/rustdoc-ui/invalid_associated_const.stderr new file mode 100644 index 000000000..1a8863fb1 --- /dev/null +++ b/tests/rustdoc-ui/invalid_associated_const.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/invalid_associated_const.rs:4:17 + | +LL | type A: S<C<X = 0i32> = 34>; + | ^^^^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs new file mode 100644 index 000000000..c3f4fd63b --- /dev/null +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs @@ -0,0 +1,6 @@ +trait X { + type Y<'a>; +} +fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} +//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments +//~| ERROR associated type takes 0 generic arguments but 1 generic argument diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr new file mode 100644 index 000000000..527729a82 --- /dev/null +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr @@ -0,0 +1,33 @@ +error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ -- +help: add missing lifetime argument + | +LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {} + | +++ + +error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^--- help: remove these generics + | | + | expected 0 generic arguments + | +note: associated type defined here, with 0 generic parameters + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/rustdoc-ui/invalid_infered_static_and_const.rs b/tests/rustdoc-ui/invalid_infered_static_and_const.rs new file mode 100644 index 000000000..3f8e68dc0 --- /dev/null +++ b/tests/rustdoc-ui/invalid_infered_static_and_const.rs @@ -0,0 +1,2 @@ +const FOO: dyn Fn() -> _ = ""; //~ ERROR E0121 +static BOO: dyn Fn() -> _ = ""; //~ ERROR E0121 diff --git a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr new file mode 100644 index 000000000..401020224 --- /dev/null +++ b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr @@ -0,0 +1,15 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items + --> $DIR/invalid_infered_static_and_const.rs:1:24 + | +LL | const FOO: dyn Fn() -> _ = ""; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items + --> $DIR/invalid_infered_static_and_const.rs:2:25 + | +LL | static BOO: dyn Fn() -> _ = ""; + | ^ not allowed in type signatures + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/rustdoc-ui/issue-105742.rs b/tests/rustdoc-ui/issue-105742.rs index 9f36e5315..8f4172c0c 100644 --- a/tests/rustdoc-ui/issue-105742.rs +++ b/tests/rustdoc-ui/issue-105742.rs @@ -1,19 +1,50 @@ // compile-flags: -Znormalize-docs - use std::ops::Index; pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { + //~^ expected 1 lifetime argument + //~| expected 1 generic argument + //~| the trait `SVec` cannot be made into an object + //~| `SVec` cannot be made into an object + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` let _ = s; } pub trait SVec: Index< <Self as SVec>::Item, + //~^ expected 1 lifetime argument + //~| expected 1 generic argument + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Index<<Self as SVec>::Item, + //~^ expected 1 lifetime argument + //~| expected 1 generic argument + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Self as SVec>::Item> as SVec>::Item, + //~^ expected 1 lifetime argument + //~| expected 1 generic argument + //~| expected 1 lifetime argument + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| expected 1 generic argument + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` > { type Item<'a, T>; fn len(&self) -> <Self as SVec>::Item; - //~^ ERROR - //~^^ ERROR + //~^ expected 1 lifetime argument + //~| missing generics for associated type `SVec::Item` + //~| expected 1 generic argument + //~| missing generics for associated type `SVec::Item` } diff --git a/tests/rustdoc-ui/issue-105742.stderr b/tests/rustdoc-ui/issue-105742.stderr index 4d2ee9726..cd53762ef 100644 --- a/tests/rustdoc-ui/issue-105742.stderr +++ b/tests/rustdoc-ui/issue-105742.stderr @@ -1,11 +1,329 @@ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:16:38 + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | <Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | <Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:22:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Index<<Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:22:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Index<<Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:4:40 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) { + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:4:40 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) { + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | <Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | <Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:22:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Index<<Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:22:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Index<<Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:29:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:43:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, + | +++ + +error[E0038]: the trait `SVec` cannot be made into an object + --> $DIR/issue-105742.rs:4:31 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/issue-105742.rs:14:17 + | +LL | pub trait SVec: Index< + | ____________----__^ + | | | + | | this trait cannot be made into an object... +LL | | <Self as SVec>::Item, +LL | | +LL | | +... | +LL | |/ Output = <Index<<Self as SVec>::Item, +LL | || +LL | || +LL | || +... || +LL | || +LL | || Output = <Self as SVec>::Item> as SVec>::Item, + | ||_________________________________________________^ ...because it uses `Self` as a type parameter +... | +LL | | +LL | | > { + | |__^ ...because it uses `Self` as a type parameter + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:45:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:14:10 + --> $DIR/issue-105742.rs:43:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -15,13 +333,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>; | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:16:38 + --> $DIR/issue-105742.rs:45:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:14:10 + --> $DIR/issue-105742.rs:43:10 | LL | type Item<'a, T>; | ^^^^ - @@ -30,6 +348,7 @@ help: add missing generic argument LL | fn len(&self) -> <Self as SVec>::Item<T>; | +++ -error: aborting due to 2 previous errors +error: aborting due to 21 previous errors -For more information about this error, try `rustc --explain E0107`. +Some errors have detailed explanations: E0038, E0107. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/rustdoc-ui/issue-106226.stderr b/tests/rustdoc-ui/issue-106226.stderr index 2beffbc12..1c973dab6 100644 --- a/tests/rustdoc-ui/issue-106226.stderr +++ b/tests/rustdoc-ui/issue-106226.stderr @@ -1,9 +1,9 @@ -error[E0308]: mismatched types - --> $DIR/issue-106226.rs:2:14 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases + --> $DIR/issue-106226.rs:2:11 | LL | type F = [_; ()]; - | ^^ expected `usize`, found `()` + | ^ not allowed in type signatures error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/rustdoc-ui/issue-109282-import-inline-merge.rs b/tests/rustdoc-ui/issue-109282-import-inline-merge.rs new file mode 100644 index 000000000..0ec852322 --- /dev/null +++ b/tests/rustdoc-ui/issue-109282-import-inline-merge.rs @@ -0,0 +1,14 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/109282>. +// Import for `ValueEnum` is inlined and doc comments on the import and `ValueEnum` itself are +// merged. After the merge they still have correct parent scopes to resolve both `[ValueEnum]`. + +// check-pass + +mod m { + pub enum ValueEnum {} +} +mod m2 { + /// [`ValueEnum`] + pub use crate::m::ValueEnum; +} +pub use m2::ValueEnum; diff --git a/tests/rustdoc-ui/issue-79465.rs b/tests/rustdoc-ui/issue-79465.rs index f1a77982f..e50f3995b 100644 --- a/tests/rustdoc-ui/issue-79465.rs +++ b/tests/rustdoc-ui/issue-79465.rs @@ -1,3 +1,2 @@ pub fn f1<T>(x: T::A) {} //~^ ERROR -//~^^ ERROR diff --git a/tests/rustdoc-ui/issue-79465.stderr b/tests/rustdoc-ui/issue-79465.stderr index 489cc1442..d187a2e66 100644 --- a/tests/rustdoc-ui/issue-79465.stderr +++ b/tests/rustdoc-ui/issue-79465.stderr @@ -4,12 +4,6 @@ error[E0220]: associated type `A` not found for `T` LL | pub fn f1<T>(x: T::A) {} | ^ associated type `A` not found -error[E0220]: associated type `A` not found for `T` - --> $DIR/issue-79465.rs:1:20 - | -LL | pub fn f1<T>(x: T::A) {} - | ^ associated type `A` not found - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0220`. diff --git a/tests/rustdoc-ui/issue-96287.rs b/tests/rustdoc-ui/issue-96287.rs index 8d8b4456e..08cc7ef4c 100644 --- a/tests/rustdoc-ui/issue-96287.rs +++ b/tests/rustdoc-ui/issue-96287.rs @@ -6,7 +6,6 @@ pub trait TraitWithAssoc { pub type Foo<V> = impl Trait<V::Assoc>; //~^ ERROR -//~^^ ERROR pub trait Trait<U> {} diff --git a/tests/rustdoc-ui/issue-96287.stderr b/tests/rustdoc-ui/issue-96287.stderr index 0236b9fe6..7722eb960 100644 --- a/tests/rustdoc-ui/issue-96287.stderr +++ b/tests/rustdoc-ui/issue-96287.stderr @@ -4,12 +4,6 @@ error[E0220]: associated type `Assoc` not found for `V` LL | pub type Foo<V> = impl Trait<V::Assoc>; | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` -error[E0220]: associated type `Assoc` not found for `V` - --> $DIR/issue-96287.rs:7:33 - | -LL | pub type Foo<V> = impl Trait<V::Assoc>; - | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0220`. diff --git a/tests/rustdoc-ui/mismatched_arg_count.rs b/tests/rustdoc-ui/mismatched_arg_count.rs new file mode 100644 index 000000000..784144298 --- /dev/null +++ b/tests/rustdoc-ui/mismatched_arg_count.rs @@ -0,0 +1,8 @@ +trait Trait<'a> { + type Assoc; +} + +type Alias<'a, T> = <T as Trait<'a>>::Assoc; + +fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {} +//~^ error: type alias takes 1 lifetime argument but 2 lifetime arguments were supplied diff --git a/tests/rustdoc-ui/mismatched_arg_count.stderr b/tests/rustdoc-ui/mismatched_arg_count.stderr new file mode 100644 index 000000000..7e88ce954 --- /dev/null +++ b/tests/rustdoc-ui/mismatched_arg_count.stderr @@ -0,0 +1,17 @@ +error[E0107]: type alias takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/mismatched_arg_count.rs:7:29 + | +LL | fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {} + | ^^^^^ -- help: remove this lifetime argument + | | + | expected 1 lifetime argument + | +note: type alias defined here, with 1 lifetime parameter: `'a` + --> $DIR/mismatched_arg_count.rs:5:6 + | +LL | type Alias<'a, T> = <T as Trait<'a>>::Assoc; + | ^^^^^ -- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/rustdoc-ui/run-directory.rs b/tests/rustdoc-ui/run-directory.rs index bbceaaf82..b8d0647f0 100644 --- a/tests/rustdoc-ui/run-directory.rs +++ b/tests/rustdoc-ui/run-directory.rs @@ -2,8 +2,8 @@ // revisions: correct incorrect // check-pass -// [correct]compile-flags:--test --test-run-directory={{src-base}} -Zunstable-options -// [incorrect]compile-flags:--test --test-run-directory={{src-base}}/coverage -Zunstable-options +// [correct]compile-flags:--test --test-run-directory={{src-base}} +// [incorrect]compile-flags:--test --test-run-directory={{src-base}}/coverage // normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" diff --git a/tests/rustdoc-ui/z-help.rs b/tests/rustdoc-ui/z-help.rs deleted file mode 100644 index c7cf841b9..000000000 --- a/tests/rustdoc-ui/z-help.rs +++ /dev/null @@ -1,6 +0,0 @@ -// check-pass -// compile-flags: -Zhelp -// check-stdout -// regex-error-pattern: -Z\s+self-profile - -pub struct Foo; diff --git a/tests/rustdoc-ui/z-help.stdout b/tests/rustdoc-ui/z-help.stdout deleted file mode 100644 index 79e6b94f1..000000000 --- a/tests/rustdoc-ui/z-help.stdout +++ /dev/null @@ -1,218 +0,0 @@ - -Z allow-features=val -- only allow the listed language features to be enabled in code (comma separated) - -Z always-encode-mir=val -- encode MIR of all functions into the crate metadata (default: no) - -Z asm-comments=val -- generate comments into the assembly (may change behavior) (default: no) - -Z assert-incr-state=val -- assert that the incremental cache is in given state: either `loaded` or `not-loaded`. - -Z assume-incomplete-release=val -- make cfg(version) treat the current version as incomplete (default: no) - -Z binary-dep-depinfo=val -- include artifacts (sysroot, crate dependencies) used during compilation in dep-info (default: no) - -Z box-noalias=val -- emit noalias metadata for box (default: yes) - -Z branch-protection=val -- set options for branch target identification and pointer authentication on AArch64 - -Z cf-protection=val -- instrument control-flow architecture protection - -Z cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use - -Z codegen-backend=val -- the backend to use - -Z combine-cgu=val -- combine CGUs into a single one - -Z crate-attr=val -- inject the given attribute in the crate - -Z debug-info-for-profiling=val -- emit discriminators and other data necessary for AutoFDO - -Z debug-macros=val -- emit line numbers debug info inside macros (default: no) - -Z deduplicate-diagnostics=val -- deduplicate identical diagnostics (default: yes) - -Z dep-info-omit-d-target=val -- in dep-info output, omit targets for tracking dependencies of the dep-info files themselves (default: no) - -Z dep-tasks=val -- print tasks that execute and the color their dep node gets (requires debug build) (default: no) - -Z diagnostic-width=val -- set the current output width for diagnostic truncation - -Z dlltool=val -- import library generation tool (windows-gnu only) - -Z dont-buffer-diagnostics=val -- emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) (default: no) - -Z drop-tracking=val -- enables drop tracking in generators (default: no) - -Z drop-tracking-mir=val -- enables drop tracking on MIR in generators (default: no) - -Z dual-proc-macros=val -- load proc macros for both target and host, but only link to the target (default: no) - -Z dump-dep-graph=val -- dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) (default: no) - -Z dump-drop-tracking-cfg=val -- dump drop-tracking control-flow graph as a `.dot` file (default: no) - -Z dump-mir=val -- dump MIR state to file. - `val` is used to select which passes and functions to dump. For example: - `all` matches all passes and functions, - `foo` matches all passes for functions whose name contains 'foo', - `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo', - `foo | bar` all passes for function names containing 'foo' or 'bar'. - -Z dump-mir-dataflow=val -- in addition to `.mir` files, create graphviz `.dot` files with dataflow results (default: no) - -Z dump-mir-dir=val -- the directory the MIR is dumped into (default: `mir_dump`) - -Z dump-mir-exclude-pass-number=val -- exclude the pass number when dumping MIR (used in tests) (default: no) - -Z dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no) - -Z dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans. - -Z dump-mono-stats=val -- output statistics about monomorphization collection - -Z dump-mono-stats-format=val -- the format to use for -Z dump-mono-stats (`markdown` (default) or `json`) - -Z dwarf-version=val -- version of DWARF debug information to emit (default: 2 or 4, depending on platform) - -Z dylib-lto=val -- enables LTO for dylib crate type - -Z emit-stack-sizes=val -- emit a section containing stack size metadata (default: no) - -Z emit-thin-lto=val -- emit the bc module with thin LTO info (default: yes) - -Z export-executable-symbols=val -- export symbols from executables, as if they were dynamic libraries - -Z extra-const-ub-checks=val -- turns on more checks to detect const UB, which can be slow (default: no) - -Z fewer-names=val -- reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) (default: no) - -Z force-unstable-if-unmarked=val -- force all crates to be `rustc_private` unstable (default: no) - -Z fuel=val -- set the optimization fuel quota for a crate - -Z function-sections=val -- whether each function should go in its own section - -Z future-incompat-test=val -- forces all lints to be future incompatible, used for internal testing (default: no) - -Z gcc-ld=val -- implementation of ld used by cc - -Z graphviz-dark-mode=val -- use dark-themed colors in graphviz output (default: no) - -Z graphviz-font=val -- use the given `fontname` in graphviz output; can be overridden by setting environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`) - -Z hir-stats=val -- print some statistics about AST and HIR (default: no) - -Z human-readable-cgu-names=val -- generate human-readable, predictable names for codegen units (default: no) - -Z identify-regions=val -- display unnamed regions as `'<id>`, using a non-ident unique id (default: no) - -Z incremental-ignore-spans=val -- ignore spans during ICH computation -- used for testing (default: no) - -Z incremental-info=val -- print high-level information about incremental reuse (or the lack thereof) (default: no) - -Z incremental-relative-spans=val -- hash spans relative to their parent item for incr. comp. (default: no) - -Z incremental-verify-ich=val -- verify incr. comp. hashes of green query instances (default: no) - -Z inline-in-all-cgus=val -- control whether `#[inline]` functions are in all CGUs - -Z inline-llvm=val -- enable LLVM inlining (default: yes) - -Z inline-mir=val -- enable MIR inlining (default: no) - -Z inline-mir-hint-threshold=val -- inlining threshold for functions with inline hint (default: 100) - -Z inline-mir-threshold=val -- a default MIR inlining threshold (default: 50) - -Z input-stats=val -- gather statistics about the input (default: no) - -Z instrument-coverage=val -- instrument the generated code to support LLVM source-based code coverage reports (note, the compiler build config must include `profiler = true`); implies `-C symbol-mangling-version=v0`. Optional values are: - `=all` (implicit value) - `=except-unused-generics` - `=except-unused-functions` - `=off` (default) - -Z instrument-mcount=val -- insert function instrument code for mcount-based tracing (default: no) - -Z instrument-xray=val -- insert function instrument code for XRay-based tracing (default: no) - Optional extra settings: - `=always` - `=never` - `=ignore-loops` - `=instruction-threshold=N` - `=skip-entry` - `=skip-exit` - Multiple options can be combined with commas. - -Z keep-hygiene-data=val -- keep hygiene data after analysis (default: no) - -Z layout-seed=val -- seed layout randomization - -Z link-directives=val -- honor #[link] directives in the compiled crate (default: yes) - -Z link-native-libraries=val -- link native libraries in the linker invocation (default: yes) - -Z link-only=val -- link the `.rlink` file generated by `-Z no-link` (default: no) - -Z llvm-plugins=val -- a list LLVM plugins to enable (space separated) - -Z llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no) - -Z location-detail=val -- what location details should be tracked when using caller_location, either `none`, or a comma separated list of location details, for which valid options are `file`, `line`, and `column` (default: `file,line,column`) - -Z lower-impl-trait-in-trait-to-assoc-ty=val -- modify the lowering strategy for `impl Trait` in traits so that they are lowered to generic associated types - -Z ls=val -- list the symbols defined by a library crate (default: no) - -Z macro-backtrace=val -- show macro backtraces (default: no) - -Z maximal-hir-to-mir-coverage=val -- save as much information as possible about the correspondence between MIR and HIR as source scopes (default: no) - -Z merge-functions=val -- control the operation of the MergeFunctions LLVM pass, taking the same values as the target option of the same name - -Z meta-stats=val -- gather metadata statistics (default: no) - -Z mir-emit-retag=val -- emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 (default: no) - -Z mir-enable-passes=val -- use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be enabled, overriding all other checks. Passes that are not specified are enabled or disabled by other flags as usual. - -Z mir-opt-level=val -- MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds) - -Z mir-pretty-relative-line-numbers=val -- use line numbers relative to the function in mir pretty printing - -Z move-size-limit=val -- the size at which the `large_assignments` lint starts to be emitted - -Z mutable-noalias=val -- emit noalias metadata for mutable references (default: yes) - -Z nll-facts=val -- dump facts from NLL analysis into side files (default: no) - -Z nll-facts-dir=val -- the directory the NLL facts are dumped into (default: `nll-facts`) - -Z no-analysis=val -- parse and expand the source, but run no analysis - -Z no-codegen=val -- run all passes except codegen; no output - -Z no-generate-arange-section=val -- omit DWARF address ranges that give faster lookups - -Z no-jump-tables=val -- disable the jump tables and lookup tables that can be generated from a switch case lowering - -Z no-leak-check=val -- disable the 'leak check' for subtyping; unsound, but useful for tests - -Z no-link=val -- compile without linking - -Z no-parallel-llvm=val -- run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO) - -Z no-profiler-runtime=val -- prevent automatic injection of the profiler_builtins crate - -Z no-unique-section-names=val -- do not use unique names for text and data sections when -Z function-sections is used - -Z normalize-docs=val -- normalize associated items in rustdoc when generating documentation - -Z oom=val -- panic strategy for out-of-memory handling - -Z osx-rpath-install-name=val -- pass `-install_name @rpath/...` to the macOS linker (default: no) - -Z packed-bundled-libs=val -- change rlib format to store native libraries as archives - -Z panic-abort-tests=val -- support compiling tests with panic=abort (default: no) - -Z panic-in-drop=val -- panic strategy for panics in drops - -Z parse-only=val -- parse only; do not compile, assemble, or link (default: no) - -Z perf-stats=val -- print some performance-related statistics (default: no) - -Z plt=val -- whether to use the PLT when calling into shared libraries; - only has effect for PIC code on systems with ELF binaries - (default: PLT is disabled if full relro is enabled) - -Z polonius=val -- enable polonius-based borrow-checker (default: no) - -Z polymorphize=val -- perform polymorphization analysis - -Z pre-link-arg=val -- a single extra argument to prepend the linker invocation (can be used several times) - -Z pre-link-args=val -- extra arguments to prepend to the linker invocation (space separated) - -Z precise-enum-drop-elaboration=val -- use a more precise version of drop elaboration for matches on enums (default: yes). This results in better codegen, but has caused miscompilations on some tier 2 platforms. See #77382 and #74551. - -Z print-fuel=val -- make rustc print the total optimization fuel used by a crate - -Z print-llvm-passes=val -- print the LLVM optimization passes being run (default: no) - -Z print-mono-items=val -- print the result of the monomorphization collection pass - -Z print-type-sizes=val -- print layout information for each type encountered (default: no) - -Z proc-macro-backtrace=val -- show backtraces for panics during proc-macro execution (default: no) - -Z proc-macro-execution-strategy=val -- how to run proc-macro code (default: same-thread) - -Z profile=val -- insert profiling code (default: no) - -Z profile-closures=val -- profile size of closures - -Z profile-emit=val -- file path to emit profiling data at runtime when using 'profile' (default based on relative source path) - -Z profile-sample-use=val -- use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO) - -Z profiler-runtime=val -- name of the profiler runtime crate to automatically inject (default: `profiler_builtins`) - -Z query-dep-graph=val -- enable queries of the dependency graph for regression testing (default: no) - -Z randomize-layout=val -- randomize the layout of types (default: no) - -Z relax-elf-relocations=val -- whether ELF relocations can be relaxed - -Z relro-level=val -- choose which RELRO level to use - -Z remap-cwd-prefix=val -- remap paths under the current working directory to this path prefix - -Z report-delayed-bugs=val -- immediately print bugs registered with `delay_span_bug` (default: no) - -Z sanitizer=val -- use a sanitizer - -Z sanitizer-memory-track-origins=val -- enable origins tracking in MemorySanitizer - -Z sanitizer-recover=val -- enable recovery for selected sanitizers - -Z saturating-float-casts=val -- make float->int casts UB-free: numbers outside the integer type's range are clipped to the max/min integer respectively, and NaN is mapped to 0 (default: yes) - -Z self-profile=val -- run the self profiler and output the raw event data - -Z self-profile-counter=val -- counter used by the self profiler (default: `wall-time`), one of: - `wall-time` (monotonic clock, i.e. `std::time::Instant`) - `instructions:u` (retired instructions, userspace-only) - `instructions-minus-irqs:u` (subtracting hardware interrupt counts for extra accuracy) - -Z self-profile-events=val -- specify the events recorded by the self profiler; - for example: `-Z self-profile-events=default,query-keys` - all options: none, all, default, generic-activity, query-provider, query-cache-hit - query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes - -Z share-generics=val -- make the current crate share its generic instantiations - -Z show-span=val -- show spans for compiler debugging (expr|pat|ty) - -Z simulate-remapped-rust-src-base=val -- simulate the effect of remap-debuginfo = true at bootstrapping by remapping path to rust's source base directory. only meant for testing purposes - -Z span-debug=val -- forward proc_macro::Span's `Debug` impl to `Span` - -Z span-free-formats=val -- exclude spans when debug-printing compiler state (default: no) - -Z split-dwarf-inlining=val -- provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF - -Z split-dwarf-kind=val -- split dwarf variant (only if -Csplit-debuginfo is enabled and on relevant platform) - (default: `split`) - - `split`: sections which do not require relocation are written into a DWARF object (`.dwo`) - file which is ignored by the linker - `single`: sections which do not require relocation are written into object file but ignored - by the linker - -Z src-hash-algorithm=val -- hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`) - -Z stack-protector=val -- control stack smash protection strategy (`rustc --print stack-protector-strategies` for details) - -Z strict-init-checks=val -- control if mem::uninitialized and mem::zeroed panic on more UB - -Z strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`) - -Z symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0') - -Z teach=val -- show extended diagnostic help (default: no) - -Z temps-dir=val -- the directory the intermediate files are written to - -Z terminal-urls=val -- use the OSC 8 hyperlink terminal specification to print hyperlinks in the compiler output - -Z thinlto=val -- enable ThinLTO when possible - -Z thir-unsafeck=val -- use the THIR unsafety checker (default: no) - -Z threads=val -- use a thread pool with N threads - -Z time-llvm-passes=val -- measure time of each LLVM pass (default: no) - -Z time-passes=val -- measure time of each rustc pass (default: no) - -Z tiny-const-eval-limit=val -- sets a tiny, non-configurable limit for const eval; useful for compiler tests - -Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) - -Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no) - -Z track-diagnostics=val -- tracks where in rustc a diagnostic was emitted - -Z trait-solver=val -- specify the trait solver mode used by rustc (default: classic) - -Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) - -Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics - -Z translate-lang=val -- language identifier for diagnostic output - -Z translate-remapped-path-to-local-path=val -- translate remapped paths into local paths when possible (default: yes) - -Z trap-unreachable=val -- generate trap instructions for unreachable intrinsics (default: use target setting, usually yes) - -Z treat-err-as-bug=val -- treat error number `val` that occurs as bug - -Z trim-diagnostic-paths=val -- in diagnostics, use heuristics to shorten paths referring to items - -Z tune-cpu=val -- select processor to schedule for (`rustc --print target-cpus` for details) - -Z ui-testing=val -- emit compiler diagnostics in a form suitable for UI testing (default: no) - -Z uninit-const-chunk-threshold=val -- allow generating const initializers with mixed init/uninit chunks, and set the maximum number of chunks for which this is allowed (default: 16) - -Z unleash-the-miri-inside-of-you=val -- take the brakes off const evaluation. NOTE: this is unsound (default: no) - -Z unpretty=val -- present the input source, unstable (and less-pretty) variants; - `normal`, `identified`, - `expanded`, `expanded,identified`, - `expanded,hygiene` (with internal representations), - `ast-tree` (raw AST before expansion), - `ast-tree,expanded` (raw AST after expansion), - `hir` (the HIR), `hir,identified`, - `hir,typed` (HIR with types for each node), - `hir-tree` (dump the raw HIR), - `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR) - -Z unsound-mir-opts=val -- enable unsound and buggy MIR optimizations (default: no) - -Z unstable-options=val -- adds unstable command line options to rustc interface (default: no) - -Z use-ctors-section=val -- use legacy .ctors section for initializers rather than .init_array - -Z validate-mir=val -- validate MIR after each transformation - -Z verbose=val -- in general, enable more debug printouts (default: no) - -Z verify-llvm-ir=val -- verify LLVM IR (default: no) - -Z virtual-function-elimination=val -- enables dead virtual function elimination optimization. Requires `-Clto[=[fat,yes]]` - -Z wasi-exec-model=val -- whether to build a wasi command or reactor diff --git a/tests/rustdoc/anonymous-reexport.rs b/tests/rustdoc/anonymous-reexport.rs index 6b884ff14..839c1a303 100644 --- a/tests/rustdoc/anonymous-reexport.rs +++ b/tests/rustdoc/anonymous-reexport.rs @@ -4,9 +4,13 @@ // @has 'foo/index.html' // @has - '//*[@id="main-content"]' '' -// We check that the only "h2" present is for "Bla". -// @count - '//*[@id="main-content"]/h2' 1 +// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports". +// @count - '//*[@id="main-content"]/h2' 2 // @has - '//*[@id="main-content"]/h2' 'Structs' +// @has - '//*[@id="main-content"]/h2' 'Re-exports' +// The 3 re-exports. +// @count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3 +// The public struct. // @count - '//*[@id="main-content"]//a[@class="struct"]' 1 mod ext { diff --git a/tests/rustdoc/auto-impl-primitive.rs b/tests/rustdoc/auto-impl-primitive.rs index 172333d44..a6db93dbc 100644 --- a/tests/rustdoc/auto-impl-primitive.rs +++ b/tests/rustdoc/auto-impl-primitive.rs @@ -1,10 +1,10 @@ -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![crate_name = "foo"] pub use std::fs::File; // @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' -#[doc(primitive = "i16")] +#[rustc_doc_primitive = "i16"] /// I love poneys! mod prim {} diff --git a/tests/rustdoc/auxiliary/issue-15318.rs b/tests/rustdoc/auxiliary/issue-15318.rs index 695fa58ef..a2f426c63 100644 --- a/tests/rustdoc/auxiliary/issue-15318.rs +++ b/tests/rustdoc/auxiliary/issue-15318.rs @@ -2,6 +2,7 @@ // compile-flags: -Cmetadata=aux #![crate_type = "rlib"] #![doc(html_root_url = "http://example.com/")] +#![feature(rustc_attrs)] #![feature(lang_items)] #![no_std] @@ -12,5 +13,5 @@ fn foo() {} fn bar(_: &core::panic::PanicInfo) -> ! { loop {} } /// dox -#[doc(primitive = "pointer")] +#[rustc_doc_primitive = "pointer"] pub mod ptr {} diff --git a/tests/rustdoc/auxiliary/issue-73061.rs b/tests/rustdoc/auxiliary/issue-73061.rs index e05a3bc6d..01e9a984d 100644 --- a/tests/rustdoc/auxiliary/issue-73061.rs +++ b/tests/rustdoc/auxiliary/issue-73061.rs @@ -1,6 +1,6 @@ //edition:2018 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Foo { type X: std::future::Future<Output = ()>; diff --git a/tests/rustdoc/auxiliary/primitive-doc.rs b/tests/rustdoc/auxiliary/primitive-doc.rs index e8da852a5..d1785e423 100644 --- a/tests/rustdoc/auxiliary/primitive-doc.rs +++ b/tests/rustdoc/auxiliary/primitive-doc.rs @@ -1,9 +1,10 @@ // compile-flags: --crate-type lib --edition 2018 +#![feature(rustc_attrs)] #![feature(no_core)] #![no_core] -#[doc(primitive = "usize")] +#[rustc_doc_primitive = "usize"] /// This is the built-in type `usize`. mod usize { } diff --git a/tests/rustdoc/check-source-code-urls-to-def.rs b/tests/rustdoc/check-source-code-urls-to-def.rs index 5959f9c7c..41b9d41fa 100644 --- a/tests/rustdoc/check-source-code-urls-to-def.rs +++ b/tests/rustdoc/check-source-code-urls-to-def.rs @@ -2,7 +2,7 @@ // aux-build:source_code.rs // build-aux-docs -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![crate_name = "foo"] @@ -65,5 +65,5 @@ pub fn foo4() { } // @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' -#[doc(primitive = "bool")] +#[rustc_doc_primitive = "bool"] mod whatever {} diff --git a/tests/rustdoc/compiler-derive-proc-macro.rs b/tests/rustdoc/compiler-derive-proc-macro.rs new file mode 100644 index 000000000..489ec924c --- /dev/null +++ b/tests/rustdoc/compiler-derive-proc-macro.rs @@ -0,0 +1,15 @@ +// This test ensures that compiler builtin proc-macros are considered as such. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// Each compiler builtin proc-macro has a trait equivalent so we should have +// a trait section as well. +// @count - '//*[@id="main-content"]//*[@class="small-section-header"]' 2 +// @has - '//*[@id="main-content"]//*[@class="small-section-header"]' 'Traits' +// @has - '//*[@id="main-content"]//*[@class="small-section-header"]' 'Derive Macros' + +// Now checking the correct file is generated as well. +// @has 'foo/derive.Clone.html' +// @!has 'foo/macro.Clone.html' +pub use std::clone::Clone; diff --git a/tests/rustdoc/deprecated.rs b/tests/rustdoc/deprecated.rs index 51860441b..9c9c0945b 100644 --- a/tests/rustdoc/deprecated.rs +++ b/tests/rustdoc/deprecated.rs @@ -28,6 +28,6 @@ pub struct V; pub struct W; // @matches deprecated/struct.X.html '//*[@class="stab deprecated"]' \ -// 'Deprecated: shorthand reason$' -#[deprecated = "shorthand reason"] +// 'Deprecated: shorthand reason: code$' +#[deprecated = "shorthand reason: `code`"] pub struct X; diff --git a/tests/rustdoc/footnote-in-summary.rs b/tests/rustdoc/footnote-in-summary.rs new file mode 100644 index 000000000..e6ff5a7fd --- /dev/null +++ b/tests/rustdoc/footnote-in-summary.rs @@ -0,0 +1,17 @@ +// This test ensures that no footnote reference is generated inside +// summary doc. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// @has - '//*[@class="desc docblock-short"]' 'hello bla' +// @!has - '//*[@class="desc docblock-short"]/sup' '1' + +// @has 'foo/struct.S.html' +// @has - '//*[@class="docblock"]//sup' '1' +// @has - '//*[@class="docblock"]' 'hello 1 bla' + +/// hello [^foot] bla +/// +/// [^foot]: blabla +pub struct S; diff --git a/tests/rustdoc/generic-associated-types/issue-109488.rs b/tests/rustdoc/generic-associated-types/issue-109488.rs new file mode 100644 index 000000000..99ae8a6c3 --- /dev/null +++ b/tests/rustdoc/generic-associated-types/issue-109488.rs @@ -0,0 +1,18 @@ +// Make sure that we escape the arguments of the GAT projection even if we fail to compute +// the href of the corresponding trait (in this case it is private). +// Further, test that we also linkify the GAT arguments. + +// @has 'issue_109488/type.A.html' +// @has - '//pre[@class="rust item-decl"]' '<S as Tr>::P<Option<i32>>' +// @has - '//pre[@class="rust item-decl"]//a[@class="enum"]/@href' '{{channel}}/core/option/enum.Option.html' +pub type A = <S as Tr>::P<Option<i32>>; + +/*private*/ trait Tr { + type P<T>; +} + +pub struct S; + +impl Tr for S { + type P<T> = (); +} diff --git a/tests/rustdoc/intra-doc/auxiliary/my-core.rs b/tests/rustdoc/intra-doc/auxiliary/my-core.rs index e22feb03a..c050929db 100644 --- a/tests/rustdoc/intra-doc/auxiliary/my-core.rs +++ b/tests/rustdoc/intra-doc/auxiliary/my-core.rs @@ -3,7 +3,7 @@ #![rustc_coherence_is_core] #![crate_type="rlib"] -#[doc(primitive = "char")] +#[rustc_doc_primitive = "char"] /// Some char docs mod char {} diff --git a/tests/rustdoc/intra-doc/no-doc-primitive.rs b/tests/rustdoc/intra-doc/no-doc-primitive.rs index e5eba1d8d..711ac09ba 100644 --- a/tests/rustdoc/intra-doc/no-doc-primitive.rs +++ b/tests/rustdoc/intra-doc/no-doc-primitive.rs @@ -1,4 +1,4 @@ -// Crate tree without a `doc(primitive)` module for primitive type linked to by a doc link. +// Crate tree without a `rustc_doc_primitive` module for primitive type linked to by a doc link. #![deny(rustdoc::broken_intra_doc_links)] #![feature(no_core, lang_items, rustc_attrs)] diff --git a/tests/rustdoc/intra-doc/prim-methods-local.rs b/tests/rustdoc/intra-doc/prim-methods-local.rs index 79d8df045..6de4ec180 100644 --- a/tests/rustdoc/intra-doc/prim-methods-local.rs +++ b/tests/rustdoc/intra-doc/prim-methods-local.rs @@ -10,7 +10,7 @@ //! A [prim@`char`] and its [`char::len_utf8`]. -#[doc(primitive = "char")] +#[rustc_doc_primitive = "char"] mod char {} impl char { diff --git a/tests/rustdoc/intra-doc/prim-methods.rs b/tests/rustdoc/intra-doc/prim-methods.rs index a412a23fd..bc1965aac 100644 --- a/tests/rustdoc/intra-doc/prim-methods.rs +++ b/tests/rustdoc/intra-doc/prim-methods.rs @@ -2,6 +2,8 @@ // @has prim_methods/index.html // @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]/@title' 'primitive char' // @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' +// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]/@title' 'method char::len_utf8' //! A [`char`] and its [`char::len_utf8`]. diff --git a/tests/rustdoc/intra-doc/prim-self.rs b/tests/rustdoc/intra-doc/prim-self.rs index c7ce71b15..d13858a53 100644 --- a/tests/rustdoc/intra-doc/prim-self.rs +++ b/tests/rustdoc/intra-doc/prim-self.rs @@ -25,7 +25,7 @@ impl usize { pub type ME = usize; } -#[doc(primitive = "usize")] +#[rustc_doc_primitive = "usize"] /// This has some docs. mod usize {} diff --git a/tests/rustdoc/issue-108679-reexport-of-reexport.rs b/tests/rustdoc/issue-108679-reexport-of-reexport.rs new file mode 100644 index 000000000..5f977801c --- /dev/null +++ b/tests/rustdoc/issue-108679-reexport-of-reexport.rs @@ -0,0 +1,29 @@ +// This test ensures that the `struct.B.html` only exists in `a`: +// since `a::B` is public (and inlined too), `self::a::B` doesn't +// need to be inlined as well. + +#![crate_name = "foo"] + +pub mod a { + // @has 'foo/a/index.html' + // Should only contain "Structs". + // @count - '//*[@id="main-content"]//*[@class="item-table"]' 1 + // @has - '//*[@id="structs"]' 'Structs' + // @has - '//*[@id="main-content"]//a[@href="struct.A.html"]' 'A' + // @has - '//*[@id="main-content"]//a[@href="struct.B.html"]' 'B' + mod b { + pub struct B; + } + pub use self::b::B; + pub struct A; +} + +// @has 'foo/index.html' +// @!has - '//*[@id="structs"]' 'Structs' +// @has - '//*[@id="reexports"]' 'Re-exports' +// @has - '//*[@id="modules"]' 'Modules' +// @has - '//*[@id="main-content"]//*[@id="reexport.A"]' 'pub use self::a::A;' +// @has - '//*[@id="main-content"]//*[@id="reexport.B"]' 'pub use self::a::B;' +// Should only contain "Modules" and "Re-exports". +// @count - '//*[@id="main-content"]//*[@class="item-table"]' 2 +pub use self::a::{A, B}; diff --git a/tests/rustdoc/issue-108925.rs b/tests/rustdoc/issue-108925.rs new file mode 100644 index 000000000..9c36d0d71 --- /dev/null +++ b/tests/rustdoc/issue-108925.rs @@ -0,0 +1,10 @@ +// @has issue_108925/enum.MyThing.html +// @has - '//code' 'Shown' +// @!has - '//code' 'NotShown' +// @!has - '//code' '// some variants omitted' +#[non_exhaustive] +pub enum MyThing { + Shown, + #[doc(hidden)] + NotShown, +} diff --git a/tests/rustdoc/issue-108931-anonymous-reexport.rs b/tests/rustdoc/issue-108931-anonymous-reexport.rs new file mode 100644 index 000000000..302f74133 --- /dev/null +++ b/tests/rustdoc/issue-108931-anonymous-reexport.rs @@ -0,0 +1,21 @@ +// Ensuring that anonymous re-exports are always inlined. + +#![crate_name = "foo"] + +pub mod foo { + pub struct Foo; +} + +mod bar { + pub struct Bar; +} + +// @has 'foo/index.html' +// We check that the only "h2" present are "Re-exports" and "Modules". +// @count - '//*[@id="main-content"]/h2' 2 +// @has - '//*[@id="main-content"]/h2' 'Re-exports' +// @has - '//*[@id="main-content"]/h2' 'Modules' +// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use foo::Foo as _;' +// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use bar::Bar as _;' +pub use foo::Foo as _; +pub use bar::Bar as _; diff --git a/tests/rustdoc/issue-109258-missing-private-inlining.rs b/tests/rustdoc/issue-109258-missing-private-inlining.rs new file mode 100644 index 000000000..96f606368 --- /dev/null +++ b/tests/rustdoc/issue-109258-missing-private-inlining.rs @@ -0,0 +1,27 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/109258>. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// We should only have a "Re-exports" and a "Modules" headers. +// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 2 +// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Re-exports' +// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Modules' + +// @has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;' +// @has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo' +// @!has 'foo/struct.Foo.html' +pub use crate::issue_109258::Foo; + +// @has 'foo/issue_109258/index.html' +// We should only have a "Structs" header. +// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 1 +// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Structs' +// @has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo' +// @has 'foo/issue_109258/struct.Foo.html' +pub mod issue_109258 { + mod priv_mod { + pub struct Foo; + } + pub use self::priv_mod::Foo; +} diff --git a/tests/rustdoc/issue-109695-crate-doc-hidden.rs b/tests/rustdoc/issue-109695-crate-doc-hidden.rs new file mode 100644 index 000000000..7a3e53a0d --- /dev/null +++ b/tests/rustdoc/issue-109695-crate-doc-hidden.rs @@ -0,0 +1,8 @@ +// This test ensures that even if the crate module is `#[doc(hidden)]`, the file +// is generated. + +// @has 'foo/index.html' +// @has 'foo/all.html' + +#![crate_name = "foo"] +#![doc(hidden)] diff --git a/tests/rustdoc/issue-15318-2.rs b/tests/rustdoc/issue-15318-2.rs index f7f5052a3..614f2c1c0 100644 --- a/tests/rustdoc/issue-15318-2.rs +++ b/tests/rustdoc/issue-15318-2.rs @@ -6,7 +6,7 @@ extern crate issue_15318; pub use issue_15318::ptr; -// @has issue_15318_2/fn.bar.html \ +// @!has issue_15318_2/fn.bar.html \ // '//*[@href="primitive.pointer.html"]' \ // '*mut T' pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/issue-15318-3.rs b/tests/rustdoc/issue-15318-3.rs index 2fadc26b0..2dab8f948 100644 --- a/tests/rustdoc/issue-15318-3.rs +++ b/tests/rustdoc/issue-15318-3.rs @@ -1,7 +1,7 @@ -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has issue_15318_3/primitive.pointer.html /// dox -#[doc(primitive = "pointer")] +#[rustc_doc_primitive = "pointer"] pub mod ptr {} diff --git a/tests/rustdoc/issue-23511.rs b/tests/rustdoc/issue-23511.rs index 7576ebb03..21d028424 100644 --- a/tests/rustdoc/issue-23511.rs +++ b/tests/rustdoc/issue-23511.rs @@ -3,7 +3,7 @@ #![no_std] pub mod str { - #![doc(primitive = "str")] + #![rustc_doc_primitive = "str"] impl str { // @hasraw search-index.js foo diff --git a/tests/rustdoc/issue-25001.rs b/tests/rustdoc/issue-25001.rs index c97b35ada..268fae594 100644 --- a/tests/rustdoc/issue-25001.rs +++ b/tests/rustdoc/issue-25001.rs @@ -21,14 +21,14 @@ impl Foo<u32> { } impl<T> Bar for Foo<T> { - // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' 'type Item = T' + // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T' type Item=T; // @has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a Foo<T> { - // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item = &'a T" + // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T" type Item=&'a T; // @has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)' diff --git a/tests/rustdoc/macro_pub_in_module.rs b/tests/rustdoc/macro_pub_in_module.rs index 4fd85d689..42f760cff 100644 --- a/tests/rustdoc/macro_pub_in_module.rs +++ b/tests/rustdoc/macro_pub_in_module.rs @@ -7,8 +7,8 @@ #![crate_name = "krate"] #![no_core] - // @has external_crate/some_module/macro.external_macro.html - // @!has external_crate/macro.external_macro.html +// @has external_crate/some_module/macro.external_macro.html +// @!has external_crate/macro.external_macro.html extern crate external_crate; pub mod inner { @@ -16,13 +16,17 @@ pub mod inner { // @!has krate/macro.raw_const.html pub macro raw_const() {} - // @has krate/inner/macro.test.html + // @has krate/inner/attr.test.html // @!has krate/macro.test.html + // @!has krate/inner/macro.test.html + // @!has krate/attr.test.html #[rustc_builtin_macro] pub macro test($item:item) {} - // @has krate/inner/macro.Clone.html + // @has krate/inner/derive.Clone.html + // @!has krate/inner/macro.Clone.html // @!has krate/macro.Clone.html + // @!has krate/derive.Clone.html #[rustc_builtin_macro] pub macro Clone($item:item) {} diff --git a/tests/rustdoc/non_lifetime_binders.rs b/tests/rustdoc/non_lifetime_binders.rs new file mode 100644 index 000000000..da9a4e6a8 --- /dev/null +++ b/tests/rustdoc/non_lifetime_binders.rs @@ -0,0 +1,9 @@ +#![feature(non_lifetime_binders)] +#![allow(incomplete_features)] + +pub trait Trait {} + +pub struct Wrapper<T: ?Sized>(Box<T>); + +// @has non_lifetime_binders/fn.foo.html '//pre' "fn foo()where for<'a, T> &'a Wrapper<T>: Trait" +pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/rustdoc/normalize-assoc-item.rs b/tests/rustdoc/normalize-assoc-item.rs index af7b2f955..c6fd5e110 100644 --- a/tests/rustdoc/normalize-assoc-item.rs +++ b/tests/rustdoc/normalize-assoc-item.rs @@ -63,12 +63,12 @@ impl<'a> Lifetimes<'a> for usize { type Y = &'a isize; } -// @has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &isize" +// @has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &'static isize" pub fn g() -> <usize as Lifetimes<'static>>::Y { &0 } -// @has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &isize" +// @has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &'static isize" pub const A: <usize as Lifetimes<'static>>::Y = &0; // test cross-crate re-exports diff --git a/tests/rustdoc/doc-notable_trait-mut_t_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs index bfce46cf4..5af5f7616 100644 --- a/tests/rustdoc/doc-notable_trait-mut_t_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs @@ -6,10 +6,10 @@ //! //! [#80737]: https://github.com/rust-lang/rust/issues/80737 -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![no_std] -#[doc(primitive = "reference")] +#[rustc_doc_primitive = "reference"] /// Some useless docs, wouhou! /// /// We need to put this in here, because notable traits diff --git a/tests/rustdoc/doc-notable_trait-mut_t_is_not_ref_t.rs b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs index b359dcea0..6c980aaa2 100644 --- a/tests/rustdoc/doc-notable_trait-mut_t_is_not_ref_t.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs @@ -5,9 +5,9 @@ //! //! [#78160]: https://github.com/rust-lang/rust/issues/78160 -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] -#[doc(primitive = "reference")] +#[rustc_doc_primitive = "reference"] /// Some useless docs, wouhou! /// /// We need to put this in here, because notable traits diff --git a/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html b/tests/rustdoc/notable-trait/doc-notable_trait-slice.bare_fn_matches.html index 46be00a08..46be00a08 100644 --- a/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html +++ b/tests/rustdoc/notable-trait/doc-notable_trait-slice.bare_fn_matches.html diff --git a/tests/rustdoc/doc-notable_trait-slice.rs b/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs index 2411da8cd..ef206710b 100644 --- a/tests/rustdoc/doc-notable_trait-slice.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs @@ -18,3 +18,9 @@ pub fn bare_fn_matches() -> &'static [SomeStruct] { pub fn bare_fn_no_matches() -> &'static [OtherStruct] { &[] } + +// @has doc_notable_trait_slice/fn.bare_fn_mut_no_matches.html +// @count - '//script[@id="notable-traits-data"]' 0 +pub fn bare_fn_mut_no_matches() -> &'static mut [SomeStruct] { + &mut [] +} diff --git a/tests/rustdoc/doc-notable_trait.bare-fn.html b/tests/rustdoc/notable-trait/doc-notable_trait.bare-fn.html index f592e3b37..f592e3b37 100644 --- a/tests/rustdoc/doc-notable_trait.bare-fn.html +++ b/tests/rustdoc/notable-trait/doc-notable_trait.bare-fn.html diff --git a/tests/rustdoc/doc-notable_trait.rs b/tests/rustdoc/notable-trait/doc-notable_trait.rs index d8941769f..d8941769f 100644 --- a/tests/rustdoc/doc-notable_trait.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait.rs diff --git a/tests/rustdoc/doc-notable_trait.some-struct-new.html b/tests/rustdoc/notable-trait/doc-notable_trait.some-struct-new.html index e8f4f6000..e8f4f6000 100644 --- a/tests/rustdoc/doc-notable_trait.some-struct-new.html +++ b/tests/rustdoc/notable-trait/doc-notable_trait.some-struct-new.html diff --git a/tests/rustdoc/doc-notable_trait.wrap-me.html b/tests/rustdoc/notable-trait/doc-notable_trait.wrap-me.html index e7909669b..e7909669b 100644 --- a/tests/rustdoc/doc-notable_trait.wrap-me.html +++ b/tests/rustdoc/notable-trait/doc-notable_trait.wrap-me.html diff --git a/tests/rustdoc/doc-notable_trait_box_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs index 3fb00c7db..3fb00c7db 100644 --- a/tests/rustdoc/doc-notable_trait_box_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs diff --git a/tests/rustdoc/notable-trait/notable-trait-generics.rs b/tests/rustdoc/notable-trait/notable-trait-generics.rs new file mode 100644 index 000000000..611902aba --- /dev/null +++ b/tests/rustdoc/notable-trait/notable-trait-generics.rs @@ -0,0 +1,35 @@ +#![feature(doc_notable_trait)] + +// Notable traits SHOULD NOT be shown when the `impl` has a concrete type and +// the return type has a generic type. +pub mod generic_return { + pub struct Wrapper<T>(T); + + #[doc(notable_trait)] + pub trait NotableTrait {} + + impl NotableTrait for Wrapper<u8> {} + + // @has notable_trait_generics/generic_return/fn.returning.html + // @!has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<T>' + pub fn returning<T>() -> Wrapper<T> { + loop {} + } +} + +// Notable traits SHOULD be shown when the `impl` has a generic type and the +// return type has a concrete type. +pub mod generic_impl { + pub struct Wrapper<T>(T); + + #[doc(notable_trait)] + pub trait NotableTrait {} + + impl<T> NotableTrait for Wrapper<T> {} + + // @has notable_trait_generics/generic_impl/fn.returning.html + // @has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<u8>' + pub fn returning() -> Wrapper<u8> { + loop {} + } +} diff --git a/tests/rustdoc/spotlight-from-dependency.odd.html b/tests/rustdoc/notable-trait/spotlight-from-dependency.odd.html index 5f54b7522..5f54b7522 100644 --- a/tests/rustdoc/spotlight-from-dependency.odd.html +++ b/tests/rustdoc/notable-trait/spotlight-from-dependency.odd.html diff --git a/tests/rustdoc/spotlight-from-dependency.rs b/tests/rustdoc/notable-trait/spotlight-from-dependency.rs index 426759c7b..426759c7b 100644 --- a/tests/rustdoc/spotlight-from-dependency.rs +++ b/tests/rustdoc/notable-trait/spotlight-from-dependency.rs diff --git a/tests/rustdoc/primitive-reference.rs b/tests/rustdoc/primitive-reference.rs index 10efbefd2..6f034224d 100644 --- a/tests/rustdoc/primitive-reference.rs +++ b/tests/rustdoc/primitive-reference.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has foo/index.html // @has - '//h2[@id="primitives"]' 'Primitive Types' @@ -16,7 +16,7 @@ // @count - '//*[@class="impl"]' 1 // @has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ // 'impl<A, B> Foo<&A> for &B' -#[doc(primitive = "reference")] +#[rustc_doc_primitive = "reference"] /// this is a test! mod reference {} diff --git a/tests/rustdoc/primitive-slice-auto-trait.rs b/tests/rustdoc/primitive-slice-auto-trait.rs index 779224146..ba15a73ca 100644 --- a/tests/rustdoc/primitive-slice-auto-trait.rs +++ b/tests/rustdoc/primitive-slice-auto-trait.rs @@ -1,7 +1,7 @@ // compile-flags: --crate-type lib --edition 2018 #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice' // @has - '//h1' 'Primitive Type slice' @@ -9,6 +9,6 @@ // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T]where T: Send' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T]where T: Sync' -#[doc(primitive = "slice")] +#[rustc_doc_primitive = "slice"] /// this is a test! mod slice_prim {} diff --git a/tests/rustdoc/primitive-tuple-auto-trait.rs b/tests/rustdoc/primitive-tuple-auto-trait.rs index 4344d24f9..2b407b586 100644 --- a/tests/rustdoc/primitive-tuple-auto-trait.rs +++ b/tests/rustdoc/primitive-tuple-auto-trait.rs @@ -1,7 +1,7 @@ // compile-flags: --crate-type lib --edition 2018 #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple' // @has - '//h1' 'Primitive Type tuple' @@ -9,7 +9,7 @@ // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' -#[doc(primitive = "tuple")] +#[rustc_doc_primitive = "tuple"] /// this is a test! /// // Hardcoded anchor to header written in library/core/src/primitive_docs.rs diff --git a/tests/rustdoc/primitive-unit-auto-trait.rs b/tests/rustdoc/primitive-unit-auto-trait.rs index 61850e246..5a56f1fd8 100644 --- a/tests/rustdoc/primitive-unit-auto-trait.rs +++ b/tests/rustdoc/primitive-unit-auto-trait.rs @@ -1,7 +1,7 @@ // compile-flags: --crate-type lib --edition 2018 #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit' // @has - '//h1' 'Primitive Type unit' @@ -9,6 +9,6 @@ // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' -#[doc(primitive = "unit")] +#[rustc_doc_primitive = "unit"] /// this is a test! mod unit_prim {} diff --git a/tests/rustdoc/primitive/primitive-generic-impl.rs b/tests/rustdoc/primitive/primitive-generic-impl.rs index 7b336b398..2da8ae6ff 100644 --- a/tests/rustdoc/primitive/primitive-generic-impl.rs +++ b/tests/rustdoc/primitive/primitive-generic-impl.rs @@ -1,8 +1,8 @@ -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] #![crate_name = "foo"] // @has foo/primitive.i32.html '//*[@id="impl-ToString-for-i32"]//h3[@class="code-header"]' 'impl<T> ToString for T' -#[doc(primitive = "i32")] +#[rustc_doc_primitive = "i32"] /// Some useless docs, wouhou! mod i32 {} diff --git a/tests/rustdoc/primitive.rs b/tests/rustdoc/primitive/primitive.rs index 516c7c0c6..32af2636c 100644 --- a/tests/rustdoc/primitive.rs +++ b/tests/rustdoc/primitive/primitive.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has foo/index.html '//h2[@id="primitives"]' 'Primitive Types' // @has foo/index.html '//a[@href="primitive.i32.html"]' 'i32' @@ -11,11 +11,11 @@ // @has foo/primitive.i32.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // @has foo/index.html '//a/@href' '../foo/index.html' // @!has foo/index.html '//span' '🔒' -#[doc(primitive = "i32")] +#[rustc_doc_primitive = "i32"] /// this is a test! mod i32{} // @has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' -#[doc(primitive = "bool")] +#[rustc_doc_primitive = "bool"] /// hello mod bool {} diff --git a/tests/rustdoc/sidebar-all-page.rs b/tests/rustdoc/sidebar-all-page.rs index e74b981de..45a6ba8ed 100644 --- a/tests/rustdoc/sidebar-all-page.rs +++ b/tests/rustdoc/sidebar-all-page.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @has 'foo/all.html' // @has - '//*[@class="sidebar-elems"]//li' 'Structs' @@ -31,5 +31,5 @@ macro_rules! foo { pub type Type = u8; pub const FOO: u8 = 0; pub static BAR: u8 = 0; -#[doc(primitive = "u8")] +#[rustc_doc_primitive = "u8"] mod u8 {} diff --git a/tests/rustdoc/tab_title.rs b/tests/rustdoc/tab_title.rs index 0cc4f147e..8d781b40e 100644 --- a/tests/rustdoc/tab_title.rs +++ b/tests/rustdoc/tab_title.rs @@ -1,4 +1,5 @@ #![crate_name = "foo"] +#![feature(rustc_attrs)] #![feature(rustdoc_internals)] // tests for the html <title> element @@ -39,6 +40,6 @@ mod continue_keyword {} // @has foo/primitive.u8.html '//head/title' 'u8 - Rust' // @!has - '//head/title' 'foo' -#[doc(primitive = "u8")] +#[rustc_doc_primitive = "u8"] /// `u8` docs mod u8 {} diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index 69e8b856b..e1feb1cd6 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -#![feature(rustdoc_internals)] +#![feature(rustc_attrs)] // @matches 'foo/index.html' '//h1' 'Crate foo' // @matches 'foo/index.html' '//h2[@class="location"]' 'Crate foo' @@ -41,7 +41,7 @@ macro_rules! foo_macro { } // @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool' -#[doc(primitive = "bool")] +#[rustc_doc_primitive = "bool"] mod bool {} // @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC' diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index 5e0a0411a..bd88e73af 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -83,3 +83,11 @@ pub enum WithNiche { None, Some(std::num::NonZeroU32), } + +// @hasraw type_layout/enum.Uninhabited.html 'Size: ' +// @hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +pub enum Uninhabited {} + +// @hasraw type_layout/struct.Uninhabited2.html 'Size: ' +// @hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +pub struct Uninhabited2(std::convert::Infallible, u64); |