diff options
Diffstat (limited to '')
479 files changed, 5869 insertions, 2035 deletions
diff --git a/src/test/rustdoc-gui/anchor-navigable.goml b/src/test/rustdoc-gui/anchor-navigable.goml index 424c31223..9d5c55a1e 100644 --- a/src/test/rustdoc-gui/anchor-navigable.goml +++ b/src/test/rustdoc-gui/anchor-navigable.goml @@ -4,8 +4,8 @@ // 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 +goto: "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": "9"}) +assert-property: (".impl > a.anchor", {"offsetWidth": "8"}) assert-css: (".impl > a.anchor", {"left": "-8px"}) diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index 84b8bbd1b..fb8e288fa 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -1,34 +1,107 @@ // This test is to ensure that the anchors (`ยง`) have the expected color and position. -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -show-text: true -// This is needed to ensure that the text color is computed. -show-text: true +define-function: ( + "check-colors", + (theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color), + [ + ("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"), + // This is needed to ensure that the text color is computed. + ("show-text", true), -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: + // Setting the theme. + ("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: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"}) -assert-css: (".srclink", {"color": "rgb(56, 115, 173)"}) + ("assert-css", ("#toggle-all-docs", {"color": |main_color|})), + ("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})), + ("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})), + ("assert-css", ( + ".rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + ALL, + )), + ( + "compare-elements-css", + (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), + ( + "compare-elements-css", + (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), -move-cursor-to: ".main-heading .srclink" -assert-css: (".srclink", {"text-decoration": "underline solid rgb(56, 115, 173)"}) + ("move-cursor-to", ".main-heading .srclink"), + ("assert-css", ( + ".main-heading .srclink", + {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside .srclink"), + ("assert-css", ( + ".impl-items .rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside.srclink"), + ("assert-css", ( + ".impl-items .rightside.srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), -assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"}) + ("goto", "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"}), + // We reload the page so the local storage settings are being used. + ("reload"), -assert-css: (".sidebar a", {"color": "rgb(53, 109, 164)"}) -assert-css: (".in-band a", {"color": "rgb(0, 0, 0)"}) + ("assert-css", ("#top-doc-prose-title", {"color": |title_color|})), -// We move the cursor over the "Implementations" title so the anchor is displayed. -move-cursor-to: "h2#implementations" -assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"}) + ("assert-css", (".sidebar a", {"color": |sidebar_link_color|})), + ("assert-css", ("h1.fqn a", {"color": |title_color|})), -// Same thing with the impl block title. -move-cursor-to: "#impl-HeavilyDocumentedStruct" -assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(0, 0, 0)"}) + // We move the cursor over the "Implementations" title so the anchor is displayed. + ("move-cursor-to", "h2#implementations"), + ("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})), -assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) + // Same thing with the impl block title. + ("move-cursor-to", "#impl-HeavilyDocumentedStruct"), + ("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})), + + ("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})), + ], +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "main_color": "rgb(197, 197, 197)", + "title_color": "rgb(255, 255, 255)", + "fqn_color": "rgb(255, 255, 255)", + "fqn_type_color": "rgb(255, 160, 165)", + "src_link_color": "rgb(57, 175, 215)", + "sidebar_link_color": "rgb(83, 177, 219)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "main_color": "rgb(221, 221, 221)", + "title_color": "rgb(221, 221, 221)", + "fqn_color": "rgb(221, 221, 221)", + "fqn_type_color": "rgb(45, 191, 184)", + "src_link_color": "rgb(210, 153, 29)", + "sidebar_link_color": "rgb(253, 191, 53)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "main_color": "rgb(0, 0, 0)", + "title_color": "rgb(0, 0, 0)", + "fqn_color": "rgb(0, 0, 0)", + "fqn_type_color": "rgb(173, 55, 138)", + "src_link_color": "rgb(56, 115, 173)", + "sidebar_link_color": "rgb(53, 109, 164)", + }, +) diff --git a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml index 7b1358fed..0a619c352 100644 --- a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml +++ b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml @@ -1,5 +1,5 @@ // Checks that the setting "auto hide trait implementations" is working as expected. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +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) diff --git a/src/test/rustdoc-gui/basic-code.goml b/src/test/rustdoc-gui/basic-code.goml index 27deb2c98..f4ba5a128 100644 --- a/src/test/rustdoc-gui/basic-code.goml +++ b/src/test/rustdoc-gui/basic-code.goml @@ -1,3 +1,3 @@ -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" -assert-count: (".line-numbers", 1) +assert-count: (".src-line-numbers", 1) diff --git a/src/test/rustdoc-gui/basic.goml b/src/test/rustdoc-gui/basic.goml index 239e51a91..60292835b 100644 --- a/src/test/rustdoc-gui/basic.goml +++ b/src/test/rustdoc-gui/basic.goml @@ -1,4 +1,4 @@ -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert: ("#functions") -goto: ./struct.Foo.html +goto: "./struct.Foo.html" assert: ("div.item-decl") diff --git a/src/test/rustdoc-gui/check-code-blocks-margin.goml b/src/test/rustdoc-gui/check-code-blocks-margin.goml index f6266eba7..c2cec0020 100644 --- a/src/test/rustdoc-gui/check-code-blocks-margin.goml +++ b/src/test/rustdoc-gui/check-code-blocks-margin.goml @@ -1,6 +1,6 @@ // This test ensures that the docblock elements have the appropriate left margin. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // The top docblock elements shouldn't have left margin... -assert-css: ("#main-content .docblock.item-decl", {"margin-left": "0px"}) +assert-css: ("#main-content .item-decl", {"margin-left": "0px"}) // ... but all the others should! -assert-css: ("#main-content .docblock:not(.item-decl)", {"margin-left": "24px"}) +assert-css: ("#main-content .docblock", {"margin-left": "24px"}) diff --git a/src/test/rustdoc-gui/check-stab-in-docblock.goml b/src/test/rustdoc-gui/check-stab-in-docblock.goml new file mode 100644 index 000000000..266fa9997 --- /dev/null +++ b/src/test/rustdoc-gui/check-stab-in-docblock.goml @@ -0,0 +1,27 @@ +// This test checks that using `.stab` attributes in `.docblock` elements doesn't +// create scrollable paragraphs. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Needs the text to be display to check for scrollable content. +show-text: true +size: (786, 600) +// Confirms that there 3 paragraphs. +assert-count: (".top-doc .docblock p", 3) +// Checking that there is no scrollable content. +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(1)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(1)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(1)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(2)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(2)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(2)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(3)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(3)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(3)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/src/test/rustdoc-gui/check_info_sign_position.goml index 3bed7a0a0..f36e73fc5 100644 --- a/src/test/rustdoc-gui/check_info_sign_position.goml +++ b/src/test/rustdoc-gui/check_info_sign_position.goml @@ -1,11 +1,11 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +goto: "./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 > .information > .compile_fail", { "margin-top": "16px" }) +assert-css: (".docblock > .example-wrap.compile_fail .tooltip", { "margin-top": "16px" }) // Checks that the other codeblocks don't have this top margin. -assert-css: ("ol > li > .information > .compile_fail", { "margin-top": "0px" }) -assert-css: ("ol > li > .information > .ignore", { "margin-top": "0px" }) -assert-css: (".docblock > .information > .ignore", { "margin-top": "0px" }) +assert-css: ("ol > li > .example-wrap.compile_fail .tooltip", { "margin-top": "0px" }) +assert-css: ("ol > li > .example-wrap.ignore .tooltip", { "margin-top": "0px" }) +assert-css: (".docblock > .example-wrap.ignore .tooltip", { "margin-top": "0px" }) diff --git a/src/test/rustdoc-gui/code-blocks-overflow.goml b/src/test/rustdoc-gui/code-blocks-overflow.goml index f93f3f0ae..fbf0e890b 100644 --- a/src/test/rustdoc-gui/code-blocks-overflow.goml +++ b/src/test/rustdoc-gui/code-blocks-overflow.goml @@ -1,8 +1,8 @@ // This test ensures that codeblocks content don't overflow. -goto: file://|DOC_PATH|/lib2/sub_mod/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" 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" assert: ".docblock > .example-wrap > .rust-example-rendered" -assert-css: (".docblock > .example-wrap > pre", {"width": "785.25px", "overflow-x": "auto"}, ALL) +assert-css: (".docblock > .example-wrap > pre", {"width": "796px", "overflow-x": "auto"}, ALL) diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml index 2f95bfb6b..118f04ad6 100644 --- a/src/test/rustdoc-gui/code-color.goml +++ b/src/test/rustdoc-gui/code-color.goml @@ -2,29 +2,23 @@ // 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 +goto: "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 -// Set the theme to dark. -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: -assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL) +define-function: ( + "check-colors", + (theme, doc_code_color, doc_inline_code_color), + [ + // Set the theme. + ("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)), + ("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)), + ], +) -// Set the theme to ayu. -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL) - -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL) +call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)")) +call-function: ("check-colors", ("dark", "rgb(221, 221, 221)", "rgb(221, 221, 221)")) +call-function: ("check-colors", ("light", "rgb(0, 0, 0)", "rgb(0, 0, 0)")) diff --git a/src/test/rustdoc-gui/code-sidebar-toggle.goml b/src/test/rustdoc-gui/code-sidebar-toggle.goml index 867db0569..00a0ea1e1 100644 --- a/src/test/rustdoc-gui/code-sidebar-toggle.goml +++ b/src/test/rustdoc-gui/code-sidebar-toggle.goml @@ -1,5 +1,5 @@ // This test checks that the source code pages sidebar toggle is working as expected. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" wait-for: "#sidebar-toggle" click: "#sidebar-toggle" diff --git a/src/test/rustdoc-gui/code-tags.goml b/src/test/rustdoc-gui/code-tags.goml index 200569a28..837a2c1d5 100644 --- a/src/test/rustdoc-gui/code-tags.goml +++ b/src/test/rustdoc-gui/code-tags.goml @@ -1,20 +1,20 @@ // This test ensures that items and documentation code blocks are wrapped in <pre><code> -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" size: (1080, 600) -// There should be three doc codeblocks +// There should be four doc codeblocks. // Check that their content is inside <pre><code> -assert-count: (".example-wrap pre > code", 3) +assert-count: (".example-wrap pre > code", 4) // Check that function signature is inside <pre><code> assert: "pre.rust.fn > code" -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert: "pre.rust.struct > code" -goto: file://|DOC_PATH|/test_docs/enum.AnEnum.html +goto: "file://" + |DOC_PATH| + "/test_docs/enum.AnEnum.html" assert: "pre.rust.enum > code" -goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html +goto: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" assert: "pre.rust.trait > code" -goto: file://|DOC_PATH|/test_docs/type.SomeType.html +goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" assert: "pre.rust.typedef > code" diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/src/test/rustdoc-gui/codeblock-tooltip.goml new file mode 100644 index 000000000..8e681a2a0 --- /dev/null +++ b/src/test/rustdoc-gui/codeblock-tooltip.goml @@ -0,0 +1,80 @@ +// Checking the colors of the codeblocks tooltips. +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +show-text: true + +define-function: ( + "check-colors", + (theme), + [ + // Setting the theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + + // compile_fail block + ("assert-css", ( + ".docblock .example-wrap.compile_fail .tooltip", + {"color": "rgba(255, 0, 0, 0.5)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.compile_fail", + {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.compile_fail"), + + ("assert-css", ( + ".docblock .example-wrap.compile_fail .tooltip", + {"color": "rgb(255, 0, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.compile_fail", + {"border-left": "2px solid rgb(255, 0, 0)"}, + )), + + // should_panic block + ("assert-css", ( + ".docblock .example-wrap.should_panic .tooltip", + {"color": "rgba(255, 0, 0, 0.5)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.should_panic", + {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.should_panic"), + + ("assert-css", ( + ".docblock .example-wrap.should_panic .tooltip", + {"color": "rgb(255, 0, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.should_panic", + {"border-left": "2px solid rgb(255, 0, 0)"}, + )), + + // ignore block + ("assert-css", ( + ".docblock .example-wrap.ignore .tooltip", + {"color": "rgba(255, 142, 0, 0.6)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.ignore", + {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.ignore"), + + ("assert-css", ( + ".docblock .example-wrap.ignore .tooltip", + {"color": "rgb(255, 142, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.ignore", + {"border-left": "2px solid rgb(255, 142, 0)"}, + )), + ], +) + +call-function: ("check-colors", ("ayu")) +call-function: ("check-colors", ("dark")) +call-function: ("check-colors", ("light")) diff --git a/src/test/rustdoc-gui/default-settings.goml b/src/test/rustdoc-gui/default-settings.goml index 90f0b087a..ab27b001e 100644 --- a/src/test/rustdoc-gui/default-settings.goml +++ b/src/test/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 +goto: "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/src/test/rustdoc-gui/docblock-big-code-mobile.goml b/src/test/rustdoc-gui/docblock-big-code-mobile.goml index 02f79f1fc..9f8df44d7 100644 --- a/src/test/rustdoc-gui/docblock-big-code-mobile.goml +++ b/src/test/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 +goto: "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 diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml index baf9651c4..911ee34be 100644 --- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml +++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml @@ -1,8 +1,8 @@ // Checks that the setting "line numbers" is working as expected. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // We check that without this setting, there is no line number displayed. -assert-false: "pre.line-number" +assert-false: "pre.example-line-numbers" // We now set the setting to show the line numbers on code examples. local-storage: {"rustdoc-line-numbers": "true" } @@ -10,13 +10,30 @@ local-storage: {"rustdoc-line-numbers": "true" } reload: // We wait for them to be added into the DOM by the JS... -wait-for: "pre.line-number" +wait-for: "pre.example-line-numbers" // If the test didn't fail, it means that it was found! // Let's now check some CSS properties... -assert-css: ("pre.line-number", { +assert-css: ("pre.example-line-numbers", { "margin": "0px", "padding": "13px 8px", "text-align": "right", }) // The first code block has two lines so let's check its `<pre>` elements lists both of them. -assert-text: ("pre.line-number", "1\n2") +assert-text: ("pre.example-line-numbers", "1\n2") + +// Now, try changing the setting dynamically. We'll turn it off, using the settings menu, +// and make sure it goes away. + +// First, open the settings menu. +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) + +// Then, click the toggle button. +click: "input#line-numbers + .slider" +wait-for: 100 // wait-for-false does not exist +assert-false: "pre.example-line-numbers" + +// Finally, turn it on again. +click: "input#line-numbers + .slider" +wait-for: "pre.example-line-numbers" diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml index f6287ade2..9ae571efb 100644 --- a/src/test/rustdoc-gui/docblock-details.goml +++ b/src/test/rustdoc-gui/docblock-details.goml @@ -1,5 +1,5 @@ // This ensures that the `<details>`/`<summary>` elements are displayed as expected. -goto: file://|DOC_PATH|/test_docs/details/struct.Details.html +goto: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html" show-text: true local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: @@ -14,10 +14,21 @@ assert-css: ( // We now check that the `<summary>` doesn't have a bottom border and has the correct display. assert-css: ( ".top-doc .docblock summary h4", - {"border-bottom": "0px none rgb(210, 210, 210)"}, + {"border-bottom-width": "0px"}, ) // This allows to ensure that summary is on one line only! assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) // So `33 + 15 + 5` == `53` assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) + +// We now check the `<summary>` on a method. +assert-css: ( + ".method-toggle .docblock summary h4", + {"border-bottom-width": "0px"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"}) +assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `30 + 15 + 5` == `50` +assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"}) diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/src/test/rustdoc-gui/docblock-table-overflow.goml index af76d2ea4..d8670089a 100644 --- a/src/test/rustdoc-gui/docblock-table-overflow.goml +++ b/src/test/rustdoc-gui/docblock-table-overflow.goml @@ -1,12 +1,12 @@ // 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 +goto: "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) // 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": "801"}) +assert-property: (".top-doc .docblock", {"scrollWidth": "816"}) // However, since there is overflow in the <table>, its scroll width is bigger. -assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"}) +assert-property: (".top-doc .docblock table", {"scrollWidth": "1572"}) // Checking it works on other doc blocks as well... @@ -16,6 +16,6 @@ compare-elements-property: ( "#implementations-list > details .docblock > p", ["scrollWidth"], ) -assert-property: ("#implementations-list > details .docblock", {"scrollWidth": "801"}) +assert-property: ("#implementations-list > details .docblock", {"scrollWidth": "816"}) // However, since there is overflow in the <table>, its scroll width is bigger. -assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1573"}) +assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1572"}) diff --git a/src/test/rustdoc-gui/docblock-table.goml b/src/test/rustdoc-gui/docblock-table.goml new file mode 100644 index 000000000..4e316ce0b --- /dev/null +++ b/src/test/rustdoc-gui/docblock-table.goml @@ -0,0 +1,4 @@ +goto: "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"]) diff --git a/src/test/rustdoc-gui/duplicate-macro-reexport.goml b/src/test/rustdoc-gui/duplicate-macro-reexport.goml index 9ea599062..496203c12 100644 --- a/src/test/rustdoc-gui/duplicate-macro-reexport.goml +++ b/src/test/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 +goto: "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/src/test/rustdoc-gui/escape-key.goml b/src/test/rustdoc-gui/escape-key.goml index a5afb037d..78e9f2309 100644 --- a/src/test/rustdoc-gui/escape-key.goml +++ b/src/test/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 +goto: "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/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml index 5f29fde66..8ba005b0c 100644 --- a/src/test/rustdoc-gui/font-weight.goml +++ b/src/test/rustdoc-gui/font-weight.goml @@ -1,6 +1,6 @@ // This test checks that the font weight is correctly applied. -goto: file://|DOC_PATH|/lib2/struct.Foo.html -assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"}) +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +assert-css: ("//*[@class='item-decl']//a[text()='Alias']", {"font-weight": "400"}) assert-css: ( "//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"}, @@ -9,17 +9,17 @@ 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 +goto: "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 -assert-css: (".impl-items .method", {"font-weight": "600"}, ALL) +goto: "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 +goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // This is a complex selector, so here's how it works: // -// * //*[@class='docblock item-decl'] โ selects element of any tag with classes docblock and item-decl +// * //*[@class='item-decl'] โ selects element of any tag with classes docblock and item-decl // * /pre[@class='rust trait'] โ selects immediate child with tag pre and classes rust and trait // * /code โ selects immediate child with tag code // * /a[@class='constant'] โ selects immediate child with tag a and class constant @@ -29,11 +29,11 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html // This uses '/parent::*' as a proxy for the style of the text node. // We can't just select the '<a>' because intermediate tags could be added. assert-count: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1, ) assert-css: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"}, ) @@ -41,4 +41,4 @@ assert-count: (".methods .associatedtype", 1) assert-css: (".methods .associatedtype", {"font-weight": "600"}) assert-count: (".methods .constant", 1) assert-css: (".methods .constant", {"font-weight": "600"}) -assert-css: (".methods .method", {"font-weight": "600"}) +assert-css: (".methods .method > .code-header", {"font-weight": "600"}) diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/src/test/rustdoc-gui/hash-item-expansion.goml index 861f69283..3cf94f624 100644 --- a/src/test/rustdoc-gui/hash-item-expansion.goml +++ b/src/test/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 +goto: "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/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index a47a9c8a1..c80a49c52 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -1,117 +1,70 @@ // This test check for headers text and background colors for the different themes. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html -// This is needed so that the text color is computed. -show-text: true - -// Ayu theme -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".impl", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, - ALL, +define-function: ( + "check-colors", + (theme, color, code_header_color, focus_background_color, headings_color), + [ + ("goto", "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"}), + ("reload"), + ("assert-css", ( + ".impl", + {"color": |color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("assert-css", ( + ".impl .code-header", + {"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("goto", "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"), + ("assert-css", ( + "#method\.must_use", + {"color": |color|, "background-color": |focus_background_color|}, + ALL, + )), + ("goto", "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"), + // We select headings (h2, h3, h...). + ("assert-css", (".docblock > :not(p) > a", {"color": |headings_color|}, ALL)), + ], ) -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ( - "#impl-Foo", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, +call-function: ( + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "code_header_color": "rgb(230, 225, 207)", + "focus_background_color": "rgba(255, 236, 164, 0.06)", + "headings_color": "rgb(57, 175, 215)", + }, ) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "code_header_color": "rgb(221, 221, 221)", + "focus_background_color": "rgb(73, 74, 61)", + "headings_color": "rgb(210, 153, 29)", + }, ) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL) - -// Dark theme -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -goto: file://|DOC_PATH|/test_docs/struct.Foo.html - -assert-css: ( - ".impl", - {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ( - "#impl-Foo", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "code_header_color": "rgb(0, 0, 0)", + "focus_background_color": "rgb(253, 255, 211)", + "headings_color": "rgb(56, 115, 173)", + }, ) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL) - -// Light theme -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html - -assert-css: ( - ".impl", - {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ("#impl-Foo", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL) diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml index 8c2c3df15..85e17ca95 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" assert-css: ("h1.fqn", {"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 +goto: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -106,10 +106,10 @@ assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0 assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"}) -assert-text: (".sidebar .mod h3", "Modules") -assert-css: (".sidebar .mod h3", {"border-bottom-width": "0px"}, ALL) +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 +goto: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html" assert-css: ("h1.fqn", {"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 +goto: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -150,109 +150,85 @@ assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) -// Checking colors now. +// Needed to check colors show-text: true -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) - -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) - -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) - -local-storage: {"rustdoc-theme": "light"} -goto: file://|DOC_PATH|/staged_api/struct.Foo.html -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) - -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) - -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" + +define-function: ( + "check-colors", + (theme, heading_color, small_heading_color, heading_border_color), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".top-doc .docblock h2", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h3", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h4", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h4", + {"color": |heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h6", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ], +) +call-function: ( + "check-colors", + { + "theme": "ayu", + "heading_color": "rgb(255, 255, 255)", + "small_heading_color": "rgb(197, 197, 197)", + "heading_border_color": "rgb(92, 103, 115)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "heading_color": "rgb(221, 221, 221)", + "small_heading_color": "rgb(221, 221, 221)", + "heading_border_color": "rgb(210, 210, 210)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "heading_color": "rgb(0, 0, 0)", + "small_heading_color": "rgb(0, 0, 0)", + "heading_border_color": "rgb(221, 221, 221)", + }, +) + +define-function: ( + "check-since-color", + (theme), + [ + ("local-storage", {"rustdoc-theme": |theme|}), + ("reload"), + ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)), + ], +) + +goto: "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/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml new file mode 100644 index 000000000..521e14748 --- /dev/null +++ b/src/test/rustdoc-gui/help-page.goml @@ -0,0 +1,24 @@ +// 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. +wait-for: "#help" +assert-css: ("#help", {"display": "block"}) +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. +assert-css: ("#help", {"display": "block"}) +compare-elements-property: (".sub", "#help", ["offsetWidth"]) +compare-elements-position: (".sub", "#help", ("x")) + +// 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. +assert-false: "#help" +click: "#help-button > a" +assert-css: ("#help", {"display": "block"}) +click: "#help-button > a" +assert-css: ("#help", {"display": "none"}) +compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) +compare-elements-position-false: (".sub", "#help", ("x")) diff --git a/src/test/rustdoc-gui/highlight-colors.goml b/src/test/rustdoc-gui/highlight-colors.goml new file mode 100644 index 000000000..51693314e --- /dev/null +++ b/src/test/rustdoc-gui/highlight-colors.goml @@ -0,0 +1,94 @@ +// This test checks the highlight colors in the source code pages. +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +show-text: true + +define-function: ( + "check-colors", + ( + theme, + kw, + kw2, + prelude_ty, + prelude_val, + lifetime, + number, + string, + bool_val, + self, + attribute, + macro, + question_mark, + comment, + doc_comment, + ), + [ + ("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)), + ("assert-css", ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)), + ("assert-css", ("pre.rust .prelude-val", {"color": |prelude_val|}, ALL)), + ("assert-css", ("pre.rust .lifetime", {"color": |lifetime|}, ALL)), + ("assert-css", ("pre.rust .number", {"color": |number|}, ALL)), + ("assert-css", ("pre.rust .string", {"color": |string|}, ALL)), + ("assert-css", ("pre.rust .bool-val", {"color": |bool_val|}, ALL)), + ("assert-css", ("pre.rust .self", {"color": |self|}, ALL)), + ("assert-css", ("pre.rust .attribute", {"color": |attribute|}, ALL)), + ("assert-css", ("pre.rust .macro", {"color": |macro|}, ALL)), + ("assert-css", ("pre.rust .question-mark", {"color": |question_mark|}, ALL)), + ("assert-css", ("pre.rust .comment", {"color": |comment|}, ALL)), + ("assert-css", ("pre.rust .doccomment", {"color": |doc_comment|}, ALL)), + ], +) + +call-function: ("check-colors", { + "theme": "ayu", + "kw": "rgb(255, 119, 51)", + "kw2": "rgb(255, 119, 51)", + "prelude_ty": "rgb(105, 242, 223)", + "prelude_val": "rgb(255, 119, 51)", + "lifetime": "rgb(255, 119, 51)", + "number": "rgb(184, 204, 82)", + "string": "rgb(184, 204, 82)", + "bool_val": "rgb(255, 119, 51)", + "self": "rgb(54, 163, 217)", + "attribute": "rgb(230, 225, 207)", + "macro": "rgb(163, 122, 204)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(120, 135, 151)", + "doc_comment": "rgb(161, 172, 136)", +}) +call-function: ("check-colors", { + "theme": "dark", + "kw": "rgb(171, 138, 193)", + "kw2": "rgb(118, 154, 203)", + "prelude_ty": "rgb(118, 154, 203)", + "prelude_val": "rgb(238, 104, 104)", + "lifetime": "rgb(217, 127, 38)", + "number": "rgb(131, 163, 0)", + "string": "rgb(131, 163, 0)", + "bool_val": "rgb(238, 104, 104)", + "self": "rgb(238, 104, 104)", + "attribute": "rgb(238, 104, 104)", + "macro": "rgb(62, 153, 159)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(141, 141, 139)", + "doc_comment": "rgb(140, 163, 117)", +}) +call-function: ("check-colors", { + "theme": "light", + "kw": "rgb(137, 89, 168)", + "kw2": "rgb(66, 113, 174)", + "prelude_ty": "rgb(66, 113, 174)", + "prelude_val": "rgb(200, 40, 41)", + "lifetime": "rgb(183, 101, 20)", + "number": "rgb(113, 140, 0)", + "string": "rgb(113, 140, 0)", + "bool_val": "rgb(200, 40, 41)", + "self": "rgb(200, 40, 41)", + "attribute": "rgb(200, 40, 41)", + "macro": "rgb(62, 153, 159)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(142, 144, 140)", + "doc_comment": "rgb(77, 77, 76)", +}) diff --git a/src/test/rustdoc-gui/huge-collection-of-constants.goml b/src/test/rustdoc-gui/huge-collection-of-constants.goml index 4f75b5841..3ccd33f1c 100644 --- a/src/test/rustdoc-gui/huge-collection-of-constants.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/huge_amount_of_consts/index.html" compare-elements-position-near-false: ( "//*[@class='item-table']//div[last()-1]", diff --git a/src/test/rustdoc-gui/impl-default-expansion.goml b/src/test/rustdoc-gui/impl-default-expansion.goml index 6df2661e6..c3f9240cc 100644 --- a/src/test/rustdoc-gui/impl-default-expansion.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-attribute: ("#implementations-list details.implementors-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml index 666a6e125..4999283dc 100644 --- a/src/test/rustdoc-gui/implementors.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" assert: "#implementors-list" // There are supposed to be two implementors listed. assert-count: ("#implementors-list .impl", 2) @@ -8,28 +8,28 @@ assert-count: ("#implementors-list .impl", 2) assert: ("#implementors-list .impl:nth-child(1) > a.anchor") assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever-for-Struct"}) assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever-for-Struct"}) -assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band" +assert: "#implementors-list .impl:nth-child(1) > .code-header" assert: ("#implementors-list .impl:nth-child(2) > a.anchor") assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"}) assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"}) -assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band" +assert: "#implementors-list .impl:nth-child(2) > .code-header" -goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HasEmptyTraits.html" compare-elements-position-near-false: ( "#impl-EmptyTrait1-for-HasEmptyTraits", "#impl-EmptyTrait2-for-HasEmptyTraits", - {"y": 30}, + {"y": 34}, ) compare-elements-position-near: ( "#impl-EmptyTrait3-for-HasEmptyTraits h3", "#impl-EmptyTrait3-for-HasEmptyTraits .item-info", - {"y": 30}, + {"y": 34}, ) // 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 +goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) -goto: file://|DOC_PATH|/implementors/trait.TraitToReexport.html +goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) diff --git a/src/test/rustdoc-gui/item-decl-colors.goml b/src/test/rustdoc-gui/item-decl-colors.goml new file mode 100644 index 000000000..ce688287a --- /dev/null +++ b/src/test/rustdoc-gui/item-decl-colors.goml @@ -0,0 +1,74 @@ +// This test ensures that the color of the items in the type decl are working as expected. +define-function: ( + "check-colors", + ( + theme, + attr_color, + trait_color, + struct_color, + enum_color, + primitive_color, + constant_color, + fn_color, + assoc_type_color, + ), + [ + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"), + ("show-text", true), + ("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)), + // We need to add `code` here because otherwise it would select the parent too. + ("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)), + ("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"), + ("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)), + ("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)), + ("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)), + ], +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(57, 175, 215)", + "struct_color": "rgb(255, 160, 165)", + "enum_color": "rgb(255, 160, 165)", + "primitive_color": "rgb(255, 160, 165)", + "constant_color": "rgb(57, 175, 215)", + "fn_color": "rgb(253, 214, 135)", + "assoc_type_color": "rgb(57, 175, 215)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(183, 140, 242)", + "struct_color": "rgb(45, 191, 184)", + "enum_color": "rgb(45, 191, 184)", + "primitive_color": "rgb(45, 191, 184)", + "constant_color": "rgb(210, 153, 29)", + "fn_color": "rgb(43, 171, 99)", + "assoc_type_color": "rgb(210, 153, 29)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(110, 79, 201)", + "struct_color": "rgb(173, 55, 138)", + "enum_color": "rgb(173, 55, 138)", + "primitive_color": "rgb(173, 55, 138)", + "constant_color": "rgb(56, 115, 173)", + "fn_color": "rgb(173, 124, 55)", + "assoc_type_color": "rgb(56, 115, 173)", + }, +) diff --git a/src/test/rustdoc-gui/item-info-alignment.goml b/src/test/rustdoc-gui/item-info-alignment.goml new file mode 100644 index 000000000..94b52f005 --- /dev/null +++ b/src/test/rustdoc-gui/item-info-alignment.goml @@ -0,0 +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" + +// First, we try it in "desktop" mode. +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) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) diff --git a/src/test/rustdoc-gui/item-info-overflow.goml b/src/test/rustdoc-gui/item-info-overflow.goml index b7095a3c5..8ea14621c 100644 --- a/src/test/rustdoc-gui/item-info-overflow.goml +++ b/src/test/rustdoc-gui/item-info-overflow.goml @@ -1,10 +1,10 @@ // This test ensures that the "item-info" elements don't overflow. -goto: file://|DOC_PATH|/lib2/struct.LongItemInfo.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo.html" // We set a fixed size so there is no chance of "random" resize. size: (1200, 870) // Logically, the "item-decl" and the "item-info" should have the same scroll width. -compare-elements-property: (".docblock.item-decl", ".item-info", ["scrollWidth"]) -assert-property: (".item-info", {"scrollWidth": "890"}) +compare-elements-property: (".item-decl", ".item-info", ["scrollWidth"]) +assert-property: (".item-info", {"scrollWidth": "940"}) // Just to be sure we're comparing the correct "item-info": assert-text: ( ".item-info", @@ -13,7 +13,7 @@ assert-text: ( ) // Checking the "item-info" on an impl block as well: -goto: file://|DOC_PATH|/lib2/struct.LongItemInfo2.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo2.html" compare-elements-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", "#impl-SimpleTrait-for-LongItemInfo2 + .docblock", @@ -21,7 +21,7 @@ compare-elements-property: ( ) assert-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", - {"scrollWidth": "866"}, + {"scrollWidth": "916"}, ) // Just to be sure we're comparing the correct "item-info": assert-text: ( diff --git a/src/test/rustdoc-gui/item-info.goml b/src/test/rustdoc-gui/item-info.goml index 50c45b76b..6780dfca6 100644 --- a/src/test/rustdoc-gui/item-info.goml +++ b/src/test/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 +goto: "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) // We check that ".item-info" is bigger than its content. -assert-css: (".item-info", {"width": "790px"}) +assert-css: (".item-info", {"width": "840px"}) assert-css: (".item-info .stab", {"width": "289px"}) -assert-position: (".item-info .stab", {"x": 295}) +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 +goto: "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/src/test/rustdoc-gui/item-summary-table.goml b/src/test/rustdoc-gui/item-summary-table.goml index 6bf4e288c..2a92e9da5 100644 --- a/src/test/rustdoc-gui/item-summary-table.goml +++ b/src/test/rustdoc-gui/item-summary-table.goml @@ -1,6 +1,6 @@ // This test ensures that <table> elements aren't display in items summary. -goto: file://|DOC_PATH|/lib2/summary_table/index.html +goto: "file://" + |DOC_PATH| + "/lib2/summary_table/index.html" // We check that we picked the right item first. assert-text: (".item-table .item-left", "Foo") // Then we check that its summary is empty. -assert-text: (".item-table .item-right", "") +assert-false: ".item-table .item-right" diff --git a/src/test/rustdoc-gui/javascript-disabled.goml b/src/test/rustdoc-gui/javascript-disabled.goml index 1693f7b64..edf179d0d 100644 --- a/src/test/rustdoc-gui/javascript-disabled.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-css: (".sub", {"display": "none"}) diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml index d17400f5b..b65faf13d 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -1,43 +1,22 @@ // 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 +goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" -// Set the theme to dark. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, -) - -// Set the theme to ayu. -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, +define-function: ( + "check-background-color", + (theme, background_color), + [ + // Set the theme. + ("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", ( + "body.source .example-wrap pre.rust a", + {"background-color": |background_color|}, + ALL, + )), + ], ) -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(238, 238, 238)"}, - ALL, -) +call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("dark", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("light", "rgb(238, 238, 238)")) diff --git a/src/test/rustdoc-gui/label-next-to-symbol.goml b/src/test/rustdoc-gui/label-next-to-symbol.goml index ca3994a08..05f8ddc71 100644 --- a/src/test/rustdoc-gui/label-next-to-symbol.goml +++ b/src/test/rustdoc-gui/label-next-to-symbol.goml @@ -1,20 +1,20 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // Desktop view size: (1080, 600) assert: (".stab.deprecated") assert: (".stab.portability") -// make sure that deprecated and portability are different colours +// make sure that deprecated and portability have the right colors assert-css: ( ".item-table .item-left .stab.deprecated", - { "background-color": "rgb(255, 196, 196)" }, + { "background-color": "rgb(255, 245, 214)" }, ) assert-css: ( ".item-table .item-left .stab.portability", - { "background-color": "rgb(243, 223, 255)" }, + { "background-color": "rgb(255, 245, 214)" }, ) // table like view @@ -31,15 +31,9 @@ compare-elements-position: ( ) // Ensure no wrap -compare-elements-position-near: ( - "//*[@class='item-left module-item']//a[text()='replaced_function']", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", - {"y": 2}, -) -// compare parent elements compare-elements-position: ( "//*[@class='item-left module-item']//a[text()='replaced_function']/..", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) @@ -51,7 +45,7 @@ assert-css: (".item-right.docblock-short", { "padding-left": "32px" }) compare-elements-position-near: ( "//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", - {"y": 1}, + {"y": 2}, ) compare-elements-position: ( ".item-left .stab.deprecated", @@ -60,19 +54,13 @@ compare-elements-position: ( ) // Ensure wrap -compare-elements-position-near-false: ( - "//*[@class='item-left module-item']//a[text()='replaced_function']", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", - {"y": 12}, -) -// compare parent elements compare-elements-position-false: ( "//*[@class='item-left module-item']//a[text()='replaced_function']/..", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) compare-elements-position-false: ( ".item-left .stab.deprecated", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) diff --git a/src/test/rustdoc-gui/links-color.goml b/src/test/rustdoc-gui/links-color.goml new file mode 100644 index 000000000..839629ad9 --- /dev/null +++ b/src/test/rustdoc-gui/links-color.goml @@ -0,0 +1,85 @@ +// This test checks links colors. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +// This is needed so that the text color is computed. +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(57, 175, 215)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(163, 122, 204)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(57, 175, 215)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(253, 214, 135)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(57, 175, 215)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "500"}, + ALL, +) + + +// Dark theme +local-storage: {"rustdoc-theme": "dark"} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(210, 153, 29)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(9, 189, 0)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(183, 140, 242)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(43, 171, 99)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(210, 153, 29)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)", "font-weight": "500"}, + ALL, +) + + +// Light theme +local-storage: {"rustdoc-theme": "light"} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(56, 115, 173)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(6, 128, 0)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(110, 79, 201)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(173, 124, 55)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(56, 115, 173)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)", "font-weight": "500"}, + ALL, +) diff --git a/src/test/rustdoc-gui/list_code_block.goml b/src/test/rustdoc-gui/list_code_block.goml index eba1a662b..3423a449d 100644 --- a/src/test/rustdoc-gui/list_code_block.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +goto: "./fn.check_list_code_block.html" assert: ("pre.rust.fn") diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml index 13b9b563d..704542a39 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/src/test/rustdoc-gui/mobile.goml @@ -1,5 +1,5 @@ // Test various properties of the mobile UI -goto: file://|DOC_PATH|/staged_api/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" size: (400, 600) font-size: 18 @@ -12,7 +12,7 @@ assert-css: (".main-heading", { "flex-direction": "column" }) -assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) +assert-property: (".mobile-topbar h2", {"offsetHeight": 36}) // Note: We can't use assert-text here because the 'Since' is set by CSS and // is therefore not part of the DOM. @@ -24,7 +24,7 @@ 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 +goto: "file://" + |DOC_PATH| + "/settings.html" size: (400, 600) // Ignored for now https://github.com/rust-lang/rust/issues/93784. // compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml index 758ee391a..cd3676a98 100644 --- a/src/test/rustdoc-gui/module-items-font.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-css: ( ".item-table .module-item a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, diff --git a/src/test/rustdoc-gui/no-docblock.goml b/src/test/rustdoc-gui/no-docblock.goml new file mode 100644 index 000000000..2366a60f5 --- /dev/null +++ b/src/test/rustdoc-gui/no-docblock.goml @@ -0,0 +1,8 @@ +// This test checks that there are margins applied to methods with no docblocks. +goto: "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" +// 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/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml new file mode 100644 index 000000000..efe0cb15f --- /dev/null +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -0,0 +1,128 @@ +// This test checks the position of the `i` for the notable traits. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" +show-text: true +// We start with a wide screen. +size: (1100, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 677}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 951}, +) +// The tooltip should be beside the `i` +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" +compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"y": 2} +) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + ("x") +) +// The docblock should be flush with the border. +assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']/*[@class='docblock']", + {"margin-left": "0px"} +) + +// Now only the `i` should be on the next line. +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='notable-traits']", + ("y", "x"), +) + +// Now both the `i` and the struct name should be on the next line. +size: (980, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 245}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 519}, +) + +// Checking on mobile now. +size: (650, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 15}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 289}, +) +// The tooltip should be below `i` +compare-elements-position-near-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"y": 2} +) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + ("x") +) +compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']/parent::*", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"x": 5} +) +// The docblock should be flush with the border. +assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']/*[@class='docblock']", + {"margin-left": "0px"} +) + +// Checking on very small mobile. The `i` should be on its own line. +size: (365, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y", "x"), +) diff --git a/src/test/rustdoc-gui/overflow-tooltip-information.goml b/src/test/rustdoc-gui/overflow-tooltip-information.goml index 7ef85a4c4..09ad6cdd7 100644 --- a/src/test/rustdoc-gui/overflow-tooltip-information.goml +++ b/src/test/rustdoc-gui/overflow-tooltip-information.goml @@ -1,8 +1,8 @@ // 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 -assert-css: (".docblock > .information", { +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +assert-css: (".docblock > .example-wrap .tooltip", { "overflow-x": "visible", "max-width": "none" }, ALL) diff --git a/src/test/rustdoc-gui/pocket-menu.goml b/src/test/rustdoc-gui/pocket-menu.goml index 54f3790a7..fb63ea62a 100644 --- a/src/test/rustdoc-gui/pocket-menu.goml +++ b/src/test/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 +goto: "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. @@ -56,7 +56,7 @@ reload: click: "#help-button" assert-css: ( "#help-button .popover", - {"display": "block", "border-color": "rgb(210, 210, 210)"}, + {"display": "block", "border-color": "rgb(224, 224, 224)"}, ) compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) @@ -71,7 +71,7 @@ reload: click: "#help-button" assert-css: ( "#help-button .popover", - {"display": "block", "border-color": "rgb(221, 221, 221)"}, + {"display": "block", "border-color": "rgb(224, 224, 224)"}, ) compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/src/test/rustdoc-gui/run-on-hover.goml index b8efa8e30..6c785e1c4 100644 --- a/src/test/rustdoc-gui/run-on-hover.goml +++ b/src/test/rustdoc-gui/run-on-hover.goml @@ -1,7 +1,7 @@ // Example code blocks sometimes have a "Run" button to run them on the // 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. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" assert-css: (".test-arrow", {"visibility": "hidden"}) move-cursor-to: ".example-wrap" assert-css: (".test-arrow", {"visibility": "visible"}) diff --git a/src/test/rustdoc-gui/rust-logo.goml b/src/test/rustdoc-gui/rust-logo.goml index 4a9dcf735..6c8dc8594 100644 --- a/src/test/rustdoc-gui/rust-logo.goml +++ b/src/test/rustdoc-gui/rust-logo.goml @@ -1,78 +1,34 @@ // This test ensures that the correct style is applied to the rust logo in the sidebar. -goto: file://|DOC_PATH|/test_docs/index.html - -// First we start with the dark theme. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, -) - -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, -) - -// Then with the ayu theme. -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +define-function: ( + "check-logo", + (theme, filter), + [ + // Going to the doc page. + ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), + // Changing theme. + ("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"), + // Changing theme (since it's local files, the local storage works by folder). + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", (".rust-logo", {"filter": |filter|})), + ], ) -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +call-function: ( + "check-logo", + ("ayu", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), ) - -// And finally with the light theme. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "none"}, +call-function: ( + "check-logo", + ("dark", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), ) - -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "none"}, +call-function: ( + "check-logo", + ("light", "none"), ) diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml index d645e2370..27db816e6 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true write: (".search-input", "test") // To be SURE that the search will be run. @@ -40,16 +40,16 @@ press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#titles" -assert-property: ("#crate-search", {"value": "All crates"}) +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 +goto: "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" -// Checking that the text for the "title" is correct (the "All" comes from the "<select>"). -assert-text: ("#search-settings", "Results for test in All", STARTS_WITH) +// Checking that the text for the "title" is correct (the "all crates" comes from the "<select>"). +assert-text: (".search-results-title", "Results in all crates", STARTS_WITH) // Checking the display of the crate filter. // We start with the light theme. @@ -69,15 +69,15 @@ click: "#settings-menu" wait-for: "#settings" click: "#theme-dark" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - "background-color": "rgb(240, 240, 240)", + "border": "1px solid rgb(224, 224, 224)", + "color": "rgb(221, 221, 221)", + "background-color": "rgb(53, 53, 53)", }) // And finally we check the ayu theme. click: "#theme-ayu" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(66, 76, 87)", - "color": "rgb(197, 197, 197)", - "background-color": "rgb(20, 25, 32)", + "border": "1px solid rgb(92, 103, 115)", + "color": "rgb(255, 255, 255)", + "background-color": "rgb(15, 20, 25)", }) diff --git a/src/test/rustdoc-gui/search-form-elements.goml b/src/test/rustdoc-gui/search-form-elements.goml new file mode 100644 index 000000000..542db348c --- /dev/null +++ b/src/test/rustdoc-gui/search-form-elements.goml @@ -0,0 +1,263 @@ +// This test ensures that the elements in ".search-form" have the expected display. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + "color": "rgb(255, 255, 255)", + }, +) +focus: ".search-input" +// Nothing should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + "color": "rgb(255, 255, 255)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(197, 197, 197)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(255, 255, 255)", + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(197, 197, 197)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(255, 255, 255)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(20, 25, 32)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(57, 175, 215)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(197, 197, 197)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(197, 197, 197)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(20, 25, 32)", + }, +) + +// Dark theme +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + "color": "rgb(17, 17, 17)", + }, +) +focus: ".search-input" +// Only "border-color" should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(0, 141, 253)", + "background-color": "rgb(240, 240, 240)", + "color": "rgb(17, 17, 17)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(221, 221, 221)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(221, 221, 221)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(255, 185, 0)", + "background-color": "rgb(240, 240, 240)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(210, 153, 29)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(221, 221, 221)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(221, 221, 221)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(255, 185, 0)", + "background-color": "rgb(240, 240, 240)", + }, +) + +// Light theme +local-storage: { + "rustdoc-theme": "light", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + "color": "rgb(0, 0, 0)", + }, +) +focus: ".search-input" +// Nothing should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(102, 175, 233)", + "background-color": "rgb(255, 255, 255)", + "color": "rgb(0, 0, 0)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(0, 0, 0)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(0, 0, 0)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(113, 113, 113)", + "background-color": "rgb(255, 255, 255)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(56, 115, 173)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(0, 0, 0)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(0, 0, 0)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(113, 113, 113)", + "background-color": "rgb(255, 255, 255)", + }, +) diff --git a/src/test/rustdoc-gui/search-input-mobile.goml b/src/test/rustdoc-gui/search-input-mobile.goml index 5c95db70a..ce0cef77c 100644 --- a/src/test/rustdoc-gui/search-input-mobile.goml +++ b/src/test/rustdoc-gui/search-input-mobile.goml @@ -1,6 +1,6 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" size: (463, 700) // We first check that the search input isn't already focused. assert-false: ("input.search-input:focus") diff --git a/src/test/rustdoc-gui/search-input.goml b/src/test/rustdoc-gui/search-input.goml deleted file mode 100644 index 44123b702..000000000 --- a/src/test/rustdoc-gui/search-input.goml +++ /dev/null @@ -1,23 +0,0 @@ -// Ensures that the search input border color changes on focus. -goto: file://|DOC_PATH|/test_docs/index.html -local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(224, 224, 224)"}) -click: ".search-input" -focus: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(0, 141, 253)"}) - -local-storage: {"rustdoc-theme": "light"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(224, 224, 224)"}) -click: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(102, 175, 233)"}) - -local-storage: {"rustdoc-theme": "ayu"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(66, 76, 87)"}) -click: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(66, 76, 87)"}) diff --git a/src/test/rustdoc-gui/search-reexport.goml b/src/test/rustdoc-gui/search-reexport.goml index 5ef890d47..dd19f03bd 100644 --- a/src/test/rustdoc-gui/search-reexport.goml +++ b/src/test/rustdoc-gui/search-reexport.goml @@ -1,6 +1,6 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" 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. diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 9a49ae2c6..69bb30df9 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -1,5 +1,58 @@ // The goal of this test is to ensure the color of the text is the one expected. -goto: file://|DOC_PATH|/test_docs/index.html?search=coo + +define-function: ( + "check-result-color", + (result_kind, color, hover_color), + [ + ( + "assert-css", + (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL), + ), + ( + "assert-css", + ( + ".result-" + |result_kind|, + {"color": |entry_color|, "background-color": |background_color|}, + ), + ), + ( + "move-cursor-to", + ".result-" + |result_kind|, + ), + ( + "assert-css", + ( + ".result-" + |result_kind| + ":hover", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ), + ), + ( + "assert-css", + (".result-" + |result_kind| + ":hover ." + |result_kind|, {"color": |hover_color|}), + ), + ( + "move-cursor-to", + ".search-input", + ), + ( + "focus", + ".result-" + |result_kind|, + ), + ( + "assert-css", + ( + ".result-" + |result_kind| + ":focus", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ), + ), + ( + "assert-css", + (".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}), + ), + ], +) + +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" // This is needed so that the text color is computed. show-text: true @@ -7,7 +60,6 @@ show-text: true // Ayu theme local-storage: { "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false", } reload: @@ -23,16 +75,97 @@ assert-css: ( {"color": "rgb(0, 150, 207)"}, ) -// Checking the color for "keyword". +// Checking the color of "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(120, 135, 151)"}, ) +store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry +store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(57, 175, 215)", // color of item kind + "rgb(57, 175, 215)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(255, 160, 165)", // color of item kind + "rgb(255, 160, 165)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(57, 175, 215)", // color of item kind + "rgb(57, 175, 215)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(0, 150, 207)", // color of item kind + "rgb(255, 255, 255)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(163, 122, 204)", // color of item kind + "rgb(163, 122, 204)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) + +// Checking the `<a>` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) + +// Checking color and background on hover. +move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']" +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']", + {"color": "rgb(255, 255, 255)"}, +) +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"}, +) + // Dark theme local-storage: { "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false", } reload: @@ -48,12 +181,82 @@ assert-css: ( {"color": "rgb(221, 221, 221)"}, ) -// Checking the color for "keyword". +// Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"}, ) +store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry +store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(210, 153, 29)", // color of item kind + "rgb(210, 153, 29)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(45, 191, 184)", // color of item kind + "rgb(45, 191, 184)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(210, 153, 29)", // color of item kind + "rgb(210, 153, 29)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(221, 221, 221)", // color of item kind + "rgb(221, 221, 221)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(9, 189, 0)", // color of item kind + "rgb(9, 189, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) + +// Checking the `<a>` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, +) + // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: @@ -69,19 +272,88 @@ assert-css: ( {"color": "rgb(0, 0, 0)"}, ) -// Checking the color for "keyword". +// Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"}, ) +store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry +store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(56, 115, 173)", // color of item kind + "rgb(56, 115, 173)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(173, 55, 138)", // color of item kind + "rgb(173, 55, 138)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(56, 115, 173)", // color of item kind + "rgb(56, 115, 173)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(0, 0, 0)", // color of item kind + "rgb(0, 0, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(6, 128, 0)", // color of item kind + "rgb(6, 128, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) + +// Checking the `<a>` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, +) + // Check the alias more specifically in the dark theme. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // We set the theme so we're sure that the correct values will be used, whatever the computer // this test is running on. local-storage: { "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false", } // If the text isn't displayed, the browser doesn't compute color style correctly... diff --git a/src/test/rustdoc-gui/search-result-description.goml b/src/test/rustdoc-gui/search-result-description.goml index d8cb6ee57..53a335b63 100644 --- a/src/test/rustdoc-gui/search-result-description.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=some_more_function" // Waiting for the search results to appear... wait-for: "#titles" assert-text: (".search-results .desc code", "format!") diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index 8464ba7c2..053bfd8c9 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -1,29 +1,28 @@ // Checks that the search results have the expected width. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" size: (900, 1000) write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' -wait-for: "#search-settings" +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": "295px"}) +assert-css: (".search-results div.desc", {"width": "318px"}) 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": "570px"}) +assert-css: (".search-results div.desc", {"width": "566px"}) + +// The result set is all on one line. +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) -// First we check the current width and position. -assert-css: ("#crate-search", {"width": "218px"}) -compare-elements-position-near: ( - "#crate-search", - "#search-settings .search-results-title", - {"y": 5}, -) +// First we check the current width, height and position. +assert-css: ("#crate-search", {"width": "223px"}) +assert-css: (".search-results-title", {"height": "44px", "width": "336px"}) // Then we update the text of one of the `<option>`. text: ( @@ -31,12 +30,8 @@ text: ( "sdjfaksdjfaksjdbfkadsbfkjsadbfkdsbkfbsadkjfbkdsabfkadsfkjdsafa", ) -// Then we compare again. -assert-css: ("#crate-search", {"width": "640px"}) -compare-elements-position-near-false: ( - "#crate-search", - "#search-settings .search-results-title", - {"y": 5}, -) -// And we check that the `<select>` isn't bigger than its container. +// Then we compare again to confirm the height didn't change. +assert-css: ("#crate-search", {"width": "527px"}) +assert-css: (".search-results-title", {"height": "44px", "width": "640px"}) +// And we check that the `<select>` isn't bigger than its container (".search-results-title"). assert-css: ("#search", {"width": "640px"}) diff --git a/src/test/rustdoc-gui/search-result-go-to-first.goml b/src/test/rustdoc-gui/search-result-go-to-first.goml index 255470a3e..eeddf5ef6 100644 --- a/src/test/rustdoc-gui/search-result-go-to-first.goml +++ b/src/test/rustdoc-gui/search-result-go-to-first.goml @@ -2,18 +2,18 @@ // 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 -assert-text-false: (".fqn .in-band", "Struct test_docs::Foo") +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-text-false: (".fqn", "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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo" // Waiting for the search results to appear... wait-for: "#titles" -assert-text-false: (".fqn .in-band", "Struct test_docs::Foo") +assert-text-false: (".fqn", "Struct test_docs::Foo") // Ensure that the search results are displayed, not the "normal" content. 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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo&go_to_first=true" // Waiting for the page to load... -wait-for-text: (".fqn .in-band", "Struct test_docs::Foo") +wait-for-text: (".fqn", "Struct test_docs::Foo") diff --git a/src/test/rustdoc-gui/search-result-keyword.goml b/src/test/rustdoc-gui/search-result-keyword.goml index 16ae10431..66e63155a 100644 --- a/src/test/rustdoc-gui/search-result-keyword.goml +++ b/src/test/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 +goto: "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/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml b/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml index 9d506c151..a19dc6a8b 100644 --- a/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml +++ b/src/test/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 +goto: "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: ("#titles > button:nth-of-type(3)", {"class": "selected"}) // Now try search-by-return -goto: file://|DOC_PATH|/test_docs/index.html +goto: "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: ("#titles > button:nth-of-type(1)", {"class": "selected"}) // Try with a search-by-return with no results -goto: file://|DOC_PATH|/test_docs/index.html +goto: "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: ("#titles > button:nth-of-type(1)", {"class": "selected"}) assert-text: ("#titles > 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 +goto: "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: ("#titles > button:nth-of-type(1)", {"class": "selected"}) assert-text: ("#titles > 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 +goto: "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/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index d9cf5ee66..f258f4d2a 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -1,5 +1,6 @@ -// This test ensures that the settings menu display is working as expected. -goto: file://|DOC_PATH|/test_docs/index.html +// 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" show-text: true // needed when we check for colors below. // First, we check that the settings page doesn't exist. assert-false: "#settings" @@ -138,9 +139,15 @@ wait-for-css: ("#help-button .popover", {"display": "block"}) assert-css: ("#settings-menu .popover", {"display": "none"}) // Now we go to the settings page to check that the CSS is loaded as expected. -goto: file://|DOC_PATH|/settings.html +goto: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" -assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"}) +assert-css: ( + ".setting-line .toggle .slider", + {"width": "45px", "margin-right": "20px", "border": "0px none rgb(0, 0, 0)"}, +) + +assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS) +compare-elements-position: (".sub form", "#settings", ("x")) // We now check the display with JS disabled. assert-false: "noscript section" diff --git a/src/test/rustdoc-gui/shortcuts.goml b/src/test/rustdoc-gui/shortcuts.goml index 1f20a0eaa..9068680d6 100644 --- a/src/test/rustdoc-gui/shortcuts.goml +++ b/src/test/rustdoc-gui/shortcuts.goml @@ -1,5 +1,5 @@ // Check that the various shortcuts are working. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "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" @@ -11,3 +11,21 @@ press-key: "?" assert-css: ("#help-button .popover", {"display": "block"}) press-key: "Escape" assert-css: ("#help-button .popover", {"display": "none"}) +// Checking doc collapse and expand. +// It should be displaying a "-": +assert-text: ("#toggle-all-docs", "[\u2212]") +press-key: "-" +wait-for-text: ("#toggle-all-docs", "[+]") +assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) +// Pressing it again shouldn't do anything. +press-key: "-" +assert-text: ("#toggle-all-docs", "[+]") +assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) +// Expanding now. +press-key: "+" +wait-for-text: ("#toggle-all-docs", "[\u2212]") +assert-attribute: ("#toggle-all-docs", {"class": ""}) +// Pressing it again shouldn't do anything. +press-key: "+" +assert-text: ("#toggle-all-docs", "[\u2212]") +assert-attribute: ("#toggle-all-docs", {"class": ""}) diff --git a/src/test/rustdoc-gui/sidebar-links-color.goml b/src/test/rustdoc-gui/sidebar-links-color.goml new file mode 100644 index 000000000..18a1a3fad --- /dev/null +++ b/src/test/rustdoc-gui/sidebar-links-color.goml @@ -0,0 +1,233 @@ +// This test checks links colors in sidebar before and after hover. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" + +// This is needed so that the text color is computed. +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +// Struct +assert-css: ( + ".sidebar .block.struct a:not(.current)", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.struct a:not(.current)" +assert-css: ( + ".sidebar .block.struct a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Enum +assert-css: ( + ".sidebar .block.enum a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.enum a" +assert-css: ( + ".sidebar .block.enum a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Union +assert-css: ( + ".sidebar .block.union a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.union a" +assert-css: ( + ".sidebar .block.union a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Trait +assert-css: ( + ".sidebar .block.trait a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.trait a" +assert-css: ( + ".sidebar .block.trait a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Function +assert-css: ( + ".sidebar .block.fn a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.fn a" +assert-css: ( + ".sidebar .block.fn a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Type definition +assert-css: ( + ".sidebar .block.type a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.type a" +assert-css: ( + ".sidebar .block.type a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) +// Keyword +assert-css: ( + ".sidebar .block.keyword a", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.keyword a" +assert-css: ( + ".sidebar .block.keyword a:hover", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"}, +) + +// Dark theme +local-storage: {"rustdoc-theme": "dark"} +reload: + +// Struct +assert-css: ( + ".sidebar .block.struct a:not(.current)", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.struct a:not(.current)" +assert-css: ( + ".sidebar .block.struct a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Enum +assert-css: ( + ".sidebar .block.enum a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.enum a" +assert-css: ( + ".sidebar .block.enum a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Union +assert-css: ( + ".sidebar .block.union a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.union a" +assert-css: ( + ".sidebar .block.union a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Trait +assert-css: ( + ".sidebar .block.trait a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.trait a" +assert-css: ( + ".sidebar .block.trait a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Function +assert-css: ( + ".sidebar .block.fn a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.fn a" +assert-css: ( + ".sidebar .block.fn a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Type definition +assert-css: ( + ".sidebar .block.type a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.type a" +assert-css: ( + ".sidebar .block.type a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) +// Keyword +assert-css: ( + ".sidebar .block.keyword a", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.keyword a" +assert-css: ( + ".sidebar .block.keyword a:hover", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"}, +) + +// Light theme +local-storage: {"rustdoc-theme": "light"} +reload: + +// Struct +assert-css: ( + ".sidebar .block.struct a:not(.current)", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.struct a:not(.current)" +assert-css: ( + ".sidebar .block.struct a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Enum +assert-css: ( + ".sidebar .block.enum a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.enum a" +assert-css: ( + ".sidebar .block.enum a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Union +assert-css: ( + ".sidebar .block.union a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.union a" +assert-css: ( + ".sidebar .block.union a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Trait +assert-css: ( + ".sidebar .block.trait a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.trait a" +assert-css: ( + ".sidebar .block.trait a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Function +assert-css: ( + ".sidebar .block.fn a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.fn a" +assert-css: ( + ".sidebar .block.fn a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Type definition +assert-css: ( + ".sidebar .block.type a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.type a" +assert-css: ( + ".sidebar .block.type a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) +// Keyword +assert-css: ( + ".sidebar .block.keyword a", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"}, +) +move-cursor-to: ".sidebar .block.keyword a" +assert-css: ( + ".sidebar .block.keyword a:hover", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"}, +) diff --git a/src/test/rustdoc-gui/sidebar-macro-reexport.goml b/src/test/rustdoc-gui/sidebar-macro-reexport.goml index a3a62fe54..b5c1b6a43 100644 --- a/src/test/rustdoc-gui/sidebar-macro-reexport.goml +++ b/src/test/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 -wait-for: ".sidebar-elems .macro .macro" +goto: "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/src/test/rustdoc-gui/sidebar-mobile-scroll.goml b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml new file mode 100644 index 000000000..2449269b1 --- /dev/null +++ b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml @@ -0,0 +1,31 @@ +// 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": "627"} + +// 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": "627"} + +// 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": "627"} diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 033c65783..453873f1b 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -1,7 +1,7 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // Switching to "mobile view" by reducing the width to 600px. size: (600, 600) assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) @@ -13,7 +13,7 @@ click: ".sidebar-menu-toggle" assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) // Force the sidebar open by focusing a link inside it. // This makes it easier for keyboard users to get to it. -focus: ".sidebar-title a" +focus: ".sidebar-elems h3 a" assert-css: (".sidebar", {"display": "block", "left": "0px"}) // When we tab out of the sidebar, close it. focus: ".search-input" @@ -23,6 +23,11 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) click: ".sidebar-menu-toggle" assert-css: (".sidebar", {"left": "0px"}) +// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it. +assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"}) +// Make sure the global navigation is still here. +assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"}) + // Click elsewhere. click: "body" assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) @@ -39,26 +44,27 @@ assert-position: ("#method\.must_use", {"y": 45}) // Check that the bottom-most item on the sidebar menu can be scrolled fully into view. click: ".sidebar-menu-toggle" scroll-to: ".block.keyword li:nth-child(1)" -compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543}) +compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19}) // Now checking the background color of the sidebar. +show-text: true local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(80, 80, 80)"}) +assert-css: (".sidebar", {"background-color": "rgb(80, 80, 80)", "color": "rgb(221, 221, 221)"}) local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "ayu"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(20, 25, 31)"}) +assert-css: (".sidebar", {"background-color": "rgb(20, 25, 31)", "color": "rgb(197, 197, 197)"}) local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "light"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(245, 245, 245)"}) +assert-css: (".sidebar", {"background-color": "rgb(245, 245, 245)", "color": "rgb(0, 0, 0)"}) diff --git a/src/test/rustdoc-gui/sidebar-source-code-display.goml b/src/test/rustdoc-gui/sidebar-source-code-display.goml index fa322574f..4155dab64 100644 --- a/src/test/rustdoc-gui/sidebar-source-code-display.goml +++ b/src/test/rustdoc-gui/sidebar-source-code-display.goml @@ -1,22 +1,19 @@ // This test ensures that the elements in the sidebar are displayed correctly. javascript: false -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // Since the javascript is disabled, there shouldn't be a toggle. assert-false: "#sidebar-toggle" -// For some reason, we need to wait a bit here because it seems like the transition on opacity -// is being applied whereas it can't be reproduced in a browser... -wait-for-css: (".sidebar > *", {"visibility": "hidden", "opacity": 0}) +wait-for-css: (".sidebar", {"display": "none"}) // Let's retry with javascript enabled. javascript: true reload: wait-for: "#sidebar-toggle" -assert-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) -assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden", "opacity": 0}) +assert-css: ("#sidebar-toggle", {"visibility": "visible"}) +assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden"}) // Let's expand the sidebar now. click: "#sidebar-toggle" -// Because of the transition CSS, we check by using `wait-for-css` instead of `assert-css`. -wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) +wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) // We now check that opening the sidebar and clicking a link will leave it open. // The behavior here on desktop is different than the behavior on mobile, @@ -25,7 +22,7 @@ wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) 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 +goto: "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 +33,7 @@ show-text: true local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: // Waiting for the sidebar to be displayed... -wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) +wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) assert-css: ( "#source-sidebar details[open] > .files a.selected", {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, @@ -91,7 +88,7 @@ assert-css: ( local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: // Waiting for the sidebar to be displayed... -wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) +wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) assert-css: ( "#source-sidebar details[open] > .files > a.selected", {"color": "rgb(221, 221, 221)", "background-color": "rgb(51, 51, 51)"}, @@ -146,7 +143,7 @@ assert-css: ( local-storage: {"rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false"} reload: // Waiting for the sidebar to be displayed... -wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) +wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) assert-css: ( "#source-sidebar details[open] > .files a.selected", {"color": "rgb(255, 180, 76)", "background-color": "rgb(20, 25, 31)"}, @@ -201,7 +198,7 @@ assert-css: ( size: (500, 700) reload: // Waiting for the sidebar to be displayed... -wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1}) +wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) // We now check it takes the full size of the display. assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"}) @@ -224,14 +221,25 @@ click: "#sidebar-toggle" wait-for-css: (".sidebar", {"width": "0px"}) // We scroll to line 117 to change the scroll position. scroll-to: '//*[@id="117"]' -assert-window-property: {"pageYOffset": "2519"} +assert-window-property: {"pageYOffset": "2542"} // Expanding the sidebar... click: "#sidebar-toggle" wait-for-css: (".sidebar", {"width": "500px"}) click: "#sidebar-toggle" wait-for-css: (".sidebar", {"width": "0px"}) // The "scrollTop" property should be the same. -assert-window-property: {"pageYOffset": "2519"} +assert-window-property: {"pageYOffset": "2542"} + +// We now check that the scroll position is restored if the window is resized. +size: (500, 700) +click: "#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: "#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, @@ -242,7 +250,7 @@ click: "#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 +goto: "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. diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml index e882080c7..9ba663687 100644 --- a/src/test/rustdoc-gui/sidebar-source-code.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // First: desktop mode. size: (1100, 800) // We check that the sidebar isn't expanded and has the expected width. @@ -17,7 +17,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 +goto: "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. @@ -42,4 +42,4 @@ assert-false: ".source-sidebar-expanded" assert: "nav.sidebar" // Check that the topbar is not visible -assert-property: (".mobile-topbar", {"offsetParent": "null"}) +assert-false: ".mobile-topbar" diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index 32fe3334f..5058630f4 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -1,5 +1,6 @@ // Checks multiple things on the sidebar display (width of its elements, colors, etc). -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) show-text: true local-storage: {"rustdoc-theme": "light"} // We reload the page so the local storage settings are being used. @@ -8,26 +9,29 @@ reload: assert-text: (".sidebar > .location", "Crate test_docs") // In modules, we only have one "location" element. assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 1) assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"}) // We check that we have the crates list and that the "current" on is "test_docs". -assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs") +assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs") // And we're also supposed to have the list of items in the current module. assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports") assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules") assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros") assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs") assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums") -assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits") -assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions") -assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions") -assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions") -assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords") +assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants") +assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits") +assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions") +assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions") +assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords") assert-text: ("#structs + .item-table .item-left > a", "Foo") click: "#structs + .item-table .item-left > a" // PAGE: struct.Foo.html -assert-count: (".sidebar .location", 2) +assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 2) // We check that there is no crate listed outside of the top level. assert-false: ".sidebar-elems > .crate" @@ -38,38 +42,43 @@ 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 -assert-css: (".sidebar-elems .crate > ul > li:first-child > a", {"color": "rgb(53, 109, 164)"}) -click: ".sidebar-elems .crate > ul > li:first-child > a" +goto: "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 +goto: "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". -assert-text: (".sidebar-elems .crate > ul > li > a.current", "lib2") +assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2") // We now go to the "foobar" function page. -assert-text: (".sidebar-elems > section .block ul > li:nth-child(1)", "Modules") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(2)", "Structs") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(3)", "Traits") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(4)", "Functions") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(5)", "Type Definitions") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Definitions") assert-text: ("#functions + .item-table .item-left > a", "foobar") click: "#functions + .item-table .item-left > a" // PAGE: fn.foobar.html -// In items containing no items (like functions or constants) and in modules, we have one -// "location" elements. -assert-count: (".sidebar .location", 1) -assert-text: (".sidebar .sidebar-elems .location", "In lib2") +// In items containing no items (like functions or constants) and in modules, we have no +// "location" elements. Only the parent module h2. +assert-count: (".sidebar .location", 0) +assert-count: (".sidebar h2", 1) +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 +goto: "./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 +goto: "./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. assert-false: ".sidebar-elems .crate" @@ -77,12 +86,22 @@ assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-left > 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 +goto: "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 -click: ".block.mod h3 a" +goto: "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 assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"}) + +// Finally, assert that the `[+]/[โ]` toggle doesn't affect sidebar width. +click: "#toggle-all-docs" +assert-text: ("#toggle-all-docs", "[+]") +assert-property: (".sidebar", {"clientWidth": "200"}) +click: "#toggle-all-docs" +assert-text: ("#toggle-all-docs", "[โ]") +assert-property: (".sidebar", {"clientWidth": "200"})
\ No newline at end of file diff --git a/src/test/rustdoc-gui/source-anchor-scroll.goml b/src/test/rustdoc-gui/source-anchor-scroll.goml index 4e51c8dca..ddfe0c3d1 100644 --- a/src/test/rustdoc-gui/source-anchor-scroll.goml +++ b/src/test/rustdoc-gui/source-anchor-scroll.goml @@ -1,6 +1,6 @@ // 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 +goto: "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) @@ -10,7 +10,7 @@ assert-property: ("html", {"scrollTop": "0"}) click: '//a[text() = "barbar"]' assert-property: ("html", {"scrollTop": "125"}) click: '//a[text() = "bar"]' -assert-property: ("html", {"scrollTop": "166"}) +assert-property: ("html", {"scrollTop": "156"}) click: '//a[text() = "sub_fn"]' assert-property: ("html", {"scrollTop": "53"}) diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index 581f826a3..a2dac2aa6 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -1,30 +1,72 @@ // Checks that the interactions with the source code pages are working as expected. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +show-text: true // Check that we can click on the line number. -click: ".line-numbers > span:nth-child(4)" // This is the span for line 4. +click: ".src-line-numbers > span:nth-child(4)" // This is the span for line 4. // Ensure that the page URL was updated. assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH) assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) // We now check that the good spans are highlighted -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6 -assert-attribute-false: (".line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(5)", {"class": "line-highlighted"}) -assert-attribute: (".line-numbers > span:nth-child(6)", {"class": "line-highlighted"}) -assert-attribute-false: (".line-numbers > span:nth-child(7)", {"class": "line-highlighted"}) +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" +assert-attribute-false: (".src-line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(5)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > span:nth-child(6)", {"class": "line-highlighted"}) +assert-attribute-false: (".src-line-numbers > span:nth-child(7)", {"class": "line-highlighted"}) + +define-function: ( + "check-colors", + (theme, color, background_color, highlight_color, highlight_background_color), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".src-line-numbers > span:not(.line-highlighted)", + {"color": |color|, "background-color": |background_color|}, + ALL, + )), + ("assert-css", ( + ".src-line-numbers > span.line-highlighted", + {"color": |highlight_color|, "background-color": |highlight_background_color|}, + ALL, + )), + ], +) + +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(92, 103, 115)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(112, 128, 144)", + "highlight_background_color": "rgba(255, 236, 164, 0.06)", +}) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(59, 145, 226)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(59, 145, 226)", + "highlight_background_color": "rgb(10, 4, 47)", +}) +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(198, 126, 45)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(198, 126, 45)", + "highlight_background_color": "rgb(253, 255, 211)", +}) + // This is to ensure that the content is correctly align with the line numbers. compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) // Assert that the line numbers text is aligned to the right. -assert-css: (".line-numbers", {"text-align": "right"}) +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!). -show-text: true -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html +goto: "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": 104, "y": 103}) -// We click on the left of the "1" span but still in the "line-number" `<pre>`. +assert-position: ("//*[@id='1']", {"x": 104, "y": 112}) +// We click on the left of the "1" span but still in the "src-line-number" `<pre>`. click: (103, 103) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) @@ -47,3 +89,25 @@ assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) // Check the spacing. assert-css: ("#source-sidebar > details.dir-entry", {"padding-left": "4px"}) + +// Check the search form +assert-css: ("nav.sub", {"flex-direction": "row"}) +// The goal of this test is to ensure the search input is perfectly centered +// between the top of the page and the top of the gray code block. +// To check this, we maintain the invariant: +// +// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form] +assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 90}) +// 28 = 90 - 34 - 28 + +// Now do the same check on moderately-sized mobile. +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}) +// 21 = 76 - 34 - 21 + +// Tiny mobile gets a different display where the logo is stacked on top. +size: (450, 700) +assert-css: ("nav.sub", {"flex-direction": "column"}) diff --git a/src/test/rustdoc-gui/src-font-size.goml b/src/test/rustdoc-gui/src-font-size.goml index 0c01e2545..b17dfd94c 100644 --- a/src/test/rustdoc-gui/src-font-size.goml +++ b/src/test/rustdoc-gui/src-font-size.goml @@ -1,11 +1,11 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" show-text: true // Check the impl headers. -assert-css: (".impl.has-srclink .srclink", {"font-size": "16px"}, ALL) -assert-css: (".impl.has-srclink .code-header.in-band", {"font-size": "18px"}, ALL) +assert-css: (".impl.has-srclink .srclink", {"font-size": "16px", "font-weight": 400}, ALL) +assert-css: (".impl.has-srclink .code-header", {"font-size": "18px", "font-weight": 600}, ALL) // Check the impl items. -assert-css: (".impl-items .has-srclink .srclink", {"font-size": "16px"}, ALL) -assert-css: (".impl-items .has-srclink .code-header", {"font-size": "16px"}, ALL) +assert-css: (".impl-items .has-srclink .srclink", {"font-size": "16px", "font-weight": 400}, ALL) +assert-css: (".impl-items .has-srclink .code-header", {"font-size": "16px", "font-weight": 600}, ALL) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 87f91be3a..24aecc70d 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -38,11 +38,14 @@ pub trait Trait { #[deprecated = "Whatever [`Foo`](#tadam)"] fn foo() {} + fn fooo(); } impl Trait for Foo { type X = u32; const Y: u32 = 0; + + fn fooo() {} } impl implementors::Whatever for Foo { @@ -143,3 +146,40 @@ pub struct LongItemInfo2; /// Some docs. #[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))] impl SimpleTrait for LongItemInfo2 {} + +pub struct WhereWhitespace<T>; + +impl<T> WhereWhitespace<T> { + pub fn new<F>(f: F) -> Self + where + F: FnMut() -> i32, + {} +} + +impl<K, T> Whitespace<&K> for WhereWhitespace<T> +where + K: std::fmt::Debug, +{ + type Output = WhereWhitespace<T>; + fn index(&self, _key: &K) -> &Self::Output { + self + } +} + +pub trait Whitespace<Idx> +where + Idx: ?Sized, +{ + type Output; + fn index(&self, index: Idx) -> &Self::Output; +} + +pub struct ItemInfoAlignmentTest; + +impl ItemInfoAlignmentTest { + /// This method has docs + #[deprecated] + pub fn foo() {} + #[deprecated] + pub fn bar() {} +} diff --git a/src/test/rustdoc-gui/src/staged_api/Cargo.toml b/src/test/rustdoc-gui/src/staged_api/Cargo.toml index 117c4134e..b231be6ee 100644 --- a/src/test/rustdoc-gui/src/staged_api/Cargo.toml +++ b/src/test/rustdoc-gui/src/staged_api/Cargo.toml @@ -7,5 +7,6 @@ edition = "2021" path = "lib.rs" [features] -default = ["some_feature"] +default = ["some_feature", "some_other_feature"] some_feature = [] +some_other_feature = [] diff --git a/src/test/rustdoc-gui/src/staged_api/lib.rs b/src/test/rustdoc-gui/src/staged_api/lib.rs index 0cb460f03..5934593a8 100644 --- a/src/test/rustdoc-gui/src/staged_api/lib.rs +++ b/src/test/rustdoc-gui/src/staged_api/lib.rs @@ -7,4 +7,6 @@ pub struct Foo {} impl Foo { #[stable(feature = "some_feature", since = "1.3.5")] pub fn bar() {} + #[stable(feature = "some_other_feature", since = "1.3.6")] + pub fn yo() {} } diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 1b26aaecb..fdf97e492 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -5,6 +5,25 @@ #![crate_name = "test_docs"] #![feature(rustdoc_internals)] #![feature(doc_cfg)] +#![feature(associated_type_defaults)] + +/*! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! + +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. + +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +*/ use std::convert::AsRef; use std::fmt; @@ -28,6 +47,12 @@ use std::fmt; /// Let's say I'm just some text will ya? /// ``` /// +/// A failing to run one: +/// +/// ```should_panic +/// panic!("tadam"); +/// ``` +/// /// An inlined `code`! pub fn foo() {} @@ -292,4 +317,102 @@ pub mod details { /// <div>I'm the content of the details!</div> /// </details> pub struct Details; + + impl Details { + /// We check the appearance of the `<details>`/`<summary>` in here. + /// + /// ## Hello + /// + /// <details> + /// <summary><h4>I'm a summary</h4></summary> + /// <div>I'm the content of the details!</div> + /// </details> + pub fn method() {} + } +} + +pub mod doc_block_table { + + pub trait DocBlockTableTrait { + fn func(); + } + + /// Struct doc. + /// + /// | header1 | header2 | + /// |--------------------------|--------------------------| + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + pub struct DocBlockTable {} + + impl DocBlockTableTrait for DocBlockTable { + /// Trait impl func doc for struct. + /// + /// | header1 | header2 | + /// |--------------------------|--------------------------| + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + fn func() { + println!(); + } + } + +} + +pub struct NotableStructWithLongName<R>(R); + +impl<R: std::io::Read> NotableStructWithLongName<R> { + pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName<R> { Self(r) } +} + +impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> { + type Item = (); + + fn next(&mut self) -> Option<Self::Item> { () } +} + +pub trait TraitWithNoDocblocks { + fn first_fn(&self); + fn second_fn(&self); +} + +pub struct TypeWithNoDocblocks; + +impl TypeWithNoDocblocks { + fn x() -> Option<Self> { + Some(Self) + } + fn y() -> Option<u32> { + // code comment + let t = Self::x()?; + Some(0) + } +} + +impl TypeWithNoDocblocks { + pub fn first_fn(&self) {} + pub fn second_fn<'a>(&'a self) { + let x = 12; + let y = "a"; + let z = false; + } +} + +pub unsafe fn unsafe_fn() {} + +pub fn safe_fn() {} + +#[repr(C)] +pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> { + s: S, + t: T, + e: E, + p: P, +} + +pub const CONST: u8 = 0; + +pub trait TraitWithoutGenerics { + const C: u8 = CONST; + type T = SomeType; + + fn foo(); } diff --git a/src/test/rustdoc-gui/theme-change.goml b/src/test/rustdoc-gui/theme-change.goml index fb1c37ae6..b1de3c366 100644 --- a/src/test/rustdoc-gui/theme-change.goml +++ b/src/test/rustdoc-gui/theme-change.goml @@ -1,5 +1,5 @@ // Ensures that the theme change is working as expected. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} reload: click: "#settings-menu" @@ -17,7 +17,7 @@ click: "#theme-dark" wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" }) assert-local-storage: { "rustdoc-theme": "dark" } -goto: file://|DOC_PATH|/settings.html +goto: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" click: "#theme-light" wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" }) diff --git a/src/test/rustdoc-gui/theme-in-history.goml b/src/test/rustdoc-gui/theme-in-history.goml index f576ced1c..c29571728 100644 --- a/src/test/rustdoc-gui/theme-in-history.goml +++ b/src/test/rustdoc-gui/theme-in-history.goml @@ -1,5 +1,5 @@ // Ensures that the theme is working when going back in history. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // Set the theme to dark. local-storage: { "rustdoc-theme": "dark", @@ -12,7 +12,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 +goto: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" // We change the theme to "light". click: "#theme-light" diff --git a/src/test/rustdoc-gui/toggle-click-deadspace.goml b/src/test/rustdoc-gui/toggle-click-deadspace.goml index 4a328c9f9..029403ee1 100644 --- a/src/test/rustdoc-gui/toggle-click-deadspace.goml +++ b/src/test/rustdoc-gui/toggle-click-deadspace.goml @@ -1,12 +1,15 @@ // 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 +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) click: "h4.code-header" // This is the position of "pub" in "pub fn a_method" assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) -click: ".impl-items .rustdoc-toggle summary::before" // This is the position of "[-]" next to that pub fn. +click-with-offset: ( + ".impl-items .rustdoc-toggle summary", + {"x": -24, "y": 8}, // This is the position of "[-]" next to that pub fn. +) assert-attribute-false: (".impl-items .rustdoc-toggle", {"open": ""}) // Click the "Trait" part of "impl Trait" and verify it navigates. click: "#impl-Trait-for-Foo h3 a:first-of-type" -assert-text: (".fqn .in-band", "Trait lib2::Trait") +assert-text: (".fqn", "Trait lib2::Trait") diff --git a/src/test/rustdoc-gui/toggle-docs-mobile.goml b/src/test/rustdoc-gui/toggle-docs-mobile.goml index ee6bc3cf7..6ce24a81b 100644 --- a/src/test/rustdoc-gui/toggle-docs-mobile.goml +++ b/src/test/rustdoc-gui/toggle-docs-mobile.goml @@ -1,6 +1,6 @@ // 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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" size: (433, 600) assert-attribute: (".top-doc", {"open": ""}) click: (4, 270) // This is the position of the top doc comment toggle diff --git a/src/test/rustdoc-gui/toggle-docs.goml b/src/test/rustdoc-gui/toggle-docs.goml index 63962b576..8c9fd0a88 100644 --- a/src/test/rustdoc-gui/toggle-docs.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-attribute: ("#main-content > details.top-doc", {"open": ""}) assert-text: ("#toggle-all-docs", "[โ]") click: "#toggle-all-docs" @@ -13,7 +13,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 +goto: "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.rustdoc-toggle", {"open": ""}, ALL) diff --git a/src/test/rustdoc-gui/toggle-implementors.goml b/src/test/rustdoc-gui/toggle-implementors.goml index 15521ff0f..8ff5b91af 100644 --- a/src/test/rustdoc-gui/toggle-implementors.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" assert-attribute-false: ("#implementors-list > details", {"open": ""}, ALL) diff --git a/src/test/rustdoc-gui/toggled-open-implementations.goml b/src/test/rustdoc-gui/toggled-open-implementations.goml index bc97b38c8..e4d59b5d7 100644 --- a/src/test/rustdoc-gui/toggled-open-implementations.goml +++ b/src/test/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 +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-attribute: (".rustdoc-toggle.implementors-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/trait-sidebar-item-order.goml b/src/test/rustdoc-gui/trait-sidebar-item-order.goml index d77d1dca4..a799444a1 100644 --- a/src/test/rustdoc-gui/trait-sidebar-item-order.goml +++ b/src/test/rustdoc-gui/trait-sidebar-item-order.goml @@ -1,5 +1,5 @@ // Checks that the elements in the sidebar are alphabetically sorted. -goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html +goto: "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/src/test/rustdoc-gui/type-declation-overflow.goml b/src/test/rustdoc-gui/type-declation-overflow.goml index 22212a317..fce3002e7 100644 --- a/src/test/rustdoc-gui/type-declation-overflow.goml +++ b/src/test/rustdoc-gui/type-declation-overflow.goml @@ -1,5 +1,5 @@ // This test ensures that the items declaration content overflow is handled inside the <pre> directly. -goto: file://|DOC_PATH|/lib2/long_trait/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.html +goto: "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) // Logically, the <body> scroll width should be the width of the window. @@ -8,30 +8,30 @@ assert-property: ("body", {"scrollWidth": "1100"}) assert-property: (".item-decl pre", {"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 +goto: "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 +goto: "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": "825"}) +assert-property: ("#main-content", {"scrollWidth": "840"}) // And now checking that it has scrollable content. assert-property: (".item-decl pre", {"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 +goto: "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": "825"}) +assert-property: ("#main-content", {"scrollWidth": "840"}) // And now checking that it has scrollable content. assert-property: (".item-decl pre", {"scrollWidth": "950"}) // On mobile: size: (600, 600) -goto: file://|DOC_PATH|/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html +goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" // It shouldn't have an overflow in the topbar either. -assert-property: (".mobile-topbar .location", {"scrollWidth": "492"}) -assert-property: (".mobile-topbar .location", {"clientWidth": "492"}) -assert-css: (".mobile-topbar .location", {"overflow-x": "hidden"}) +store-property: (scrollWidth, ".mobile-topbar h2", "scrollWidth") +assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|}) +assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"}) diff --git a/src/test/rustdoc-gui/unsafe-fn.goml b/src/test/rustdoc-gui/unsafe-fn.goml new file mode 100644 index 000000000..5e43b85fc --- /dev/null +++ b/src/test/rustdoc-gui/unsafe-fn.goml @@ -0,0 +1,28 @@ +// Check position and color of the `<sup>` for unsafe elements. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +// If the text isn't displayed, the browser doesn't compute color style correctly... +show-text: true + +compare-elements-property: ( + "//a[@title='test_docs::safe_fn fn']/..", + "//a[@title='test_docs::unsafe_fn fn']/..", + ["clientHeight"] +) + +define-function: ( + "sup-check", + // `theme` is the theme being tested. + // `color` is the expected color of the `<sup>` element. + (theme, color), + [ + // Set the theme. + ("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-left sup", {"color": |color|})), + ], +) + +call-function: ("sup-check", ("dark", "rgb(221, 221, 221)")) +call-function: ("sup-check", ("ayu", "rgb(197, 197, 197)")) +call-function: ("sup-check", ("light", "rgb(0, 0, 0)")) diff --git a/src/test/rustdoc-gui/where-whitespace.goml b/src/test/rustdoc-gui/where-whitespace.goml new file mode 100644 index 000000000..776c8ec72 --- /dev/null +++ b/src/test/rustdoc-gui/where-whitespace.goml @@ -0,0 +1,27 @@ +// This test ensures that the where conditions are correctly displayed. +goto: "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>"). +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 .fnname", ".where.fmt-newline", ("y")) + +goto: "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) + +compare-elements-position-false: ("#method\.new .fnname", "#method\.new .where.fmt-newline", ("y")) +// We ensure that both the trait name and the struct name are on the same line in +// "impl<K, T> Whitespace<&K> for WhereWhitespace<T>". +compare-elements-position: ( + "#trait-implementations-list .impl h3 .trait", + "#trait-implementations-list .impl h3 .struct", + ("y"), +) +// And we now check that the where condition isn't on the same line. +compare-elements-position-false: ( + "#trait-implementations-list .impl h3 .trait", + "#trait-implementations-list .impl h3 .where.fmt-newline", + ("y"), +) diff --git a/src/test/rustdoc-js-std/asrawfd.js b/src/test/rustdoc-js-std/asrawfd.js index fd228a590..369a34f9c 100644 --- a/src/test/rustdoc-js-std/asrawfd.js +++ b/src/test/rustdoc-js-std/asrawfd.js @@ -6,9 +6,9 @@ const EXPECTED = { 'others': [ // Reproduction test for https://github.com/rust-lang/rust/issues/78724 // Validate that type alias methods get the correct path. - { 'path': 'std::os::unix::io::AsRawFd', 'name': 'as_raw_fd' }, - { 'path': 'std::os::wasi::io::AsRawFd', 'name': 'as_raw_fd' }, + { 'path': 'std::os::fd::AsRawFd', 'name': 'as_raw_fd' }, + { 'path': 'std::os::fd::AsRawFd', 'name': 'as_raw_fd' }, { 'path': 'std::os::linux::process::PidFd', 'name': 'as_raw_fd' }, - { 'path': 'std::os::unix::io::RawFd', 'name': 'as_raw_fd' }, + { 'path': 'std::os::fd::RawFd', 'name': 'as_raw_fd' }, ], }; diff --git a/src/test/rustdoc-json/assoc_items.rs b/src/test/rustdoc-json/assoc_items.rs index 2ee64c9f6..6d7f6bb96 100644 --- a/src/test/rustdoc-json/assoc_items.rs +++ b/src/test/rustdoc-json/assoc_items.rs @@ -1,29 +1,37 @@ #![no_std] -// @has assoc_items.json - pub struct Simple; impl Simple { - // @has - "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" + // @is "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" pub const CONSTANT: usize = 0; } pub trait EasyToImpl { - // @has - "$.index[*][?(@.name=='ToDeclare')].kind" \"assoc_type\" - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default" null + // @is "$.index[*][?(@.docs=='ToDeclare trait')].kind" \"assoc_type\" + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.default" null + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.bounds" [] + /// ToDeclare trait type ToDeclare; - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].kind" \"assoc_const\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" null + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].kind" \"assoc_const\" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.default" null + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.kind" '"primitive"' + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.inner" '"usize"' + /// AN_ATTRIBUTE trait const AN_ATTRIBUTE: usize; } impl EasyToImpl for Simple { - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.kind" \"primitive\" - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.inner" \"usize\" + // @is "$.index[*][?(@.docs=='ToDeclare impl')].kind" '"assoc_type"' + // @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.kind" \"primitive\" + // @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.inner" \"usize\" + /// ToDeclare impl type ToDeclare = usize; - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.type.kind" \"primitive\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.type.inner" \"usize\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" \"12\" + + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].kind" '"assoc_const"' + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.kind" \"primitive\" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.inner" \"usize\" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.default" \"12\" + /// AN_ATTRIBUTE impl const AN_ATTRIBUTE: usize = 12; } diff --git a/src/test/rustdoc-json/assoc_type.rs b/src/test/rustdoc-json/assoc_type.rs index 716bb3d28..edc1f73c8 100644 --- a/src/test/rustdoc-json/assoc_type.rs +++ b/src/test/rustdoc-json/assoc_type.rs @@ -1,10 +1,9 @@ // Regression test for <https://github.com/rust-lang/rust/issues/98547>. -// @has assoc_type.json -// @has - "$.index[*][?(@.name=='Trait')]" -// @has - "$.index[*][?(@.name=='AssocType')]" -// @has - "$.index[*][?(@.name=='S')]" -// @has - "$.index[*][?(@.name=='S2')]" +// @has "$.index[*][?(@.name=='Trait')]" +// @has "$.index[*][?(@.name=='AssocType')]" +// @has "$.index[*][?(@.name=='S')]" +// @has "$.index[*][?(@.name=='S2')]" pub trait Trait { type AssocType; diff --git a/src/test/rustdoc-json/blanket_impls.rs b/src/test/rustdoc-json/blanket_impls.rs index edf1a9fe2..c5cc87ca1 100644 --- a/src/test/rustdoc-json/blanket_impls.rs +++ b/src/test/rustdoc-json/blanket_impls.rs @@ -2,8 +2,7 @@ #![no_std] -// @has blanket_impls.json -// @has - "$.index[*][?(@.name=='Error')].kind" \"assoc_type\" -// @has - "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" -// @has - "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" +// @has "$.index[*][?(@.name=='Error')].kind" \"assoc_type\" +// @has "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" +// @has "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" pub struct ForBlanketTryFromImpl; diff --git a/src/test/rustdoc-json/doc_hidden_failure.rs b/src/test/rustdoc-json/doc_hidden_failure.rs index 5c4ccf996..6573166c4 100644 --- a/src/test/rustdoc-json/doc_hidden_failure.rs +++ b/src/test/rustdoc-json/doc_hidden_failure.rs @@ -14,7 +14,7 @@ mod auto { } } -// @count doc_hidden_failure.json "$.index[*][?(@.name=='builders')]" 2 +// @count "$.index[*][?(@.name=='builders')]" 2 pub use auto::*; pub mod builders { diff --git a/src/test/rustdoc-json/enums/discriminant/basic.rs b/src/test/rustdoc-json/enums/discriminant/basic.rs new file mode 100644 index 000000000..8c221615a --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/basic.rs @@ -0,0 +1,12 @@ +#[repr(i8)] +pub enum Ordering { + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.expr" '"-1"' + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.value" '"-1"' + Less = -1, + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.expr" '"0"' + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.value" '"0"' + Equal = 0, + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.expr" '"1"' + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.value" '"1"' + Greater = 1, +} diff --git a/src/test/rustdoc-json/enums/discriminant/expr.rs b/src/test/rustdoc-json/enums/discriminant/expr.rs new file mode 100644 index 000000000..235b0b473 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/expr.rs @@ -0,0 +1,39 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.expr" '"{ _ }"' + Addition = 0 + 0, + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.value" '"1"' + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.expr" '"0b1"' + Bin = 0b1, + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.value" '"2"' + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.expr" '"0o2"' + Oct = 0o2, + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.value" '"3"' + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.expr" '"THREE"' + PubConst = THREE, + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.value" '"4"' + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.expr" '"0x4"' + Hex = 0x4, + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.value" '"5"' + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.expr" '"{ _ }"' + Cast = 5 as isize, + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.value" '"6"' + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.expr" '"{ _ }"' + PubCall = six(), + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.value" '"7"' + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.expr" '"{ _ }"' + PrivCall = seven(), + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.value" '"8"' + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.expr" '"EIGHT"' + PrivConst = EIGHT, +} + +pub const THREE: isize = 3; +const EIGHT: isize = 8; + +pub const fn six() -> isize { + 6 +} +const fn seven() -> isize { + 7 +} diff --git a/src/test/rustdoc-json/enums/discriminant/limits.rs b/src/test/rustdoc-json/enums/discriminant/limits.rs new file mode 100644 index 000000000..8df73d78d --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/limits.rs @@ -0,0 +1,43 @@ +// ignore-tidy-linelength +#![feature(repr128)] +#![allow(incomplete_features)] + +#[repr(u64)] +pub enum U64 { + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.expr" '"u64::MIN"' + U64Min = u64::MIN, + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.value" '"18446744073709551615"' + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.expr" '"u64::MAX"' + U64Max = u64::MAX, +} + +#[repr(i64)] +pub enum I64 { + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.value" '"-9223372036854775808"' + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.expr" '"i64::MIN"' + I64Min = i64::MIN, + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.value" '"9223372036854775807"' + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.expr" '"i64::MAX"' + I64Max = i64::MAX, +} + +#[repr(u128)] +pub enum U128 { + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.expr" '"u128::MIN"' + U128Min = u128::MIN, + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.value" '"340282366920938463463374607431768211455"' + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.expr" '"u128::MAX"' + U128Max = u128::MAX, +} + +#[repr(i128)] +pub enum I128 { + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.value" '"-170141183460469231731687303715884105728"' + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.expr" '"i128::MIN"' + I128Min = i128::MIN, + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.value" '"170141183460469231731687303715884105727"' + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.expr" '"i128::MAX"' + I128Max = i128::MAX, +} diff --git a/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs new file mode 100644 index 000000000..3417baa07 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs @@ -0,0 +1,15 @@ +#[repr(u32)] +pub enum Foo { + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.expr" '"0"' + Basic = 0, + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.value" '"10"' + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.expr" '"10u32"' + Suffix = 10u32, + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.value" '"100"' + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.expr" '"1_0_0"' + Underscore = 1_0_0, + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.value" '"1000"' + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.expr" '"1_0_0_0u32"' + SuffixUnderscore = 1_0_0_0u32, +} diff --git a/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs new file mode 100644 index 000000000..6af944a22 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs @@ -0,0 +1,10 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Has')].inner.variant_inner" '{"expr":"0", "value":"0"}' + Has = 0, + // @is "$.index[*][?(@.name=='Doesnt')].inner.variant_inner" null + Doesnt, + // @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant_inner" null + AlsoDoesnt, + // @is "$.index[*][?(@.name=='AlsoHas')].inner.variant_inner" '{"expr":"44", "value":"44"}' + AlsoHas = 44, +} diff --git a/src/test/rustdoc-json/enums/field_hidden.rs b/src/test/rustdoc-json/enums/field_hidden.rs new file mode 100644 index 000000000..e6310cc3b --- /dev/null +++ b/src/test/rustdoc-json/enums/field_hidden.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/100529>. + +#![no_core] +#![feature(no_core)] + +// @has "$.index[*][?(@.name=='ParseError')]" +// @has "$.index[*][?(@.name=='UnexpectedEndTag')]" +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [null] + +pub enum ParseError { + UnexpectedEndTag(#[doc(hidden)] u32), +} diff --git a/src/test/rustdoc-json/enums/kind.rs b/src/test/rustdoc-json/enums/kind.rs new file mode 100644 index 000000000..e9ea3ae23 --- /dev/null +++ b/src/test/rustdoc-json/enums/kind.rs @@ -0,0 +1,37 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +pub enum Foo { + // @set Unit = "$.index[*][?(@.name=='Unit')].id" + // @is "$.index[*][?(@.name=='Unit')].inner.variant_kind" '"plain"' + // @is "$.index[*][?(@.name=='Unit')].inner.variant_inner" null + Unit, + // @set Named = "$.index[*][?(@.name=='Named')].id" + // @is "$.index[*][?(@.name=='Named')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='Named')].inner.variant_inner" '{"fields": [], "fields_stripped": false}' + Named {}, + // @set Tuple = "$.index[*][?(@.name=='Tuple')].id" + // @is "$.index[*][?(@.name=='Tuple')].inner.variant_kind" '"tuple"' + // @is "$.index[*][?(@.name=='Tuple')].inner.variant_inner" [] + Tuple(), + // @set NamedField = "$.index[*][?(@.name=='NamedField')].id" + // @set x = "$.index[*][?(@.name=='x' && @.kind=='struct_field')].id" + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_inner.fields[*]" $x + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_inner.fields_stripped" false + NamedField { x: i32 }, + // @set TupleField = "$.index[*][?(@.name=='TupleField')].id" + // @is "$.index[*][?(@.name=='TupleField')].inner.variant_kind" '"tuple"' + // @set tup_field = "$.index[*][?(@.name=='0' && @.kind=='struct_field')].id" + // @is "$.index[*][?(@.name=='TupleField')].inner.variant_inner[*]" $tup_field + TupleField(i32), +} + +// @is "$.index[*][?(@.name=='Foo')].inner.variants[0]" $Unit +// @is "$.index[*][?(@.name=='Foo')].inner.variants[1]" $Named +// @is "$.index[*][?(@.name=='Foo')].inner.variants[2]" $Tuple +// @is "$.index[*][?(@.name=='Foo')].inner.variants[3]" $NamedField +// @is "$.index[*][?(@.name=='Foo')].inner.variants[4]" $TupleField +// @count "$.index[*][?(@.name=='Foo')].inner.variants[*]" 5 diff --git a/src/test/rustdoc-json/enums/struct_field_hidden.rs b/src/test/rustdoc-json/enums/struct_field_hidden.rs new file mode 100644 index 000000000..f612a34a4 --- /dev/null +++ b/src/test/rustdoc-json/enums/struct_field_hidden.rs @@ -0,0 +1,17 @@ +pub enum Foo { + Variant { + #[doc(hidden)] + a: i32, + // @set b = "$.index[*][?(@.name=='b')].id" + b: i32, + #[doc(hidden)] + x: i32, + // @set y = "$.index[*][?(@.name=='y')].id" + y: i32, + }, + // @is "$.index[*][?(@.name=='Variant')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields_stripped" true + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[0]" $b + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[1]" $y + // @count "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[*]" 2 +} diff --git a/src/test/rustdoc-json/enums/tuple_fields_hidden.rs b/src/test/rustdoc-json/enums/tuple_fields_hidden.rs new file mode 100644 index 000000000..f546eaa0d --- /dev/null +++ b/src/test/rustdoc-json/enums/tuple_fields_hidden.rs @@ -0,0 +1,94 @@ +#![feature(no_core)] +#![no_core] + +// @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id" +// @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id" +// @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id" +// @set 2.2.1 = "$.index[*][?(@.docs=='2.2.1')].id" +// @set 2.3.0 = "$.index[*][?(@.docs=='2.3.0')].id" +// @set 3.1.1 = "$.index[*][?(@.docs=='3.1.1')].id" +// @set 3.1.2 = "$.index[*][?(@.docs=='3.1.2')].id" +// @set 3.2.0 = "$.index[*][?(@.docs=='3.2.0')].id" +// @set 3.2.2 = "$.index[*][?(@.docs=='3.2.2')].id" +// @set 3.3.0 = "$.index[*][?(@.docs=='3.3.0')].id" +// @set 3.3.1 = "$.index[*][?(@.docs=='3.3.1')].id" + +pub enum EnumWithStrippedTupleVariants { + // @is "$.index[*][?(@.name=='None')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='None')].inner.variant_inner[*]" 0 + None(), + + // @is "$.index[*][?(@.name=='One')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='One')].inner.variant_inner[*]" 1 + // @is "$.index[*][?(@.name=='One')].inner.variant_inner[0]" $1.1.0 + One(/** 1.1.0*/ bool), + // @is "$.index[*][?(@.name=='OneHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='OneHidden')].inner.variant_inner[*]" 1 + // @is "$.index[*][?(@.name=='OneHidden')].inner.variant_inner[0]" null + OneHidden(#[doc(hidden)] bool), + + // @is "$.index[*][?(@.name=='Two')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Two')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='Two')].inner.variant_inner[0]" $2.1.0 + // @is "$.index[*][?(@.name=='Two')].inner.variant_inner[1]" $2.1.1 + Two(/** 2.1.0*/ bool, /** 2.1.1*/ bool), + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[1]" $2.2.1 + TwoLeftHidden(#[doc(hidden)] bool, /** 2.2.1*/ bool), + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[0]" $2.3.0 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[1]" null + TwoRightHidden(/** 2.3.0*/ bool, #[doc(hidden)] bool), + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[1]" null + TwoBothHidden(#[doc(hidden)] bool, #[doc(hidden)] bool), + + // @is "$.index[*][?(@.name=='Three1')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three1')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[1]" $3.1.1 + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[2]" $3.1.2 + Three1(#[doc(hidden)] bool, /** 3.1.1*/ bool, /** 3.1.2*/ bool), + // @is "$.index[*][?(@.name=='Three2')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three2')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[0]" $3.2.0 + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[1]" null + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[2]" $3.2.2 + Three2(/** 3.2.0*/ bool, #[doc(hidden)] bool, /** 3.2.2*/ bool), + // @is "$.index[*][?(@.name=='Three3')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three3')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[0]" $3.3.0 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[1]" $3.3.1 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[2]" null + Three3(/** 3.3.0*/ bool, /** 3.3.1*/ bool, #[doc(hidden)] bool), +} + + +// @is "$.index[*][?(@.docs=='1.1.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='2.1.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='2.1.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='2.2.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='2.3.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.1.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='3.1.2')].name" '"2"' +// @is "$.index[*][?(@.docs=='3.2.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.2.2')].name" '"2"' +// @is "$.index[*][?(@.docs=='3.3.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.3.1')].name" '"1"' + +// @is "$.index[*][?(@.docs=='1.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.2.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.2')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.2')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.1')].inner" '{"kind": "primitive", "inner": "bool"}' diff --git a/src/test/rustdoc-json/enums/variant_struct.rs b/src/test/rustdoc-json/enums/variant_struct.rs index fcd92887c..23b854d8d 100644 --- a/src/test/rustdoc-json/enums/variant_struct.rs +++ b/src/test/rustdoc-json/enums/variant_struct.rs @@ -1,9 +1,9 @@ -// @has variant_struct.json "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\" +// @is "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" +// @is "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\" pub enum EnumStruct { - // @has - "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\" - // @has - "$.index[*][?(@.name=='x')].kind" \"struct_field\" - // @has - "$.index[*][?(@.name=='y')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\" + // @is "$.index[*][?(@.name=='x')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='y')].kind" \"struct_field\" VariantS { x: u32, y: String, diff --git a/src/test/rustdoc-json/enums/variant_tuple_struct.rs b/src/test/rustdoc-json/enums/variant_tuple_struct.rs index ac3e72e29..b71ec47a8 100644 --- a/src/test/rustdoc-json/enums/variant_tuple_struct.rs +++ b/src/test/rustdoc-json/enums/variant_tuple_struct.rs @@ -1,8 +1,8 @@ -// @has variant_tuple_struct.json "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\" +// @is "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" +// @is "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\" pub enum EnumTupleStruct { - // @has - "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\" - // @has - "$.index[*][?(@.name=='0')].kind" \"struct_field\" - // @has - "$.index[*][?(@.name=='1')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\" + // @is "$.index[*][?(@.name=='0')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='1')].kind" \"struct_field\" VariantA(u32, String), } diff --git a/src/test/rustdoc-json/fn_pointer/abi.rs b/src/test/rustdoc-json/fn_pointer/abi.rs index eef20e60a..3c1a453d1 100644 --- a/src/test/rustdoc-json/fn_pointer/abi.rs +++ b/src/test/rustdoc-json/fn_pointer/abi.rs @@ -3,23 +3,23 @@ #![feature(abi_vectorcall)] #![feature(c_unwind)] -// @is abi.json "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" pub type AbiRust = fn(); -// @is - "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}' pub type AbiC = extern "C" fn(); -// @is - "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}' pub type AbiSystem = extern "system" fn(); -// @is - "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}' pub type AbiCUnwind = extern "C-unwind" fn(); -// @is - "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}' pub type AbiSystemUnwind = extern "system-unwind" fn(); -// @is - "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""' pub type AbiVecorcall = extern "vectorcall" fn(); -// @is - "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""' pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn(); diff --git a/src/test/rustdoc-json/fn_pointer/generics.rs b/src/test/rustdoc-json/fn_pointer/generics.rs index 646f720e6..a93b01ac2 100644 --- a/src/test/rustdoc-json/fn_pointer/generics.rs +++ b/src/test/rustdoc-json/fn_pointer/generics.rs @@ -3,12 +3,12 @@ #![feature(no_core)] #![no_core] -// @count generics.json "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' -// @count - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/src/test/rustdoc-json/fn_pointer/qualifiers.rs b/src/test/rustdoc-json/fn_pointer/qualifiers.rs index 381922085..bd65bb3ee 100644 --- a/src/test/rustdoc-json/fn_pointer/qualifiers.rs +++ b/src/test/rustdoc-json/fn_pointer/qualifiers.rs @@ -1,9 +1,9 @@ -// @is qualifiers.json "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false -// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false -// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false pub type FnPointer = fn(); -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false pub type UnsafePointer = unsafe fn(); diff --git a/src/test/rustdoc-json/fns/abi.rs b/src/test/rustdoc-json/fns/abi.rs index 16b579130..0e8b78bc0 100644 --- a/src/test/rustdoc-json/fns/abi.rs +++ b/src/test/rustdoc-json/fns/abi.rs @@ -3,23 +3,23 @@ #![feature(abi_vectorcall)] #![feature(c_unwind)] -// @is abi.json "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" pub fn abi_rust() {} -// @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} -// @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} -// @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} -// @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} -// @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} -// @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} diff --git a/src/test/rustdoc-json/fns/async_return.rs b/src/test/rustdoc-json/fns/async_return.rs new file mode 100644 index 000000000..b89781ca9 --- /dev/null +++ b/src/test/rustdoc-json/fns/async_return.rs @@ -0,0 +1,36 @@ +// edition:2021 +// ignore-tidy-linelength + +// Regression test for <https://github.com/rust-lang/rust/issues/101199> + +use std::future::Future; + +// @is "$.index[*][?(@.name=='get_int')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int')].inner.header.async" false +pub fn get_int() -> i32 { + 42 +} + +// @is "$.index[*][?(@.name=='get_int_async')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_async')].inner.header.async" true +pub async fn get_int_async() -> i32 { + 42 +} + +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_future')].inner.header.async" false +pub fn get_int_future() -> impl Future<Output = i32> { + async { 42 } +} + +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.header.async" true +pub async fn get_int_future_async() -> impl Future<Output = i32> { + async { 42 } +} diff --git a/src/test/rustdoc-json/fns/generic_args.rs b/src/test/rustdoc-json/fns/generic_args.rs index 69150443c..eec295efe 100644 --- a/src/test/rustdoc-json/fns/generic_args.rs +++ b/src/test/rustdoc-json/fns/generic_args.rs @@ -3,65 +3,65 @@ #![feature(no_core)] #![no_core] -// @set foo = generic_args.json "$.index[*][?(@.name=='Foo')].id" +// @set foo = "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} -// @set generic_foo = generic_args.json "$.index[*][?(@.name=='GenericFoo')].id" +// @set generic_foo = "$.index[*][?(@.name=='GenericFoo')].id" pub trait GenericFoo<'a> {} -// @is - "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" -// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' -// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" '$foo' -// @count - "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' +// @count "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" '$foo' +// @count "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' pub fn generics<F: Foo>(f: F) {} -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" -// @count - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $foo -// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $foo +// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $foo pub fn impl_trait(f: impl Foo) {} -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' +// @count "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.id" $foo -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.inner.id" $generic_foo -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.id" $generic_foo +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub fn where_clase<F, G, H>(f: F, g: G, h: H) where F: Foo, diff --git a/src/test/rustdoc-json/fns/generic_returns.rs b/src/test/rustdoc-json/fns/generic_returns.rs index 1a0f33fe3..a9bc2d5d7 100644 --- a/src/test/rustdoc-json/fns/generic_returns.rs +++ b/src/test/rustdoc-json/fns/generic_returns.rs @@ -3,15 +3,15 @@ #![feature(no_core)] #![no_core] -// @count generic_returns.json "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 +// @count "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 -// @set foo = - "$.index[*][?(@.name=='Foo')].id" +// @set foo = "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' -// @count - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' +// @count "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.id" $foo pub fn get_foo() -> impl Foo { Fooer {} } diff --git a/src/test/rustdoc-json/fns/generics.rs b/src/test/rustdoc-json/fns/generics.rs index e777fabaa..7b70ff1df 100644 --- a/src/test/rustdoc-json/fns/generics.rs +++ b/src/test/rustdoc-json/fns/generics.rs @@ -3,24 +3,24 @@ #![feature(no_core)] #![no_core] -// @set wham_id = generics.json "$.index[*][?(@.name=='Wham')].id" +// @set wham_id = "$.index[*][?(@.name=='Wham')].id" pub trait Wham {} -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' -// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false -// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' pub fn one_generic_param_fn<T: Wham>(w: T) {} -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' -// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true -// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id -// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $wham_id +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $wham_id pub fn one_synthetic_generic_param_fn(w: impl Wham) {} diff --git a/src/test/rustdoc-json/fns/qualifiers.rs b/src/test/rustdoc-json/fns/qualifiers.rs index 5cb3b43e6..7ff542900 100644 --- a/src/test/rustdoc-json/fns/qualifiers.rs +++ b/src/test/rustdoc-json/fns/qualifiers.rs @@ -1,33 +1,33 @@ // edition:2018 -// @is qualifiers.json "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false pub fn nothing_fn() {} -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true pub unsafe fn unsafe_fn() {} -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.const" true -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='const_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='const_fn')].inner.header.const" true +// @is "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false pub const fn const_fn() {} -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.async" true -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='async_fn')].inner.header.async" true +// @is "$.index[*][?(@.name=='async_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false pub async fn async_fn() {} -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true pub async unsafe fn async_unsafe_fn() {} -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true pub const unsafe fn const_unsafe_fn() {} // It's impossible for a function to be both const and async, so no test for that diff --git a/src/test/rustdoc-json/generic-associated-types/gats.rs b/src/test/rustdoc-json/generic-associated-types/gats.rs index 368ff8d8d..e5809783a 100644 --- a/src/test/rustdoc-json/generic-associated-types/gats.rs +++ b/src/test/rustdoc-json/generic-associated-types/gats.rs @@ -1,44 +1,42 @@ // ignore-tidy-linelength #![no_core] -#![feature(generic_associated_types, lang_items, no_core)] +#![feature(lang_items, no_core)] #[lang = "sized"] pub trait Sized {} pub trait Display {} -// @has gats.json pub trait LendingIterator { - // @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1 - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\" - // @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1 - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" - // @count - "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.type.inner" \"Self\" + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1 type LendingItem<'a>: Display where Self: 'a; - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\" - // @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1 - // @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\" + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\" + // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1 + // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\" + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\" fn lending_next<'a>(&'a self) -> Self::LendingItem<'a>; } -// @has gats.json pub trait Iterator { - // @count - "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0 - // @count - "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0 - // @count - "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1 type Item: Display; - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\" - // @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0 - // @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\" + // @is "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\" + // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0 + // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\" + // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\" fn next<'a>(&'a self) -> Self::Item; } diff --git a/src/test/rustdoc-json/generic_impl.rs b/src/test/rustdoc-json/generic_impl.rs index ac68ba578..31f41d0f3 100644 --- a/src/test/rustdoc-json/generic_impl.rs +++ b/src/test/rustdoc-json/generic_impl.rs @@ -1,9 +1,8 @@ // Regression test for <https://github.com/rust-lang/rust/issues/97986>. -// @has generic_impl.json -// @has - "$.index[*][?(@.name=='f')]" -// @has - "$.index[*][?(@.name=='AssocTy')]" -// @has - "$.index[*][?(@.name=='AssocConst')]" +// @has "$.index[*][?(@.name=='f')]" +// @has "$.index[*][?(@.name=='AssocTy')]" +// @has "$.index[*][?(@.name=='AssocConst')]" pub mod m { pub struct S; diff --git a/src/test/rustdoc-json/glob_import.rs b/src/test/rustdoc-json/glob_import.rs index d7ac952d1..00051b121 100644 --- a/src/test/rustdoc-json/glob_import.rs +++ b/src/test/rustdoc-json/glob_import.rs @@ -4,9 +4,8 @@ #![no_std] #![no_core] -// @has glob_import.json -// @has - "$.index[*][?(@.name=='glob')]" -// @has - "$.index[*][?(@.kind=='import')].inner.name" \"*\" +// @has "$.index[*][?(@.name=='glob')]" +// @has "$.index[*][?(@.kind=='import')].inner.name" \"*\" mod m1 { diff --git a/src/test/rustdoc-json/impls/auto.rs b/src/test/rustdoc-json/impls/auto.rs new file mode 100644 index 000000000..50d852414 --- /dev/null +++ b/src/test/rustdoc-json/impls/auto.rs @@ -0,0 +1,18 @@ +#![feature(no_core, auto_traits, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +pub auto trait Bar {} + +/// has span +impl Foo { + pub fn baz(&self) {} +} + +// Testing spans, so all tests below code +// @is "$.index[*][?(@.kind=='impl' && @.inner.synthetic==true)].span" null +// @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]" +// @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]" +pub struct Foo; diff --git a/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs b/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs new file mode 100644 index 000000000..832d0fce5 --- /dev/null +++ b/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs @@ -0,0 +1 @@ +pub struct ForeignStruct; diff --git a/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs b/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs new file mode 100644 index 000000000..2c81bee61 --- /dev/null +++ b/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs @@ -0,0 +1 @@ +pub trait ForeignTrait {} diff --git a/src/test/rustdoc-json/impls/blanket_with_local.rs b/src/test/rustdoc-json/impls/blanket_with_local.rs index a3d55b35f..2fb4a84b9 100644 --- a/src/test/rustdoc-json/impls/blanket_with_local.rs +++ b/src/test/rustdoc-json/impls/blanket_with_local.rs @@ -1,11 +1,11 @@ // Test for the ICE in rust/83718 // A blanket impl plus a local type together shouldn't result in mismatched ID issues -// @has blanket_with_local.json "$.index[*][?(@.name=='Load')]" +// @has "$.index[*][?(@.name=='Load')]" pub trait Load { - // @has - "$.index[*][?(@.name=='load')]" + // @has "$.index[*][?(@.name=='load')]" fn load() {} - // @has - "$.index[*][?(@.name=='write')]" + // @has "$.index[*][?(@.name=='write')]" fn write(self) {} } @@ -14,5 +14,5 @@ impl<P> Load for P { fn write(self) {} } -// @has - "$.index[*][?(@.name=='Wrapper')]" +// @has "$.index[*][?(@.name=='Wrapper')]" pub struct Wrapper {} diff --git a/src/test/rustdoc-json/impls/foreign_for_local.rs b/src/test/rustdoc-json/impls/foreign_for_local.rs new file mode 100644 index 000000000..290c2d571 --- /dev/null +++ b/src/test/rustdoc-json/impls/foreign_for_local.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_trait.rs +extern crate foreign_trait; + +/// ForeignTrait id hack +pub use foreign_trait::ForeignTrait as _; +// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.id" + +pub struct LocalStruct; +// @set LocalStruct = "$.index[*][?(@.name=='LocalStruct')].id" + +/// foreign for local +impl foreign_trait::ForeignTrait for LocalStruct {} + +// @set impl = "$.index[*][?(@.docs=='foreign for local')].id" +// @is "$.index[*][?(@.docs=='foreign for local')].inner.for.inner.id" $LocalStruct +// @is "$.index[*][?(@.docs=='foreign for local')].inner.trait.id" $ForeignTrait + +// @has "$.index[*][?(@.name=='LocalStruct')].inner.impls[*]" $impl diff --git a/src/test/rustdoc-json/impls/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs new file mode 100644 index 000000000..856f7c701 --- /dev/null +++ b/src/test/rustdoc-json/impls/import_from_private.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/100252 + +#![feature(no_core)] +#![no_core] + +mod bar { + // @set baz = "$.index[*][?(@.kind=='struct')].id" + pub struct Baz; + // @set impl = "$.index[*][?(@.kind=='impl')].id" + impl Baz { + // @set doit = "$.index[*][?(@.kind=='method')].id" + pub fn doit() {} + } +} + +// @set import = "$.index[*][?(@.kind=='import')].id" +pub use bar::Baz; + +// @is "$.index[*][?(@.kind=='module')].inner.items[*]" $import +// @is "$.index[*][?(@.kind=='import')].inner.id" $baz +// @is "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit diff --git a/src/test/rustdoc-json/impls/local_for_foreign.rs b/src/test/rustdoc-json/impls/local_for_foreign.rs new file mode 100644 index 000000000..74f2f08b5 --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_foreign.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_struct.rs +extern crate foreign_struct; + +/// ForeignStruct id hack +pub use foreign_struct::ForeignStruct as _; +// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.id" + +pub trait LocalTrait {} +// @set LocalTrait = "$.index[*][?(@.name=='LocalTrait')].id" + +/// local for foreign +impl LocalTrait for foreign_struct::ForeignStruct {} + +// @set impl = "$.index[*][?(@.docs=='local for foreign')].id" +// @is "$.index[*][?(@.docs=='local for foreign')].inner.trait.id" $LocalTrait +// @is "$.index[*][?(@.docs=='local for foreign')].inner.for.inner.id" $ForeignStruct + +// @is "$.index[*][?(@.name=='LocalTrait')].inner.implementations[*]" $impl diff --git a/src/test/rustdoc-json/impls/local_for_local.rs b/src/test/rustdoc-json/impls/local_for_local.rs new file mode 100644 index 000000000..93dedb7ec --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_local.rs @@ -0,0 +1,15 @@ +#![feature(no_core)] +#![no_core] + +// @set struct = "$.index[*][?(@.name=='Struct')].id" +pub struct Struct; +// @set trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl = "$.index[*][?(@.docs=='impl')].id" +/// impl +impl Trait for Struct {} + +// @is "$.index[*][?(@.name=='Struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.name=='Trait')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.docs=='impl')].inner.trait.id" $trait +// @is "$.index[*][?(@.docs=='impl')].inner.for.inner.id" $struct diff --git a/src/test/rustdoc-json/impls/local_for_local_primitive.rs b/src/test/rustdoc-json/impls/local_for_local_primitive.rs new file mode 100644 index 000000000..38e7e2658 --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_local_primitive.rs @@ -0,0 +1,21 @@ +#![feature(no_core)] +#![feature(rustdoc_internals)] +#![no_core] + +// @set Local = "$.index[*][?(@.name=='Local')].id" +pub trait Local {} + +// @is "$.index[*][?(@.docs=='Local for bool')].inner.trait.id" $Local +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.kind" '"primitive"' +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.inner" '"bool"' +/// Local for bool +impl Local for bool {} + +// @set impl = "$.index[*][?(@.docs=='Local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl + +// FIXME(#101695): Test bool's `impls` include "Local for bool" +// @has "$.index[*][?(@.name=='bool')]" +#[doc(primitive = "bool")] +/// Boolean docs +mod prim_bool {} diff --git a/src/test/rustdoc-json/impls/local_for_primitive.rs b/src/test/rustdoc-json/impls/local_for_primitive.rs new file mode 100644 index 000000000..7702a526f --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_primitive.rs @@ -0,0 +1,7 @@ +// @set local = "$.index[*][?(@.name=='Local')]" +pub trait Local {} + +// @set impl = "$.index[*][?(@.docs=='local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl +/// local for bool +impl Local for bool {} diff --git a/src/test/rustdoc-json/intra-doc-links/non_page.rs b/src/test/rustdoc-json/intra-doc-links/non_page.rs new file mode 100644 index 000000000..73c5334bb --- /dev/null +++ b/src/test/rustdoc-json/intra-doc-links/non_page.rs @@ -0,0 +1,34 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/101531>, +// where links where to the item who's HTML page had the item linked to. + +//! [`Struct::struct_field`] +//! [`Enum::Variant`] +//! [`Trait::AssocType`] +//! [`Trait::ASSOC_CONST`] +//! [`Trait::method`] + +// @set struct_field = "$.index[*][?(@.name=='struct_field')].id" +// @set Variant = "$.index[*][?(@.name=='Variant')].id" +// @set AssocType = "$.index[*][?(@.name=='AssocType')].id" +// @set ASSOC_CONST = "$.index[*][?(@.name=='ASSOC_CONST')].id" +// @set method = "$.index[*][?(@.name=='method')].id" + +// @is "$.index[*][?(@.name=='non_page')].links['`Struct::struct_field`']" $struct_field +// @is "$.index[*][?(@.name=='non_page')].links['`Enum::Variant`']" $Variant +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::AssocType`']" $AssocType +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::ASSOC_CONST`']" $ASSOC_CONST +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::method`']" $method + +pub struct Struct { + pub struct_field: i32, +} + +pub enum Enum { + Variant(), +} + +pub trait Trait { + const ASSOC_CONST: i32; + type AssocType; + fn method(); +} diff --git a/src/test/rustdoc-json/intra-doc-links/user_written.rs b/src/test/rustdoc-json/intra-doc-links/user_written.rs new file mode 100644 index 000000000..6871dfea4 --- /dev/null +++ b/src/test/rustdoc-json/intra-doc-links/user_written.rs @@ -0,0 +1,8 @@ +//! For motivation, see [the reasons](foo#reasons) + +/// # Reasons +/// To test rustdoc json +pub fn foo() {} + +// @set foo = "$.index[*][?(@.name=='foo')].id" +// @is "$.index[*][?(@.name=='user_written')].links['foo#reasons']" $foo diff --git a/src/test/rustdoc-json/keyword.rs b/src/test/rustdoc-json/keyword.rs index 78a843aca..3446b212c 100644 --- a/src/test/rustdoc-json/keyword.rs +++ b/src/test/rustdoc-json/keyword.rs @@ -6,16 +6,15 @@ #![feature(rustdoc_internals)] #![no_std] -// @has keyword.json -// @!has - "$.index[*][?(@.name=='match')]" -// @has - "$.index[*][?(@.name=='foo')]" +// @!has "$.index[*][?(@.name=='match')]" +// @has "$.index[*][?(@.name=='foo')]" #[doc(keyword = "match")] /// this is a test! pub mod foo {} -// @!has - "$.index[*][?(@.name=='hello')]" -// @!has - "$.index[*][?(@.name=='bar')]" +// @!has "$.index[*][?(@.name=='hello')]" +// @!has "$.index[*][?(@.name=='bar')]" #[doc(keyword = "hello")] /// hello mod bar {} diff --git a/src/test/rustdoc-json/lifetime/longest.rs b/src/test/rustdoc-json/lifetime/longest.rs index 95b99599e..326dab8e5 100644 --- a/src/test/rustdoc-json/lifetime/longest.rs +++ b/src/test/rustdoc-json/lifetime/longest.rs @@ -3,30 +3,30 @@ #![feature(no_core)] #![no_core] -// @is longest.json "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @count - "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @count "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' +// @count "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str { if l.len() > r.len() { l } else { r } diff --git a/src/test/rustdoc-json/lifetime/outlives.rs b/src/test/rustdoc-json/lifetime/outlives.rs index 096dd7f7a..e15a533ef 100644 --- a/src/test/rustdoc-json/lifetime/outlives.rs +++ b/src/test/rustdoc-json/lifetime/outlives.rs @@ -3,21 +3,21 @@ #![feature(no_core)] #![no_core] -// @count outlives.json "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 -// @is - "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null -// @count - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' +// @count "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null +// @count "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' pub fn foo<'a, 'b: 'a, T: 'b>(_: &'a &'b T) {} diff --git a/src/test/rustdoc-json/methods/abi.rs b/src/test/rustdoc-json/methods/abi.rs index 07b01d03b..4c97d97ce 100644 --- a/src/test/rustdoc-json/methods/abi.rs +++ b/src/test/rustdoc-json/methods/abi.rs @@ -5,51 +5,51 @@ #![feature(no_core)] #![no_core] -// @has abi.json "$.index[*][?(@.name=='Foo')]" +// @has "$.index[*][?(@.name=='Foo')]" pub struct Foo; impl Foo { - // @is - "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" pub fn abi_rust() {} - // @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} - // @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} - // @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} - // @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} - // @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} - // @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} } pub trait Bar { - // @is - "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\" fn trait_abi_rust() {} - // @is - "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}' extern "C" fn trait_abi_c() {} - // @is - "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}' extern "system" fn trait_abi_system() {} - // @is - "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' extern "C-unwind" fn trait_abi_c_unwind() {} - // @is - "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' extern "system-unwind" fn trait_abi_system_unwind() {} - // @is - "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' extern "vectorcall" fn trait_abi_vectorcall() {} - // @is - "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {} } diff --git a/src/test/rustdoc-json/methods/qualifiers.rs b/src/test/rustdoc-json/methods/qualifiers.rs index af36d36b6..b9a5e5601 100644 --- a/src/test/rustdoc-json/methods/qualifiers.rs +++ b/src/test/rustdoc-json/methods/qualifiers.rs @@ -3,34 +3,34 @@ pub struct Foo; impl Foo { - // @is qualifiers.json "$.index[*][?(@.name=='const_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='const_meth')].inner.header.const" true - // @is - "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='const_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='const_meth')].inner.header.const" true + // @is "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false pub const fn const_meth() {} - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false pub fn nothing_meth() {} - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true pub unsafe fn unsafe_meth() {} - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.async" true - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='async_meth')].inner.header.async" true + // @is "$.index[*][?(@.name=='async_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false pub async fn async_meth() {} - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true pub async unsafe fn async_unsafe_meth() {} - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true pub const unsafe fn const_unsafe_meth() {} // It's impossible for a method to be both const and async, so no test for that diff --git a/src/test/rustdoc-json/nested.rs b/src/test/rustdoc-json/nested.rs index b0e717d8a..ee2d2efa9 100644 --- a/src/test/rustdoc-json/nested.rs +++ b/src/test/rustdoc-json/nested.rs @@ -1,30 +1,31 @@ // edition:2018 // compile-flags: --crate-version 1.0.0 -// @is nested.json "$.crate_version" \"1.0.0\" -// @is - "$.index[*][?(@.name=='nested')].kind" \"module\" -// @is - "$.index[*][?(@.name=='nested')].inner.is_crate" true -// @count - "$.index[*][?(@.name=='nested')].inner.items[*]" 1 +// @is "$.crate_version" \"1.0.0\" +// @is "$.index[*][?(@.name=='nested')].kind" \"module\" +// @is "$.index[*][?(@.name=='nested')].inner.is_crate" true -// @is nested.json "$.index[*][?(@.name=='l1')].kind" \"module\" -// @is - "$.index[*][?(@.name=='l1')].inner.is_crate" false -// @count - "$.index[*][?(@.name=='l1')].inner.items[*]" 2 -pub mod l1 { +// @set l1_id = "$.index[*][?(@.name=='l1')].id" +// @ismany "$.index[*][?(@.name=='nested')].inner.items[*]" $l1_id - // @is nested.json "$.index[*][?(@.name=='l3')].kind" \"module\" - // @is - "$.index[*][?(@.name=='l3')].inner.is_crate" false - // @count - "$.index[*][?(@.name=='l3')].inner.items[*]" 1 - // @set l3_id = - "$.index[*][?(@.name=='l3')].id" - // @has - "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id +// @is "$.index[*][?(@.name=='l1')].kind" \"module\" +// @is "$.index[*][?(@.name=='l1')].inner.is_crate" false +pub mod l1 { + // @is "$.index[*][?(@.name=='l3')].kind" \"module\" + // @is "$.index[*][?(@.name=='l3')].inner.is_crate" false + // @set l3_id = "$.index[*][?(@.name=='l3')].id" pub mod l3 { - // @is nested.json "$.index[*][?(@.name=='L4')].kind" \"struct\" - // @is - "$.index[*][?(@.name=='L4')].inner.struct_type" \"unit\" - // @set l4_id = - "$.index[*][?(@.name=='L4')].id" - // @has - "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id + // @is "$.index[*][?(@.name=='L4')].kind" \"struct\" + // @is "$.index[*][?(@.name=='L4')].inner.kind" \"unit\" + // @set l4_id = "$.index[*][?(@.name=='L4')].id" + // @ismany "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id pub struct L4; } - // @is nested.json "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" - // @is - "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false + // @is "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" + // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false + // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.id" $l4_id + // @set l4_use_id = "$.index[*][?(@.inner.source=='l3::L4')].id" pub use l3::L4; } +// @ismany "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id $l4_use_id diff --git a/src/test/rustdoc-json/output_generics.rs b/src/test/rustdoc-json/output_generics.rs index d80656c7f..04b1a358f 100644 --- a/src/test/rustdoc-json/output_generics.rs +++ b/src/test/rustdoc-json/output_generics.rs @@ -2,12 +2,11 @@ // This is a regression test for #98009. -// @has output_generics.json -// @has - "$.index[*][?(@.name=='this_compiles')]" -// @has - "$.index[*][?(@.name=='this_does_not')]" -// @has - "$.index[*][?(@.name=='Events')]" -// @has - "$.index[*][?(@.name=='Other')]" -// @has - "$.index[*][?(@.name=='Trait')]" +// @has "$.index[*][?(@.name=='this_compiles')]" +// @has "$.index[*][?(@.name=='this_does_not')]" +// @has "$.index[*][?(@.name=='Events')]" +// @has "$.index[*][?(@.name=='Other')]" +// @has "$.index[*][?(@.name=='Trait')]" struct Events<R>(R); diff --git a/src/test/rustdoc-json/primitive.rs b/src/test/rustdoc-json/primitive.rs deleted file mode 100644 index b84c2f7c6..000000000 --- a/src/test/rustdoc-json/primitive.rs +++ /dev/null @@ -1,14 +0,0 @@ -// edition:2018 - -#![feature(rustdoc_internals)] - -#[doc(primitive = "usize")] -mod usize {} - -// @set local_crate_id = primitive.json "$.index[*][?(@.name=='primitive')].crate_id" - -// @has - "$.index[*][?(@.name=='log10')]" -// @!is - "$.index[*][?(@.name=='log10')].crate_id" $local_crate_id -// @has - "$.index[*][?(@.name=='checked_add')]" -// @!is - "$.index[*][?(@.name=='checked_add')]" $local_crate_id -// @!has - "$.index[*][?(@.name=='is_ascii_uppercase')]" diff --git a/src/test/rustdoc-json/primitive_overloading.rs b/src/test/rustdoc-json/primitive_overloading.rs deleted file mode 100644 index a10d5a837..000000000 --- a/src/test/rustdoc-json/primitive_overloading.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags: --document-private-items - -// Regression test for <https://github.com/rust-lang/rust/issues/98006>. - -#![feature(rustdoc_internals)] -#![feature(no_core)] - -#![no_core] - -// @has primitive_overloading.json -// @has - "$.index[*][?(@.name=='usize')]" -// @has - "$.index[*][?(@.name=='prim')]" - -#[doc(primitive = "usize")] -/// This is the built-in type `usize`. -mod prim { -} diff --git a/src/test/rustdoc-json/primitives.rs b/src/test/rustdoc-json/primitives.rs deleted file mode 100644 index fd04f04da..000000000 --- a/src/test/rustdoc-json/primitives.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![feature(never_type)] - -// @has primitives.json "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" -pub type PrimNever = !; - -// @has - "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" -pub type PrimStr = str; - -// @has - "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" -pub type PrimBool = bool; - -// @has - "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" -pub type PrimChar = char; - -// @has - "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" -pub type PrimU8 = u8; diff --git a/src/test/rustdoc-json/primitives/primitive_impls.rs b/src/test/rustdoc-json/primitives/primitive_impls.rs new file mode 100644 index 000000000..1fc937406 --- /dev/null +++ b/src/test/rustdoc-json/primitives/primitive_impls.rs @@ -0,0 +1,34 @@ +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +// @set impl_i32 = "$.index[*][?(@.docs=='Only core can do this')].id" + +/// Only core can do this +impl i32 { + // @set identity = "$.index[*][?(@.docs=='Do Nothing')].id" + + /// Do Nothing + pub fn identity(self) -> Self { + self + } + + // @is "$.index[*][?(@.docs=='Only core can do this')].inner.items[*]" $identity +} + +// @set Trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl_trait_for_i32 = "$.index[*][?(@.docs=='impl Trait for i32')].id" +/// impl Trait for i32 +impl Trait for i32 {} + +/// i32 +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set i32 = "$.index[*][?(@.docs=='i32')].id" +// @is "$.index[*][?(@.docs=='i32')].name" '"i32"' +// @is "$.index[*][?(@.docs=='i32')].inner.name" '"i32"' +// @ismany "$.index[*][?(@.docs=='i32')].inner.impls[*]" $impl_i32 $impl_trait_for_i32 diff --git a/src/test/rustdoc-json/primitives/primitive_overloading.rs b/src/test/rustdoc-json/primitives/primitive_overloading.rs new file mode 100644 index 000000000..56b35cd14 --- /dev/null +++ b/src/test/rustdoc-json/primitives/primitive_overloading.rs @@ -0,0 +1,16 @@ +// compile-flags: --document-private-items + +// Regression test for <https://github.com/rust-lang/rust/issues/98006>. + +#![feature(rustdoc_internals)] +#![feature(no_core)] + +#![no_core] + +// @has "$.index[*][?(@.name=='usize')]" +// @has "$.index[*][?(@.name=='prim')]" + +#[doc(primitive = "usize")] +/// This is the built-in type `usize`. +mod prim { +} diff --git a/src/test/rustdoc-json/primitives/primitive_type.rs b/src/test/rustdoc-json/primitives/primitive_type.rs new file mode 100644 index 000000000..8024044bc --- /dev/null +++ b/src/test/rustdoc-json/primitives/primitive_type.rs @@ -0,0 +1,22 @@ +#![feature(never_type)] + +// @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" +pub type PrimNever = !; + +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" +pub type PrimStr = str; + +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" +pub type PrimBool = bool; + +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" +pub type PrimChar = char; + +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" +pub type PrimU8 = u8; diff --git a/src/test/rustdoc-json/primitives/use_primitive.rs b/src/test/rustdoc-json/primitives/use_primitive.rs new file mode 100644 index 000000000..e22927374 --- /dev/null +++ b/src/test/rustdoc-json/primitives/use_primitive.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(rustdoc_internals)] + +#[doc(primitive = "usize")] +mod usize {} + +// @set local_crate_id = "$.index[*][?(@.name=='use_primitive')].crate_id" + +// @has "$.index[*][?(@.name=='ilog10')]" +// @!is "$.index[*][?(@.name=='ilog10')].crate_id" $local_crate_id +// @has "$.index[*][?(@.name=='checked_add')]" +// @!is "$.index[*][?(@.name=='checked_add')]" $local_crate_id +// @!has "$.index[*][?(@.name=='is_ascii_uppercase')]" + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='my_i32')].inner.id" null +pub use i32 as my_i32; + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='u32')].inner.id" null +pub use u32; diff --git a/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs new file mode 100644 index 000000000..f076feb71 --- /dev/null +++ b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs @@ -0,0 +1,11 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/100531> + +#![feature(no_core)] +#![no_core] + +#![crate_name = "export_extern_crate_as_self"] + +// ignore-tidy-linelength + +// @is "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" +pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has diff --git a/src/test/rustdoc-json/reexport/glob_collision.rs b/src/test/rustdoc-json/reexport/glob_collision.rs new file mode 100644 index 000000000..f91144dbf --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_collision.rs @@ -0,0 +1,28 @@ +// Regression test for https://github.com/rust-lang/rust/issues/100973 + +#![feature(no_core)] +#![no_core] + +// @set m1 = "$.index[*][?(@.name == 'm1' && @.kind == 'module')].id" +// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.items" [] +// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.is_stripped" true +mod m1 { + pub fn f() {} +} +// @set m2 = "$.index[*][?(@.name == 'm2' && @.kind == 'module')].id" +// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.items" [] +// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.is_stripped" true +mod m2 { + pub fn f(_: u8) {} +} + +// @set m1_use = "$.index[*][?(@.inner.name=='m1')].id" +// @is "$.index[*][?(@.inner.name=='m1')].inner.id" $m1 +// @is "$.index[*][?(@.inner.name=='m1')].inner.glob" true +pub use m1::*; +// @set m2_use = "$.index[*][?(@.inner.name=='m2')].id" +// @is "$.index[*][?(@.inner.name=='m2')].inner.id" $m2 +// @is "$.index[*][?(@.inner.name=='m2')].inner.glob" true +pub use m2::*; + +// @ismany "$.index[*][?(@.inner.is_crate==true)].inner.items[*]" $m1_use $m2_use diff --git a/src/test/rustdoc-json/reexport/glob_empty_mod.rs b/src/test/rustdoc-json/reexport/glob_empty_mod.rs new file mode 100644 index 000000000..da6822835 --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_empty_mod.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/100973 + +// @is "$.index[*][?(@.name=='m1' && @.kind == 'module')].inner.is_stripped" true +// @set m1 = "$.index[*][?(@.name=='m1')].id" +mod m1 {} + +// @is "$.index[*][?(@.inner.name=='m1' && @.kind=='import')].inner.id" $m1 +pub use m1::*; diff --git a/src/test/rustdoc-json/reexport/glob_extern.rs b/src/test/rustdoc-json/reexport/glob_extern.rs index ba1cfd8a0..7a1e8c11f 100644 --- a/src/test/rustdoc-json/reexport/glob_extern.rs +++ b/src/test/rustdoc-json/reexport/glob_extern.rs @@ -3,16 +3,21 @@ #![no_core] #![feature(no_core)] -// @is glob_extern.json "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is glob_extern.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" mod mod1 { extern "C" { - // @has - "$.index[*][?(@.name=='public_fn')].id" + // @set public_fn_id = "$.index[*][?(@.name=='public_fn')].id" pub fn public_fn(); - // @!has - "$.index[*][?(@.name=='private_fn')]" + // @!has "$.index[*][?(@.name=='private_fn')]" fn private_fn(); } + // @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $public_fn_id + // @set mod1_id = "$.index[*][?(@.name=='mod1')].id" } -// @is - "$.index[*][?(@.kind=='import')].inner.glob" true +// @is "$.index[*][?(@.kind=='import')].inner.glob" true +// @is "$.index[*][?(@.kind=='import')].inner.id" $mod1_id +// @set use_id = "$.index[*][?(@.kind=='import')].id" +// @ismany "$.index[*][?(@.name=='glob_extern')].inner.items[*]" $use_id pub use mod1::*; diff --git a/src/test/rustdoc-json/reexport/glob_private.rs b/src/test/rustdoc-json/reexport/glob_private.rs index e6a44748c..3a83a2081 100644 --- a/src/test/rustdoc-json/reexport/glob_private.rs +++ b/src/test/rustdoc-json/reexport/glob_private.rs @@ -3,30 +3,31 @@ #![no_core] #![feature(no_core)] -// @is glob_private.json "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is glob_private.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" mod mod1 { - // @is - "$.index[*][?(@.name=='mod2')].kind" \"module\" - // @is - "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true" + // @is "$.index[*][?(@.name=='mod2')].kind" \"module\" + // @is "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true" mod mod2 { - // @set m2pub_id = - "$.index[*][?(@.name=='Mod2Public')].id" + // @set m2pub_id = "$.index[*][?(@.name=='Mod2Public')].id" pub struct Mod2Public; - // @!has - "$.index[*][?(@.name=='Mod2Private')]" + // @!has "$.index[*][?(@.name=='Mod2Private')]" struct Mod2Private; } - // @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')]" + // @set mod2_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')].id" pub use self::mod2::*; - // @set m1pub_id = - "$.index[*][?(@.name=='Mod1Public')].id" + // @set m1pub_id = "$.index[*][?(@.name=='Mod1Public')].id" pub struct Mod1Public; - // @!has - "$.index[*][?(@.name=='Mod1Private')]" + // @!has "$.index[*][?(@.name=='Mod1Private')]" struct Mod1Private; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')]" +// @set mod1_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id" pub use mod1::*; -// @has - "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id -// @has - "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id +// @ismany "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id +// @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id $mod2_use_id +// @ismany "$.index[*][?(@.name=='glob_private')].inner.items[*]" $mod1_use_id diff --git a/src/test/rustdoc-json/reexport/in_root_and_mod.rs b/src/test/rustdoc-json/reexport/in_root_and_mod.rs index 7bf10a986..7b97ebf21 100644 --- a/src/test/rustdoc-json/reexport/in_root_and_mod.rs +++ b/src/test/rustdoc-json/reexport/in_root_and_mod.rs @@ -1,17 +1,16 @@ #![feature(no_core)] #![no_core] -// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].kind" \"module\" -// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='foo')]" mod foo { - // @has - "$.index[*][?(@.name=='Foo')]" + // @has "$.index[*][?(@.name=='Foo')]" pub struct Foo; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]" +// @has "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]" pub use foo::Foo; pub mod bar { - // @has - "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]" + // @has "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]" pub use crate::foo::Foo; } diff --git a/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs index 2daadf762..f6d932d92 100644 --- a/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs +++ b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs @@ -2,19 +2,19 @@ #![no_core] pub mod foo { - // @set bar_id = in_root_and_mod_pub.json "$.index[*][?(@.name=='Bar')].id" - // @has - "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id + // @set bar_id = "$.index[*][?(@.name=='Bar')].id" + // @ismany "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id pub struct Bar; } -// @set root_import_id = - "$.index[*][?(@.inner.source=='foo::Bar')].id" -// @is - "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id -// @has - "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id +// @set root_import_id = "$.index[*][?(@.inner.source=='foo::Bar')].id" +// @is "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id +// @has "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id pub use foo::Bar; pub mod baz { - // @set baz_import_id = - "$.index[*][?(@.inner.source=='crate::foo::Bar')].id" - // @is - "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id - // @has - "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id + // @set baz_import_id = "$.index[*][?(@.inner.source=='crate::foo::Bar')].id" + // @is "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id + // @ismany "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id pub use crate::foo::Bar; } diff --git a/src/test/rustdoc-json/reexport/macro.rs b/src/test/rustdoc-json/reexport/macro.rs index b86614ffb..b4882100f 100644 --- a/src/test/rustdoc-json/reexport/macro.rs +++ b/src/test/rustdoc-json/reexport/macro.rs @@ -3,15 +3,13 @@ #![no_core] #![feature(no_core)] -// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2 - -// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id" -// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id +// @set repro_id = "$.index[*][?(@.name=='repro')].id" #[macro_export] macro_rules! repro { () => {}; } -// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id" -// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id +// @set repro2_id = "$.index[*][?(@.inner.name=='repro2')].id" pub use crate::repro as repro2; + +// @ismany "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id diff --git a/src/test/rustdoc-json/reexport/mod_not_included.rs b/src/test/rustdoc-json/reexport/mod_not_included.rs new file mode 100644 index 000000000..7b7600ef2 --- /dev/null +++ b/src/test/rustdoc-json/reexport/mod_not_included.rs @@ -0,0 +1,14 @@ +// Regression test for https://github.com/rust-lang/rust/issues/101103 + +#![feature(no_core)] +#![no_core] + +mod m1 { + pub fn x() {} +} + +pub use m1::x; + +// @has "$.index[*][?(@.name=='x' && @.kind=='function')]" +// @has "$.index[*][?(@.kind=='import' && @.inner.name=='x')].inner.source" '"m1::x"' +// @!has "$.index[*][?(@.name=='m1')]" diff --git a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs index 327b0f45f..687a3b2ac 100644 --- a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs +++ b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs @@ -1,18 +1,28 @@ // aux-build:pub-struct.rs +// ignore-tidy-linelength -// Test for the ICE in rust/83057 -// Am external type re-exported with different attributes shouldn't cause an error +// Test for the ICE in https://github.com/rust-lang/rust/issues/83057 +// An external type re-exported with different attributes shouldn't cause an error #![no_core] #![feature(no_core)] extern crate pub_struct as foo; - #[doc(inline)] + +// @set crate_use_id = "$.index[*][?(@.docs=='Hack A')].id" +// @set foo_id = "$.index[*][?(@.docs=='Hack A')].inner.id" +/// Hack A pub use foo::Foo; +// @set bar_id = "$.index[*][?(@.name=='bar')].id" pub mod bar { + // @is "$.index[*][?(@.docs=='Hack B')].inner.id" $foo_id + // @set bar_use_id = "$.index[*][?(@.docs=='Hack B')].id" + // @ismany "$.index[*][?(@.name=='bar')].inner.items[*]" $bar_use_id + /// Hack B pub use foo::Foo; } -// @count private_twice_one_inline.json "$.index[*][?(@.kind=='import')]" 2 +// @ismany "$.index[*][?(@.kind=='import')].id" $crate_use_id $bar_use_id +// @ismany "$.index[*][?(@.name=='private_twice_one_inline')].inner.items[*]" $bar_id $crate_use_id diff --git a/src/test/rustdoc-json/reexport/private_two_names.rs b/src/test/rustdoc-json/reexport/private_two_names.rs index 36d6a50d3..9858538a9 100644 --- a/src/test/rustdoc-json/reexport/private_two_names.rs +++ b/src/test/rustdoc-json/reexport/private_two_names.rs @@ -1,17 +1,22 @@ -// Test for the ICE in rust/83720 +// ignore-tidy-linelength + +// Test for the ICE in https://github.com/rust-lang/rust/issues/83720 // A pub-in-private type re-exported under two different names shouldn't cause an error #![no_core] #![feature(no_core)] -// @is private_two_names.json "$.index[*][?(@.name=='style')].kind" \"module\" -// @is private_two_names.json "$.index[*][?(@.name=='style')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='style')]" mod style { - // @has - "$.index[*](?(@.name=='Color'))" + // @set color_struct_id = "$.index[*][?(@.kind=='struct' && @.name=='Color')].id" pub struct Color; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Color')]" +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].inner.id" $color_struct_id +// @set color_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].id" pub use style::Color; -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')]" +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].inner.id" $color_struct_id +// @set colour_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].id" pub use style::Color as Colour; + +// @ismany "$.index[*][?(@.name=='private_two_names')].inner.items[*]" $color_export_id $colour_export_id diff --git a/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs b/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs new file mode 100644 index 000000000..239b1a23b --- /dev/null +++ b/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs @@ -0,0 +1,28 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/102583>. + +// @set impl_S = "$.index[*][?(@.docs=='impl S')].id" +// @has "$.index[*][?(@.name=='S')].inner.impls[*]" $impl_S +// @set is_present = "$.index[*][?(@.name=='is_present')].id" +// @is "$.index[*][?(@.docs=='impl S')].inner.items[*]" $is_present +// @!has "$.index[*][?(@.name=='hidden_impl')]" +// @!has "$.index[*][?(@.name=='hidden_fn')]" + +#![no_std] + +mod private_mod { + pub struct S; + + /// impl S + impl S { + pub fn is_present() {} + #[doc(hidden)] + pub fn hidden_fn() {} + } + + #[doc(hidden)] + impl S { + pub fn hidden_impl() {} + } +} + +pub use private_mod::*; diff --git a/src/test/rustdoc-json/reexport/rename_private.rs b/src/test/rustdoc-json/reexport/rename_private.rs index 2476399bd..8fd850f9b 100644 --- a/src/test/rustdoc-json/reexport/rename_private.rs +++ b/src/test/rustdoc-json/reexport/rename_private.rs @@ -3,12 +3,11 @@ #![no_core] #![feature(no_core)] -// @is rename_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" -// @is rename_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.kind=='inner')]" mod inner { - // @has - "$.index[*][?(@.name=='Public')]" + // @has "$.index[*][?(@.name=='Public')]" pub struct Public; } -// @is - "$.index[*][?(@.kind=='import')].inner.name" \"NewName\" +// @is "$.index[*][?(@.kind=='import')].inner.name" \"NewName\" pub use inner::Public as NewName; diff --git a/src/test/rustdoc-json/reexport/rename_public.rs b/src/test/rustdoc-json/reexport/rename_public.rs index 2dd438d22..e30907fe2 100644 --- a/src/test/rustdoc-json/reexport/rename_public.rs +++ b/src/test/rustdoc-json/reexport/rename_public.rs @@ -3,15 +3,15 @@ #![no_core] #![feature(no_core)] -// @set inner_id = rename_public.json "$.index[*][?(@.name=='inner')].id" -// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @set public_id = "$.index[*][?(@.name=='Public')].id" + // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id pub struct Public; } -// @set import_id = - "$.index[*][?(@.inner.name=='NewName')].id" -// @!has - "$.index[*][?(@.inner.name=='Public')]" -// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $import_id -// @is - "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.inner.name=='NewName')].id" +// @!has "$.index[*][?(@.inner.name=='Public')]" +// @is "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" pub use inner::Public as NewName; + +// @ismany "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id $import_id diff --git a/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs index eedddd6a7..880dbdc44 100644 --- a/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs +++ b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs @@ -1,15 +1,21 @@ +// ignore-tidy-linelength + // Regression test for <https://github.com/rust-lang/rust/issues/97432>. #![feature(no_core)] #![no_std] #![no_core] -// @has same_type_reexported_more_than_once.json -// @has - "$.index[*][?(@.name=='Trait')]" -pub use inner::Trait; -// @has - "$.index[*].inner[?(@.name=='Reexport')].id" -pub use inner::Trait as Reexport; - mod inner { + // @set trait_id = "$.index[*][?(@.name=='Trait')].id" pub trait Trait {} } + +// @set export_id = "$.index[*][?(@.inner.name=='Trait')].id" +// @is "$.index[*][?(@.inner.name=='Trait')].inner.id" $trait_id +pub use inner::Trait; +// @set reexport_id = "$.index[*][?(@.inner.name=='Reexport')].id" +// @is "$.index[*][?(@.inner.name=='Reexport')].inner.id" $trait_id +pub use inner::Trait as Reexport; + +// @ismany "$.index[*][?(@.name=='same_type_reexported_more_than_once')].inner.items[*]" $reexport_id $export_id diff --git a/src/test/rustdoc-json/reexport/simple_private.rs b/src/test/rustdoc-json/reexport/simple_private.rs index 5ec13e403..d058ce059 100644 --- a/src/test/rustdoc-json/reexport/simple_private.rs +++ b/src/test/rustdoc-json/reexport/simple_private.rs @@ -2,14 +2,15 @@ #![no_core] #![feature(no_core)] -// @is simple_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" -// @is simple_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='inner')]" mod inner { - // @set pub_id = - "$.index[*][?(@.name=='Public')].id" + // @set pub_id = "$.index[*][?(@.name=='Public')].id" pub struct Public; } -// @is - "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +// @is "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +// @is "$.index[*][?(@.kind=='import')].inner.id" $pub_id +// @set use_id = "$.index[*][?(@.kind=='import')].id" pub use inner::Public; -// @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $pub_id +// @ismany "$.index[*][?(@.name=='simple_private')].inner.items[*]" $use_id diff --git a/src/test/rustdoc-json/reexport/simple_public.rs b/src/test/rustdoc-json/reexport/simple_public.rs index 2e4de301f..e64a0dcb7 100644 --- a/src/test/rustdoc-json/reexport/simple_public.rs +++ b/src/test/rustdoc-json/reexport/simple_public.rs @@ -3,16 +3,16 @@ #![no_core] #![feature(no_core)] -// @set inner_id = simple_public.json "$.index[*][?(@.name=='inner')].id" -// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $inner_id +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @set public_id = "$.index[*][?(@.name=='Public')].id" + // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id pub struct Public; } -// @set import_id = - "$.index[*][?(@.inner.name=='Public')].id" -// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id -// @is - "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.inner.name=='Public')].id" +// @is "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" pub use inner::Public; + +// @ismany "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id $inner_id diff --git a/src/test/rustdoc-json/return_private.rs b/src/test/rustdoc-json/return_private.rs index 6b324d009..a8d1fae30 100644 --- a/src/test/rustdoc-json/return_private.rs +++ b/src/test/rustdoc-json/return_private.rs @@ -8,8 +8,8 @@ mod secret { pub struct Secret; } -// @is return_private.json "$.index[*][?(@.name=='get_secret')].kind" \"function\" -// @is return_private.json "$.index[*][?(@.name=='get_secret')].inner.decl.output.inner.name" \"secret::Secret\" +// @is "$.index[*][?(@.name=='get_secret')].kind" \"function\" +// @is "$.index[*][?(@.name=='get_secret')].inner.decl.output.inner.name" \"secret::Secret\" pub fn get_secret() -> secret::Secret { secret::Secret } diff --git a/src/test/rustdoc-json/stripped_modules.rs b/src/test/rustdoc-json/stripped_modules.rs index 91f9f02ad..d2664b49e 100644 --- a/src/test/rustdoc-json/stripped_modules.rs +++ b/src/test/rustdoc-json/stripped_modules.rs @@ -1,20 +1,20 @@ #![no_core] #![feature(no_core)] -// @!has stripped_modules.json "$.index[*][?(@.name=='no_pub_inner')]" +// @!has "$.index[*][?(@.name=='no_pub_inner')]" mod no_pub_inner { fn priv_inner() {} } -// @!has - "$.index[*][?(@.name=='pub_inner_unreachable')]" +// @!has "$.index[*][?(@.name=='pub_inner_unreachable')]" mod pub_inner_unreachable { - // @!has - "$.index[*][?(@.name=='pub_inner_1')]" + // @!has "$.index[*][?(@.name=='pub_inner_1')]" pub fn pub_inner_1() {} } -// @has - "$.index[*][?(@.name=='pub_inner_reachable')]" +// @!has "$.index[*][?(@.name=='pub_inner_reachable')]" mod pub_inner_reachable { - // @has - "$.index[*][?(@.name=='pub_inner_2')]" + // @has "$.index[*][?(@.name=='pub_inner_2')]" pub fn pub_inner_2() {} } diff --git a/src/test/rustdoc-json/structs/plain_all_pub.rs b/src/test/rustdoc-json/structs/plain_all_pub.rs new file mode 100644 index 000000000..b86ab93c2 --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_all_pub.rs @@ -0,0 +1,11 @@ +pub struct Demo { + pub x: i32, + pub y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @set y = "$.index[*][?(@.name=='y')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[1]" $y +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 2 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" false diff --git a/src/test/rustdoc-json/structs/plain_doc_hidden.rs b/src/test/rustdoc-json/structs/plain_doc_hidden.rs new file mode 100644 index 000000000..7800b55a4 --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_doc_hidden.rs @@ -0,0 +1,11 @@ +pub struct Demo { + pub x: i32, + #[doc(hidden)] + pub y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @!has "$.index[*][?(@.name=='y')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true diff --git a/src/test/rustdoc-json/structs/plain_empty.rs b/src/test/rustdoc-json/structs/plain_empty.rs index a251caf4b..1d01b8bc1 100644 --- a/src/test/rustdoc-json/structs/plain_empty.rs +++ b/src/test/rustdoc-json/structs/plain_empty.rs @@ -1,6 +1,5 @@ -// @has plain_empty.json "$.index[*][?(@.name=='PlainEmpty')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.fields_stripped" false -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.fields" [] +// @is "$.index[*][?(@.name=='PlainEmpty')].visibility" \"public\" +// @is "$.index[*][?(@.name=='PlainEmpty')].kind" \"struct\" +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields_stripped" false +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields" [] pub struct PlainEmpty {} diff --git a/src/test/rustdoc-json/structs/plain_pub_priv.rs b/src/test/rustdoc-json/structs/plain_pub_priv.rs new file mode 100644 index 000000000..9b771224d --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_pub_priv.rs @@ -0,0 +1,9 @@ +pub struct Demo { + pub x: i32, + y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true diff --git a/src/test/rustdoc-json/structs/tuple.rs b/src/test/rustdoc-json/structs/tuple.rs index 4e510b398..6bdb753ee 100644 --- a/src/test/rustdoc-json/structs/tuple.rs +++ b/src/test/rustdoc-json/structs/tuple.rs @@ -1,5 +1,4 @@ -// @has tuple.json "$.index[*][?(@.name=='Tuple')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Tuple')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='Tuple')].inner.struct_type" \"tuple\" -// @has - "$.index[*][?(@.name=='Tuple')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='Tuple')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Tuple')].kind" \"struct\" +// @is "$.index[*][?(@.name=='Tuple')].inner.kind.tuple" '[null, null]' pub struct Tuple(u32, String); diff --git a/src/test/rustdoc-json/structs/tuple_empty.rs b/src/test/rustdoc-json/structs/tuple_empty.rs new file mode 100644 index 000000000..0ad6a8954 --- /dev/null +++ b/src/test/rustdoc-json/structs/tuple_empty.rs @@ -0,0 +1,2 @@ +// @is "$.index[*][?(@.name=='TupleUnit')].inner.kind.tuple" [] +pub struct TupleUnit(); diff --git a/src/test/rustdoc-json/structs/tuple_pub_priv.rs b/src/test/rustdoc-json/structs/tuple_pub_priv.rs new file mode 100644 index 000000000..9d5a1d1c8 --- /dev/null +++ b/src/test/rustdoc-json/structs/tuple_pub_priv.rs @@ -0,0 +1,13 @@ +pub struct Demo( + i32, + /// field + pub i32, + #[doc(hidden)] i32, +); + +// @set field = "$.index[*][?(@.docs=='field')].id" + +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[0]" null +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[1]" $field +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[2]" null +// @count "$.index[*][?(@.name=='Demo')].inner.kind.tuple[*]" 3 diff --git a/src/test/rustdoc-json/structs/unit.rs b/src/test/rustdoc-json/structs/unit.rs index 559d3068d..265709717 100644 --- a/src/test/rustdoc-json/structs/unit.rs +++ b/src/test/rustdoc-json/structs/unit.rs @@ -1,5 +1,4 @@ -// @has unit.json "$.index[*][?(@.name=='Unit')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Unit')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='Unit')].inner.struct_type" \"unit\" -// @has - "$.index[*][?(@.name=='Unit')].inner.fields" [] +// @is "$.index[*][?(@.name=='Unit')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Unit')].kind" \"struct\" +// @is "$.index[*][?(@.name=='Unit')].inner.kind" \"unit\" pub struct Unit; diff --git a/src/test/rustdoc-json/structs/with_generics.rs b/src/test/rustdoc-json/structs/with_generics.rs index 65cfe7eff..00474800a 100644 --- a/src/test/rustdoc-json/structs/with_generics.rs +++ b/src/test/rustdoc-json/structs/with_generics.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; -// @has with_generics.json "$.index[*][?(@.name=='WithGenerics')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='WithGenerics')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].name" \"T\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].kind.type" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].name" \"U\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].kind.type" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='WithGenerics')].visibility" \"public\" +// @is "$.index[*][?(@.name=='WithGenerics')].kind" \"struct\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].name" \"U\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields" [] pub struct WithGenerics<T, U> { stuff: Vec<T>, things: HashMap<U, U>, diff --git a/src/test/rustdoc-json/structs/with_primitives.rs b/src/test/rustdoc-json/structs/with_primitives.rs index 9e64317ec..9c5a37f39 100644 --- a/src/test/rustdoc-json/structs/with_primitives.rs +++ b/src/test/rustdoc-json/structs/with_primitives.rs @@ -1,9 +1,9 @@ -// @has with_primitives.json "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].name" \"\'a\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].kind.lifetime.outlives" [] -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\" +// @is "$.index[*][?(@.name=='WithPrimitives')].kind" \"struct\" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields" [] pub struct WithPrimitives<'a> { num: u32, s: &'a str, diff --git a/src/test/rustdoc-json/traits/has_body.rs b/src/test/rustdoc-json/traits/has_body.rs index 44dacb1ee..a57cb97d4 100644 --- a/src/test/rustdoc-json/traits/has_body.rs +++ b/src/test/rustdoc-json/traits/has_body.rs @@ -1,21 +1,21 @@ -// @has has_body.json "$.index[*][?(@.name=='Foo')]" +// @has "$.index[*][?(@.name=='Foo')]" pub trait Foo { - // @has - "$.index[*][?(@.name=='no_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='no_self')].inner.has_body" false fn no_self(); - // @has - "$.index[*][?(@.name=='move_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='move_self')].inner.has_body" false fn move_self(self); - // @has - "$.index[*][?(@.name=='ref_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='ref_self')].inner.has_body" false fn ref_self(&self); - // @has - "$.index[*][?(@.name=='no_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='no_self_def')].inner.has_body" true fn no_self_def() {} - // @has - "$.index[*][?(@.name=='move_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='move_self_def')].inner.has_body" true fn move_self_def(self) {} - // @has - "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true fn ref_self_def(&self) {} } pub trait Bar: Clone { - // @has - "$.index[*][?(@.name=='method')].inner.has_body" false + // @is "$.index[*][?(@.name=='method')].inner.has_body" false fn method(&self, param: usize); } diff --git a/src/test/rustdoc-json/traits/implementors.rs b/src/test/rustdoc-json/traits/implementors.rs index f7f03d987..db3fe5df7 100644 --- a/src/test/rustdoc-json/traits/implementors.rs +++ b/src/test/rustdoc-json/traits/implementors.rs @@ -1,19 +1,19 @@ #![feature(no_core)] #![no_core] -// @set wham = implementors.json "$.index[*][?(@.name=='Wham')].id" -// @count - "$.index[*][?(@.name=='Wham')].inner.implementations[*]" 1 -// @set gmWham = - "$.index[*][?(@.name=='Wham')].inner.implementations[0]" +// @set wham = "$.index[*][?(@.name=='Wham')].id" +// @count "$.index[*][?(@.name=='Wham')].inner.implementations[*]" 1 +// @set gmWham = "$.index[*][?(@.name=='Wham')].inner.implementations[0]" pub trait Wham {} -// @count - "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[*]" 1 -// @is - "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[0]" $gmWham -// @set gm = - "$.index[*][?(@.name=='Wham')].id" +// @count "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[*]" 1 +// @is "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[0]" $gmWham +// @set gm = "$.index[*][?(@.name=='Wham')].id" // jsonpath_lib isnt expressive enough (for now) to get the "impl" item, so we // just check it isn't pointing to the type, but when you port to jsondocck-ng // check what the impl item is -// @!is - "$.index[*][?(@.name=='Wham')].inner.implementations[0]" $gm +// @!is "$.index[*][?(@.name=='Wham')].inner.implementations[0]" $gm pub struct GeorgeMichael {} impl Wham for GeorgeMichael {} diff --git a/src/test/rustdoc-json/traits/supertrait.rs b/src/test/rustdoc-json/traits/supertrait.rs index 486a8e713..4048fdd74 100644 --- a/src/test/rustdoc-json/traits/supertrait.rs +++ b/src/test/rustdoc-json/traits/supertrait.rs @@ -4,23 +4,23 @@ #![feature(lang_items)] #![no_core] -// @set loud_id = supertrait.json "$.index[*][?(@.name=='Loud')].id" +// @set loud_id = "$.index[*][?(@.name=='Loud')].id" pub trait Loud {} -// @set very_loud_id = - "$.index[*][?(@.name=='VeryLoud')].id" -// @count - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.inner.id" $loud_id +// @set very_loud_id = "$.index[*][?(@.name=='VeryLoud')].id" +// @count "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 +// @is "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.id" $loud_id pub trait VeryLoud: Loud {} -// @set sounds_good_id = - "$.index[*][?(@.name=='SoundsGood')].id" +// @set sounds_good_id = "$.index[*][?(@.name=='SoundsGood')].id" pub trait SoundsGood {} -// @count - "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 -// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.inner.id" $very_loud_id -// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.inner.id" $sounds_good_id +// @count "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 +// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.id" $sounds_good_id pub trait MetalBand: VeryLoud + SoundsGood {} -// @count - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 -// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.inner.id" $very_loud_id -// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.inner.id" $sounds_good_id +// @count "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 +// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.id" $sounds_good_id pub trait DnabLatem: SoundsGood + VeryLoud {} diff --git a/src/test/rustdoc-json/traits/uses_extern_trait.rs b/src/test/rustdoc-json/traits/uses_extern_trait.rs new file mode 100644 index 000000000..430dd1543 --- /dev/null +++ b/src/test/rustdoc-json/traits/uses_extern_trait.rs @@ -0,0 +1,7 @@ +#![no_std] +pub fn drop_default<T: core::default::Default>(_x: T) {} + +// FIXME(adotinthevoid): Theses shouldn't be here +// @has "$.index[*][?(@.name=='Debug')]" +// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[*]" +// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt diff --git a/src/test/rustdoc-json/type/dyn.rs b/src/test/rustdoc-json/type/dyn.rs index f53dc03f4..eaf249252 100644 --- a/src/test/rustdoc-json/type/dyn.rs +++ b/src/test/rustdoc-json/type/dyn.rs @@ -1,21 +1,46 @@ // ignore-tidy-linelength +use std::fmt::Debug; -// @count dyn.json "$.index[*][?(@.name=='dyn')].inner.items" 1 -// @set sync_int_gen = - "$.index[*][?(@.name=='SyncIntGen')].id" -// @is - "$.index[*][?(@.name=='dyn')].inner.items[0]" $sync_int_gen +// @count "$.index[*][?(@.name=='dyn')].inner.items[*]" 3 +// @set sync_int_gen = "$.index[*][?(@.name=='SyncIntGen')].id" +// @set ref_fn = "$.index[*][?(@.name=='RefFn')].id" +// @set weird_order = "$.index[*][?(@.name=='WeirdOrder')].id" +// @ismany "$.index[*][?(@.name=='dyn')].inner.items[*]" $sync_int_gen $ref_fn $weird_order -// @is - "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}' -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" [] -// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1 -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.name" \"Fn\" -// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[*]" 3 -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[0].trait_bound.trait.inner.name" \"Send\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[1].trait_bound.trait.inner.name" \"Sync\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[2]" "{\"outlives\": \"'static\"}" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}' +// @is "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" [] +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"dyn_trait\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.lifetime" \"\'static\" +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[*]" 3 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].trait.name" '"Sync"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}' pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>; + +// @is "$.index[*][?(@.name=='RefFn')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='RefFn')].inner.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.mutable" 'false' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.lifetime" "\"'a\"" +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.kind" '"dyn_trait"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.lifetime" null +// @count "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[*]" 1 +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].inner.lifetime" "\"'b\"" +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.inner.lifetime" "\"'b\"" +pub type RefFn<'a> = &'a dyn for<'b> Fn(&'b i32) -> &'b i32; + +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Debug"' +pub type WeirdOrder = Box<dyn Send + Debug>; diff --git a/src/test/rustdoc-json/type/extern.rs b/src/test/rustdoc-json/type/extern.rs new file mode 100644 index 000000000..d287d5ebe --- /dev/null +++ b/src/test/rustdoc-json/type/extern.rs @@ -0,0 +1,10 @@ +#![feature(extern_types)] + +extern { + /// No inner information + pub type Foo; +} + +// @is "$.index[*][?(@.docs=='No inner information')].name" '"Foo"' +// @is "$.index[*][?(@.docs=='No inner information')].kind" '"foreign_type"' +// @!has "$.index[*][?(@.docs=='No inner information')].inner" diff --git a/src/test/rustdoc-json/type/fn_lifetime.rs b/src/test/rustdoc-json/type/fn_lifetime.rs index e0d1e9649..d7216ec76 100644 --- a/src/test/rustdoc-json/type/fn_lifetime.rs +++ b/src/test/rustdoc-json/type/fn_lifetime.rs @@ -1,28 +1,27 @@ // ignore-tidy-linelength -// @is fn_lifetime.json "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\" -// @has - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0 -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0 -// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @ismany "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\" +// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" pub type GenericFn<'a> = fn(&'a i32) -> &'a i32; -// @is fn_lifetime.json "$.index[*][?(@.name=='ForAll')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\" -// @has - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime" -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].kind" \"typedef\" +// @count "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" pub type ForAll = for<'a> fn(&'a i32) -> &'a i32; diff --git a/src/test/rustdoc-json/type/generic_default.rs b/src/test/rustdoc-json/type/generic_default.rs index b6bb6dcc5..9c6d4540b 100644 --- a/src/test/rustdoc-json/type/generic_default.rs +++ b/src/test/rustdoc-json/type/generic_default.rs @@ -1,33 +1,33 @@ // ignore-tidy-linelength -// @set result = generic_default.json "$.index[*][?(@.name=='Result')].id" +// @set result = "$.index[*][?(@.name=='Result')].id" pub enum Result<T, E> { Ok(T), Err(E), } -// @set my_error = - "$.index[*][?(@.name=='MyError')].id" +// @set my_error = "$.index[*][?(@.name=='MyError')].id" pub struct MyError {} -// @is - "$.index[*][?(@.name=='MyResult')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0 -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2 -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\" -// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type" -// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type" -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0 -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0 -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" [] -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\" +// @is "$.index[*][?(@.name=='MyResult')].kind" \"typedef\" +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2 +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type" +// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type" +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0 +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" [] +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\" pub type MyResult<T, E = MyError> = Result<T, E>; diff --git a/src/test/rustdoc-json/type/hrtb.rs b/src/test/rustdoc-json/type/hrtb.rs new file mode 100644 index 000000000..2c4ee00d4 --- /dev/null +++ b/src/test/rustdoc-json/type/hrtb.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength + +// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F","kind": "generic"}' +// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +pub fn genfn<F>(f: F) +where + for<'a, 'b> F: Fn(&'a i32, &'b i32), +{ + let zero = 0; + f(&zero, &zero); +} + +// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.kind" '"dyn_trait"' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.lifetime" null +// @count "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[*]" 1 +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].trait.name" '"Fn"' +pub fn dynfn(f: &dyn for<'a, 'b> Fn(&'a i32, &'b i32)) { + let zero = 0; + f(&zero, &zero); +} diff --git a/src/test/rustdoc-json/unions/impl.rs b/src/test/rustdoc-json/unions/impl.rs index 0388b4a8c..4454a69ec 100644 --- a/src/test/rustdoc-json/unions/impl.rs +++ b/src/test/rustdoc-json/unions/impl.rs @@ -1,15 +1,15 @@ #![no_std] -// @has impl.json "$.index[*][?(@.name=='Ux')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Ux')].kind" \"union\" +// @is "$.index[*][?(@.name=='Ux')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Ux')].kind" \"union\" pub union Ux { a: u32, b: u64 } -// @has - "$.index[*][?(@.name=='Num')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Num')].kind" \"trait\" +// @is "$.index[*][?(@.name=='Num')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Num')].kind" \"trait\" pub trait Num {} -// @count - "$.index[*][?(@.name=='Ux')].inner.impls" 1 +// @count "$.index[*][?(@.name=='Ux')].inner.impls" 1 impl Num for Ux {} diff --git a/src/test/rustdoc-json/unions/union.rs b/src/test/rustdoc-json/unions/union.rs index ac2eb7977..c9df2b81c 100644 --- a/src/test/rustdoc-json/unions/union.rs +++ b/src/test/rustdoc-json/unions/union.rs @@ -1,7 +1,15 @@ -// @has union.json "$.index[*][?(@.name=='Union')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Union')].kind" \"union\" -// @!has - "$.index[*][?(@.name=='Union')].inner.struct_type" +// @has "$.index[*][?(@.name=='Union')].visibility" \"public\" +// @has "$.index[*][?(@.name=='Union')].kind" \"union\" +// @!has "$.index[*][?(@.name=='Union')].inner.struct_type" +// @set Union = "$.index[*][?(@.name=='Union')].id" pub union Union { int: i32, float: f32, } + + +// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.kind" '"resolved_path"' +// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.inner.id" $Union +pub fn make_int_union(int: i32) -> Union { + Union { int } +} diff --git a/src/test/rustdoc-ui/bare-urls.stderr b/src/test/rustdoc-ui/bare-urls.stderr index 7097a8ddf..ccf52cd0b 100644 --- a/src/test/rustdoc-ui/bare-urls.stderr +++ b/src/test/rustdoc-ui/bare-urls.stderr @@ -4,12 +4,12 @@ error: this URL is not a hyperlink LL | /// https://somewhere.com | ^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com>` | + = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/bare-urls.rs:3:9 | LL | #![deny(rustdoc::bare_urls)] | ^^^^^^^^^^^^^^^^^^ - = note: bare URLs are not automatically turned into clickable links error: this URL is not a hyperlink --> $DIR/bare-urls.rs:7:5 diff --git a/src/test/rustdoc-ui/check-attr-test.stderr b/src/test/rustdoc-ui/check-attr-test.stderr index b1fa9edf0..01beba1ff 100644 --- a/src/test/rustdoc-ui/check-attr-test.stderr +++ b/src/test/rustdoc-ui/check-attr-test.stderr @@ -8,12 +8,12 @@ error: unknown attribute `compile-fail`. Did you mean `compile_fail`? 9 | | /// ``` | |_______^ | + = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully note: the lint level is defined here --> $DIR/check-attr-test.rs:3:9 | 3 | #![deny(rustdoc::invalid_codeblock_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully error: unknown attribute `compilefail`. Did you mean `compile_fail`? --> $DIR/check-attr-test.rs:5:1 diff --git a/src/test/rustdoc-ui/check-attr.stderr b/src/test/rustdoc-ui/check-attr.stderr index 370b804c5..f66e63ab7 100644 --- a/src/test/rustdoc-ui/check-attr.stderr +++ b/src/test/rustdoc-ui/check-attr.stderr @@ -10,12 +10,12 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully note: the lint level is defined here --> $DIR/check-attr.rs:1:9 | LL | #![deny(rustdoc::invalid_codeblock_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully error: unknown attribute `compilefail`. Did you mean `compile_fail`? --> $DIR/check-attr.rs:3:1 diff --git a/src/test/rustdoc-ui/check-cfg-test.stderr b/src/test/rustdoc-ui/check-cfg-test.stderr index dc25205da..9770be2f1 100644 --- a/src/test/rustdoc-ui/check-cfg-test.stderr +++ b/src/test/rustdoc-ui/check-cfg-test.stderr @@ -4,8 +4,8 @@ warning: unexpected `cfg` condition value LL | #[cfg(feature = "invalid")] | ^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unexpected_cfgs)]` on by default = note: expected values for `feature` are: test + = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/check-fail.rs b/src/test/rustdoc-ui/check-fail.rs index 2355d6a3d..c5e1759ee 100644 --- a/src/test/rustdoc-ui/check-fail.rs +++ b/src/test/rustdoc-ui/check-fail.rs @@ -1,5 +1,6 @@ // compile-flags: -Z unstable-options --check +#![feature(rustdoc_missing_doc_code_examples)] #![deny(missing_docs)] #![deny(rustdoc::all)] diff --git a/src/test/rustdoc-ui/check-fail.stderr b/src/test/rustdoc-ui/check-fail.stderr index 5d46dc720..d8aeccbfc 100644 --- a/src/test/rustdoc-ui/check-fail.stderr +++ b/src/test/rustdoc-ui/check-fail.stderr @@ -1,30 +1,30 @@ error: missing documentation for a function - --> $DIR/check-fail.rs:11:1 + --> $DIR/check-fail.rs:12:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/check-fail.rs:3:9 + --> $DIR/check-fail.rs:4:9 | LL | #![deny(missing_docs)] | ^^^^^^^^^^^^ error: missing code example in this documentation - --> $DIR/check-fail.rs:11:1 + --> $DIR/check-fail.rs:12:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/check-fail.rs:4:9 + --> $DIR/check-fail.rs:5:9 | LL | #![deny(rustdoc::all)] | ^^^^^^^^^^^^ = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]` error: unknown attribute `testharness`. Did you mean `test_harness`? - --> $DIR/check-fail.rs:6:1 + --> $DIR/check-fail.rs:7:1 | LL | / //! ```rust,testharness LL | | @@ -32,11 +32,11 @@ LL | | //! let x = 12; LL | | //! ``` | |_______^ | - = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]` error: unknown attribute `testharness`. Did you mean `test_harness`? - --> $DIR/check-fail.rs:15:1 + --> $DIR/check-fail.rs:16:1 | LL | / /// hello LL | | diff --git a/src/test/rustdoc-ui/check.rs b/src/test/rustdoc-ui/check.rs index 2b44ba24b..f70b03361 100644 --- a/src/test/rustdoc-ui/check.rs +++ b/src/test/rustdoc-ui/check.rs @@ -2,9 +2,11 @@ // compile-flags: -Z unstable-options --check // normalize-stderr-test: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL" -#![warn(missing_docs)] +#![feature(rustdoc_missing_doc_code_examples)] //~^ WARN //~^^ WARN + +#![warn(missing_docs)] #![warn(rustdoc::all)] pub fn foo() {} diff --git a/src/test/rustdoc-ui/check.stderr b/src/test/rustdoc-ui/check.stderr index 06e607fbe..d379f33f2 100644 --- a/src/test/rustdoc-ui/check.stderr +++ b/src/test/rustdoc-ui/check.stderr @@ -1,44 +1,46 @@ warning: missing documentation for the crate --> $DIR/check.rs:5:1 | -LL | / #![warn(missing_docs)] +LL | / #![feature(rustdoc_missing_doc_code_examples)] LL | | LL | | -LL | | #![warn(rustdoc::all)] +LL | | +... | LL | | LL | | pub fn foo() {} | |_______________^ | note: the lint level is defined here - --> $DIR/check.rs:5:9 + --> $DIR/check.rs:9:9 | LL | #![warn(missing_docs)] | ^^^^^^^^^^^^ warning: missing documentation for a function - --> $DIR/check.rs:10:1 + --> $DIR/check.rs:12:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^ warning: no documentation found for this crate's top-level module | + = help: The following guide may be of use: + https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html note: the lint level is defined here - --> $DIR/check.rs:8:9 + --> $DIR/check.rs:10:9 | LL | #![warn(rustdoc::all)] | ^^^^^^^^^^^^ = note: `#[warn(rustdoc::missing_crate_level_docs)]` implied by `#[warn(rustdoc::all)]` - = help: The following guide may be of use: - https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html warning: missing code example in this documentation --> $DIR/check.rs:5:1 | -LL | / #![warn(missing_docs)] +LL | / #![feature(rustdoc_missing_doc_code_examples)] +LL | | LL | | LL | | -LL | | #![warn(rustdoc::all)] +... | LL | | LL | | pub fn foo() {} | |_______________^ @@ -46,7 +48,7 @@ LL | | pub fn foo() {} = note: `#[warn(rustdoc::missing_doc_code_examples)]` implied by `#[warn(rustdoc::all)]` warning: missing code example in this documentation - --> $DIR/check.rs:10:1 + --> $DIR/check.rs:12:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 67d9c3989..3e08354a6 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -4,12 +4,12 @@ error: unresolved link to `v2` LL | /// [v2] | ^^ no item named `v2` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/deny-intra-link-resolution-failure.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/diagnostic-width.rs b/src/test/rustdoc-ui/diagnostic-width.rs index 61961d5ec..290d9db77 100644 --- a/src/test/rustdoc-ui/diagnostic-width.rs +++ b/src/test/rustdoc-ui/diagnostic-width.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zunstable-options --diagnostic-width=10 +// compile-flags: --diagnostic-width=10 #![deny(rustdoc::bare_urls)] /// This is a long line that contains a http://link.com diff --git a/src/test/rustdoc-ui/diagnostic-width.stderr b/src/test/rustdoc-ui/diagnostic-width.stderr index fed049d2b..1a00d10d3 100644 --- a/src/test/rustdoc-ui/diagnostic-width.stderr +++ b/src/test/rustdoc-ui/diagnostic-width.stderr @@ -4,12 +4,12 @@ error: this URL is not a hyperlink LL | ... a http://link.com | ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://link.com>` | + = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/diagnostic-width.rs:2:9 | LL | ...ny(rustdoc::bare_url... | ^^^^^^^^^^^^^^^^^^ - = note: bare URLs are not automatically turned into clickable links error: aborting due to previous error diff --git a/src/test/rustdoc-ui/doc-attr.stderr b/src/test/rustdoc-ui/doc-attr.stderr index cc2494c92..68df2771f 100644 --- a/src/test/rustdoc-ui/doc-attr.stderr +++ b/src/test/rustdoc-ui/doc-attr.stderr @@ -4,14 +4,14 @@ error: unknown `doc` attribute `as_ptr` LL | #[doc(as_ptr)] | ^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> note: the lint level is defined here --> $DIR/doc-attr.rs:2:9 | LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> error: invalid `doc` attribute --> $DIR/doc-attr.rs:12:7 diff --git a/src/test/rustdoc-ui/doc-include-suggestion.stderr b/src/test/rustdoc-ui/doc-include-suggestion.stderr index 870b7efa2..fcc93d053 100644 --- a/src/test/rustdoc-ui/doc-include-suggestion.stderr +++ b/src/test/rustdoc-ui/doc-include-suggestion.stderr @@ -4,9 +4,9 @@ warning: unknown `doc` attribute `include` LL | #[doc(include = "external-cross-doc.md")] | ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- help: use `doc = include_str!` instead: `#[doc = include_str!("external-cross-doc.md")]` | - = note: `#[warn(invalid_doc_attributes)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + = note: `#[warn(invalid_doc_attributes)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/doc-spotlight.stderr b/src/test/rustdoc-ui/doc-spotlight.stderr index 8e7831139..58612327f 100644 --- a/src/test/rustdoc-ui/doc-spotlight.stderr +++ b/src/test/rustdoc-ui/doc-spotlight.stderr @@ -4,16 +4,16 @@ error: unknown `doc` attribute `spotlight` LL | #[doc(spotlight)] | ^^^^^^^^^ help: use `notable_trait` instead | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + = note: `doc(spotlight)` was renamed to `doc(notable_trait)` + = note: `doc(spotlight)` is now a no-op note: the lint level is defined here --> $DIR/doc-spotlight.rs:2:9 | LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: `doc(spotlight)` was renamed to `doc(notable_trait)` - = note: `doc(spotlight)` is now a no-op error: aborting due to previous error diff --git a/src/test/rustdoc-ui/doc-test-attr.stderr b/src/test/rustdoc-ui/doc-test-attr.stderr index 7f5e2d6bc..5e6014954 100644 --- a/src/test/rustdoc-ui/doc-test-attr.stderr +++ b/src/test/rustdoc-ui/doc-test-attr.stderr @@ -4,13 +4,13 @@ error: `#[doc(test(...)]` takes a list of attributes LL | #![doc(test)] | ^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> note: the lint level is defined here --> $DIR/doc-test-attr.rs:2:9 | LL | #![deny(invalid_doc_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> error: `#[doc(test(...)]` takes a list of attributes --> $DIR/doc-test-attr.rs:7:8 diff --git a/src/test/rustdoc-ui/doc-without-codeblock.rs b/src/test/rustdoc-ui/doc-without-codeblock.rs index 315fca195..86d7c83d3 100644 --- a/src/test/rustdoc-ui/doc-without-codeblock.rs +++ b/src/test/rustdoc-ui/doc-without-codeblock.rs @@ -1,4 +1,5 @@ -#![deny(rustdoc::missing_doc_code_examples)] //~ ERROR missing code example in this documentation +#![feature(rustdoc_missing_doc_code_examples)] //~ ERROR missing code example in this documentation +#![deny(rustdoc::missing_doc_code_examples)] /// Some docs. //~^ ERROR missing code example in this documentation diff --git a/src/test/rustdoc-ui/doc-without-codeblock.stderr b/src/test/rustdoc-ui/doc-without-codeblock.stderr index 1c1380441..ebf2a2d54 100644 --- a/src/test/rustdoc-ui/doc-without-codeblock.stderr +++ b/src/test/rustdoc-ui/doc-without-codeblock.stderr @@ -1,35 +1,35 @@ error: missing code example in this documentation --> $DIR/doc-without-codeblock.rs:1:1 | -LL | / #![deny(rustdoc::missing_doc_code_examples)] +LL | / #![feature(rustdoc_missing_doc_code_examples)] +LL | | #![deny(rustdoc::missing_doc_code_examples)] LL | | LL | | /// Some docs. -LL | | ... | LL | | } LL | | } | |_^ | note: the lint level is defined here - --> $DIR/doc-without-codeblock.rs:1:9 + --> $DIR/doc-without-codeblock.rs:2:9 | LL | #![deny(rustdoc::missing_doc_code_examples)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing code example in this documentation - --> $DIR/doc-without-codeblock.rs:7:1 + --> $DIR/doc-without-codeblock.rs:8:1 | LL | /// And then, the princess died. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing code example in this documentation - --> $DIR/doc-without-codeblock.rs:10:5 + --> $DIR/doc-without-codeblock.rs:11:5 | LL | /// Or maybe not because she saved herself! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing code example in this documentation - --> $DIR/doc-without-codeblock.rs:3:1 + --> $DIR/doc-without-codeblock.rs:4:1 | LL | /// Some docs. | ^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/doc_cfg_hide.rs b/src/test/rustdoc-ui/doc_cfg_hide.rs new file mode 100644 index 000000000..5d8791748 --- /dev/null +++ b/src/test/rustdoc-ui/doc_cfg_hide.rs @@ -0,0 +1,11 @@ +#![feature(doc_cfg_hide)] +#![deny(warnings)] + +#![doc(cfg_hide = "test")] //~ ERROR +//~^ WARN +#![doc(cfg_hide)] //~ ERROR +//~^ WARN + +#[doc(cfg_hide(doc))] //~ ERROR +//~^ WARN +pub fn foo() {} diff --git a/src/test/rustdoc-ui/doc_cfg_hide.stderr b/src/test/rustdoc-ui/doc_cfg_hide.stderr new file mode 100644 index 000000000..03623368c --- /dev/null +++ b/src/test/rustdoc-ui/doc_cfg_hide.stderr @@ -0,0 +1,40 @@ +error: this attribute can only be applied at the crate level + --> $DIR/doc_cfg_hide.rs:9:7 + | +LL | #[doc(cfg_hide(doc))] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information +note: the lint level is defined here + --> $DIR/doc_cfg_hide.rs:2:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` +help: to apply to the crate, use an inner attribute + | +LL | #![doc(cfg_hide(doc))] + | ~~~~~~~~~~~~~~~~~~~~~~ + +error: `#[doc(cfg_hide(...)]` takes a list of attributes + --> $DIR/doc_cfg_hide.rs:4:8 + | +LL | #![doc(cfg_hide = "test")] + | ^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + +error: `#[doc(cfg_hide(...)]` takes a list of attributes + --> $DIR/doc_cfg_hide.rs:6:8 + | +LL | #![doc(cfg_hide)] + | ^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + +error: aborting due to 3 previous errors + diff --git a/src/test/rustdoc-ui/doctest-edition.stderr b/src/test/rustdoc-ui/doctest-edition.stderr index 1643d6053..8a3329aa3 100644 --- a/src/test/rustdoc-ui/doctest-edition.stderr +++ b/src/test/rustdoc-ui/doctest-edition.stderr @@ -7,12 +7,12 @@ LL | | //! foo'b' LL | | //! ``` | |_______^ | + = note: error from rustc: prefix `foo` is unknown note: the lint level is defined here --> $DIR/doctest-edition.rs:3:9 | LL | #![deny(rustdoc::invalid_rust_codeblocks)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: error from rustc: prefix `foo` is unknown help: mark blocks that do not contain Rust code as text | LL | //! ```text diff --git a/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs b/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs new file mode 100644 index 000000000..daba69868 --- /dev/null +++ b/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs @@ -0,0 +1,10 @@ +#![deny(unknown_lints)] +//~^ NOTE defined here + +#![allow(rustdoc::missing_doc_code_examples)] +//~^ ERROR unknown lint +//~| ERROR unknown lint +//~| NOTE lint is unstable +//~| NOTE lint is unstable +//~| NOTE see issue +//~| NOTE see issue diff --git a/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr b/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr new file mode 100644 index 000000000..cbe9a3d14 --- /dev/null +++ b/src/test/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr @@ -0,0 +1,29 @@ +error: unknown lint: `rustdoc::missing_doc_code_examples` + --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:4:1 + | +LL | #![allow(rustdoc::missing_doc_code_examples)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `rustdoc::missing_doc_code_examples` lint is unstable + = note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information + = help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable +note: the lint level is defined here + --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:1:9 + | +LL | #![deny(unknown_lints)] + | ^^^^^^^^^^^^^ + +error: unknown lint: `rustdoc::missing_doc_code_examples` + --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:4:1 + | +LL | #![allow(rustdoc::missing_doc_code_examples)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `rustdoc::missing_doc_code_examples` lint is unstable + = note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information + = help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable + +error: Compilation failed, aborting rustdoc + +error: aborting due to 3 previous errors + diff --git a/src/test/rustdoc-ui/ignore-block-help.stderr b/src/test/rustdoc-ui/ignore-block-help.stderr index 9c02ff11d..a30ea51dd 100644 --- a/src/test/rustdoc-ui/ignore-block-help.stderr +++ b/src/test/rustdoc-ui/ignore-block-help.stderr @@ -7,13 +7,13 @@ LL | | /// let heart = 'โค๏ธ'; LL | | /// ``` | |_______^ | - = note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default help: `ignore` code blocks require valid Rust code for syntax highlighting; mark blocks that do not contain Rust code as text: ```text --> $DIR/ignore-block-help.rs:3:5 | LL | /// ```ignore (to-prevent-tidy-error) | ^^^ = note: error from rustc: character literal may only contain one codepoint + = note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs index 2319de556..4b1e04234 100644 --- a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs +++ b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs @@ -1,11 +1,12 @@ +// check-pass // normalize-stderr-test: "`.*`" -> "`DEF_ID`" // normalize-stdout-test: "`.*`" -> "`DEF_ID`" // edition:2018 pub async fn f() -> impl std::fmt::Debug { + // rustdoc doesn't care that this is infinitely sized #[derive(Debug)] enum E { - //~^ ERROR recursive type `f::{closure#0}::E` has infinite size This(E), Unit, } diff --git a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr deleted file mode 100644 index aa39d26fe..000000000 --- a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0072]: recursive type `DEF_ID` has infinite size - --> $DIR/infinite-recursive-type-impl-trait-return.rs:7:5 - | -LL | enum E { - | ^^^^^^ recursive type has infinite size -LL | -LL | This(E), - | - recursive without indirection - | -help: insert some indirection (e.g., a `DEF_ID` representable - | -LL | This(Box<E>), - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `DEF_ID`. diff --git a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.rs b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.rs index b3a7ee563..ac79582fb 100644 --- a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.rs +++ b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.rs @@ -1,6 +1,8 @@ +// check-pass + fn f() -> impl Sized { + // rustdoc doesn't care that this is infinitely sized enum E { - //~^ ERROR recursive type `f::E` has infinite size V(E), } unimplemented!() diff --git a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.stderr b/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.stderr deleted file mode 100644 index 009bedec5..000000000 --- a/src/test/rustdoc-ui/infinite-recursive-type-impl-trait.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0072]: recursive type `f::E` has infinite size - --> $DIR/infinite-recursive-type-impl-trait.rs:2:5 - | -LL | enum E { - | ^^^^^^ recursive type has infinite size -LL | -LL | V(E), - | - recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `f::E` representable - | -LL | V(Box<E>), - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/rustdoc-ui/infinite-recursive-type.stderr b/src/test/rustdoc-ui/infinite-recursive-type.stderr index b33aba446..9e2c3ff16 100644 --- a/src/test/rustdoc-ui/infinite-recursive-type.stderr +++ b/src/test/rustdoc-ui/infinite-recursive-type.stderr @@ -2,12 +2,12 @@ error[E0072]: recursive type `E` has infinite size --> $DIR/infinite-recursive-type.rs:1:1 | LL | enum E { - | ^^^^^^ recursive type has infinite size + | ^^^^^^ LL | LL | V(E), | - recursive without indirection | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `E` representable +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | LL | V(Box<E>), | ++++ + diff --git a/src/test/rustdoc-ui/intra-doc/html-as-generics-intra-doc.stderr b/src/test/rustdoc-ui/intra-doc/html-as-generics-intra-doc.stderr index 00fe229da..7c81044db 100644 --- a/src/test/rustdoc-ui/intra-doc/html-as-generics-intra-doc.stderr +++ b/src/test/rustdoc-ui/intra-doc/html-as-generics-intra-doc.stderr @@ -4,12 +4,12 @@ error: unresolved link to `NonExistentStruct` LL | /// This [test][NonExistentStruct<i32>] thing! | ^^^^^^^^^^^^^^^^^^^^^^ no item named `NonExistentStruct` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/html-as-generics-intra-doc.rs:2:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: unresolved link to `NonExistentStruct2` --> $DIR/html-as-generics-intra-doc.rs:17:11 diff --git a/src/test/rustdoc-ui/intra-doc/macro-rules-error.stderr b/src/test/rustdoc-ui/intra-doc/macro-rules-error.stderr index 8e17323fd..6ad8084b0 100644 --- a/src/test/rustdoc-ui/intra-doc/macro-rules-error.stderr +++ b/src/test/rustdoc-ui/intra-doc/macro-rules-error.stderr @@ -4,12 +4,12 @@ error: unresolved link to `before_but_limited_to_module` LL | /// [before_but_limited_to_module] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `before_but_limited_to_module` in scope | + = note: `macro_rules` named `before_but_limited_to_module` exists in this crate, but it is not in scope at this link's location note: the lint level is defined here --> $DIR/macro-rules-error.rs:5:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `macro_rules` named `before_but_limited_to_module` exists in this crate, but it is not in scope at this link's location error: unresolved link to `after` --> $DIR/macro-rules-error.rs:15:6 diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.rs b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs index 15e02925e..161625ed2 100644 --- a/src/test/rustdoc-ui/intra-doc/malformed-generics.rs +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs @@ -3,17 +3,26 @@ //! [Vec<] //~ ERROR //! [Vec<Box<T] //~ ERROR //! [Vec<Box<T>] //~ ERROR +//~^ WARN //! [Vec<Box<T>>>] //~ ERROR +//~^ WARN //! [Vec<T>>>] //~ ERROR +//~^ WARN //! [<Vec] //~ ERROR //! [Vec::<] //~ ERROR //! [<T>] //~ ERROR +//~^ WARN //! [<invalid syntax>] //~ ERROR +//~^ WARN //! [Vec:<T>:new()] //~ ERROR +//~^ WARN //! [Vec<<T>>] //~ ERROR +//~^ WARN //! [Vec<>] //~ ERROR //! [Vec<<>>] //~ ERROR // FIXME(#74563) support UFCS //! [<Vec as IntoIterator>::into_iter] //~ ERROR +//~^ WARN //! [<Vec<T> as IntoIterator>::iter] //~ ERROR +//~^ WARN diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr index 5bc0f84e2..08349fef8 100644 --- a/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr @@ -23,67 +23,67 @@ LL | //! [Vec<Box<T>] | ^^^^^^^^^^ unbalanced angle brackets error: unresolved link to `Vec<Box<T>>>` - --> $DIR/malformed-generics.rs:6:6 + --> $DIR/malformed-generics.rs:7:6 | LL | //! [Vec<Box<T>>>] | ^^^^^^^^^^^^ unbalanced angle brackets error: unresolved link to `Vec<T>>>` - --> $DIR/malformed-generics.rs:7:6 + --> $DIR/malformed-generics.rs:9:6 | LL | //! [Vec<T>>>] | ^^^^^^^^ unbalanced angle brackets error: unresolved link to `<Vec` - --> $DIR/malformed-generics.rs:8:6 + --> $DIR/malformed-generics.rs:11:6 | LL | //! [<Vec] | ^^^^ unbalanced angle brackets error: unresolved link to `Vec::<` - --> $DIR/malformed-generics.rs:9:6 + --> $DIR/malformed-generics.rs:12:6 | LL | //! [Vec::<] | ^^^^^^ unbalanced angle brackets error: unresolved link to `<T>` - --> $DIR/malformed-generics.rs:10:6 + --> $DIR/malformed-generics.rs:13:6 | LL | //! [<T>] | ^^^ missing type for generic parameters error: unresolved link to `<invalid syntax>` - --> $DIR/malformed-generics.rs:11:6 + --> $DIR/malformed-generics.rs:15:6 | LL | //! [<invalid syntax>] | ^^^^^^^^^^^^^^^^ missing type for generic parameters error: unresolved link to `Vec:<T>:new` - --> $DIR/malformed-generics.rs:12:6 + --> $DIR/malformed-generics.rs:17:6 | LL | //! [Vec:<T>:new()] | ^^^^^^^^^^^^^ has invalid path separator error: unresolved link to `Vec<<T>>` - --> $DIR/malformed-generics.rs:13:6 + --> $DIR/malformed-generics.rs:19:6 | LL | //! [Vec<<T>>] | ^^^^^^^^ too many angle brackets error: unresolved link to `Vec<>` - --> $DIR/malformed-generics.rs:14:6 + --> $DIR/malformed-generics.rs:21:6 | LL | //! [Vec<>] | ^^^^^ empty angle brackets error: unresolved link to `Vec<<>>` - --> $DIR/malformed-generics.rs:15:6 + --> $DIR/malformed-generics.rs:22:6 | LL | //! [Vec<<>>] | ^^^^^^^ too many angle brackets error: unresolved link to `<Vec as IntoIterator>::into_iter` - --> $DIR/malformed-generics.rs:18:6 + --> $DIR/malformed-generics.rs:25:6 | LL | //! [<Vec as IntoIterator>::into_iter] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported @@ -91,12 +91,68 @@ LL | //! [<Vec as IntoIterator>::into_iter] = note: see https://github.com/rust-lang/rust/issues/74563 for more information error: unresolved link to `<Vec<T> as IntoIterator>::iter` - --> $DIR/malformed-generics.rs:19:6 + --> $DIR/malformed-generics.rs:27:6 | LL | //! [<Vec<T> as IntoIterator>::iter] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported | = note: see https://github.com/rust-lang/rust/issues/74563 for more information -error: aborting due to 15 previous errors +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:5:13 + | +LL | //! [Vec<Box<T>] + | ^^^ + | + = note: `#[warn(rustdoc::invalid_html_tags)]` on by default + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:7:13 + | +LL | //! [Vec<Box<T>>>] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:9:9 + | +LL | //! [Vec<T>>>] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:13:6 + | +LL | //! [<T>] + | ^^^ + +warning: unclosed HTML tag `invalid` + --> $DIR/malformed-generics.rs:15:6 + | +LL | //! [<invalid syntax>] + | ^^^^^^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:17:10 + | +LL | //! [Vec:<T>:new()] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:19:10 + | +LL | //! [Vec<<T>>] + | ^^^ + +warning: unclosed HTML tag `Vec` + --> $DIR/malformed-generics.rs:25:6 + | +LL | //! [<Vec as IntoIterator>::into_iter] + | ^^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:27:10 + | +LL | //! [<Vec<T> as IntoIterator>::iter] + | ^^^ + +error: aborting due to 15 previous errors; 9 warnings emitted diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr index 4828a3044..8ec894d10 100644 --- a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr +++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr @@ -4,12 +4,12 @@ error: unresolved link to `T` LL | //! [[T]::rotate_left] | ^ no item named `T` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/non-path-primitives.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: unresolved link to `Z` --> $DIR/non-path-primitives.rs:14:5 diff --git a/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr index 6172cd2e3..4d5bd70bf 100644 --- a/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr +++ b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr @@ -4,8 +4,8 @@ warning: public documentation for `private_from_crate_level` links to private it LL | //! [my_module] | ^^^^^^^^^ this item is private | - = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-doc/private.private.stderr b/src/test/rustdoc-ui/intra-doc/private.private.stderr index 392321f9c..6661e9021 100644 --- a/src/test/rustdoc-ui/intra-doc/private.private.stderr +++ b/src/test/rustdoc-ui/intra-doc/private.private.stderr @@ -4,8 +4,8 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ^^^^^^^^^ this item is private | - = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: public documentation for `DocMe` links to private item `DontDocMe::f` --> $DIR/private.rs:7:23 diff --git a/src/test/rustdoc-ui/intra-doc/private.public.stderr b/src/test/rustdoc-ui/intra-doc/private.public.stderr index 5d1c34b91..45b51e12e 100644 --- a/src/test/rustdoc-ui/intra-doc/private.public.stderr +++ b/src/test/rustdoc-ui/intra-doc/private.public.stderr @@ -4,8 +4,8 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ^^^^^^^^^ this item is private | - = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: public documentation for `DocMe` links to private item `DontDocMe::f` --> $DIR/private.rs:7:23 diff --git a/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr b/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr index bf4ab9fdd..e8ee40ad4 100644 --- a/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr @@ -4,12 +4,12 @@ error: unresolved link to `i` LL | /// ๏ผarr[i]๏ผ | ^ no item named `i` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/span-ice-55723.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc/through-proc-macro.stderr b/src/test/rustdoc-ui/intra-doc/through-proc-macro.stderr index f0a7ed178..508d0683d 100644 --- a/src/test/rustdoc-ui/intra-doc/through-proc-macro.stderr +++ b/src/test/rustdoc-ui/intra-doc/through-proc-macro.stderr @@ -4,12 +4,12 @@ warning: unresolved link to `Oooops` LL | /// [Oooops] | ^^^^^^ no item named `Oooops` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/through-proc-macro.rs:7:9 | LL | #![warn(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr index d280e6497..e7b4c43e7 100644 --- a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr +++ b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr @@ -4,13 +4,13 @@ error: unknown disambiguator `foo` LL | //! Linking to [foo@banana] and [`bar@banana!()`]. | ^^^ | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators note: the lint level is defined here --> $DIR/unknown-disambiguator.rs:2:9 | LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]` - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `bar` --> $DIR/unknown-disambiguator.rs:4:35 diff --git a/src/test/rustdoc-ui/intra-doc/unused-extern-crate.stderr b/src/test/rustdoc-ui/intra-doc/unused-extern-crate.stderr index 5c0df1d1b..815324563 100644 --- a/src/test/rustdoc-ui/intra-doc/unused-extern-crate.stderr +++ b/src/test/rustdoc-ui/intra-doc/unused-extern-crate.stderr @@ -4,12 +4,12 @@ error: unresolved link to `zip` LL | /// See [zip] crate. | ^^^ no item named `zip` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/unused-extern-crate.rs:2:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr b/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr index d46df9264..c309a55f4 100644 --- a/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr +++ b/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr @@ -4,8 +4,8 @@ warning: unresolved link to `error` LL | /// [error] | ^^^^^ no item named `error` in scope | - = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default warning: unresolved link to `error1` --> $DIR/warning-crlf.rs:12:11 diff --git a/src/test/rustdoc-ui/invalid-doc-attr.stderr b/src/test/rustdoc-ui/invalid-doc-attr.stderr index a4fa38179..3c66e587b 100644 --- a/src/test/rustdoc-ui/invalid-doc-attr.stderr +++ b/src/test/rustdoc-ui/invalid-doc-attr.stderr @@ -4,15 +4,15 @@ error: this attribute can only be applied at the crate level LL | #[doc(test(no_crate_inject))] | ^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> + = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information note: the lint level is defined here --> $DIR/invalid-doc-attr.rs:2:9 | LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information help: to apply to the crate, use an inner attribute | LL | #![doc(test(no_crate_inject))] diff --git a/src/test/rustdoc-ui/invalid-html-self-closing-tag.rs b/src/test/rustdoc-ui/invalid-html-self-closing-tag.rs new file mode 100644 index 000000000..d973a53cb --- /dev/null +++ b/src/test/rustdoc-ui/invalid-html-self-closing-tag.rs @@ -0,0 +1,70 @@ +#![deny(rustdoc::invalid_html_tags)] + +/// <p/> +//~^ ERROR invalid self-closing HTML tag `p` +pub struct A; + +/// <p style/> +//~^ ERROR invalid self-closing HTML tag `p` +pub struct B; + +/// <p style=""/> +//~^ ERROR invalid self-closing HTML tag `p` +pub struct C; + +/// <p style="x"/> +//~^ ERROR invalid self-closing HTML tag `p` +pub struct D; + +/// <p style="x/></p> +//~^ ERROR unclosed quoted HTML attribute +pub struct E; + +/// <p style='x/></p> +//~^ ERROR unclosed quoted HTML attribute +pub struct F; + +/// <p style="x/"></p> +pub struct G; + +/// <p style="x/"/> +//~^ ERROR invalid self-closing HTML tag `p` +pub struct H; + +/// <p / > +//~^ ERROR invalid self-closing HTML tag `p` +pub struct I; + +/// <br/> +pub struct J; + +/// <a href=/></a> +pub struct K; + +/// <a href=//></a> +pub struct L; + +/// <a href="/"/> +//~^ ERROR invalid self-closing HTML tag `a` +pub struct M; + +/// <a href=x /> +//~^ ERROR invalid self-closing HTML tag `a` +pub struct N; + +/// <a href= /> +//~^ ERROR invalid self-closing HTML tag `a` +pub struct O; + +/// <a href=x/></a> +pub struct P; + +/// <svg><rect width=1 height=1 /></svg> +pub struct Q; + +/// <svg><rect width=1 height=/></svg> +//~^ ERROR unclosed HTML tag `rect` +pub struct R; + +/// <svg / q> +pub struct S; diff --git a/src/test/rustdoc-ui/invalid-html-self-closing-tag.stderr b/src/test/rustdoc-ui/invalid-html-self-closing-tag.stderr new file mode 100644 index 000000000..e45edfb43 --- /dev/null +++ b/src/test/rustdoc-ui/invalid-html-self-closing-tag.stderr @@ -0,0 +1,80 @@ +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:3:5 + | +LL | /// <p/> + | ^^ + | +note: the lint level is defined here + --> $DIR/invalid-html-self-closing-tag.rs:1:9 + | +LL | #![deny(rustdoc::invalid_html_tags)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:7:5 + | +LL | /// <p style/> + | ^^ + +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:11:5 + | +LL | /// <p style=""/> + | ^^ + +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:15:5 + | +LL | /// <p style="x"/> + | ^^ + +error: unclosed quoted HTML attribute on tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:19:14 + | +LL | /// <p style="x/></p> + | ^ + +error: unclosed quoted HTML attribute on tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:23:14 + | +LL | /// <p style='x/></p> + | ^ + +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:30:5 + | +LL | /// <p style="x/"/> + | ^^ + +error: invalid self-closing HTML tag `p` + --> $DIR/invalid-html-self-closing-tag.rs:34:5 + | +LL | /// <p / > + | ^^ + +error: invalid self-closing HTML tag `a` + --> $DIR/invalid-html-self-closing-tag.rs:47:5 + | +LL | /// <a href="/"/> + | ^^ + +error: invalid self-closing HTML tag `a` + --> $DIR/invalid-html-self-closing-tag.rs:51:5 + | +LL | /// <a href=x /> + | ^^ + +error: invalid self-closing HTML tag `a` + --> $DIR/invalid-html-self-closing-tag.rs:55:5 + | +LL | /// <a href= /> + | ^^ + +error: unclosed HTML tag `rect` + --> $DIR/invalid-html-self-closing-tag.rs:65:10 + | +LL | /// <svg><rect width=1 height=/></svg> + | ^^^^^ + +error: aborting due to 12 previous errors + diff --git a/src/test/rustdoc-ui/invalid-html-tags.rs b/src/test/rustdoc-ui/invalid-html-tags.rs index 0f9d2e4b3..317f1fd1d 100644 --- a/src/test/rustdoc-ui/invalid-html-tags.rs +++ b/src/test/rustdoc-ui/invalid-html-tags.rs @@ -114,3 +114,10 @@ pub fn k() {} /// Web Components style </unopened-tag> //~^ ERROR unopened HTML tag `unopened-tag` pub fn m() {} + +/// backslashed \<a href=""> +pub fn no_error_1() {} + +/// backslashed \<<a href=""> +//~^ ERROR unclosed HTML tag `a` +pub fn p() {} diff --git a/src/test/rustdoc-ui/invalid-html-tags.stderr b/src/test/rustdoc-ui/invalid-html-tags.stderr index 24a455576..9c2bfcf2c 100644 --- a/src/test/rustdoc-ui/invalid-html-tags.stderr +++ b/src/test/rustdoc-ui/invalid-html-tags.stderr @@ -94,5 +94,11 @@ error: unclosed HTML tag `dashed-tags` LL | /// Web Components style <dashed-tags> | ^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +error: unclosed HTML tag `a` + --> $DIR/invalid-html-tags.rs:121:19 + | +LL | /// backslashed \<<a href=""> + | ^^ + +error: aborting due to 16 previous errors diff --git a/src/test/rustdoc-ui/invalid-syntax.rs b/src/test/rustdoc-ui/invalid-syntax.rs index b503d1093..acb2a6f08 100644 --- a/src/test/rustdoc-ui/invalid-syntax.rs +++ b/src/test/rustdoc-ui/invalid-syntax.rs @@ -99,3 +99,9 @@ pub fn indent_after_fenced() {} /// ``` pub fn invalid() {} //~^^^^ WARNING could not parse code block as Rust code + +/// ``` +/// fn wook_at_my_beautifuw_bwaces_plz() {); +/// ``` +pub fn uwu() {} +//~^^^^ WARNING could not parse code block as Rust code diff --git a/src/test/rustdoc-ui/invalid-syntax.stderr b/src/test/rustdoc-ui/invalid-syntax.stderr index 4c6249cc6..597d19e74 100644 --- a/src/test/rustdoc-ui/invalid-syntax.stderr +++ b/src/test/rustdoc-ui/invalid-syntax.stderr @@ -7,10 +7,10 @@ LL | | /// \__________pkt->size___________/ \_result->size_/ \__pkt->si LL | | /// ``` | |_______^ | - = note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default = note: error from rustc: unknown start of token: \ = note: error from rustc: unknown start of token: \ = note: error from rustc: unknown start of token: \ + = note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default help: mark blocks that do not contain Rust code as text | LL | /// ```text @@ -150,5 +150,20 @@ help: mark blocks that do not contain Rust code as text LL | /// ```text | ++++ -warning: 12 warnings emitted +warning: could not parse code block as Rust code + --> $DIR/invalid-syntax.rs:103:5 + | +LL | /// ``` + | _____^ +LL | | /// fn wook_at_my_beautifuw_bwaces_plz() {); +LL | | /// ``` + | |_______^ + | + = note: error from rustc: mismatched closing delimiter: `)` +help: mark blocks that do not contain Rust code as text + | +LL | /// ```text + | ++++ + +warning: 13 warnings emitted diff --git a/src/test/rustdoc-ui/issue-101076.rs b/src/test/rustdoc-ui/issue-101076.rs new file mode 100644 index 000000000..648f99029 --- /dev/null +++ b/src/test/rustdoc-ui/issue-101076.rs @@ -0,0 +1,14 @@ +// check-pass + +const _: () = { + #[macro_export] + macro_rules! first_macro { + () => {} + } + mod foo { + #[macro_export] + macro_rules! second_macro { + () => {} + } + } +}; diff --git a/src/test/rustdoc-ui/issue-102986.rs b/src/test/rustdoc-ui/issue-102986.rs new file mode 100644 index 000000000..001784ac2 --- /dev/null +++ b/src/test/rustdoc-ui/issue-102986.rs @@ -0,0 +1,4 @@ +struct Struct { + y: (typeof("hey"),), + //~^ `typeof` is a reserved keyword but unimplemented +} diff --git a/src/test/rustdoc-ui/issue-102986.stderr b/src/test/rustdoc-ui/issue-102986.stderr new file mode 100644 index 000000000..3a573726c --- /dev/null +++ b/src/test/rustdoc-ui/issue-102986.stderr @@ -0,0 +1,14 @@ +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-102986.rs:2:9 + | +LL | y: (typeof("hey"),), + | ^^^^^^^^^^^^^ reserved keyword + | +help: consider replacing `typeof(...)` with an actual type + | +LL | y: (&'static str,), + | ~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0516`. diff --git a/src/test/rustdoc-ui/issue-74134.private.stderr b/src/test/rustdoc-ui/issue-74134.private.stderr index 31d2dbe96..44c88b618 100644 --- a/src/test/rustdoc-ui/issue-74134.private.stderr +++ b/src/test/rustdoc-ui/issue-74134.private.stderr @@ -4,8 +4,8 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^ this item is private | - = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/issue-74134.public.stderr b/src/test/rustdoc-ui/issue-74134.public.stderr index 6a3173e3e..5b1887b83 100644 --- a/src/test/rustdoc-ui/issue-74134.public.stderr +++ b/src/test/rustdoc-ui/issue-74134.public.stderr @@ -4,8 +4,8 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^ this item is private | - = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/lint-group.rs b/src/test/rustdoc-ui/lint-group.rs index 61555a6e6..09aca6d2b 100644 --- a/src/test/rustdoc-ui/lint-group.rs +++ b/src/test/rustdoc-ui/lint-group.rs @@ -1,3 +1,5 @@ +#![feature(rustdoc_missing_doc_code_examples)] + //! Documenting the kinds of lints emitted by rustdoc. //! //! ``` diff --git a/src/test/rustdoc-ui/lint-group.stderr b/src/test/rustdoc-ui/lint-group.stderr index e28600160..4f2c96588 100644 --- a/src/test/rustdoc-ui/lint-group.stderr +++ b/src/test/rustdoc-ui/lint-group.stderr @@ -1,18 +1,18 @@ error: missing code example in this documentation - --> $DIR/lint-group.rs:16:1 + --> $DIR/lint-group.rs:18:1 | LL | /// wait, this doesn't have a doctest? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-group.rs:7:9 + --> $DIR/lint-group.rs:9:9 | LL | #![deny(rustdoc::all)] | ^^^^^^^^^^^^ = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]` error: documentation test in private item - --> $DIR/lint-group.rs:19:1 + --> $DIR/lint-group.rs:21:1 | LL | / /// wait, this *does* have a doctest? LL | | /// @@ -24,22 +24,22 @@ LL | | /// ``` = note: `#[deny(rustdoc::private_doc_tests)]` implied by `#[deny(rustdoc::all)]` error: missing code example in this documentation - --> $DIR/lint-group.rs:26:1 + --> $DIR/lint-group.rs:28:1 | LL | /// <unknown> | ^^^^^^^^^^^^^ error: unresolved link to `error` - --> $DIR/lint-group.rs:9:29 + --> $DIR/lint-group.rs:11:29 | LL | /// what up, let's make an [error] | ^^^^^ no item named `error` in scope | - = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc::all)]` = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc::all)]` error: unclosed HTML tag `unknown` - --> $DIR/lint-group.rs:26:5 + --> $DIR/lint-group.rs:28:5 | LL | /// <unknown> | ^^^^^^^^^ diff --git a/src/test/rustdoc-ui/lint-missing-doc-code-example.rs b/src/test/rustdoc-ui/lint-missing-doc-code-example.rs index fac6342cd..40f35728d 100644 --- a/src/test/rustdoc-ui/lint-missing-doc-code-example.rs +++ b/src/test/rustdoc-ui/lint-missing-doc-code-example.rs @@ -1,3 +1,4 @@ +#![feature(rustdoc_missing_doc_code_examples)] #![deny(missing_docs)] #![deny(rustdoc::missing_doc_code_examples)] diff --git a/src/test/rustdoc-ui/lint-missing-doc-code-example.stderr b/src/test/rustdoc-ui/lint-missing-doc-code-example.stderr index 9e51ecd2b..f93312501 100644 --- a/src/test/rustdoc-ui/lint-missing-doc-code-example.stderr +++ b/src/test/rustdoc-ui/lint-missing-doc-code-example.stderr @@ -1,35 +1,35 @@ error: missing code example in this documentation - --> $DIR/lint-missing-doc-code-example.rs:19:1 + --> $DIR/lint-missing-doc-code-example.rs:20:1 | LL | pub mod module1 { | ^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-missing-doc-code-example.rs:2:9 + --> $DIR/lint-missing-doc-code-example.rs:3:9 | LL | #![deny(rustdoc::missing_doc_code_examples)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing code example in this documentation - --> $DIR/lint-missing-doc-code-example.rs:37:3 + --> $DIR/lint-missing-doc-code-example.rs:38:3 | LL | /// doc | ^^^^^^^ error: missing code example in this documentation - --> $DIR/lint-missing-doc-code-example.rs:49:1 + --> $DIR/lint-missing-doc-code-example.rs:50:1 | LL | /// Doc | ^^^^^^^ error: missing code example in this documentation - --> $DIR/lint-missing-doc-code-example.rs:56:1 + --> $DIR/lint-missing-doc-code-example.rs:57:1 | LL | /// Doc | ^^^^^^^ error: missing code example in this documentation - --> $DIR/lint-missing-doc-code-example.rs:63:1 + --> $DIR/lint-missing-doc-code-example.rs:64:1 | LL | /// Doc | ^^^^^^^ diff --git a/src/test/rustdoc-ui/macro-docs.stderr b/src/test/rustdoc-ui/macro-docs.stderr index e3cc17311..2b136f5be 100644 --- a/src/test/rustdoc-ui/macro-docs.stderr +++ b/src/test/rustdoc-ui/macro-docs.stderr @@ -7,13 +7,13 @@ LL | /// A LL | m!(); | ---- in this macro invocation | - = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default = note: the link appears in this line: [`long_cat`] is really long ^^^^^^^^^^ = note: no item named `long_cat` in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/no-crate-level-doc-lint.stderr b/src/test/rustdoc-ui/no-crate-level-doc-lint.stderr index 1a1f8085a..fb3a5e415 100644 --- a/src/test/rustdoc-ui/no-crate-level-doc-lint.stderr +++ b/src/test/rustdoc-ui/no-crate-level-doc-lint.stderr @@ -1,12 +1,12 @@ error: no documentation found for this crate's top-level module | + = help: The following guide may be of use: + https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html note: the lint level is defined here --> $DIR/no-crate-level-doc-lint.rs:3:9 | LL | #![deny(rustdoc::missing_crate_level_docs)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: The following guide may be of use: - https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html error: aborting due to previous error diff --git a/src/test/rustdoc-ui/normalize-cycle.rs b/src/test/rustdoc-ui/normalize-cycle.rs index f48cad373..1ed9ac6bc 100644 --- a/src/test/rustdoc-ui/normalize-cycle.rs +++ b/src/test/rustdoc-ui/normalize-cycle.rs @@ -1,5 +1,6 @@ // check-pass -// Regresion test for <https://github.com/rust-lang/rust/issues/79459>. +// compile-flags: -Znormalize-docs +// Regression test for <https://github.com/rust-lang/rust/issues/79459>. pub trait Query {} pub trait AsQuery { diff --git a/src/test/rustdoc-ui/normalize-overflow.rs b/src/test/rustdoc-ui/normalize-overflow.rs index 0cdcc88e3..3698fe70e 100644 --- a/src/test/rustdoc-ui/normalize-overflow.rs +++ b/src/test/rustdoc-ui/normalize-overflow.rs @@ -1,3 +1,5 @@ // aux-crate:overflow=overflow.rs // check-pass // Regression test for <https://github.com/rust-lang/rust/issues/79506>. + +extern crate overflow; diff --git a/src/test/rustdoc-ui/pub-export-lint.stderr b/src/test/rustdoc-ui/pub-export-lint.stderr index c6be9c6a9..81ef79961 100644 --- a/src/test/rustdoc-ui/pub-export-lint.stderr +++ b/src/test/rustdoc-ui/pub-export-lint.stderr @@ -4,12 +4,12 @@ error: unresolved link to `aloha` LL | /// [aloha] | ^^^^^ no item named `aloha` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/pub-export-lint.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/reference-link-reports-error-once.stderr b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr index b46a51e93..2ab67090f 100644 --- a/src/test/rustdoc-ui/reference-link-reports-error-once.stderr +++ b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr @@ -4,12 +4,12 @@ error: unresolved link to `ref` LL | /// [a]: ref | ^^^ no item named `ref` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/reference-link-reports-error-once.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: unresolved link to `ref2` --> $DIR/reference-link-reports-error-once.rs:15:10 diff --git a/src/test/rustdoc-ui/renamed-lint-still-applies.stderr b/src/test/rustdoc-ui/renamed-lint-still-applies.stderr index 8e2a2cdd7..ee9b67cb9 100644 --- a/src/test/rustdoc-ui/renamed-lint-still-applies.stderr +++ b/src/test/rustdoc-ui/renamed-lint-still-applies.stderr @@ -18,12 +18,12 @@ error: unresolved link to `x` LL | //! [x] | ^ no item named `x` in scope | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` note: the lint level is defined here --> $DIR/renamed-lint-still-applies.rs:2:9 | LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: this URL is not a hyperlink --> $DIR/renamed-lint-still-applies.rs:9:5 @@ -31,12 +31,12 @@ error: this URL is not a hyperlink LL | //! http://example.com | ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com>` | + = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/renamed-lint-still-applies.rs:7:9 | LL | #![deny(rustdoc::non_autolinks)] | ^^^^^^^^^^^^^^^^^^^^^^ - = note: bare URLs are not automatically turned into clickable links error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/src/test/rustdoc-ui/rustc-check-passes.rs b/src/test/rustdoc-ui/rustc-check-passes.rs index 731cc8ba6..56d59164d 100644 --- a/src/test/rustdoc-ui/rustc-check-passes.rs +++ b/src/test/rustdoc-ui/rustc-check-passes.rs @@ -1,4 +1,4 @@ -#![feature(box_syntax)] -#![feature(box_syntax)] //~ ERROR +#![feature(rustdoc_internals)] +#![feature(rustdoc_internals)] //~ ERROR pub fn foo() {} diff --git a/src/test/rustdoc-ui/rustc-check-passes.stderr b/src/test/rustdoc-ui/rustc-check-passes.stderr index 9707895ff..83f4e87c6 100644 --- a/src/test/rustdoc-ui/rustc-check-passes.stderr +++ b/src/test/rustdoc-ui/rustc-check-passes.stderr @@ -1,8 +1,8 @@ -error[E0636]: the feature `box_syntax` has already been declared +error[E0636]: the feature `rustdoc_internals` has already been declared --> $DIR/rustc-check-passes.rs:2:12 | -LL | #![feature(box_syntax)] - | ^^^^^^^^^^ +LL | #![feature(rustdoc_internals)] + | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.rs b/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.rs index 744b3071f..476e3b2d4 100644 --- a/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.rs +++ b/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.rs @@ -8,6 +8,48 @@ pub struct ConstGeneric; // HTML tags cannot contain commas, so no error. pub struct MultipleGenerics; +/// This <[u32] as Iterator<Item>> thing! +//~^ERROR unclosed HTML tag `Item` +// Some forms of fully-qualified path are simultaneously valid HTML tags +// with attributes. They produce an error, but no suggestion, because figuring +// out if this is valid would require parsing the entire path grammar. +// +// The important part is that we don't produce any *wrong* suggestions. +// While several other examples below are added to make sure we don't +// produce suggestions when given complex paths, this example is the actual +// reason behind not just using the real path parser. It's ambiguous: there's +// no way to locally reason out whether that `[u32]` is intended to be a slice +// or an intra-doc link. +pub struct FullyQualifiedPathsDoNotCount; + +/// This <Vec as IntoIter>::Iter thing! +//~^ERROR unclosed HTML tag `Vec` +// Some forms of fully-qualified path are simultaneously valid HTML tags +// with attributes. They produce an error, but no suggestion, because figuring +// out if this is valid would require parsing the entire path grammar. +pub struct FullyQualifiedPathsDoNotCount1; + +/// This Vec<Vec as IntoIter>::Iter thing! +//~^ERROR unclosed HTML tag `Vec` +// Some forms of fully-qualified path are simultaneously valid HTML tags +// with attributes. They produce an error, but no suggestion, because figuring +// out if this is valid would require parsing the entire path grammar. +pub struct FullyQualifiedPathsDoNotCount2; + +/// This Vec<Vec as IntoIter> thing! +//~^ERROR unclosed HTML tag `Vec` +// Some forms of fully-qualified path are simultaneously valid HTML tags +// with attributes. They produce an error, but no suggestion, because figuring +// out if this is valid would require parsing the entire path grammar. +pub struct FullyQualifiedPathsDoNotCount3; + +/// This Vec<Vec<i32> as IntoIter> thing! +//~^ERROR unclosed HTML tag `i32` +// Some forms of fully-qualified path are simultaneously valid HTML tags +// with attributes. They produce an error, but no suggestion, because figuring +// out if this is valid would require parsing the entire path grammar. +pub struct FullyQualifiedPathsDoNotCount4; + /// This Vec<i32 class="test"> thing! //~^ERROR unclosed HTML tag `i32` // HTML attributes shouldn't be treated as Rust syntax, so no suggestions. diff --git a/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.stderr b/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.stderr index 832b8b2ca..3856a2513 100644 --- a/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.stderr +++ b/src/test/rustdoc-ui/suggestions/html-as-generics-no-suggestions.stderr @@ -1,8 +1,8 @@ -error: unclosed HTML tag `i32` - --> $DIR/html-as-generics-no-suggestions.rs:11:13 +error: unclosed HTML tag `Item` + --> $DIR/html-as-generics-no-suggestions.rs:11:28 | -LL | /// This Vec<i32 class="test"> thing! - | ^^^^ +LL | /// This <[u32] as Iterator<Item>> thing! + | ^^^^^^ | note: the lint level is defined here --> $DIR/html-as-generics-no-suggestions.rs:1:9 @@ -10,29 +10,59 @@ note: the lint level is defined here LL | #![deny(rustdoc::invalid_html_tags)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: unclosed HTML tag `Vec` + --> $DIR/html-as-generics-no-suggestions.rs:25:10 + | +LL | /// This <Vec as IntoIter>::Iter thing! + | ^^^^ + +error: unclosed HTML tag `Vec` + --> $DIR/html-as-generics-no-suggestions.rs:32:13 + | +LL | /// This Vec<Vec as IntoIter>::Iter thing! + | ^^^^ + +error: unclosed HTML tag `Vec` + --> $DIR/html-as-generics-no-suggestions.rs:39:13 + | +LL | /// This Vec<Vec as IntoIter> thing! + | ^^^^ + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics-no-suggestions.rs:46:17 + | +LL | /// This Vec<Vec<i32> as IntoIter> thing! + | ^^^^^ + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics-no-suggestions.rs:53:13 + | +LL | /// This Vec<i32 class="test"> thing! + | ^^^^ + error: unopened HTML tag `i32` - --> $DIR/html-as-generics-no-suggestions.rs:20:13 + --> $DIR/html-as-generics-no-suggestions.rs:62:13 | LL | /// This Vec</i32> thing! | ^^^^^^ error: unclosed HTML tag `i32` - --> $DIR/html-as-generics-no-suggestions.rs:25:13 + --> $DIR/html-as-generics-no-suggestions.rs:67:13 | LL | /// This 123<i32> thing! | ^^^^^ error: unclosed HTML tag `i32` - --> $DIR/html-as-generics-no-suggestions.rs:30:14 + --> $DIR/html-as-generics-no-suggestions.rs:72:14 | LL | /// This Vec:<i32> thing! | ^^^^^ error: unclosed HTML tag `i32` - --> $DIR/html-as-generics-no-suggestions.rs:35:39 + --> $DIR/html-as-generics-no-suggestions.rs:77:39 | LL | /// This [link](https://rust-lang.org)<i32> thing! | ^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/rustdoc-ui/suggestions/html-as-generics.fixed b/src/test/rustdoc-ui/suggestions/html-as-generics.fixed index c0a0de24c..003542d38 100644 --- a/src/test/rustdoc-ui/suggestions/html-as-generics.fixed +++ b/src/test/rustdoc-ui/suggestions/html-as-generics.fixed @@ -30,3 +30,53 @@ pub struct BareTurbofish; //~^ERROR unclosed HTML tag `i32` //~|HELP try marking as source pub struct Nested; + +/// Nested generics `Vec<Vec<u32>>` +//~^ ERROR unclosed HTML tag `u32` +//~|HELP try marking as source +pub struct NestedGenerics; + +/// Generics with path `Vec<i32>::Iter` +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct GenericsWithPath; + +/// Generics with path `<Vec<i32>>::Iter` +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPath; + +/// Generics with path `Vec<Vec<i32>>::Iter` +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPath2; + +/// Generics with bump `<Vec<i32>>`s +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithBump; + +/// Generics with bump `Vec<Vec<i32>>`s +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithBump2; + +/// Generics with punct `<Vec<i32>>`! +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPunct; + +/// Generics with punct `Vec<Vec<i32>>`! +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPunct2; + +/// This [`Vec<i32>`] thing! +//~^ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct IntraDocLink; + +/// This [`Vec::<i32>`] thing! +//~^ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct IntraDocLinkTurbofish; diff --git a/src/test/rustdoc-ui/suggestions/html-as-generics.rs b/src/test/rustdoc-ui/suggestions/html-as-generics.rs index 0b6009b0e..4254a660b 100644 --- a/src/test/rustdoc-ui/suggestions/html-as-generics.rs +++ b/src/test/rustdoc-ui/suggestions/html-as-generics.rs @@ -30,3 +30,53 @@ pub struct BareTurbofish; //~^ERROR unclosed HTML tag `i32` //~|HELP try marking as source pub struct Nested; + +/// Nested generics Vec<Vec<u32>> +//~^ ERROR unclosed HTML tag `u32` +//~|HELP try marking as source +pub struct NestedGenerics; + +/// Generics with path Vec<i32>::Iter +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct GenericsWithPath; + +/// Generics with path <Vec<i32>>::Iter +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPath; + +/// Generics with path Vec<Vec<i32>>::Iter +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPath2; + +/// Generics with bump <Vec<i32>>s +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithBump; + +/// Generics with bump Vec<Vec<i32>>s +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithBump2; + +/// Generics with punct <Vec<i32>>! +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPunct; + +/// Generics with punct Vec<Vec<i32>>! +//~^ ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct NestedGenericsWithPunct2; + +/// This [Vec<i32>] thing! +//~^ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct IntraDocLink; + +/// This [Vec::<i32>] thing! +//~^ERROR unclosed HTML tag `i32` +//~|HELP try marking as source +pub struct IntraDocLinkTurbofish; diff --git a/src/test/rustdoc-ui/suggestions/html-as-generics.stderr b/src/test/rustdoc-ui/suggestions/html-as-generics.stderr index df54b7126..481278bda 100644 --- a/src/test/rustdoc-ui/suggestions/html-as-generics.stderr +++ b/src/test/rustdoc-ui/suggestions/html-as-generics.stderr @@ -69,5 +69,115 @@ help: try marking as source code LL | /// This <span>`Vec::<i32>`</span> thing! | + + -error: aborting due to 6 previous errors +error: unclosed HTML tag `u32` + --> $DIR/html-as-generics.rs:34:28 + | +LL | /// Nested generics Vec<Vec<u32>> + | ^^^^^ + | +help: try marking as source code + | +LL | /// Nested generics `Vec<Vec<u32>>` + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:39:27 + | +LL | /// Generics with path Vec<i32>::Iter + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with path `Vec<i32>::Iter` + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:44:28 + | +LL | /// Generics with path <Vec<i32>>::Iter + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with path `<Vec<i32>>::Iter` + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:49:31 + | +LL | /// Generics with path Vec<Vec<i32>>::Iter + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with path `Vec<Vec<i32>>::Iter` + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:54:28 + | +LL | /// Generics with bump <Vec<i32>>s + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with bump `<Vec<i32>>`s + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:59:31 + | +LL | /// Generics with bump Vec<Vec<i32>>s + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with bump `Vec<Vec<i32>>`s + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:64:29 + | +LL | /// Generics with punct <Vec<i32>>! + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with punct `<Vec<i32>>`! + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:69:32 + | +LL | /// Generics with punct Vec<Vec<i32>>! + | ^^^^^ + | +help: try marking as source code + | +LL | /// Generics with punct `Vec<Vec<i32>>`! + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:74:14 + | +LL | /// This [Vec<i32>] thing! + | ^^^^^ + | +help: try marking as source code + | +LL | /// This [`Vec<i32>`] thing! + | + + + +error: unclosed HTML tag `i32` + --> $DIR/html-as-generics.rs:79:16 + | +LL | /// This [Vec::<i32>] thing! + | ^^^^^ + | +help: try marking as source code + | +LL | /// This [`Vec::<i32>`] thing! + | + + + +error: aborting due to 16 previous errors diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index 6dc412315..46f11d2e5 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -1,8 +1,8 @@ -Z allow-features=val -- only allow the listed language features to be enabled in code (space separated) -Z always-encode-mir=val -- encode MIR of all functions into the crate metadata (default: no) - -Z assume-incomplete-release=val -- make cfg(version) treat the current version as incomplete (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 @@ -17,6 +17,7 @@ -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) @@ -35,9 +36,11 @@ -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 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 @@ -53,10 +56,11 @@ -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-threshold=val -- a default MIR inlining threshold (default: 50) -Z inline-mir-hint-threshold=val -- inlining threshold for functions with inline hint (default: 100) - -Z inline-in-all-cgus=val -- control whether `#[inline]` functions are in all CGUs + -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) @@ -65,6 +69,7 @@ `=off` (default) -Z instrument-mcount=val -- insert function instrument code for mcount-based tracing (default: no) -Z keep-hygiene-data=val -- keep hygiene data after analysis (default: no) + -Z layout-seed=val -- seed layout randomization -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) @@ -76,11 +81,10 @@ -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-pretty-relative-line-numbers=val -- use line numbers relative to the function in mir pretty printing -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 new-llvm-pass-manager=val -- use new LLVM pass manager (default: no) -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 @@ -90,12 +94,12 @@ -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-unique-section-names=val -- do not use unique names for text and data sections when -Z function-sections is used -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 diagnostic-width=val -- set the current output width for diagnostic truncation + -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) @@ -118,15 +122,13 @@ -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 profiler-runtime=val -- name of the profiler runtime crate to automatically inject (default: `profiler_builtins`) -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 layout-seed=val -- seed layout randomization -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 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 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 @@ -134,22 +136,20 @@ -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 save-analysis=val -- write syntax and type analysis (in JSON format) information, in addition to normal output (default: no) -Z self-profile=val -- run the self profiler and output the raw event data - -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 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 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 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`) @@ -157,26 +157,28 @@ 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 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 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 translate-lang=val -- language identifier for diagnostic output - -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 tune-cpu=val -- select processor to schedule for (`rustc --print target-cpus` for details) -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=val -- measure time of rustc processes (default: no) -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 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 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) diff --git a/src/test/rustdoc/all.rs b/src/test/rustdoc/all.rs index a95d6c462..4c8d02310 100644 --- a/src/test/rustdoc/all.rs +++ b/src/test/rustdoc/all.rs @@ -24,5 +24,5 @@ mod private_module { } // @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct' -// @!has foo/all.html 'private_module' +// @!hasraw foo/all.html 'private_module' pub use private_module::ReexportedStruct; diff --git a/src/test/rustdoc/anchors.no_const_anchor.html b/src/test/rustdoc/anchors.no_const_anchor.html index 98f47e530..75e67330a 100644 --- a/src/test/rustdoc/anchors.no_const_anchor.html +++ b/src/test/rustdoc/anchors.no_const_anchor.html @@ -1 +1 @@ -<div id="associatedconstant.YOLO" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#16">source</a></div><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></div> +<section id="associatedconstant.YOLO" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_const_anchor2.html b/src/test/rustdoc/anchors.no_const_anchor2.html index 6d37e8e5e..c00251976 100644 --- a/src/test/rustdoc/anchors.no_const_anchor2.html +++ b/src/test/rustdoc/anchors.no_const_anchor2.html @@ -1 +1 @@ -<section id="associatedconstant.X" class="associatedconstant has-srclink"><span class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#42">source</a></span><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section> +<section id="associatedconstant.X" class="associatedconstant has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_method_anchor.html b/src/test/rustdoc/anchors.no_method_anchor.html index f46d3090e..521fdcb78 100644 --- a/src/test/rustdoc/anchors.no_method_anchor.html +++ b/src/test/rustdoc/anchors.no_method_anchor.html @@ -1 +1 @@ -<section id="method.new" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#48">source</a></span><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -> Self</h4></section>
\ No newline at end of file +<section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -> Self</h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_trait_method_anchor.html b/src/test/rustdoc/anchors.no_trait_method_anchor.html index 445a7bb56..d7bd525ff 100644 --- a/src/test/rustdoc/anchors.no_trait_method_anchor.html +++ b/src/test/rustdoc/anchors.no_trait_method_anchor.html @@ -1 +1 @@ -<div id="method.bar" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#23">source</a></div><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></div>
\ No newline at end of file +<section id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_tymethod_anchor.html b/src/test/rustdoc/anchors.no_tymethod_anchor.html index bb0771b10..e668e5e4d 100644 --- a/src/test/rustdoc/anchors.no_tymethod_anchor.html +++ b/src/test/rustdoc/anchors.no_tymethod_anchor.html @@ -1 +1 @@ -<div id="tymethod.foo" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#20">source</a></div><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></div>
\ No newline at end of file +<section id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_type_anchor.html b/src/test/rustdoc/anchors.no_type_anchor.html index d317eb500..2c66d5aa3 100644 --- a/src/test/rustdoc/anchors.no_type_anchor.html +++ b/src/test/rustdoc/anchors.no_type_anchor.html @@ -1 +1 @@ -<div id="associatedtype.T" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/foo/anchors.rs.html#13">source</a></div><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></div>
\ No newline at end of file +<section id="associatedtype.T" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>
\ No newline at end of file diff --git a/src/test/rustdoc/anonymous-lifetime.rs b/src/test/rustdoc/anonymous-lifetime.rs index f5a7d2258..390ed5a1f 100644 --- a/src/test/rustdoc/anonymous-lifetime.rs +++ b/src/test/rustdoc/anonymous-lifetime.rs @@ -12,7 +12,7 @@ pub trait Stream { } // @has 'foo/trait.Stream.html' -// @has - '//*[@class="code-header in-band"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S' +// @has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S' impl<S: ?Sized + Stream + Unpin> Stream for &mut S { type Item = S::Item; diff --git a/src/test/rustdoc/array-links.link_box_generic.html b/src/test/rustdoc/array-links.link_box_generic.html new file mode 100644 index 000000000..3481bb6a0 --- /dev/null +++ b/src/test/rustdoc/array-links.link_box_generic.html @@ -0,0 +1 @@ +<code>pub fn delta<T>() -> <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a><<a class="primitive" href="{{channel}}/core/primitive.array.html">[T; 1]</a>></code>
\ No newline at end of file diff --git a/src/test/rustdoc/array-links.link_box_u32.html b/src/test/rustdoc/array-links.link_box_u32.html new file mode 100644 index 000000000..e864ae55c --- /dev/null +++ b/src/test/rustdoc/array-links.link_box_u32.html @@ -0,0 +1 @@ +<code>pub fn gamma() -> <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a><[<a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a>; <a class="primitive" href="{{channel}}/core/primitive.array.html">1</a>]></code>
\ No newline at end of file diff --git a/src/test/rustdoc/array-links.link_slice_generic.html b/src/test/rustdoc/array-links.link_slice_generic.html new file mode 100644 index 000000000..f1ca2f59b --- /dev/null +++ b/src/test/rustdoc/array-links.link_slice_generic.html @@ -0,0 +1 @@ +<code>pub fn beta<T>() -> &'static <a class="primitive" href="{{channel}}/core/primitive.array.html">[T; 1]</a></code>
\ No newline at end of file diff --git a/src/test/rustdoc/array-links.link_slice_u32.html b/src/test/rustdoc/array-links.link_slice_u32.html new file mode 100644 index 000000000..c3943e8d3 --- /dev/null +++ b/src/test/rustdoc/array-links.link_slice_u32.html @@ -0,0 +1 @@ +<code>pub fn alpha() -> &'static [<a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a>; <a class="primitive" href="{{channel}}/core/primitive.array.html">1</a>]</code>
\ No newline at end of file diff --git a/src/test/rustdoc/array-links.rs b/src/test/rustdoc/array-links.rs new file mode 100644 index 000000000..07f92ac51 --- /dev/null +++ b/src/test/rustdoc/array-links.rs @@ -0,0 +1,28 @@ +#![crate_name = "foo"] +#![no_std] + +pub struct MyBox<T: ?Sized>(*const T); + +// @has 'foo/fn.alpha.html' +// @snapshot link_slice_u32 - '//pre[@class="rust fn"]/code' +pub fn alpha() -> &'static [u32; 1] { + loop {} +} + +// @has 'foo/fn.beta.html' +// @snapshot link_slice_generic - '//pre[@class="rust fn"]/code' +pub fn beta<T>() -> &'static [T; 1] { + loop {} +} + +// @has 'foo/fn.gamma.html' +// @snapshot link_box_u32 - '//pre[@class="rust fn"]/code' +pub fn gamma() -> MyBox<[u32; 1]> { + loop {} +} + +// @has 'foo/fn.delta.html' +// @snapshot link_box_generic - '//pre[@class="rust fn"]/code' +pub fn delta<T>() -> MyBox<[T; 1]> { + loop {} +} diff --git a/src/test/rustdoc/assoc-consts.rs b/src/test/rustdoc/assoc-consts.rs index a79e93145..a3e10ee55 100644 --- a/src/test/rustdoc/assoc-consts.rs +++ b/src/test/rustdoc/assoc-consts.rs @@ -5,7 +5,7 @@ pub trait Foo { const FOO: usize = 12 + 1; // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' const FOO_NO_DEFAULT: bool; - // @!has - FOO_HIDDEN + // @!hasraw - FOO_HIDDEN #[doc(hidden)] const FOO_HIDDEN: u8 = 0; } @@ -13,12 +13,12 @@ pub trait Foo { pub struct Bar; impl Foo for Bar { - // @has assoc_consts/struct.Bar.html '//h3[@class="code-header in-band"]' 'impl Foo for Bar' + // @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' const FOO: usize = 12; // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' const FOO_NO_DEFAULT: bool = false; - // @!has - FOO_HIDDEN + // @!hasraw - FOO_HIDDEN #[doc(hidden)] const FOO_HIDDEN: u8 = 0; } @@ -50,9 +50,9 @@ impl Bar { } impl Bar { - // @!has assoc_consts/struct.Bar.html 'BAR_PRIVATE' + // @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' const BAR_PRIVATE: char = 'a'; - // @!has assoc_consts/struct.Bar.html 'BAR_HIDDEN' + // @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' #[doc(hidden)] pub const BAR_HIDDEN: &'static str = "a"; } @@ -81,7 +81,7 @@ pub trait Qux { const QUX_DEFAULT2: u32 = 3; } -// @has assoc_consts/struct.Bar.html '//h3[@class="code-header in-band"]' 'impl Qux for Bar' +// @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' impl Qux for Bar { // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait." diff --git a/src/test/rustdoc/associated-consts.rs b/src/test/rustdoc/associated-consts.rs index 9319a073b..adb155bb5 100644 --- a/src/test/rustdoc/associated-consts.rs +++ b/src/test/rustdoc/associated-consts.rs @@ -9,7 +9,7 @@ pub trait Trait { pub struct Bar; // @has 'foo/struct.Bar.html' -// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Bar { const FOO: u32 = 1; @@ -22,7 +22,7 @@ pub enum Foo { } // @has 'foo/enum.Foo.html' -// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Foo { const FOO: u32 = 1; @@ -33,7 +33,7 @@ impl Trait for Foo { pub struct Baz; // @has 'foo/struct.Baz.html' -// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Baz { pub const FOO: u32 = 42; @@ -44,7 +44,7 @@ pub enum Quux { } // @has 'foo/enum.Quux.html' -// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Quux { pub const FOO: u32 = 42; diff --git a/src/test/rustdoc/async-trait.rs b/src/test/rustdoc/async-trait.rs new file mode 100644 index 000000000..a473e4674 --- /dev/null +++ b/src/test/rustdoc/async-trait.rs @@ -0,0 +1,16 @@ +// aux-build:async-trait-dep.rs +// edition:2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +extern crate async_trait_dep; + +pub struct Oink {} + +// @has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()" +impl async_trait_dep::Meow for Oink { + async fn woof() { + todo!() + } +} diff --git a/src/test/rustdoc/attribute-rendering.rs b/src/test/rustdoc/attribute-rendering.rs index 677787184..36e10923c 100644 --- a/src/test/rustdoc/attribute-rendering.rs +++ b/src/test/rustdoc/attribute-rendering.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] // @has 'foo/fn.f.html' -// @has - //*[@'class="docblock item-decl"]' '#[export_name = "f"] pub fn f()' +// @has - //*[@'class="item-decl"]' '#[export_name = "f"] pub fn f()' #[export_name = "\ f"] pub fn f() {} diff --git a/src/test/rustdoc/attributes.rs b/src/test/rustdoc/attributes.rs index 1c7f4b724..a36dadced 100644 --- a/src/test/rustdoc/attributes.rs +++ b/src/test/rustdoc/attributes.rs @@ -8,6 +8,6 @@ pub extern "C" fn f() {} #[export_name = "bar"] pub extern "C" fn g() {} -// @has foo/struct.Repr.html '//*[@class="docblock item-decl"]' '#[repr(C, align(8))]' +// @has foo/struct.Repr.html '//*[@class="item-decl"]' '#[repr(C, align(8))]' #[repr(C, align(8))] pub struct Repr; diff --git a/src/test/rustdoc/auxiliary/async-trait-dep.rs b/src/test/rustdoc/auxiliary/async-trait-dep.rs new file mode 100644 index 000000000..10a55dd02 --- /dev/null +++ b/src/test/rustdoc/auxiliary/async-trait-dep.rs @@ -0,0 +1,9 @@ +// edition:2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +pub trait Meow { + /// Who's a good dog? + async fn woof(); +} diff --git a/src/test/rustdoc/auxiliary/incoherent-impl-types.rs b/src/test/rustdoc/auxiliary/incoherent-impl-types.rs new file mode 100644 index 000000000..fc51e42e5 --- /dev/null +++ b/src/test/rustdoc/auxiliary/incoherent-impl-types.rs @@ -0,0 +1,7 @@ +#![feature(rustc_attrs)] + +#[rustc_has_incoherent_inherent_impls] +pub trait FooTrait {} + +#[rustc_has_incoherent_inherent_impls] +pub struct FooStruct; diff --git a/src/test/rustdoc/auxiliary/reexport-doc-aux.rs b/src/test/rustdoc/auxiliary/reexport-doc-aux.rs new file mode 100644 index 000000000..3400717eb --- /dev/null +++ b/src/test/rustdoc/auxiliary/reexport-doc-aux.rs @@ -0,0 +1,5 @@ +pub struct Foo; + +impl Foo { + pub fn foo() {} +} diff --git a/src/test/rustdoc/blanket-reexport-item.rs b/src/test/rustdoc/blanket-reexport-item.rs index 676d656da..437f0001f 100644 --- a/src/test/rustdoc/blanket-reexport-item.rs +++ b/src/test/rustdoc/blanket-reexport-item.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-S"]//h3[@class="code-header in-band"]' 'impl<T, U> Into<U> for T' +// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-S"]//h3[@class="code-header"]' 'impl<T, U> Into<U> for T' pub struct S2 {} mod m { pub struct S {} diff --git a/src/test/rustdoc/cfg_doc_reexport.rs b/src/test/rustdoc/cfg_doc_reexport.rs new file mode 100644 index 000000000..addb6709d --- /dev/null +++ b/src/test/rustdoc/cfg_doc_reexport.rs @@ -0,0 +1,33 @@ +#![feature(doc_cfg)] +#![feature(no_core)] + +#![crate_name = "foo"] +#![no_core] + +// @has 'foo/index.html' +// @has - '//*[@class="item-left module-item"]/*[@class="stab portability"]' 'foobar' +// @has - '//*[@class="item-left module-item"]/*[@class="stab portability"]' 'bar' + +#[doc(cfg(feature = "foobar"))] +mod imp_priv { + // @has 'foo/struct.BarPriv.html' + // @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on crate feature foobar only.' + pub struct BarPriv {} + impl BarPriv { + pub fn test() {} + } +} +#[doc(cfg(feature = "foobar"))] +pub use crate::imp_priv::*; + +pub mod bar { + // @has 'foo/bar/struct.Bar.html' + // @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + // 'Available on crate feature bar only.' + #[doc(cfg(feature = "bar"))] + pub struct Bar; +} + +#[doc(cfg(feature = "bar"))] +pub use bar::Bar; diff --git a/src/test/rustdoc/check-source-code-urls-to-def-std.rs b/src/test/rustdoc/check-source-code-urls-to-def-std.rs index 3396b234a..e12d8445f 100644 --- a/src/test/rustdoc/check-source-code-urls-to-def-std.rs +++ b/src/test/rustdoc/check-source-code-urls-to-def-std.rs @@ -9,7 +9,7 @@ fn babar() {} // @has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' // @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str' // @has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#7"]' 'babar' +// @has - '//a[@href="#7"]' 'babar' pub fn foo(a: u32, b: &str, c: String) { let x = 12; let y: bool = true; @@ -31,12 +31,12 @@ macro_rules! data { pub fn another_foo() { // This is known limitation: if the macro doesn't generate anything, the visitor // can't find any item or anything that could tell us that it comes from expansion. - // @!has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#19"]' 'yolo!' + // @!has - '//a[@href="#19"]' 'yolo!' yolo!(); // @has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!' eprintln!(); - // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#27-29"]' 'data!' + // @has - '//a[@href="#27-29"]' 'data!' let x = data!(4); - // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#23-25"]' 'bar!' + // @has - '//a[@href="#23-25"]' 'bar!' bar!(x); } diff --git a/src/test/rustdoc/check-source-code-urls-to-def.rs b/src/test/rustdoc/check-source-code-urls-to-def.rs index ec44e1bc6..d00a3e355 100644 --- a/src/test/rustdoc/check-source-code-urls-to-def.rs +++ b/src/test/rustdoc/check-source-code-urls-to-def.rs @@ -10,14 +10,14 @@ extern crate source_code; // @has 'src/foo/check-source-code-urls-to-def.rs.html' -// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#1-17"]' 'bar' +// @has - '//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' #[path = "auxiliary/source-code-bar.rs"] pub mod bar; -// @count - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#5"]' 4 +// @count - '//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4 use bar::Bar; -// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#13"]' 'self' -// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14"]' 'Trait' +// @has - '//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self' +// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' use bar::sub::{self, Trait}; pub struct Foo; @@ -31,26 +31,26 @@ fn babar() {} // @has - '//a/@href' '/struct.String.html' // @has - '//a/@href' '/primitive.u32.html' // @has - '//a/@href' '/primitive.str.html' -// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5 +// @count - '//a[@href="#23"]' 5 // @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode' pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { let x = 12; let y: Foo = Foo; let z: Bar = bar::Bar { field: Foo }; babar(); - // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#26"]' 'hello' + // @has - '//a[@href="#26"]' 'hello' y.hello(); } -// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait' -// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14"]' 'Trait' +// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait' +// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {} pub trait AnotherTrait {} pub trait WhyNot {} -// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#49"]' 'AnotherTrait' -// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#50"]' 'WhyNot' +// @has - '//a[@href="#49"]' 'AnotherTrait' +// @has - '//a[@href="#50"]' 'WhyNot' pub fn foo3<T, V>(t: &T, v: &V) where T: AnotherTrait, @@ -59,7 +59,7 @@ where pub trait AnotherTrait2 {} -// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#60"]' 'AnotherTrait2' +// @has - '//a[@href="#60"]' 'AnotherTrait2' pub fn foo4() { let x: Vec<AnotherTrait2> = Vec::new(); } diff --git a/src/test/rustdoc/codeblock-title.rs b/src/test/rustdoc/codeblock-title.rs index 140c5b3a6..b9b0b0d1a 100644 --- a/src/test/rustdoc/codeblock-title.rs +++ b/src/test/rustdoc/codeblock-title.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has foo/fn.bar.html '//*[@class="tooltip compile_fail"]' "โ" -// @has foo/fn.bar.html '//*[@class="tooltip ignore"]' "โ" -// @has foo/fn.bar.html '//*[@class="tooltip should_panic"]' "โ" +// @has foo/fn.bar.html '//*[@class="example-wrap compile_fail"]/*[@class="tooltip"]' "โ" +// @has foo/fn.bar.html '//*[@class="example-wrap ignore"]/*[@class="tooltip"]' "โ" +// @has foo/fn.bar.html '//*[@class="example-wrap should_panic"]/*[@class="tooltip"]' "โ" // @has foo/fn.bar.html '//*[@data-edition="2018"]' "โ" /// foo diff --git a/src/test/rustdoc/const-display.rs b/src/test/rustdoc/const-display.rs index 8455dd9ef..594501b22 100644 --- a/src/test/rustdoc/const-display.rs +++ b/src/test/rustdoc/const-display.rs @@ -20,7 +20,7 @@ pub const fn foo() -> u32 { 42 } pub const unsafe fn foo_unsafe() -> u32 { 42 } // @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' -// @!has - '//span[@class="since"]' +// @!hasraw - '//span[@class="since"]' #[unstable(feature = "humans", issue = "none")] pub const fn foo2() -> u32 { 42 } @@ -32,7 +32,7 @@ pub const fn bar2() -> u32 { 42 } // @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' -// @!has - '//span[@class="since"]' +// @!hasraw - '//span[@class="since"]' #[unstable(feature = "foo2", issue = "none")] pub const unsafe fn foo2_gated() -> u32 { 42 } @@ -43,7 +43,7 @@ pub const unsafe fn foo2_gated() -> u32 { 42 } pub const unsafe fn bar2_gated() -> u32 { 42 } // @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' -// @!has - '//span[@class="since"]' +// @!hasraw - '//span[@class="since"]' pub const unsafe fn bar_not_gated() -> u32 { 42 } pub struct Foo; diff --git a/src/test/rustdoc/const-generics/add-impl.rs b/src/test/rustdoc/const-generics/add-impl.rs index 591139523..6cbae9abe 100644 --- a/src/test/rustdoc/const-generics/add-impl.rs +++ b/src/test/rustdoc/const-generics/add-impl.rs @@ -7,7 +7,7 @@ pub struct Simd<T, const WIDTH: usize> { inner: T, } -// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>' +// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>' impl Add for Simd<u8, 16> { type Output = Self; diff --git a/src/test/rustdoc/const-generics/const-generics-docs.rs b/src/test/rustdoc/const-generics/const-generics-docs.rs index 352a8e646..5bf76e3c4 100644 --- a/src/test/rustdoc/const-generics/const-generics-docs.rs +++ b/src/test/rustdoc/const-generics/const-generics-docs.rs @@ -19,10 +19,10 @@ pub use extern_crate::WTrait; // @has foo/trait.Trait.html '//pre[@class="rust trait"]' \ // 'pub trait Trait<const N: usize>' -// @has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<1> for u8' -// @has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<2> for u8' -// @has - '//*[@id="impl-Trait%3C{1%20+%202}%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<{1 + 2}> for u8' -// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<1> for u8' +// @has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<2> for u8' +// @has - '//*[@id="impl-Trait%3C{1%20+%202}%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<{1 + 2}> for u8' +// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//h3[@class="code-header"]' \ // 'impl<const N: usize> Trait<N> for [u8; N]' pub trait Trait<const N: usize> {} impl Trait<1> for u8 {} @@ -31,12 +31,12 @@ impl Trait<{1 + 2}> for u8 {} impl<const N: usize> Trait<N> for [u8; N] {} // @has foo/struct.Foo.html '//pre[@class="rust struct"]' \ -// 'pub struct Foo<const N: usize> where u8: Trait<N>' +// 'pub struct Foo<const N: usize>where u8: Trait<N>' pub struct Foo<const N: usize> where u8: Trait<N>; // @has foo/struct.Bar.html '//pre[@class="rust struct"]' 'pub struct Bar<T, const N: usize>(_)' pub struct Bar<T, const N: usize>([T; N]); -// @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header in-band"]' 'impl<const M: usize> Foo<M> where u8: Trait<M>' +// @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Foo<M>where u8: Trait<M>' impl<const M: usize> Foo<M> where u8: Trait<M> { // @has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' pub const FOO_ASSOC: usize = M + 13; @@ -47,17 +47,17 @@ impl<const M: usize> Foo<M> where u8: Trait<M> { } } -// @has foo/struct.Bar.html '//*[@id="impl-Bar%3Cu8%2C%20M%3E"]/h3[@class="code-header in-band"]' 'impl<const M: usize> Bar<u8, M>' +// @has foo/struct.Bar.html '//*[@id="impl-Bar%3Cu8%2C%20M%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Bar<u8, M>' impl<const M: usize> Bar<u8, M> { // @has - '//*[@id="method.hey"]' \ - // 'pub fn hey<const N: usize>(&self) -> Foo<N> where u8: Trait<N>' + // 'pub fn hey<const N: usize>(&self) -> Foo<N>where u8: Trait<N>' pub fn hey<const N: usize>(&self) -> Foo<N> where u8: Trait<N> { Foo } } // @has foo/fn.test.html '//pre[@class="rust fn"]' \ -// 'pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N>' +// 'pub fn test<const N: usize>() -> impl Trait<N>where u8: Trait<N>' pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N> { 2u8 } diff --git a/src/test/rustdoc/const-generics/const-impl.rs b/src/test/rustdoc/const-generics/const-impl.rs index f1181d54a..75ee84279 100644 --- a/src/test/rustdoc/const-generics/const-impl.rs +++ b/src/test/rustdoc/const-generics/const-impl.rs @@ -9,20 +9,20 @@ pub enum Order { } // @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>' -// @has foo/struct.VSet.html '//*[@id="impl-Send-for-VSet%3CT%2C%20ORDER%3E"]/h3[@class="code-header in-band"]' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>' -// @has foo/struct.VSet.html '//*[@id="impl-Sync-for-VSet%3CT%2C%20ORDER%3E"]/h3[@class="code-header in-band"]' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>' +// @has foo/struct.VSet.html '//*[@id="impl-Send-for-VSet%3CT%2C%20ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>' +// @has foo/struct.VSet.html '//*[@id="impl-Sync-for-VSet%3CT%2C%20ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>' pub struct VSet<T, const ORDER: Order> { inner: Vec<T>, } -// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT%2C%20{%20Order%3A%3ASorted%20}%3E"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Sorted }>' +// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT%2C%20{%20Order%3A%3ASorted%20}%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Sorted }>' impl<T> VSet<T, { Order::Sorted }> { pub fn new() -> Self { Self { inner: Vec::new() } } } -// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT%2C%20{%20Order%3A%3AUnsorted%20}%3E"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Unsorted }>' +// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT%2C%20{%20Order%3A%3AUnsorted%20}%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Unsorted }>' impl<T> VSet<T, { Order::Unsorted }> { pub fn new() -> Self { Self { inner: Vec::new() } @@ -31,7 +31,7 @@ impl<T> VSet<T, { Order::Unsorted }> { pub struct Escape<const S: &'static str>; -// @has foo/struct.Escape.html '//*[@id="impl-Escape%3Cr#%22%3Cscript%3Ealert(%22Escape%22)%3B%3C/script%3E%22#%3E"]/h3[@class="code-header in-band"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>' +// @has foo/struct.Escape.html '//*[@id="impl-Escape%3Cr#%22%3Cscript%3Ealert(%22Escape%22)%3B%3C/script%3E%22#%3E"]/h3[@class="code-header"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>' impl Escape<r#"<script>alert("Escape");</script>"#> { pub fn f() {} } diff --git a/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs b/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs index 4eac8e31e..310e89a35 100644 --- a/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs +++ b/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs @@ -12,7 +12,7 @@ pub struct Hasher<T> { unsafe impl<T: Default> Send for Hasher<T> {} // @has foo/struct.Foo.html -// @has - '//h3[@class="code-header in-band"]' 'impl Send for Foo' +// @has - '//h3[@class="code-header"]' 'impl Send for Foo' pub struct Foo { hasher: Hasher<[u8; 3]>, } diff --git a/src/test/rustdoc/const-value-display.rs b/src/test/rustdoc/const-value-display.rs index 5b2f3c48d..8d95f0de9 100644 --- a/src/test/rustdoc/const-value-display.rs +++ b/src/test/rustdoc/const-value-display.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] // @has 'foo/constant.HOUR_IN_SECONDS.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' +// @has - '//*[@class="item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' pub const HOUR_IN_SECONDS: u64 = 60 * 60; // @has 'foo/constant.NEGATIVE.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' +// @has - '//*[@class="item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' pub const NEGATIVE: i64 = -60 * 60; diff --git a/src/test/rustdoc/decl-trailing-whitespace.rs b/src/test/rustdoc/decl-trailing-whitespace.rs index 46a2307ab..e47edc132 100644 --- a/src/test/rustdoc/decl-trailing-whitespace.rs +++ b/src/test/rustdoc/decl-trailing-whitespace.rs @@ -7,7 +7,7 @@ pub struct Error; // @has 'foo/trait.Write.html' pub trait Write { - // @snapshot 'declaration' - '//*[@class="docblock item-decl"]//code' + // @snapshot 'declaration' - '//*[@class="item-decl"]//code' fn poll_write( self: Option<String>, cx: &mut Option<String>, diff --git a/src/test/rustdoc/deprecated-impls.rs b/src/test/rustdoc/deprecated-impls.rs index efd250ce9..e419d2631 100644 --- a/src/test/rustdoc/deprecated-impls.rs +++ b/src/test/rustdoc/deprecated-impls.rs @@ -5,8 +5,8 @@ pub struct Foo0; impl Foo0 { // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' - // @has - 'fn_with_doc short' - // @has - 'fn_with_doc full' + // @hasraw - 'fn_with_doc short' + // @hasraw - 'fn_with_doc full' /// fn_with_doc short /// /// fn_with_doc full @@ -52,8 +52,8 @@ pub struct Foo1; impl Bar for Foo1 { // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - // @has - 'fn_empty_with_doc_impl short' - // @has - 'fn_empty_with_doc_impl full' + // @hasraw - 'fn_empty_with_doc_impl short' + // @hasraw - 'fn_empty_with_doc_impl full' /// fn_empty_with_doc_impl short /// /// fn_empty_with_doc_impl full @@ -63,8 +63,8 @@ impl Bar for Foo1 { fn fn_empty_without_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - // @has - 'fn_def_with_doc_impl short' - // @has - 'fn_def_with_doc_impl full' + // @hasraw - 'fn_def_with_doc_impl short' + // @hasraw - 'fn_def_with_doc_impl full' /// fn_def_with_doc_impl short /// /// fn_def_with_doc_impl full @@ -74,8 +74,8 @@ impl Bar for Foo1 { fn fn_def_without_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - // @has - 'fn_def_def_with_doc short' - // @!has - 'fn_def_def_with_doc full' + // @hasraw - 'fn_def_def_with_doc short' + // @!hasraw - 'fn_def_def_with_doc full' // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' } @@ -85,34 +85,34 @@ pub struct Foo2; impl Bar for Foo2 { // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - // @has - 'fn_empty_with_doc short' - // @!has - 'fn_empty_with_doc full' + // @hasraw - 'fn_empty_with_doc short' + // @!hasraw - 'fn_empty_with_doc full' fn fn_empty_with_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - // @has - 'fn_empty_without_doc_impl short' - // @has - 'fn_empty_without_doc_impl full' + // @hasraw - 'fn_empty_without_doc_impl short' + // @hasraw - 'fn_empty_without_doc_impl full' /// fn_empty_without_doc_impl short /// /// fn_empty_without_doc_impl full fn fn_empty_without_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - // @has - 'fn_def_with_doc short' - // @!has - 'fn_def_with_doc full' + // @hasraw - 'fn_def_with_doc short' + // @!hasraw - 'fn_def_with_doc full' fn fn_def_with_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - // @has - 'fn_def_without_doc_impl short' - // @has - 'fn_def_without_doc_impl full' + // @hasraw - 'fn_def_without_doc_impl short' + // @hasraw - 'fn_def_without_doc_impl full' /// fn_def_without_doc_impl short /// /// fn_def_without_doc_impl full fn fn_def_without_doc() {} // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - // @has - 'fn_def_def_with_doc short' - // @!has - 'fn_def_def_with_doc full' + // @hasraw - 'fn_def_def_with_doc short' + // @!hasraw - 'fn_def_def_with_doc full' // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' } diff --git a/src/test/rustdoc/deref-recursive-pathbuf.rs b/src/test/rustdoc/deref-recursive-pathbuf.rs index 746df9c80..be2b42b5a 100644 --- a/src/test/rustdoc/deref-recursive-pathbuf.rs +++ b/src/test/rustdoc/deref-recursive-pathbuf.rs @@ -7,9 +7,9 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.as_path"]' 'pub fn as_path(&self)' // @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref<Target = Path>' // @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' // @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.as_path"]' 'as_path' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' // @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.exists"]' 'exists' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-recursive.rs b/src/test/rustdoc/deref-recursive.rs index d5f8473f2..0436f2f86 100644 --- a/src/test/rustdoc/deref-recursive.rs +++ b/src/test/rustdoc/deref-recursive.rs @@ -7,9 +7,9 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)' // @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>' // @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-typedef.rs b/src/test/rustdoc/deref-typedef.rs index 28f977e31..32424d13e 100644 --- a/src/test/rustdoc/deref-typedef.rs +++ b/src/test/rustdoc/deref-typedef.rs @@ -6,7 +6,7 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c' diff --git a/src/test/rustdoc/doc-notable_trait_box_is_not_an_iterator.rs b/src/test/rustdoc/doc-notable_trait_box_is_not_an_iterator.rs new file mode 100644 index 000000000..3fb00c7db --- /dev/null +++ b/src/test/rustdoc/doc-notable_trait_box_is_not_an_iterator.rs @@ -0,0 +1,38 @@ +#![feature(doc_notable_trait)] +#![feature(lang_items)] +#![feature(no_core)] +#![no_core] +#[lang = "owned_box"] +pub struct Box<T>; + +impl<T> Box<T> { + pub fn new(x: T) -> Box<T> { + Box + } +} + +#[doc(notable_trait)] +pub trait FakeIterator {} + +impl<I: FakeIterator> FakeIterator for Box<I> {} + +#[lang = "pin"] +pub struct Pin<T>; + +impl<T> Pin<T> { + pub fn new(x: T) -> Pin<T> { + Pin + } +} + +impl<I: FakeIterator> FakeIterator for Pin<I> {} + +// @!has doc_notable_trait_box_is_not_an_iterator/fn.foo.html '//*' 'Notable' +pub fn foo<T>(x: T) -> Box<T> { + Box::new(x) +} + +// @!has doc_notable_trait_box_is_not_an_iterator/fn.bar.html '//*' 'Notable' +pub fn bar<T>(x: T) -> Pin<T> { + Pin::new(x) +} diff --git a/src/test/rustdoc/doc_auto_cfg_nested_impl.rs b/src/test/rustdoc/doc_auto_cfg_nested_impl.rs new file mode 100644 index 000000000..4d73e0d82 --- /dev/null +++ b/src/test/rustdoc/doc_auto_cfg_nested_impl.rs @@ -0,0 +1,24 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/101129>. + +#![feature(doc_auto_cfg)] +#![crate_type = "lib"] +#![crate_name = "foo"] + +pub struct S; +pub trait MyTrait1 {} +pub trait MyTrait2 {} + +// @has foo/struct.S.html +// @has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ +// 'Available on non-crate feature coolstuff only.' +#[cfg(not(feature = "coolstuff"))] +impl MyTrait1 for S {} + +#[cfg(not(feature = "coolstuff"))] +mod submod { + use crate::{S, MyTrait2}; + // This impl should also have the `not(feature = "coolstuff")`. + // @has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ + // 'Available on non-crate feature coolstuff only.' + impl MyTrait2 for S {} +} diff --git a/src/test/rustdoc/duplicate_impls/issue-33054.rs b/src/test/rustdoc/duplicate_impls/issue-33054.rs index 84c9e4ac0..c1f95ac91 100644 --- a/src/test/rustdoc/duplicate_impls/issue-33054.rs +++ b/src/test/rustdoc/duplicate_impls/issue-33054.rs @@ -1,12 +1,12 @@ // ignore-tidy-linelength // @has issue_33054/impls/struct.Foo.html -// @has - '//h3[@class="code-header in-band"]' 'impl Foo' -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for Foo' +// @has - '//h3[@class="code-header"]' 'impl Foo' +// @has - '//h3[@class="code-header"]' 'impl Bar for Foo' // @count - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]' 1 // @count - '//*[@id="main-content"]/div[@id="implementations-list"]/details/summary/*[@class="impl has-srclink"]' 1 // @has issue_33054/impls/bar/trait.Bar.html -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for Foo' +// @has - '//h3[@class="code-header"]' 'impl Bar for Foo' // @count - '//*[@class="struct"]' 1 pub mod impls; diff --git a/src/test/rustdoc/elided-lifetime.rs b/src/test/rustdoc/elided-lifetime.rs index 5a32554f9..006132ef8 100644 --- a/src/test/rustdoc/elided-lifetime.rs +++ b/src/test/rustdoc/elided-lifetime.rs @@ -3,7 +3,7 @@ // rust-lang/rust#75225 // // Since Rust 2018 we encourage writing out <'_> explicitly to make it clear -// that borrowing is occuring. Make sure rustdoc is following the same idiom. +// that borrowing is occurring. Make sure rustdoc is following the same idiom. #![crate_name = "foo"] @@ -11,33 +11,33 @@ pub struct Ref<'a>(&'a u32); type ARef<'a> = Ref<'a>; // @has foo/fn.test1.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" pub fn test1(a: &u32) -> Ref { Ref(a) } // @has foo/fn.test2.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" pub fn test2(a: &u32) -> Ref<'_> { Ref(a) } // @has foo/fn.test3.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" pub fn test3(a: &u32) -> ARef { Ref(a) } // @has foo/fn.test4.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" pub fn test4(a: &u32) -> ARef<'_> { Ref(a) } // Ensure external paths in inlined docs also display elided lifetime // @has foo/bar/fn.test5.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" // @has foo/bar/fn.test6.html -// @matches - "Ref</a><'_>" +// @matchesraw - "Ref</a><'_>" #[doc(inline)] pub extern crate bar; diff --git a/src/test/rustdoc/empty-impl-block-private-with-doc.rs b/src/test/rustdoc/empty-impl-block-private-with-doc.rs new file mode 100644 index 000000000..439719961 --- /dev/null +++ b/src/test/rustdoc/empty-impl-block-private-with-doc.rs @@ -0,0 +1,44 @@ +// compile-flags: --document-private-items + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +// @has 'foo/struct.Foo.html' +pub struct Foo; + +// There are 3 impl blocks with public item and one that should not be displayed +// by default because it only contains private items (but not in this case because +// we used `--document-private-items`). +// @count - '//*[@class="impl has-srclink"]' 'impl Foo' 4 + +// Impl block only containing private items should not be displayed unless the +// `--document-private-items` flag is used. +/// Private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +// But if any element of the impl block is public, it should be displayed. +/// Not private +impl Foo { + pub const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + pub type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + pub fn hello() {} +} diff --git a/src/test/rustdoc/empty-impl-block-private.rs b/src/test/rustdoc/empty-impl-block-private.rs new file mode 100644 index 000000000..5caf02065 --- /dev/null +++ b/src/test/rustdoc/empty-impl-block-private.rs @@ -0,0 +1,40 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_name = "foo"] + +// @has 'foo/struct.Foo.html' +pub struct Foo; + +// There are 3 impl blocks with public item and one that should not be displayed +// because it only contains private items. +// @count - '//*[@class="impl has-srclink"]' 'impl Foo' 3 + +// Impl block only containing private items should not be displayed. +/// Private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +// But if any element of the impl block is public, it should be displayed. +/// Not private +impl Foo { + pub const BAR: u32 = 0; + type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + pub type FOO = i32; + fn hello() {} +} + +/// Not private +impl Foo { + const BAR: u32 = 0; + type FOO = i32; + pub fn hello() {} +} diff --git a/src/test/rustdoc/empty-impl-block.rs b/src/test/rustdoc/empty-impl-block.rs index 6a2a254f6..95d4db06b 100644 --- a/src/test/rustdoc/empty-impl-block.rs +++ b/src/test/rustdoc/empty-impl-block.rs @@ -16,5 +16,5 @@ pub struct Another; pub trait Bar {} // @has 'foo/struct.Another.html' -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for Another' +// @has - '//h3[@class="code-header"]' 'impl Bar for Another' impl Bar for Another {} diff --git a/src/test/rustdoc/empty-mod-private.rs b/src/test/rustdoc/empty-mod-private.rs index c2a98049a..147e11e58 100644 --- a/src/test/rustdoc/empty-mod-private.rs +++ b/src/test/rustdoc/empty-mod-private.rs @@ -1,16 +1,16 @@ // compile-flags: --document-private-items // @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' -// @has 'empty_mod_private/sidebar-items.js' 'foo' +// @hasraw 'empty_mod_private/sidebar-items.js' 'foo' // @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo' mod foo {} // @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar' -// @has 'empty_mod_private/sidebar-items.js' 'bar' +// @hasraw 'empty_mod_private/sidebar-items.js' 'bar' // @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar' mod bar { // @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz' - // @has 'empty_mod_private/bar/sidebar-items.js' 'baz' + // @hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz' // @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz' mod baz {} } diff --git a/src/test/rustdoc/empty-mod-public.rs b/src/test/rustdoc/empty-mod-public.rs index d097fcf83..c0bac4021 100644 --- a/src/test/rustdoc/empty-mod-public.rs +++ b/src/test/rustdoc/empty-mod-public.rs @@ -1,14 +1,14 @@ // @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo' -// @has 'empty_mod_public/sidebar-items.js' 'foo' +// @hasraw 'empty_mod_public/sidebar-items.js' 'foo' // @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo' pub mod foo {} // @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar' -// @has 'empty_mod_public/sidebar-items.js' 'bar' +// @hasraw 'empty_mod_public/sidebar-items.js' 'bar' // @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar' pub mod bar { // @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz' - // @has 'empty_mod_public/bar/sidebar-items.js' 'baz' + // @hasraw 'empty_mod_public/bar/sidebar-items.js' 'baz' // @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz' pub mod baz {} } diff --git a/src/test/rustdoc/empty-section.rs b/src/test/rustdoc/empty-section.rs index 665aa38b1..d8241ab96 100644 --- a/src/test/rustdoc/empty-section.rs +++ b/src/test/rustdoc/empty-section.rs @@ -5,7 +5,7 @@ pub struct Foo; // @has foo/struct.Foo.html -// @!has - 'Auto Trait Implementations' +// @!hasraw - 'Auto Trait Implementations' impl !Send for Foo {} impl !Sync for Foo {} impl !std::marker::Unpin for Foo {} diff --git a/src/test/rustdoc/ensure-src-link.rs b/src/test/rustdoc/ensure-src-link.rs index 9f8b0277e..c65387080 100644 --- a/src/test/rustdoc/ensure-src-link.rs +++ b/src/test/rustdoc/ensure-src-link.rs @@ -2,5 +2,5 @@ // This test ensures that the [src] link is present on traits items. -// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="srclink"]' "source" +// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="srclink rightside"]' "source" pub use std::iter::Iterator; diff --git a/src/test/rustdoc/escape-deref-methods.rs b/src/test/rustdoc/escape-deref-methods.rs index a62ad2c40..66919d73e 100644 --- a/src/test/rustdoc/escape-deref-methods.rs +++ b/src/test/rustdoc/escape-deref-methods.rs @@ -27,7 +27,7 @@ impl Deref for TitleList { } // @has foo/struct.TitleList.html -// @has - '//*[@class="sidebar-title"]' 'Methods from Deref<Target=Vec<Title>>' +// @has - '//div[@class="sidebar-elems"]//h3' 'Methods from Deref<Target=Vec<Title>>' impl DerefMut for TitleList { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.members diff --git a/src/test/rustdoc/extern-impl.rs b/src/test/rustdoc/extern-impl.rs index f357d65df..fd1bc2140 100644 --- a/src/test/rustdoc/extern-impl.rs +++ b/src/test/rustdoc/extern-impl.rs @@ -19,9 +19,9 @@ impl Foo { // @has foo/trait.Bar.html pub trait Bar {} -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for fn()' +// @has - '//h3[@class="code-header"]' 'impl Bar for fn()' impl Bar for fn() {} -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for extern "C" fn()' +// @has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' impl Bar for extern fn() {} -// @has - '//h3[@class="code-header in-band"]' 'impl Bar for extern "system" fn()' +// @has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' impl Bar for extern "system" fn() {} diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs index 4c4ffddc8..9e060ff20 100644 --- a/src/test/rustdoc/fn-bound.rs +++ b/src/test/rustdoc/fn-bound.rs @@ -11,7 +11,7 @@ pub struct ConditionalIterator<F> { } -// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header in-band"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' +// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> { type Item = (); diff --git a/src/test/rustdoc/generic-associated-types/gats.rs b/src/test/rustdoc/generic-associated-types/gats.rs index ae981b949..bcead3115 100644 --- a/src/test/rustdoc/generic-associated-types/gats.rs +++ b/src/test/rustdoc/generic-associated-types/gats.rs @@ -1,9 +1,8 @@ #![crate_name = "foo"] -#![feature(generic_associated_types)] // @has foo/trait.LendingIterator.html pub trait LendingIterator { - // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a" + // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a>where Self: 'a" type Item<'a> where Self: 'a; // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \ @@ -24,7 +23,7 @@ impl LendingIterator for () { pub struct Infinite<T>(T); // @has foo/trait.LendingIterator.html -// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T" +// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a>where Self: 'a = &'a T" impl<T> LendingIterator for Infinite<T> { type Item<'a> where Self: 'a = &'a T; diff --git a/src/test/rustdoc/generic-associated-types/issue-94683.rs b/src/test/rustdoc/generic-associated-types/issue-94683.rs index 38ecf5283..985c7e983 100644 --- a/src/test/rustdoc/generic-associated-types/issue-94683.rs +++ b/src/test/rustdoc/generic-associated-types/issue-94683.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] -#![feature(generic_associated_types)] pub trait Trait { type Gat<'a>; @@ -8,6 +7,6 @@ pub trait Trait { // Make sure that the elided lifetime shows up // @has foo/type.T.html -// @has - "pub type T = " -// @has - "<'_>" +// @hasraw - "pub type T = " +// @hasraw - "<'_>" pub type T = fn(&<() as Trait>::Gat<'_>); diff --git a/src/test/rustdoc/generic-impl.rs b/src/test/rustdoc/generic-impl.rs index c6beed70a..6f68b1574 100644 --- a/src/test/rustdoc/generic-impl.rs +++ b/src/test/rustdoc/generic-impl.rs @@ -5,7 +5,7 @@ use std::fmt; // @!has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' pub struct Bar; -// @has foo/struct.Foo.html '//*[@id="impl-ToString-for-Foo"]//h3[@class="code-header in-band"]' 'impl<T> ToString for T' +// @has foo/struct.Foo.html '//*[@id="impl-ToString-for-Foo"]//h3[@class="code-header"]' 'impl<T> ToString for T' pub struct Foo; // @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-Foo"]' 'ToString' diff --git a/src/test/rustdoc/glob-shadowing-const.rs b/src/test/rustdoc/glob-shadowing-const.rs new file mode 100644 index 000000000..5b786cf53 --- /dev/null +++ b/src/test/rustdoc/glob-shadowing-const.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/pull/83872#issuecomment-820101008 +#![crate_name="foo"] + +mod sub4 { + /// 0 + pub const X: usize = 0; + pub mod inner { + pub use super::*; + /// 1 + pub const X: usize = 1; + } +} + +#[doc(inline)] +pub use sub4::inner::*; + +// @has 'foo/index.html' +// @has - '//div[@class="item-right docblock-short"]' '1' +// @!has - '//div[@class="item-right docblock-short"]' '0' +fn main() { assert_eq!(X, 1); } diff --git a/src/test/rustdoc/glob-shadowing.rs b/src/test/rustdoc/glob-shadowing.rs new file mode 100644 index 000000000..66a31c42b --- /dev/null +++ b/src/test/rustdoc/glob-shadowing.rs @@ -0,0 +1,86 @@ +// @has 'glob_shadowing/index.html' +// @count - '//div[@class="item-left module-item"]' 6 +// @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe' +// @has - '//div[@class="item-right docblock-short"]' 'sub2::describe' + +// @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe2' + +// @!has - '//div[@class="item-right docblock-short"]' 'sub1::prelude' +// @has - '//div[@class="item-right docblock-short"]' 'mod::prelude' + +// @has - '//div[@class="item-right docblock-short"]' 'sub1::Foo (struct)' +// @has - '//div[@class="item-right docblock-short"]' 'mod::Foo (function)' + +// @has - '//div[@class="item-right docblock-short"]' 'sub4::inner::X' + +// @has 'glob_shadowing/fn.describe.html' +// @has - '//div[@class="docblock"]' 'sub2::describe' + +mod sub1 { + // this should be shadowed by sub2::describe + /// sub1::describe + pub fn describe() -> &'static str { + "sub1::describe" + } + + // this should be shadowed by mod::prelude + /// sub1::prelude + pub mod prelude { + } + + // this should *not* be shadowed, because sub1::Foo and mod::Foo are in different namespaces + /// sub1::Foo (struct) + pub struct Foo; + + // this should be shadowed, + // because both sub1::describe2 and sub3::describe2 are from glob reexport + /// sub1::describe2 + pub fn describe2() -> &'static str { + "sub1::describe2" + } +} + +mod sub2 { + /// sub2::describe + pub fn describe() -> &'static str { + "sub2::describe" + } +} + +mod sub3 { + // this should be shadowed + // because both sub1::describe2 and sub3::describe2 are from glob reexport + /// sub3::describe2 + pub fn describe2() -> &'static str { + "sub3::describe2" + } +} + +mod sub4 { + // this should be shadowed by sub4::inner::X + /// sub4::X + pub const X: usize = 0; + pub mod inner { + pub use super::*; + /// sub4::inner::X + pub const X: usize = 1; + } +} + +/// mod::Foo (function) +pub fn Foo() {} + +#[doc(inline)] +pub use sub2::describe; + +#[doc(inline)] +pub use sub1::*; + +#[doc(inline)] +pub use sub3::*; + +#[doc(inline)] +pub use sub4::inner::*; + +/// mod::prelude +pub mod prelude {} diff --git a/src/test/rustdoc/hidden-impls.rs b/src/test/rustdoc/hidden-impls.rs index 8f33a6604..26e2e0e06 100644 --- a/src/test/rustdoc/hidden-impls.rs +++ b/src/test/rustdoc/hidden-impls.rs @@ -11,7 +11,7 @@ pub mod __hidden { } // @has foo/trait.Clone.html -// @!has - 'Foo' +// @!hasraw - 'Foo' // @has implementors/core/clone/trait.Clone.js -// @!has - 'Foo' +// @!hasraw - 'Foo' pub use std::clone::Clone; diff --git a/src/test/rustdoc/hidden-line.rs b/src/test/rustdoc/hidden-line.rs index f2f6173d2..00a05a7c2 100644 --- a/src/test/rustdoc/hidden-line.rs +++ b/src/test/rustdoc/hidden-line.rs @@ -15,5 +15,5 @@ /// ``` pub fn foo() {} -// @!has hidden_line/fn.foo.html invisible +// @!hasraw hidden_line/fn.foo.html invisible // @matches - //pre "#\[derive\(PartialEq\)\] // Bar" diff --git a/src/test/rustdoc/hidden-methods.rs b/src/test/rustdoc/hidden-methods.rs index 27181d489..543d8f768 100644 --- a/src/test/rustdoc/hidden-methods.rs +++ b/src/test/rustdoc/hidden-methods.rs @@ -17,13 +17,13 @@ pub mod hidden { } // @has foo/struct.Foo.html -// @!has - 'Methods' +// @!hasraw - 'Methods' // @!has - '//code' 'impl Foo' -// @!has - 'this_should_be_hidden' +// @!hasraw - 'this_should_be_hidden' pub use hidden::Foo; // @has foo/struct.Bar.html -// @!has - 'Methods' +// @!hasraw - 'Methods' // @!has - '//code' 'impl Bar' -// @!has - 'this_should_be_hidden' +// @!hasraw - 'this_should_be_hidden' pub use hidden::Bar; diff --git a/src/test/rustdoc/hide-unstable-trait.rs b/src/test/rustdoc/hide-unstable-trait.rs index c30d6ed7b..0bf7cabc4 100644 --- a/src/test/rustdoc/hide-unstable-trait.rs +++ b/src/test/rustdoc/hide-unstable-trait.rs @@ -5,7 +5,7 @@ extern crate unstable_trait; -// @has foo/struct.Foo.html 'bar' -// @has foo/struct.Foo.html 'bar2' +// @hasraw foo/struct.Foo.html 'bar' +// @hasraw foo/struct.Foo.html 'bar2' #[doc(inline)] pub use unstable_trait::Foo; diff --git a/src/test/rustdoc/higher-ranked-trait-bounds.rs b/src/test/rustdoc/higher-ranked-trait-bounds.rs index b75b8de52..3493ae6d2 100644 --- a/src/test/rustdoc/higher-ranked-trait-bounds.rs +++ b/src/test/rustdoc/higher-ranked-trait-bounds.rs @@ -4,7 +4,7 @@ pub trait Trait<'x> {} // @has foo/fn.test1.html -// @has - '//pre' "pub fn test1<T>() where for<'a> &'a T: Iterator," +// @has - '//pre' "pub fn test1<T>()where for<'a> &'a T: Iterator," pub fn test1<T>() where for<'a> &'a T: Iterator, @@ -12,7 +12,7 @@ where } // @has foo/fn.test2.html -// @has - '//pre' "pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>," +// @has - '//pre' "pub fn test2<T>()where for<'a, 'b> &'a T: Trait<'b>," pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>, @@ -20,7 +20,7 @@ where } // @has foo/fn.test3.html -// @has - '//pre' "pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8)," +// @has - '//pre' "pub fn test3<F>()where F: for<'a, 'b> Fn(&'a u8, &'b u8)," pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8), @@ -38,7 +38,7 @@ pub struct Foo<'a> { // @has - '//span[@id="structfield.some_trait"]' "some_trait: &'a dyn for<'b> Trait<'b>" impl<'a> Foo<'a> { - // @has - '//h4[@class="code-header"]' "pub fn bar<T>() where T: Trait<'a>," + // @has - '//h4[@class="code-header"]' "pub fn bar<T>()where T: Trait<'a>," pub fn bar<T>() where T: Trait<'a>, @@ -49,7 +49,7 @@ impl<'a> Foo<'a> { // @has foo/trait.B.html pub trait B<'x> {} -// @has - '//h3[@class="code-header in-band"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>" +// @has - '//h3[@class="code-header"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>" impl<'a> B<'a> for dyn for<'b> Trait<'b> {} // @has foo/struct.Bar.html diff --git a/src/test/rustdoc/impl-disambiguation.rs b/src/test/rustdoc/impl-disambiguation.rs index d1d39ccff..9e74ede8f 100644 --- a/src/test/rustdoc/impl-disambiguation.rs +++ b/src/test/rustdoc/impl-disambiguation.rs @@ -4,13 +4,13 @@ pub trait Foo {} pub struct Bar<T> { field: T } -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar<u8>" impl Foo for Bar<u8> {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar<u16>" impl Foo for Bar<u16> {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a Bar<u8>" impl<'a> Foo for &'a Bar<u8> {} @@ -22,9 +22,9 @@ pub mod mod2 { pub enum Baz {} } -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for foo::mod1::Baz" impl Foo for mod1::Baz {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a foo::mod2::Baz" impl<'a> Foo for &'a mod2::Baz {} diff --git a/src/test/rustdoc/impl-parts-crosscrate.rs b/src/test/rustdoc/impl-parts-crosscrate.rs index 6c5e79d5a..34733f1f8 100644 --- a/src/test/rustdoc/impl-parts-crosscrate.rs +++ b/src/test/rustdoc/impl-parts-crosscrate.rs @@ -12,9 +12,9 @@ pub struct Bar<T> { t: T } // full impl string. Instead, just make sure something from each part // is mentioned. -// @has implementors/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar -// @has - Send -// @has - !AnAutoTrait -// @has - Copy +// @hasraw implementors/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar +// @hasraw - Send +// @hasraw - !AnAutoTrait +// @hasraw - Copy impl<T: Send> !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar<T> where T: Copy {} diff --git a/src/test/rustdoc/impl-parts.rs b/src/test/rustdoc/impl-parts.rs index 249158c1a..7b931727e 100644 --- a/src/test/rustdoc/impl-parts.rs +++ b/src/test/rustdoc/impl-parts.rs @@ -5,8 +5,8 @@ pub auto trait AnAutoTrait {} pub struct Foo<T> { field: T } -// @has impl_parts/struct.Foo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<T: Clone> !AnAutoTrait for Foo<T> where T: Sync," -// @has impl_parts/trait.AnAutoTrait.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ -// "impl<T: Clone> !AnAutoTrait for Foo<T> where T: Sync," +// @has impl_parts/struct.Foo.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<T: Clone> !AnAutoTrait for Foo<T>where T: Sync," +// @has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<T: Clone> !AnAutoTrait for Foo<T>where T: Sync," impl<T: Clone> !AnAutoTrait for Foo<T> where T: Sync {} diff --git a/src/test/rustdoc/impl-trait-alias.rs b/src/test/rustdoc/impl-trait-alias.rs index 54c3f856d..4f681c78e 100644 --- a/src/test/rustdoc/impl-trait-alias.rs +++ b/src/test/rustdoc/impl-trait-alias.rs @@ -3,11 +3,11 @@ trait MyTrait {} impl MyTrait for i32 {} -// @has impl_trait_alias/type.Foo.html 'Foo' +// @hasraw impl_trait_alias/type.Foo.html 'Foo' /// debug type pub type Foo = impl MyTrait; -// @has impl_trait_alias/fn.foo.html 'foo' +// @hasraw impl_trait_alias/fn.foo.html 'foo' /// debug function pub fn foo() -> Foo { 1 diff --git a/src/test/rustdoc/impossible-default.rs b/src/test/rustdoc/impossible-default.rs new file mode 100644 index 000000000..24d6e3bda --- /dev/null +++ b/src/test/rustdoc/impossible-default.rs @@ -0,0 +1,20 @@ +#![crate_name = "foo"] + +// Check that default trait items that are impossible to satisfy + +pub trait Foo { + fn needs_sized(&self) + where + Self: Sized, + {} + + fn no_needs_sized(&self) {} +} + +// @!has foo/struct.Bar.html '//*[@id="method.needs_sized"]//h4[@class="code-header"]' \ +// "fn needs_sized" +// @has foo/struct.Bar.html '//*[@id="method.no_needs_sized"]//h4[@class="code-header"]' \ +// "fn no_needs_sized" +pub struct Bar([u8]); + +impl Foo for Bar {} diff --git a/src/test/rustdoc/index-page.rs b/src/test/rustdoc/index-page.rs index be668a127..0c947ea2e 100644 --- a/src/test/rustdoc/index-page.rs +++ b/src/test/rustdoc/index-page.rs @@ -5,7 +5,7 @@ #![crate_name = "foo"] // @has foo/../index.html -// @has - '//span[@class="in-band"]' 'List of all crates' -// @has - '//ul[@class="crate mod"]//a[@href="foo/index.html"]' 'foo' -// @has - '//ul[@class="crate mod"]//a[@href="all_item_types/index.html"]' 'all_item_types' +// @has - '//h1[@class="fqn"]' 'List of all crates' +// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo' +// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types' pub struct Foo; diff --git a/src/test/rustdoc/infinite-redirection.rs b/src/test/rustdoc/infinite-redirection.rs index 96a43323c..f037a8e1a 100644 --- a/src/test/rustdoc/infinite-redirection.rs +++ b/src/test/rustdoc/infinite-redirection.rs @@ -7,7 +7,7 @@ // @has 'foo/builders/struct.ActionRowBuilder.html' // @has - '//*[@id="synthetic-implementations"]' 'Auto Trait Implementations' -// And that the link in the module is targetting it. +// And that the link in the module is targeting it. // @has 'foo/builders/index.html' // @has - '//a[@href="struct.ActionRowBuilder.html"]' 'ActionRowBuilder' diff --git a/src/test/rustdoc/inline_cross/add-docs.rs b/src/test/rustdoc/inline_cross/add-docs.rs index 8f0c4e5e6..a1124d209 100644 --- a/src/test/rustdoc/inline_cross/add-docs.rs +++ b/src/test/rustdoc/inline_cross/add-docs.rs @@ -4,6 +4,6 @@ extern crate inner; // @has add_docs/struct.MyStruct.html -// @has add_docs/struct.MyStruct.html "Doc comment from โpub useโ, Doc comment from definition" +// @hasraw add_docs/struct.MyStruct.html "Doc comment from โpub useโ, Doc comment from definition" /// Doc comment from 'pub use', pub use inner::MyStruct; diff --git a/src/test/rustdoc/inline_cross/assoc-items.rs b/src/test/rustdoc/inline_cross/assoc-items.rs index 231805a52..811827a17 100644 --- a/src/test/rustdoc/inline_cross/assoc-items.rs +++ b/src/test/rustdoc/inline_cross/assoc-items.rs @@ -7,10 +7,10 @@ extern crate assoc_items; // @has foo/struct.MyStruct.html -// @!has - 'PrivateConst' +// @!hasraw - 'PrivateConst' // @has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8' // @has - '//*[@class="docblock"]' 'docs for PublicConst' -// @!has - 'private_method' +// @!hasraw - 'private_method' // @has - '//*[@id="method.public_method"]' 'pub fn public_method()' // @has - '//*[@class="docblock"]' 'docs for public_method' // @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html new file mode 100644 index 000000000..8934bc1ee --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html @@ -0,0 +1 @@ +<h4 class="code-header">type <a href="#associatedtype.Out0" class="associatedtype">Out0</a>: <a class="trait" href="../assoc_item_trait_bounds/trait.Support.html" title="trait assoc_item_trait_bounds::Support">Support</a><Item = <a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>></h4>
\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html new file mode 100644 index 000000000..bf330670e --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html @@ -0,0 +1 @@ +<h4 class="code-header">type <a href="#associatedtype.Out2" class="associatedtype">Out2</a><T>: <a class="trait" href="../assoc_item_trait_bounds/trait.Support.html" title="trait assoc_item_trait_bounds::Support">Support</a><Item = T></h4>
\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out9.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out9.html new file mode 100644 index 000000000..69d84e1b2 --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out9.html @@ -0,0 +1 @@ +<h4 class="code-header">type <a href="#associatedtype.Out9" class="associatedtype">Out9</a>: <a class="trait" href="{{channel}}/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="{{channel}}/std/primitive.bool.html">bool</a> + <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></h4>
\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.rs new file mode 100644 index 000000000..5f4712aab --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -0,0 +1,40 @@ +// Regression test for issues #77763, #84579 and #102142. +#![crate_name = "main"] + +// aux-build:assoc_item_trait_bounds.rs +// build-aux-docs +// ignore-cross-compile +extern crate assoc_item_trait_bounds as aux; + +// @has main/trait.Main.html +// @has - '//*[@id="associatedtype.Out0"]' 'type Out0: Support<Item = ()>' +// @has - '//*[@id="associatedtype.Out1"]' 'type Out1: Support<Item = Self::Item>' +// @has - '//*[@id="associatedtype.Out2"]' 'type Out2<T>: Support<Item = T>' +// @has - '//*[@id="associatedtype.Out3"]' 'type Out3: Support<Produce<()> = bool>' +// @has - '//*[@id="associatedtype.Out4"]' 'type Out4<T>: Support<Produce<T> = T>' +// @has - '//*[@id="associatedtype.Out5"]' "type Out5: Support<Output<'static> = &'static ()>" +// @has - '//*[@id="associatedtype.Out6"]' "type Out6: for<'a> Support<Output<'a> = &'a ()>" +// @has - '//*[@id="associatedtype.Out7"]' "type Out7: Support<Item = String, Produce<i32> = u32> + Unrelated" +// @has - '//*[@id="associatedtype.Out8"]' "type Out8: Unrelated + Protocol<i16, Q1 = u128, Q0 = ()>" +// @has - '//*[@id="associatedtype.Out9"]' "type Out9: FnMut(i32) -> bool + Clone" +// @has - '//*[@id="associatedtype.Out10"]' "type Out10<'q>: Support<Output<'q> = ()>" +// @has - '//*[@id="associatedtype.Out11"]' "type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>" +// @has - '//*[@id="associatedtype.Out12"]' "type Out12: for<'w> Helper<B<'w> = Cow<'w, str>, A<'w> = bool>" +// @has - '//*[@id="associatedtype.Out13"]' "type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>" +// @has - '//*[@id="associatedtype.Out14"]' "type Out14<P: Copy + Eq, Q: ?Sized>" +// +// Snapshots: +// Check that we don't render any where-clauses for the following associated types since +// all corresponding projection equality predicates should have already been re-sugared +// to associated type bindings: +// +// @snapshot out0 - '//*[@id="associatedtype.Out0"]/*[@class="code-header"]' +// @snapshot out2 - '//*[@id="associatedtype.Out2"]/*[@class="code-header"]' +// @snapshot out9 - '//*[@id="associatedtype.Out9"]/*[@class="code-header"]' +// +// @has - '//*[@id="tymethod.make"]' \ +// "fn make<F>(F, impl FnMut(&str) -> bool)\ +// where \ +// F: FnOnce(u32) -> String, \ +// Self::Out2<()>: Protocol<u8, Q0 = Self::Item, Q1 = ()>" +pub use aux::Main; diff --git a/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs new file mode 100644 index 000000000..d326e61da --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -0,0 +1,46 @@ +pub trait Main { + type Item; + + type Out0: Support<Item = ()>; + type Out1: Support<Item = Self::Item>; + type Out2<T>: Support<Item = T>; + type Out3: Support<Produce<()> = bool>; + type Out4<T>: Support<Produce<T> = T>; + type Out5: Support<Output<'static> = &'static ()>; + type Out6: for<'a> Support<Output<'a> = &'a ()>; + type Out7: Support<Item = String, Produce<i32> = u32> + Unrelated; + type Out8: Unrelated + Protocol<i16, Q1 = u128, Q0 = ()>; + type Out9: FnMut(i32) -> bool + Clone; + type Out10<'q>: Support<Output<'q> = ()>; + type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>; + type Out12: for<'w> Helper<B<'w> = std::borrow::Cow<'w, str>, A<'w> = bool>; + type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>; + type Out14<P: Copy + Eq, Q: ?Sized>; + + fn make<F>(_: F, _: impl FnMut(&str) -> bool) + where + F: FnOnce(u32) -> String, + Self::Out2<()>: Protocol<u8, Q0 = Self::Item, Q1 = ()>; +} + +pub trait Support { + type Item; + type Output<'a>; + type Produce<T>; +} + +pub trait Protocol<K> { + type Q0; + type Q1; +} + +pub trait Unrelated {} + +pub trait Helper { + type A<'q>; + type B<'q>; +} + +pub trait Aid<'src> { + type Result<'inter>; +} diff --git a/src/test/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/src/test/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 913ba8f2a..19433c968 100644 --- a/src/test/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/src/test/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -13,6 +13,19 @@ pub fn func3(_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone) {} pub fn func4<T: Iterator<Item = impl Clone>>(_x: T) {} +pub fn func5( + _f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>, + _a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, +) {} + +pub trait Other { + type T<'dependency>; +} + +pub trait Auxiliary<'arena> { + type Item<'input>; +} + pub async fn async_fn() {} pub struct Foo; diff --git a/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs b/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs new file mode 100644 index 000000000..e7a13acc6 --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs @@ -0,0 +1,14 @@ +#![crate_type = "lib"] + +pub trait U/*: ?Sized */ { + fn modified(self) -> Self + where + Self: Sized + { + self + } + + fn touch(&self)/* where Self: ?Sized */{} +} + +pub trait S: Sized {} diff --git a/src/test/rustdoc/inline_cross/hidden-use.rs b/src/test/rustdoc/inline_cross/hidden-use.rs index 97715737f..28a4f4bac 100644 --- a/src/test/rustdoc/inline_cross/hidden-use.rs +++ b/src/test/rustdoc/inline_cross/hidden-use.rs @@ -5,8 +5,8 @@ extern crate rustdoc_hidden; // @has hidden_use/index.html -// @!has - 'rustdoc_hidden' -// @!has - 'Bar' +// @!hasraw - 'rustdoc_hidden' +// @!hasraw - 'Bar' // @!has hidden_use/struct.Bar.html #[doc(hidden)] pub use rustdoc_hidden::Bar; diff --git a/src/test/rustdoc/inline_cross/impl_trait.rs b/src/test/rustdoc/inline_cross/impl_trait.rs index ef615472b..6c1cf8252 100644 --- a/src/test/rustdoc/inline_cross/impl_trait.rs +++ b/src/test/rustdoc/inline_cross/impl_trait.rs @@ -26,6 +26,13 @@ pub use impl_trait_aux::func3; // @has - '//pre[@class="rust fn"]' "T: Iterator<Item = impl Clone>," pub use impl_trait_aux::func4; +// @has impl_trait/fn.func5.html +// @has - '//pre[@class="rust fn"]' "func5(" +// @has - '//pre[@class="rust fn"]' "_f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>," +// @has - '//pre[@class="rust fn"]' "_a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>" +// @!has - '//pre[@class="rust fn"]' 'where' +pub use impl_trait_aux::func5; + // @has impl_trait/fn.async_fn.html // @has - '//pre[@class="rust fn"]' "pub async fn async_fn()" pub use impl_trait_aux::async_fn; diff --git a/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html new file mode 100644 index 000000000..6955a9614 --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html @@ -0,0 +1 @@ +<h4 class="code-header">fn <a href="#method.touch" class="fnname">touch</a>(&self)</h4>
\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/issue-24183.rs b/src/test/rustdoc/inline_cross/issue-24183.rs new file mode 100644 index 000000000..d11b6955f --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-24183.rs @@ -0,0 +1,18 @@ +#![crate_type = "lib"] +#![crate_name = "usr"] + +// aux-crate:issue_24183=issue-24183.rs +// edition: 2021 + +// @has usr/trait.U.html +// @has - '//*[@class="item-decl"]' "pub trait U {" +// @has - '//*[@id="method.modified"]' \ +// "fn modified(self) -> Self\ +// where \ +// Self: Sized" +// @snapshot method_no_where_self_sized - '//*[@id="method.touch"]/*[@class="code-header"]' +pub use issue_24183::U; + +// @has usr/trait.S.html +// @has - '//*[@class="item-decl"]' 'pub trait S: Sized {' +pub use issue_24183::S; diff --git a/src/test/rustdoc/inline_cross/issue-31948-1.rs b/src/test/rustdoc/inline_cross/issue-31948-1.rs index be8585dd1..6e89167b3 100644 --- a/src/test/rustdoc/inline_cross/issue-31948-1.rs +++ b/src/test/rustdoc/inline_cross/issue-31948-1.rs @@ -5,22 +5,22 @@ extern crate rustdoc_nonreachable_impls; // @has issue_31948_1/struct.Wobble.html -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Bark for' -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Woof for' -// @!has - '//*[@class="impl"]//h3[@class="code-header in-band"]' 'Bar for' -// @!has - '//*[@class="impl"]//h3[@class="code-header in-band"]' 'Qux for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Bark for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Woof for' +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' pub use rustdoc_nonreachable_impls::hidden::Wobble; // @has issue_31948_1/trait.Bark.html -// @has - '//h3[@class="code-header in-band"]' 'for Foo' -// @has - '//h3[@class="code-header in-band"]' 'for Wobble' -// @!has - '//h3[@class="code-header in-band"]' 'for Wibble' +// @has - '//h3[@class="code-header"]' 'for Foo' +// @has - '//h3[@class="code-header"]' 'for Wobble' +// @!has - '//h3[@class="code-header"]' 'for Wibble' pub use rustdoc_nonreachable_impls::Bark; // @has issue_31948_1/trait.Woof.html -// @has - '//h3[@class="code-header in-band"]' 'for Foo' -// @has - '//h3[@class="code-header in-band"]' 'for Wobble' -// @!has - '//h3[@class="code-header in-band"]' 'for Wibble' +// @has - '//h3[@class="code-header"]' 'for Foo' +// @has - '//h3[@class="code-header"]' 'for Wobble' +// @!has - '//h3[@class="code-header"]' 'for Wibble' pub use rustdoc_nonreachable_impls::Woof; // @!has issue_31948_1/trait.Bar.html diff --git a/src/test/rustdoc/inline_cross/issue-31948-2.rs b/src/test/rustdoc/inline_cross/issue-31948-2.rs index 7aa994f19..141e07656 100644 --- a/src/test/rustdoc/inline_cross/issue-31948-2.rs +++ b/src/test/rustdoc/inline_cross/issue-31948-2.rs @@ -5,15 +5,15 @@ extern crate rustdoc_nonreachable_impls; // @has issue_31948_2/struct.Wobble.html -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Qux for' -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Bark for' -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Woof for' -// @!has - '//*[@class="impl"]//h3[@class="code-header in-band"]' 'Bar for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Qux for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Bark for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Woof for' +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' pub use rustdoc_nonreachable_impls::hidden::Wobble; // @has issue_31948_2/trait.Qux.html -// @has - '//h3[@class="code-header in-band"]' 'for Foo' -// @has - '//h3[@class="code-header in-band"]' 'for Wobble' +// @has - '//h3[@class="code-header"]' 'for Foo' +// @has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::hidden::Qux; // @!has issue_31948_2/trait.Bar.html diff --git a/src/test/rustdoc/inline_cross/issue-31948.rs b/src/test/rustdoc/inline_cross/issue-31948.rs index 7bf4110d3..96fc6ca47 100644 --- a/src/test/rustdoc/inline_cross/issue-31948.rs +++ b/src/test/rustdoc/inline_cross/issue-31948.rs @@ -5,22 +5,22 @@ extern crate rustdoc_nonreachable_impls; // @has issue_31948/struct.Foo.html -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Bark for' -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Woof for' -// @!has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'Bar for' -// @!has - '//*[@class="impl"]//h3[@class="code-header in-band"]' 'Qux for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Bark for' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Woof for' +// @!has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'Bar for' +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' pub use rustdoc_nonreachable_impls::Foo; // @has issue_31948/trait.Bark.html -// @has - '//h3[@class="code-header in-band"]' 'for Foo' -// @!has - '//h3[@class="code-header in-band"]' 'for Wibble' -// @!has - '//h3[@class="code-header in-band"]' 'for Wobble' +// @has - '//h3[@class="code-header"]' 'for Foo' +// @!has - '//h3[@class="code-header"]' 'for Wibble' +// @!has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::Bark; // @has issue_31948/trait.Woof.html -// @has - '//h3[@class="code-header in-band"]' 'for Foo' -// @!has - '//h3[@class="code-header in-band"]' 'for Wibble' -// @!has - '//h3[@class="code-header in-band"]' 'for Wobble' +// @has - '//h3[@class="code-header"]' 'for Foo' +// @!has - '//h3[@class="code-header"]' 'for Wibble' +// @!has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::Woof; // @!has issue_31948/trait.Bar.html diff --git a/src/test/rustdoc/inline_cross/issue-32881.rs b/src/test/rustdoc/inline_cross/issue-32881.rs index 8052339a8..183fd15ab 100644 --- a/src/test/rustdoc/inline_cross/issue-32881.rs +++ b/src/test/rustdoc/inline_cross/issue-32881.rs @@ -5,7 +5,7 @@ extern crate rustdoc_trait_object_impl; // @has issue_32881/trait.Bar.html -// @has - '//h3[@class="code-header in-band"]' "impl<'a> dyn Bar" -// @has - '//h3[@class="code-header in-band"]' "impl<'a> Debug for dyn Bar" +// @has - '//h3[@class="code-header"]' "impl<'a> dyn Bar" +// @has - '//h3[@class="code-header"]' "impl<'a> Debug for dyn Bar" pub use rustdoc_trait_object_impl::Bar; diff --git a/src/test/rustdoc/inline_cross/issue-33113.rs b/src/test/rustdoc/inline_cross/issue-33113.rs index c60859bbc..d954707fa 100644 --- a/src/test/rustdoc/inline_cross/issue-33113.rs +++ b/src/test/rustdoc/inline_cross/issue-33113.rs @@ -5,6 +5,6 @@ extern crate bar; // @has issue_33113/trait.Bar.html -// @has - '//h3[@class="code-header in-band"]' "for &'a char" -// @has - '//h3[@class="code-header in-band"]' "for Foo" +// @has - '//h3[@class="code-header"]' "for &'a char" +// @has - '//h3[@class="code-header"]' "for Foo" pub use bar::Bar; diff --git a/src/test/rustdoc/inline_cross/proc_macro.rs b/src/test/rustdoc/inline_cross/proc_macro.rs index 532a295c0..a46550865 100644 --- a/src/test/rustdoc/inline_cross/proc_macro.rs +++ b/src/test/rustdoc/inline_cross/proc_macro.rs @@ -12,25 +12,25 @@ extern crate some_macros; // @has proc_macro/derive.SomeDerive.html // @has proc_macro/macro.some_proc_macro.html -// @has - 'a proc-macro that swallows its input and does nothing.' +// @hasraw - 'a proc-macro that swallows its input and does nothing.' pub use some_macros::some_proc_macro; // @has proc_macro/macro.reexported_macro.html -// @has - 'Doc comment from the original crate' +// @hasraw - 'Doc comment from the original crate' pub use some_macros::reexported_macro; // @has proc_macro/attr.some_proc_attr.html -// @has - 'a proc-macro attribute that passes its item through verbatim.' +// @hasraw - 'a proc-macro attribute that passes its item through verbatim.' pub use some_macros::some_proc_attr; // @has proc_macro/derive.SomeDerive.html -// @has - 'a derive attribute that adds nothing to its input.' +// @hasraw - 'a derive attribute that adds nothing to its input.' pub use some_macros::SomeDerive; // @has proc_macro/attr.first_attr.html -// @has - 'Generated doc comment' +// @hasraw - 'Generated doc comment' pub use some_macros::first_attr; // @has proc_macro/attr.second_attr.html -// @has - 'Generated doc comment' +// @hasraw - 'Generated doc comment' pub use some_macros::second_attr; diff --git a/src/test/rustdoc/inline_cross/trait-vis.rs b/src/test/rustdoc/inline_cross/trait-vis.rs index 363c52a33..b646babac 100644 --- a/src/test/rustdoc/inline_cross/trait-vis.rs +++ b/src/test/rustdoc/inline_cross/trait-vis.rs @@ -3,5 +3,5 @@ extern crate inner; // @has trait_vis/struct.SomeStruct.html -// @has - '//h3[@class="code-header in-band"]' 'impl Clone for SomeStruct' +// @has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' pub use inner::SomeStruct; diff --git a/src/test/rustdoc/inline_local/glob-extern-document-private-items.rs b/src/test/rustdoc/inline_local/glob-extern-document-private-items.rs index a2f0d65ef..8e1089d60 100644 --- a/src/test/rustdoc/inline_local/glob-extern-document-private-items.rs +++ b/src/test/rustdoc/inline_local/glob-extern-document-private-items.rs @@ -12,14 +12,14 @@ mod mod1 { pub use mod1::*; // @has foo/index.html -// @has - "mod1" -// @has - "public_fn" -// @!has - "private_fn" +// @hasraw - "mod1" +// @hasraw - "public_fn" +// @!hasraw - "private_fn" // @has foo/fn.public_fn.html // @!has foo/fn.private_fn.html // @has foo/mod1/index.html -// @has - "public_fn" -// @has - "private_fn" +// @hasraw - "public_fn" +// @hasraw - "private_fn" // @has foo/mod1/fn.public_fn.html // @has foo/mod1/fn.private_fn.html diff --git a/src/test/rustdoc/inline_local/glob-extern.rs b/src/test/rustdoc/inline_local/glob-extern.rs index 686e55de3..c592a4db1 100644 --- a/src/test/rustdoc/inline_local/glob-extern.rs +++ b/src/test/rustdoc/inline_local/glob-extern.rs @@ -10,9 +10,9 @@ mod mod1 { pub use mod1::*; // @has foo/index.html -// @!has - "mod1" -// @has - "public_fn" -// @!has - "private_fn" +// @!hasraw - "mod1" +// @hasraw - "public_fn" +// @!hasraw - "private_fn" // @has foo/fn.public_fn.html // @!has foo/fn.private_fn.html diff --git a/src/test/rustdoc/inline_local/glob-private-document-private-items.rs b/src/test/rustdoc/inline_local/glob-private-document-private-items.rs index f16d21ecd..d8cbd4234 100644 --- a/src/test/rustdoc/inline_local/glob-private-document-private-items.rs +++ b/src/test/rustdoc/inline_local/glob-private-document-private-items.rs @@ -15,31 +15,31 @@ mod mod1 { pub use mod1::*; // @has foo/index.html -// @has - "mod1" -// @has - "Mod1Public" -// @!has - "Mod1Private" -// @!has - "mod2" -// @has - "Mod2Public" -// @!has - "Mod2Private" +// @hasraw - "mod1" +// @hasraw - "Mod1Public" +// @!hasraw - "Mod1Private" +// @!hasraw - "mod2" +// @hasraw - "Mod2Public" +// @!hasraw - "Mod2Private" // @has foo/struct.Mod1Public.html // @!has foo/struct.Mod1Private.html // @has foo/struct.Mod2Public.html // @!has foo/struct.Mod2Private.html // @has foo/mod1/index.html -// @has - "mod2" -// @has - "Mod1Public" -// @has - "Mod1Private" -// @!has - "Mod2Public" -// @!has - "Mod2Private" +// @hasraw - "mod2" +// @hasraw - "Mod1Public" +// @hasraw - "Mod1Private" +// @!hasraw - "Mod2Public" +// @!hasraw - "Mod2Private" // @has foo/mod1/struct.Mod1Public.html // @has foo/mod1/struct.Mod1Private.html // @!has foo/mod1/struct.Mod2Public.html // @!has foo/mod1/struct.Mod2Private.html // @has foo/mod1/mod2/index.html -// @has - "Mod2Public" -// @has - "Mod2Private" +// @hasraw - "Mod2Public" +// @hasraw - "Mod2Private" // @has foo/mod1/mod2/struct.Mod2Public.html // @has foo/mod1/mod2/struct.Mod2Private.html diff --git a/src/test/rustdoc/inline_local/glob-private.rs b/src/test/rustdoc/inline_local/glob-private.rs index d294d590e..303f1d610 100644 --- a/src/test/rustdoc/inline_local/glob-private.rs +++ b/src/test/rustdoc/inline_local/glob-private.rs @@ -13,12 +13,12 @@ mod mod1 { pub use mod1::*; // @has foo/index.html -// @!has - "mod1" -// @has - "Mod1Public" -// @!has - "Mod1Private" -// @!has - "mod2" -// @has - "Mod2Public" -// @!has - "Mod2Private" +// @!hasraw - "mod1" +// @hasraw - "Mod1Public" +// @!hasraw - "Mod1Private" +// @!hasraw - "mod2" +// @hasraw - "Mod2Public" +// @!hasraw - "Mod2Private" // @has foo/struct.Mod1Public.html // @!has foo/struct.Mod1Private.html // @has foo/struct.Mod2Public.html diff --git a/src/test/rustdoc/inline_local/hidden-use.rs b/src/test/rustdoc/inline_local/hidden-use.rs index a972d376a..de512fb26 100644 --- a/src/test/rustdoc/inline_local/hidden-use.rs +++ b/src/test/rustdoc/inline_local/hidden-use.rs @@ -3,8 +3,8 @@ mod private { } // @has hidden_use/index.html -// @!has - 'private' -// @!has - 'Foo' +// @!hasraw - 'private' +// @!hasraw - 'Foo' // @!has hidden_use/struct.Foo.html #[doc(hidden)] pub use private::Foo; diff --git a/src/test/rustdoc/inline_local/macro_by_example.rs b/src/test/rustdoc/inline_local/macro_by_example.rs index dacc7cfb3..5c33c0037 100644 --- a/src/test/rustdoc/inline_local/macro_by_example.rs +++ b/src/test/rustdoc/inline_local/macro_by_example.rs @@ -7,7 +7,7 @@ macro_rules! foo { // @has macro_by_example/macros/index.html pub mod macros { - // @!has - 'pub use foo as bar;' + // @!hasraw - 'pub use foo as bar;' // @has macro_by_example/macros/macro.bar.html // @has - '//*[@class="docblock"]' 'docs for foo' // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' diff --git a/src/test/rustdoc/inline_local/please_inline.rs b/src/test/rustdoc/inline_local/please_inline.rs index 48539361f..e4429ef33 100644 --- a/src/test/rustdoc/inline_local/please_inline.rs +++ b/src/test/rustdoc/inline_local/please_inline.rs @@ -4,7 +4,7 @@ pub mod foo { // @has please_inline/a/index.html pub mod a { - // @!has - 'pub use foo::' + // @!hasraw - 'pub use foo::' // @has please_inline/a/struct.Foo.html #[doc(inline)] pub use foo::Foo; @@ -12,7 +12,7 @@ pub mod a { // @has please_inline/b/index.html pub mod b { - // @has - 'pub use foo::' + // @hasraw - 'pub use foo::' // @!has please_inline/b/struct.Foo.html #[feature(inline)] pub use foo::Foo; diff --git a/src/test/rustdoc/inline_local/trait-vis.rs b/src/test/rustdoc/inline_local/trait-vis.rs index e7b08088f..19b69da15 100644 --- a/src/test/rustdoc/inline_local/trait-vis.rs +++ b/src/test/rustdoc/inline_local/trait-vis.rs @@ -13,6 +13,6 @@ mod asdf { } // @has trait_vis/struct.SomeStruct.html -// @has - '//h3[@class="code-header in-band"]' 'impl ThisTrait for SomeStruct' -// @!has - '//h3[@class="code-header in-band"]' 'impl PrivateTrait for SomeStruct' +// @has - '//h3[@class="code-header"]' 'impl ThisTrait for SomeStruct' +// @!has - '//h3[@class="code-header"]' 'impl PrivateTrait for SomeStruct' pub use asdf::SomeStruct; diff --git a/src/test/rustdoc/internal.rs b/src/test/rustdoc/internal.rs index f316eb24a..caad43a08 100644 --- a/src/test/rustdoc/internal.rs +++ b/src/test/rustdoc/internal.rs @@ -3,13 +3,15 @@ // Check that the unstable marker is not added for "rustc_private". // @!matches internal/index.html \ -// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' +// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' \ +// '' // @!matches internal/index.html \ -// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' +// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' \ +// '' // @matches - '//*[@class="item-right docblock-short"]' 'Docs' -// @!has internal/struct.S.html '//*[@class="stab unstable"]' -// @!has internal/struct.S.html '//*[@class="stab internal"]' +// @!has internal/struct.S.html '//*[@class="stab unstable"]' '' +// @!has internal/struct.S.html '//*[@class="stab internal"]' '' /// Docs pub struct S; diff --git a/src/test/rustdoc/intra-doc/assoc-reexport-super.rs b/src/test/rustdoc/intra-doc/assoc-reexport-super.rs new file mode 100644 index 000000000..a7bc1c6a2 --- /dev/null +++ b/src/test/rustdoc/intra-doc/assoc-reexport-super.rs @@ -0,0 +1,20 @@ +// Regression test for #93205 + +#![crate_name = "foo"] + +mod generated { + pub struct MyNewType; + impl MyNewType { + pub const FOO: Self = Self; + } +} + +pub use generated::MyNewType; + +mod prelude { + impl super::MyNewType { + /// An alias for [`Self::FOO`]. + // @has 'foo/struct.MyNewType.html' '//a[@href="struct.MyNewType.html#associatedconstant.FOO"]' 'Self::FOO' + pub const FOO2: Self = Self::FOO; + } +} diff --git a/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs b/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs new file mode 100644 index 000000000..2b8fdec1f --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs @@ -0,0 +1,4 @@ +pub trait Trait { + /// [`u8::clone`] + fn method(); +} diff --git a/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs b/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs index 5d8dcf8bc..ad50887e9 100644 --- a/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs +++ b/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs @@ -16,4 +16,4 @@ //! [`empty`] // @has - '//a[@href="../empty2/index.html"]' 'empty2' -//! [empty2<x>] +//! [`empty2<x>`] diff --git a/src/test/rustdoc/intra-doc/extern-type.rs b/src/test/rustdoc/intra-doc/extern-type.rs index ab088ab78..5440f582d 100644 --- a/src/test/rustdoc/intra-doc/extern-type.rs +++ b/src/test/rustdoc/intra-doc/extern-type.rs @@ -25,11 +25,11 @@ impl G<usize> for ExternType { } // @has 'extern_type/foreigntype.ExternType.html' -// @has 'extern_type/fn.links_to_extern_type.html' \ +// @hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.f"' -// @has 'extern_type/fn.links_to_extern_type.html' \ +// @hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.test"' -// @has 'extern_type/fn.links_to_extern_type.html' \ +// @hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.g"' /// See also [ExternType::f] /// See also [ExternType::test] diff --git a/src/test/rustdoc/intra-doc/issue-103463.rs b/src/test/rustdoc/intra-doc/issue-103463.rs new file mode 100644 index 000000000..4adf8a9a8 --- /dev/null +++ b/src/test/rustdoc/intra-doc/issue-103463.rs @@ -0,0 +1,8 @@ +// The `Trait` is not pulled into the crate resulting in doc links in its methods being resolved. + +// aux-build:issue-103463-aux.rs + +extern crate issue_103463_aux; +use issue_103463_aux::Trait; + +fn main() {} diff --git a/src/test/rustdoc/intra-doc/issue-104145.rs b/src/test/rustdoc/intra-doc/issue-104145.rs new file mode 100644 index 000000000..9ce36740d --- /dev/null +++ b/src/test/rustdoc/intra-doc/issue-104145.rs @@ -0,0 +1,14 @@ +// Doc links in `Trait`'s methods are resolved because it has a local impl. + +// aux-build:issue-103463-aux.rs + +extern crate issue_103463_aux; +use issue_103463_aux::Trait; + +pub struct LocalType; + +impl Trait for LocalType { + fn method() {} +} + +fn main() {} diff --git a/src/test/rustdoc/intra-doc/no-doc-primitive.rs b/src/test/rustdoc/intra-doc/no-doc-primitive.rs new file mode 100644 index 000000000..e5eba1d8d --- /dev/null +++ b/src/test/rustdoc/intra-doc/no-doc-primitive.rs @@ -0,0 +1,15 @@ +// Crate tree without a `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)] +#![no_core] +#![rustc_coherence_is_core] +#![crate_type = "rlib"] + +// @has no_doc_primitive/index.html +//! A [`char`] and its [`char::len_utf8`]. +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} diff --git a/src/test/rustdoc/issue-100241.rs b/src/test/rustdoc/issue-100241.rs new file mode 100644 index 000000000..9e9cba13a --- /dev/null +++ b/src/test/rustdoc/issue-100241.rs @@ -0,0 +1,12 @@ +//! See [`S`]. + +// Check that this isn't an ICE +// should-fail + +mod foo { + pub use inner::S; + //~^ ERROR unresolved imports `inner`, `foo::S` +} + +use foo::*; +use foo::S; diff --git a/src/test/rustdoc/issue-100620.rs b/src/test/rustdoc/issue-100620.rs new file mode 100644 index 000000000..097666eb5 --- /dev/null +++ b/src/test/rustdoc/issue-100620.rs @@ -0,0 +1,19 @@ +pub trait Bar<S> {} + +pub trait Qux<T> {} + +pub trait Foo<T, S> { + fn bar() + where + T: Bar<S>, + { + } +} + +pub struct Concrete; + +impl<S> Foo<(), S> for Concrete {} + +impl<T, S> Bar<S> for T where S: Qux<T> {} + +impl<T, S> Qux<T> for S where T: Bar<S> {} diff --git a/src/test/rustdoc/issue-100679-sidebar-links-deref.rs b/src/test/rustdoc/issue-100679-sidebar-links-deref.rs new file mode 100644 index 000000000..f09d23206 --- /dev/null +++ b/src/test/rustdoc/issue-100679-sidebar-links-deref.rs @@ -0,0 +1,30 @@ +#![crate_name="foo"] + +pub struct Vec; + +pub struct Slice; + +impl std::ops::Deref for Vec { + type Target = Slice; + fn deref(&self) -> &Slice { + &Slice + } +} + +// @has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ +// "is_empty" +impl Vec { + pub fn is_empty(&self) -> bool { + true + } +} + +// @has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty-1"]' \ +// "is_empty" +// @has foo/struct.Slice.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ +// "is_empty" +impl Slice { + pub fn is_empty(&self) -> bool { + true + } +} diff --git a/src/test/rustdoc/issue-101743-bold-tag.rs b/src/test/rustdoc/issue-101743-bold-tag.rs new file mode 100644 index 000000000..631181fec --- /dev/null +++ b/src/test/rustdoc/issue-101743-bold-tag.rs @@ -0,0 +1,19 @@ +// Regression test for https://github.com/rust-lang/rust/issues/101743 + +#![crate_name="foo"] + +pub type Word = usize; +pub struct Repr<const B: usize>([i32; B]); +pub struct IBig(usize); + +pub const fn base_as_ibig<const B: Word>() -> IBig { + IBig(B) +} + +impl<const B: Word> Repr<B> { + // If we change back to rendering the value of consts, check this doesn't add + // a <b> tag, but escapes correctly + + // @has foo/struct.Repr.html '//section[@id="associatedconstant.BASE"]/h4' '= _' + pub const BASE: IBig = base_as_ibig::<B>(); +} diff --git a/src/test/rustdoc/issue-16265-1.rs b/src/test/rustdoc/issue-16265-1.rs index ec007e36b..2fda637a6 100644 --- a/src/test/rustdoc/issue-16265-1.rs +++ b/src/test/rustdoc/issue-16265-1.rs @@ -1,6 +1,6 @@ pub struct Foo; -// @has issue_16265_1/traits/index.html 'source' +// @hasraw issue_16265_1/traits/index.html 'source' pub mod traits { impl PartialEq for super::Foo { fn eq(&self, _: &super::Foo) -> bool { diff --git a/src/test/rustdoc/issue-16265-2.rs b/src/test/rustdoc/issue-16265-2.rs index d5cd18d9d..c3eb35617 100644 --- a/src/test/rustdoc/issue-16265-2.rs +++ b/src/test/rustdoc/issue-16265-2.rs @@ -1,4 +1,4 @@ -// @has issue_16265_2/index.html 'source' +// @hasraw issue_16265_2/index.html 'source' trait Y {} impl Y for Option<u32> {} diff --git a/src/test/rustdoc/issue-20727-4.rs b/src/test/rustdoc/issue-20727-4.rs index 84fc6f94a..643f93875 100644 --- a/src/test/rustdoc/issue-20727-4.rs +++ b/src/test/rustdoc/issue-20727-4.rs @@ -25,7 +25,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> { pub mod reexport { // @has issue_20727_4/reexport/trait.Index.html - // @has - '//*[@class="rust trait"]' 'trait Index<Idx> where Idx: ?Sized, {' + // @has - '//*[@class="rust trait"]' 'trait Index<Idx>where Idx: ?Sized,{' // @has - '//*[@class="rust trait"]' 'type Output: ?Sized' // @has - '//*[@class="rust trait"]' \ // 'fn index(&self, index: Idx) -> &Self::Output' @@ -33,7 +33,7 @@ pub mod reexport { // @has issue_20727_4/reexport/trait.IndexMut.html // @has - '//*[@class="rust trait"]' \ - // 'trait IndexMut<Idx>: Index<Idx> where Idx: ?Sized, {' + // 'trait IndexMut<Idx>: Index<Idx>where Idx: ?Sized,{' // @has - '//*[@class="rust trait"]' \ // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' pub use issue_20727::IndexMut; diff --git a/src/test/rustdoc/issue-21801.rs b/src/test/rustdoc/issue-21801.rs index 2a586b6ff..29d2ec64c 100644 --- a/src/test/rustdoc/issue-21801.rs +++ b/src/test/rustdoc/issue-21801.rs @@ -5,5 +5,5 @@ extern crate issue_21801; // @has issue_21801/struct.Foo.html // @has - '//*[@id="method.new"]' \ -// 'fn new<F>(f: F) -> Foo where F: FnMut() -> i32' +// 'fn new<F>(f: F) -> Foowhere F: FnMut() -> i32' pub use issue_21801::Foo; diff --git a/src/test/rustdoc/issue-23511.rs b/src/test/rustdoc/issue-23511.rs index 2d2a7908f..7576ebb03 100644 --- a/src/test/rustdoc/issue-23511.rs +++ b/src/test/rustdoc/issue-23511.rs @@ -6,7 +6,7 @@ pub mod str { #![doc(primitive = "str")] impl str { - // @has search-index.js foo + // @hasraw search-index.js foo #[rustc_allow_incoherent_impl] pub fn foo(&self) {} } diff --git a/src/test/rustdoc/issue-23812.rs b/src/test/rustdoc/issue-23812.rs index 5dac8d87b..08fd1833b 100644 --- a/src/test/rustdoc/issue-23812.rs +++ b/src/test/rustdoc/issue-23812.rs @@ -16,10 +16,10 @@ doc! { } // @has issue_23812/Foo/index.html -// @has - 'Outer comment' -// @!has - '/// Outer comment' -// @has - 'Inner comment' -// @!has - '//! Inner comment' +// @hasraw - 'Outer comment' +// @!hasraw - '/// Outer comment' +// @hasraw - 'Inner comment' +// @!hasraw - '//! Inner comment' doc! { @@ -30,7 +30,7 @@ doc! { } // @has issue_23812/Bar/index.html -// @has - 'Outer block comment' -// @!has - '/** Outer block comment */' -// @has - 'Inner block comment' -// @!has - '/*! Inner block comment */' +// @hasraw - 'Outer block comment' +// @!hasraw - '/** Outer block comment */' +// @hasraw - 'Inner block comment' +// @!hasraw - '/*! Inner block comment */' diff --git a/src/test/rustdoc/issue-27104.rs b/src/test/rustdoc/issue-27104.rs index b74c3eb78..9f2fd9071 100644 --- a/src/test/rustdoc/issue-27104.rs +++ b/src/test/rustdoc/issue-27104.rs @@ -3,8 +3,8 @@ // ignore-cross-compile // @has issue_27104/index.html -// @!has - 'extern crate std' -// @!has - 'use std::prelude::' +// @!hasraw - 'extern crate std' +// @!hasraw - 'use std::prelude::' -// @has - 'pub extern crate empty' +// @hasraw - 'pub extern crate empty' pub extern crate empty; diff --git a/src/test/rustdoc/issue-27759.rs b/src/test/rustdoc/issue-27759.rs index f3739dafd..65e0f7cb8 100644 --- a/src/test/rustdoc/issue-27759.rs +++ b/src/test/rustdoc/issue-27759.rs @@ -4,11 +4,11 @@ #![unstable(feature="test", issue="27759")] // @has issue_27759/unstable/index.html -// @has - '<code>test</code> <a href="http://issue_url/27759">#27759</a>' +// @hasraw - '<code>test</code> <a href="http://issue_url/27759">#27759</a>' #[unstable(feature="test", issue="27759")] pub mod unstable { // @has issue_27759/unstable/fn.issue.html - // @has - '<code>test_function</code> <a href="http://issue_url/12345">#12345</a>' + // @hasraw - '<code>test_function</code> <a href="http://issue_url/12345">#12345</a>' #[unstable(feature="test_function", issue="12345")] pub fn issue() {} } diff --git a/src/test/rustdoc/issue-29503.rs b/src/test/rustdoc/issue-29503.rs index 635c3175f..01ae44385 100644 --- a/src/test/rustdoc/issue-29503.rs +++ b/src/test/rustdoc/issue-29503.rs @@ -5,7 +5,7 @@ pub trait MyTrait { fn my_string(&self) -> String; } -// @has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header in-band']" "impl<T> MyTrait for T where T: Debug" +// @has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl<T> MyTrait for Twhere T: Debug" impl<T> MyTrait for T where T: fmt::Debug, diff --git a/src/test/rustdoc/issue-29584.rs b/src/test/rustdoc/issue-29584.rs index 28e1efec6..4364a9649 100644 --- a/src/test/rustdoc/issue-29584.rs +++ b/src/test/rustdoc/issue-29584.rs @@ -4,5 +4,5 @@ extern crate issue_29584; // @has issue_29584/struct.Foo.html -// @!has - 'impl Bar for' +// @!hasraw - 'impl Bar for' pub use issue_29584::Foo; diff --git a/src/test/rustdoc/issue-31899.rs b/src/test/rustdoc/issue-31899.rs index e7a8ee239..3eee37446 100644 --- a/src/test/rustdoc/issue-31899.rs +++ b/src/test/rustdoc/issue-31899.rs @@ -1,8 +1,8 @@ // @has issue_31899/index.html -// @has - 'Make this line a bit longer.' -// @!has - 'rust rust-example-rendered' -// @!has - 'use ndarray::arr2' -// @!has - 'prohibited' +// @hasraw - 'Make this line a bit longer.' +// @!hasraw - 'rust rust-example-rendered' +// @!hasraw - 'use ndarray::arr2' +// @!hasraw - 'prohibited' /// A tuple or fixed size array that can be used to index an array. /// Make this line a bit longer. diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs index 01f955381..8d2c27cf3 100644 --- a/src/test/rustdoc/issue-32374.rs +++ b/src/test/rustdoc/issue-32374.rs @@ -8,20 +8,24 @@ // 'Experimental' // @matches issue_32374/index.html '//*[@class="item-right docblock-short"]/text()' 'Docs' -// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \ -// '๐ Deprecated since 1.0.0: text' -// @has - '<code>test</code> <a href="https://issue_url/32374">#32374</a>' +// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '๐' +// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \ +// 'Deprecated since 1.0.0: text' +// @hasraw - '<code>test</code> <a href="https://issue_url/32374">#32374</a>' +// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '๐ฌ' // @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ -// '๐ฌ This is a nightly-only experimental API. \(test\s#32374\)$' +// 'This is a nightly-only experimental API. \(test\s#32374\)$' /// Docs #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "test", issue = "32374")] pub struct T; +// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '๐' // @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ -// '๐ Deprecated since 1.0.0: deprecated' +// 'Deprecated since 1.0.0: deprecated' +// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '๐ฌ' // @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ -// '๐ฌ This is a nightly-only experimental API. (test #32374)' +// 'This is a nightly-only experimental API. (test #32374)' #[deprecated(since = "1.0.0", note = "deprecated")] #[unstable(feature = "test", issue = "32374", reason = "unstable")] pub struct U; diff --git a/src/test/rustdoc/issue-32395.rs b/src/test/rustdoc/issue-32395.rs index 13468c153..5552300f9 100644 --- a/src/test/rustdoc/issue-32395.rs +++ b/src/test/rustdoc/issue-32395.rs @@ -3,13 +3,13 @@ // ignore-cross-compile // @has variant_struct/enum.Foo.html -// @!has - 'pub qux' -// @!has - 'pub(crate) qux' -// @!has - 'pub Bar' +// @!hasraw - 'pub qux' +// @!hasraw - 'pub(crate) qux' +// @!hasraw - 'pub Bar' extern crate variant_struct; // @has issue_32395/enum.Foo.html -// @!has - 'pub qux' -// @!has - 'pub(crate) qux' -// @!has - 'pub Bar' +// @!hasraw - 'pub qux' +// @!hasraw - 'pub(crate) qux' +// @!hasraw - 'pub Bar' pub use variant_struct::Foo; diff --git a/src/test/rustdoc/issue-33592.rs b/src/test/rustdoc/issue-33592.rs index 815439db9..7a128f0b8 100644 --- a/src/test/rustdoc/issue-33592.rs +++ b/src/test/rustdoc/issue-33592.rs @@ -6,8 +6,8 @@ pub struct Bar; pub struct Baz; -// @has foo/trait.Foo.html '//h3[@class="code-header in-band"]' 'impl Foo<i32> for Bar' +// @has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo<i32> for Bar' impl Foo<i32> for Bar {} -// @has foo/trait.Foo.html '//h3[@class="code-header in-band"]' 'impl<T> Foo<T> for Baz' +// @has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl<T> Foo<T> for Baz' impl<T> Foo<T> for Baz {} diff --git a/src/test/rustdoc/issue-34473.rs b/src/test/rustdoc/issue-34473.rs index d96301f3a..37da3dd19 100644 --- a/src/test/rustdoc/issue-34473.rs +++ b/src/test/rustdoc/issue-34473.rs @@ -5,7 +5,7 @@ mod second { } // @has foo/index.html -// @!has - SomeTypeWithLongName +// @!hasraw - SomeTypeWithLongName // @has foo/struct.SomeType.html // @!has foo/struct.SomeTypeWithLongName.html pub use second::{SomeTypeWithLongName as SomeType}; diff --git a/src/test/rustdoc/issue-34928.rs b/src/test/rustdoc/issue-34928.rs index 4184086f6..91b677574 100644 --- a/src/test/rustdoc/issue-34928.rs +++ b/src/test/rustdoc/issue-34928.rs @@ -2,5 +2,5 @@ pub trait Bar {} -// @has foo/struct.Foo.html '//pre' 'pub struct Foo<T>(pub T) where T: Bar;' +// @has foo/struct.Foo.html '//pre' 'pub struct Foo<T>(pub T)where T: Bar;' pub struct Foo<T>(pub T) where T: Bar; diff --git a/src/test/rustdoc/issue-41783.codeblock.html b/src/test/rustdoc/issue-41783.codeblock.html new file mode 100644 index 000000000..89987491d --- /dev/null +++ b/src/test/rustdoc/issue-41783.codeblock.html @@ -0,0 +1,5 @@ +<code># single +## double +### triple +<span class="attribute">#[outer] +#![inner]</span></code> diff --git a/src/test/rustdoc/issue-41783.rs b/src/test/rustdoc/issue-41783.rs index cb9b9b153..87267a750 100644 --- a/src/test/rustdoc/issue-41783.rs +++ b/src/test/rustdoc/issue-41783.rs @@ -1,11 +1,11 @@ // @has issue_41783/struct.Foo.html -// @!has - 'space' -// @!has - 'comment' -// @has - '# <span class="ident">single' -// @has - '## <span class="ident">double</span>' -// @has - '### <span class="ident">triple</span>' -// @has - '<span class="attribute">#[<span class="ident">outer</span>]</span>' -// @has - '<span class="attribute">#![<span class="ident">inner</span>]</span>' +// @!hasraw - 'space' +// @!hasraw - 'comment' +// @hasraw - '<span class="attribute">#[outer]' +// @!hasraw - '<span class="attribute">#[outer]</span>' +// @hasraw - '#![inner]</span>' +// @!hasraw - '<span class="attribute">#![inner]</span>' +// @snapshot 'codeblock' - '//*[@class="rustdoc-toggle top-doc"]/*[@class="docblock"]//pre/code' /// ```no_run /// # # space diff --git a/src/test/rustdoc/issue-46727.rs b/src/test/rustdoc/issue-46727.rs index 00e9127a3..8cfc4827a 100644 --- a/src/test/rustdoc/issue-46727.rs +++ b/src/test/rustdoc/issue-46727.rs @@ -3,5 +3,5 @@ extern crate issue_46727; // @has issue_46727/trait.Foo.html -// @has - '//h3[@class="code-header in-band"]' 'impl<T> Foo for Bar<[T; 3]>' +// @has - '//h3[@class="code-header"]' 'impl<T> Foo for Bar<[T; 3]>' pub use issue_46727::{Foo, Bar}; diff --git a/src/test/rustdoc/issue-50159.rs b/src/test/rustdoc/issue-50159.rs index d88c29217..04bc4f304 100644 --- a/src/test/rustdoc/issue-50159.rs +++ b/src/test/rustdoc/issue-50159.rs @@ -11,8 +11,8 @@ impl<B, C> Signal2 for B where B: Signal<Item = C> { } // @has issue_50159/struct.Switch.html -// @has - '//h3[@class="code-header in-band"]' 'impl<B> Send for Switch<B> where <B as Signal>::Item: Send' -// @has - '//h3[@class="code-header in-band"]' 'impl<B> Sync for Switch<B> where <B as Signal>::Item: Sync' +// @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' +// @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' // @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 // @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]' 5 pub struct Switch<B: Signal> { diff --git a/src/test/rustdoc/issue-51236.rs b/src/test/rustdoc/issue-51236.rs index ee11ccc68..1c7aa9c7e 100644 --- a/src/test/rustdoc/issue-51236.rs +++ b/src/test/rustdoc/issue-51236.rs @@ -7,8 +7,8 @@ pub mod traits { } // @has issue_51236/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<T> Send for Owned<T> where <T as Owned<'static>>::Reader: Send" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<T> Send for Owned<T>where <T as Owned<'static>>::Reader: Send" pub struct Owned<T> where T: for<'a> ::traits::Owned<'a> { marker: PhantomData<<T as ::traits::Owned<'static>>::Reader>, } diff --git a/src/test/rustdoc/issue-53689.rs b/src/test/rustdoc/issue-53689.rs index 52ce4159d..832140e06 100644 --- a/src/test/rustdoc/issue-53689.rs +++ b/src/test/rustdoc/issue-53689.rs @@ -5,7 +5,7 @@ extern crate issue_53689; // @has foo/trait.MyTrait.html -// @!has - 'MyStruct' +// @!hasraw - 'MyStruct' // @count - '//*[h3="impl<T> MyTrait for T"]' 1 pub trait MyTrait {} diff --git a/src/test/rustdoc/issue-54705.rs b/src/test/rustdoc/issue-54705.rs index bedaf5c4d..7b7290ab4 100644 --- a/src/test/rustdoc/issue-54705.rs +++ b/src/test/rustdoc/issue-54705.rs @@ -1,13 +1,11 @@ pub trait ScopeHandle<'scope> {} - - // @has issue_54705/struct.ScopeFutureContents.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'scope, S> Send for ScopeFutureContents<'scope, S> where S: Sync" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'scope, S> Sync for ScopeFutureContents<'scope, S> where S: Sync" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Sync for ScopeFutureContents<'scope, S>where S: Sync" pub struct ScopeFutureContents<'scope, S> where S: ScopeHandle<'scope>, { diff --git a/src/test/rustdoc/issue-55321.rs b/src/test/rustdoc/issue-55321.rs index ee2420d86..22a18ef90 100644 --- a/src/test/rustdoc/issue-55321.rs +++ b/src/test/rustdoc/issue-55321.rs @@ -1,9 +1,9 @@ #![feature(negative_impls)] // @has issue_55321/struct.A.html -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl !Send for A" -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl !Sync for A" pub struct A(); @@ -11,8 +11,8 @@ impl !Send for A {} impl !Sync for A {} // @has issue_55321/struct.B.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Send for B<T>" -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Sync for B<T>" pub struct B<T: ?Sized>(A, Box<T>); diff --git a/src/test/rustdoc/issue-56822.rs b/src/test/rustdoc/issue-56822.rs index aef6ddd8d..b4eef344b 100644 --- a/src/test/rustdoc/issue-56822.rs +++ b/src/test/rustdoc/issue-56822.rs @@ -17,7 +17,7 @@ impl<'a, T> MyTrait for Inner<'a, T> { } // @has issue_56822/struct.Parser.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<'a> Send for Parser<'a>" pub struct Parser<'a> { field: <Wrapper<Inner<'a, u8>> as MyTrait>::Output diff --git a/src/test/rustdoc/issue-60726.rs b/src/test/rustdoc/issue-60726.rs index 167f0f039..fbb0f82ae 100644 --- a/src/test/rustdoc/issue-60726.rs +++ b/src/test/rustdoc/issue-60726.rs @@ -26,9 +26,9 @@ where {} // @has issue_60726/struct.IntoIter.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Send for IntoIter<T>" -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Sync for IntoIter<T>" pub struct IntoIter<T>{ hello:DynTrait<FooInterface<T>>, diff --git a/src/test/rustdoc/issue-61592.rs b/src/test/rustdoc/issue-61592.rs index aef038c07..4b6c37b94 100644 --- a/src/test/rustdoc/issue-61592.rs +++ b/src/test/rustdoc/issue-61592.rs @@ -5,11 +5,11 @@ extern crate foo; // @has issue_61592/index.html // @has - '//a[@href="#reexports"]' 'Re-exports' // @has - '//code' 'pub use foo::FooTrait as _;' -// @!has - '//a[@href="trait._.html"]' +// @!has - '//a[@href="trait._.html"]' '' pub use foo::FooTrait as _; // @has issue_61592/index.html // @has - '//a[@href="#reexports"]' 'Re-exports' // @has - '//code' 'pub use foo::FooStruct as _;' -// @!has - '//a[@href="struct._.html"]' +// @!has - '//a[@href="struct._.html"]' '' pub use foo::FooStruct as _; diff --git a/src/test/rustdoc/issue-75588.rs b/src/test/rustdoc/issue-75588.rs index ac97b94fb..3b11059a7 100644 --- a/src/test/rustdoc/issue-75588.rs +++ b/src/test/rustdoc/issue-75588.rs @@ -10,8 +10,8 @@ extern crate realcore; extern crate real_gimli; // issue #74672 -// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header in-band"]' 'impl Deref for EndianSlice' +// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' pub use realcore::Deref; -// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header in-band"]' 'impl Join for Foo' +// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' pub use realcore::Join; diff --git a/src/test/rustdoc/issue-80233-normalize-auto-trait.rs b/src/test/rustdoc/issue-80233-normalize-auto-trait.rs index 515e617b4..62fbc2444 100644 --- a/src/test/rustdoc/issue-80233-normalize-auto-trait.rs +++ b/src/test/rustdoc/issue-80233-normalize-auto-trait.rs @@ -31,7 +31,7 @@ impl<T: Trait3> Trait3 for Vec<T> { pub struct Struct1 {} // @has issue_80233_normalize_auto_trait/struct.Question.html -// @has - '//h3[@class="code-header in-band"]' 'impl<T> Send for Question<T>' +// @has - '//h3[@class="code-header"]' 'impl<T> Send for Question<T>' pub struct Question<T: Trait1> { pub ins: <<Vec<T> as Trait3>::Type3 as Trait2>::Type2, } diff --git a/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs b/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs index 8999e6a88..adf4d111a 100644 --- a/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs +++ b/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs @@ -1,14 +1,14 @@ use std::convert::AsRef; pub struct Local; -// @has issue_82465_asref_for_and_of_local/struct.Local.html '//h3[@class="code-header in-band"]' 'impl AsRef<str> for Local' +// @has issue_82465_asref_for_and_of_local/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef<str> for Local' impl AsRef<str> for Local { fn as_ref(&self) -> &str { todo!() } } -// @has - '//h3[@class="code-header in-band"]' 'impl AsRef<Local> for str' +// @has - '//h3[@class="code-header"]' 'impl AsRef<Local> for str' impl AsRef<Local> for str { fn as_ref(&self) -> &Local { todo!() diff --git a/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline-last-item.rs b/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline-last-item.rs new file mode 100644 index 000000000..d3a7a870b --- /dev/null +++ b/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline-last-item.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +pub mod sub { + pub struct Item; + + pub mod prelude { + pub use super::Item; + } +} + +#[doc(inline)] +pub use sub::*; + +// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1 +// @count foo/prelude/index.html '//div[@class="item-row"]' 0 +pub mod prelude {} diff --git a/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline.rs b/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline.rs new file mode 100644 index 000000000..b83692509 --- /dev/null +++ b/src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline.rs @@ -0,0 +1,16 @@ +#![crate_name = "foo"] + +pub mod sub { + pub struct Item; + + pub mod prelude { + pub use super::Item; + } +} + +// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1 +// @count foo/prelude/index.html '//div[@class="item-row"]' 0 +pub mod prelude {} + +#[doc(inline)] +pub use sub::*; diff --git a/src/test/rustdoc/issue-89852.rs b/src/test/rustdoc/issue-89852.rs index 45544dbee..4f2da5e07 100644 --- a/src/test/rustdoc/issue-89852.rs +++ b/src/test/rustdoc/issue-89852.rs @@ -3,8 +3,8 @@ #![no_core] #![feature(no_core)] -// @matches 'issue_89852/sidebar-items.js' '"repro"' -// @!matches 'issue_89852/sidebar-items.js' '"repro".*"repro"' +// @matchesraw 'issue_89852/sidebar-items.js' '"repro"' +// @!matchesraw 'issue_89852/sidebar-items.js' '"repro".*"repro"' #[macro_export] macro_rules! repro { diff --git a/src/test/rustdoc/issue-98697.rs b/src/test/rustdoc/issue-98697.rs index 83e08094c..d50268509 100644 --- a/src/test/rustdoc/issue-98697.rs +++ b/src/test/rustdoc/issue-98697.rs @@ -8,10 +8,10 @@ extern crate issue_98697_reexport_with_anonymous_lifetime; -// @has issue_98697/fn.repro.html '//pre[@class="rust fn"]/code' 'fn repro<F>() where F: Fn(&str)' +// @has issue_98697/fn.repro.html '//pre[@class="rust fn"]/code' 'fn repro<F>()where F: Fn(&str)' // @!has issue_98697/fn.repro.html '//pre[@class="rust fn"]/code' 'for<' pub use issue_98697_reexport_with_anonymous_lifetime::repro; -// @has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl MyTrait<&Extra> for Extra' -// @!has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl<' +// @has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl MyTrait<&Extra> for Extra' +// @!has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl<' pub use issue_98697_reexport_with_anonymous_lifetime::Extra; diff --git a/src/test/rustdoc/keyword.rs b/src/test/rustdoc/keyword.rs index 1cebe4c67..ea1273850 100644 --- a/src/test/rustdoc/keyword.rs +++ b/src/test/rustdoc/keyword.rs @@ -7,7 +7,7 @@ // @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Keywords' // @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#keywords' // @has foo/keyword.match.html '//a[@class="keyword"]' 'match' -// @has foo/keyword.match.html '//span[@class="in-band"]' 'Keyword match' +// @has foo/keyword.match.html '//h1[@class="fqn"]' 'Keyword match' // @has foo/keyword.match.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // @has foo/index.html '//a/@href' '../foo/index.html' // @!has foo/foo/index.html diff --git a/src/test/rustdoc/link-title-escape.rs b/src/test/rustdoc/link-title-escape.rs index 01aa8d00b..7a322ea6d 100644 --- a/src/test/rustdoc/link-title-escape.rs +++ b/src/test/rustdoc/link-title-escape.rs @@ -6,4 +6,4 @@ //! //! [foo]: url 'title & <stuff> & "things"' -// @has 'foo/index.html' 'title & <stuff> & "things"' +// @hasraw 'foo/index.html' 'title & <stuff> & "things"' diff --git a/src/test/rustdoc/logo-class-default.rs b/src/test/rustdoc/logo-class-default.rs index a7016d227..d2d439199 100644 --- a/src/test/rustdoc/logo-class-default.rs +++ b/src/test/rustdoc/logo-class-default.rs @@ -1,4 +1,4 @@ // Note: this test is paired with logo-class.rs. // @has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' -// @has logo_class_default/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +// @has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/src/test/rustdoc/logo-class.rs b/src/test/rustdoc/logo-class.rs index f071f356a..d3aa446da 100644 --- a/src/test/rustdoc/logo-class.rs +++ b/src/test/rustdoc/logo-class.rs @@ -5,6 +5,6 @@ // @has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' // @!has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' // -// @has logo_class/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' -// @!has logo_class/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +// @has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' +// @!has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/src/test/rustdoc/macro-document-private-duplicate.rs b/src/test/rustdoc/macro-document-private-duplicate.rs index 7576c1326..d3cf7e140 100644 --- a/src/test/rustdoc/macro-document-private-duplicate.rs +++ b/src/test/rustdoc/macro-document-private-duplicate.rs @@ -4,21 +4,21 @@ // (yes, that's a thing), rustdoc lists both of them on the index page, // but only documents the first one on the page for the macro. // Fortunately, this can only happen in document private items mode, -// but it still isn't ideal beahvior. +// but it still isn't ideal behavior. // // See https://github.com/rust-lang/rust/pull/88019#discussion_r693920453 // // compile-flags: --document-private-items -// @has macro_document_private_duplicate/index.html 'Doc 1.' -// @has macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' +// @hasraw macro_document_private_duplicate/index.html 'Doc 1.' +// @hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' /// Doc 1. macro_rules! a_macro { () => () } -// @has macro_document_private_duplicate/index.html 'Doc 2.' -// @!has macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' +// @hasraw macro_document_private_duplicate/index.html 'Doc 2.' +// @!hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' /// Doc 2. macro_rules! a_macro { () => () diff --git a/src/test/rustdoc/macro-higher-kinded-function.rs b/src/test/rustdoc/macro-higher-kinded-function.rs index 02a430564..b8c52b7b7 100644 --- a/src/test/rustdoc/macro-higher-kinded-function.rs +++ b/src/test/rustdoc/macro-higher-kinded-function.rs @@ -11,8 +11,8 @@ macro_rules! gen { } // @has 'foo/struct.Providers.html' -// @has - '//*[@class="docblock item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," -// @has - '//*[@class="docblock item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," +// @has - '//*[@class="item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," +// @has - '//*[@class="item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," // @has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8" // @has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16" gen! { diff --git a/src/test/rustdoc/macro-private-not-documented.rs b/src/test/rustdoc/macro-private-not-documented.rs index ae8b0e722..f135a3a9c 100644 --- a/src/test/rustdoc/macro-private-not-documented.rs +++ b/src/test/rustdoc/macro-private-not-documented.rs @@ -6,13 +6,13 @@ // This is a regression text for issue #88453. #![feature(decl_macro)] -// @!has macro_private_not_documented/index.html 'a_macro' +// @!hasraw macro_private_not_documented/index.html 'a_macro' // @!has macro_private_not_documented/macro.a_macro.html macro_rules! a_macro { () => () } -// @!has macro_private_not_documented/index.html 'another_macro' +// @!hasraw macro_private_not_documented/index.html 'another_macro' // @!has macro_private_not_documented/macro.another_macro.html macro another_macro { () => () diff --git a/src/test/rustdoc/macro_rules-matchers.rs b/src/test/rustdoc/macro_rules-matchers.rs index efc3b21e6..96f4126c7 100644 --- a/src/test/rustdoc/macro_rules-matchers.rs +++ b/src/test/rustdoc/macro_rules-matchers.rs @@ -5,32 +5,27 @@ // @has 'foo/macro.todo.html' // @has - '//span[@class="macro"]' 'macro_rules!' -// @has - '//span[@class="ident"]' 'todo' -// Note: the only op is the `+` -// @count - '//pre[@class="rust macro"]//span[@class="op"]' 1 +// @hasraw - ' todo {' -// @has - '{ () => { ... }; ($(' +// @hasraw - '{ () => { ... }; ($(' // @has - '//span[@class="macro-nonterminal"]' '$' // @has - '//span[@class="macro-nonterminal"]' 'arg' -// @has - ':' -// @has - '//span[@class="ident"]' 'tt' -// @has - '),' -// @has - '//span[@class="op"]' '+' -// @has - ') => { ... }; }' +// @hasraw - ':tt)+' +// @hasraw - ') => { ... }; }' pub use std::todo; mod mod1 { // @has 'foo/macro.macro1.html' - // @has - 'macro_rules!' - // @has - 'macro1' - // @has - '{ () => { ... }; ($(' + // @hasraw - 'macro_rules!' + // @hasraw - 'macro1' + // @hasraw - '{ () => { ... }; ($(' // @has - '//span[@class="macro-nonterminal"]' '$' // @has - '//span[@class="macro-nonterminal"]' 'arg' - // @has - ':' - // @has - 'expr' - // @has - '),' - // @has - '+' - // @has - ') => { ... }; }' + // @hasraw - ':' + // @hasraw - 'expr' + // @hasraw - '),' + // @hasraw - '+' + // @hasraw - ') => { ... }; }' #[macro_export] macro_rules! macro1 { () => {}; diff --git a/src/test/rustdoc/markdown-summaries.rs b/src/test/rustdoc/markdown-summaries.rs index b843e28e7..31e7072b5 100644 --- a/src/test/rustdoc/markdown-summaries.rs +++ b/src/test/rustdoc/markdown-summaries.rs @@ -7,21 +7,21 @@ //! //! [link]: https://example.com -// @has search-index.js 'This <em>summary</em> has a link and <code>code</code>.' -// @!has - 'second paragraph' +// @hasraw search-index.js 'This <em>summary</em> has a link and <code>code</code>.' +// @!hasraw - 'second paragraph' /// This `code` will be rendered in a code tag. /// /// This text should not be rendered. pub struct Sidebar; -// @has search-index.js 'This <code>code</code> will be rendered in a code tag.' -// @has summaries/sidebar-items.js 'This `code` will be rendered in a code tag.' -// @!has - 'text should not be rendered' +// @hasraw search-index.js 'This <code>code</code> will be rendered in a code tag.' +// @hasraw summaries/sidebar-items.js 'This `code` will be rendered in a code tag.' +// @!hasraw - 'text should not be rendered' /// ```text /// this block should not be rendered /// ``` pub struct Sidebar2; -// @!has summaries/sidebar-items.js 'block should not be rendered' +// @!hasraw summaries/sidebar-items.js 'block should not be rendered' diff --git a/src/test/rustdoc/masked.rs b/src/test/rustdoc/masked.rs index c7ad690d6..80d5b99c0 100644 --- a/src/test/rustdoc/masked.rs +++ b/src/test/rustdoc/masked.rs @@ -7,24 +7,24 @@ #[doc(masked)] extern crate masked; -// @!has 'search-index.js' 'masked_method' +// @!hasraw 'search-index.js' 'masked_method' -// @!has 'foo/struct.String.html' 'MaskedTrait' -// @!has 'foo/struct.String.html' 'masked_method' +// @!hasraw 'foo/struct.String.html' 'MaskedTrait' +// @!hasraw 'foo/struct.String.html' 'masked_method' pub use std::string::String; -// @!has 'foo/trait.Clone.html' 'MaskedStruct' +// @!hasraw 'foo/trait.Clone.html' 'MaskedStruct' pub use std::clone::Clone; -// @!has 'foo/struct.MyStruct.html' 'MaskedTrait' -// @!has 'foo/struct.MyStruct.html' 'masked_method' +// @!hasraw 'foo/struct.MyStruct.html' 'MaskedTrait' +// @!hasraw 'foo/struct.MyStruct.html' 'masked_method' pub struct MyStruct; impl masked::MaskedTrait for MyStruct { fn masked_method() {} } -// @!has 'foo/trait.MyTrait.html' 'MaskedStruct' +// @!hasraw 'foo/trait.MyTrait.html' 'MaskedStruct' pub trait MyTrait {} impl MyTrait for masked::MaskedStruct {} diff --git a/src/test/rustdoc/module-impls.rs b/src/test/rustdoc/module-impls.rs index 198b3446c..852f444e9 100644 --- a/src/test/rustdoc/module-impls.rs +++ b/src/test/rustdoc/module-impls.rs @@ -2,4 +2,4 @@ pub use std::marker::Send; -// @!has foo/index.html 'Implementations' +// @!hasraw foo/index.html 'Implementations' diff --git a/src/test/rustdoc/negative-impl-sidebar.rs b/src/test/rustdoc/negative-impl-sidebar.rs index b995fff1f..4af6d0084 100644 --- a/src/test/rustdoc/negative-impl-sidebar.rs +++ b/src/test/rustdoc/negative-impl-sidebar.rs @@ -4,6 +4,6 @@ pub struct Foo; // @has foo/struct.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#trait-implementations"]' 'Trait Implementations' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' // @has - '//*[@class="sidebar-elems"]//section//a' '!Sync' impl !Sync for Foo {} diff --git a/src/test/rustdoc/negative-impl.rs b/src/test/rustdoc/negative-impl.rs index 61a239868..af19c784d 100644 --- a/src/test/rustdoc/negative-impl.rs +++ b/src/test/rustdoc/negative-impl.rs @@ -5,10 +5,10 @@ pub struct Alpha; // @matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo<B>" pub struct Bravo<B>(B); -// @matches negative_impl/struct.Alpha.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @matches negative_impl/struct.Alpha.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl !Send for Alpha" impl !Send for Alpha {} -// @matches negative_impl/struct.Bravo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' "\ +// @matches negative_impl/struct.Bravo.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' "\ // impl<B> !Send for Bravo<B>" impl<B> !Send for Bravo<B> {} diff --git a/src/test/rustdoc/nested-modules.rs b/src/test/rustdoc/nested-modules.rs index 1596f4674..12234d2cf 100644 --- a/src/test/rustdoc/nested-modules.rs +++ b/src/test/rustdoc/nested-modules.rs @@ -7,22 +7,22 @@ mod a_module { pub mod a_nested_module { // @has aCrate/a_nested_module/index.html '//a[@href="fn.a_nested_public_function.html"]' 'a_nested_public_function' - // @has aCrate/a_nested_module/fn.a_nested_public_function.html 'pub fn a_nested_public_function()' + // @hasraw aCrate/a_nested_module/fn.a_nested_public_function.html 'pub fn a_nested_public_function()' pub fn a_nested_public_function() {} // @has aCrate/a_nested_module/index.html '//a[@href="fn.another_nested_public_function.html"]' 'another_nested_public_function' - // @has aCrate/a_nested_module/fn.another_nested_public_function.html 'pub fn another_nested_public_function()' + // @hasraw aCrate/a_nested_module/fn.another_nested_public_function.html 'pub fn another_nested_public_function()' pub use a_nested_module::a_nested_public_function as another_nested_public_function; } - // @!has aCrate/a_nested_module/index.html 'yet_another_nested_public_function' + // @!hasraw aCrate/a_nested_module/index.html 'yet_another_nested_public_function' pub use a_nested_module::a_nested_public_function as yet_another_nested_public_function; - // @!has aCrate/a_nested_module/index.html 'one_last_nested_public_function' + // @!hasraw aCrate/a_nested_module/index.html 'one_last_nested_public_function' pub use a_nested_module::another_nested_public_function as one_last_nested_public_function; } -// @!has aCrate/index.html 'a_module' +// @!hasraw aCrate/index.html 'a_module' // @has aCrate/index.html '//a[@href="a_nested_module/index.html"]' 'a_nested_module' pub use a_module::a_nested_module; @@ -36,7 +36,7 @@ pub use a_module::{ }; // @has aCrate/index.html '//a[@href="fn.private_function.html"]' 'private_function' -// @!has aCrate/fn.private_function.html 'a_module' +// @!hasraw aCrate/fn.private_function.html 'a_module' // @has aCrate/index.html '//a[@href="fn.other_private_function.html"]' 'other_private_function' -// @!has aCrate/fn.other_private_function.html 'a_module' +// @!hasraw aCrate/fn.other_private_function.html 'a_module' pub use a_module::{other_private_function, private_function}; diff --git a/src/test/rustdoc/no-crate-filter.rs b/src/test/rustdoc/no-crate-filter.rs index c694d1456..b2f899064 100644 --- a/src/test/rustdoc/no-crate-filter.rs +++ b/src/test/rustdoc/no-crate-filter.rs @@ -2,5 +2,5 @@ // compile-flags: -Z unstable-options --disable-per-crate-search -// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' +// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' '' pub struct Foo; diff --git a/src/test/rustdoc/normalize-assoc-item.rs b/src/test/rustdoc/normalize-assoc-item.rs index ad1a868ee..db56f6852 100644 --- a/src/test/rustdoc/normalize-assoc-item.rs +++ b/src/test/rustdoc/normalize-assoc-item.rs @@ -11,11 +11,24 @@ impl Trait for usize { type X = isize; } +impl Trait for () { + type X = fn() -> i32; +} + +impl Trait for isize { + type X = <() as Trait>::X; +} + // @has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust fn"]' 'pub fn f() -> isize' pub fn f() -> <usize as Trait>::X { 0 } +// @has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust fn"]' 'pub fn f2() -> fn() -> i32' +pub fn f2() -> <isize as Trait>::X { + todo!() +} + pub struct S { // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S, Global>' pub box_me_up: <S as Trait>::X, diff --git a/src/test/rustdoc/not-wf-ambiguous-normalization.rs b/src/test/rustdoc/not-wf-ambiguous-normalization.rs new file mode 100644 index 000000000..1e9f925f8 --- /dev/null +++ b/src/test/rustdoc/not-wf-ambiguous-normalization.rs @@ -0,0 +1,24 @@ +// compile-flags: -Znormalize-docs + +#![feature(type_alias_impl_trait)] + +trait Allocator { + type Buffer; +} + +struct DefaultAllocator; + +// This unconstrained impl parameter causes the normalization of +// `<DefaultAllocator as Allocator>::Buffer` to be ambiguous, +// which caused an ICE with `-Znormalize-docs`. +impl<T> Allocator for DefaultAllocator { + type Buffer = (); +} + +type A = impl Fn(<DefaultAllocator as Allocator>::Buffer); + +fn foo() -> A { + |_| () +} + +fn main() {} diff --git a/src/test/rustdoc/primitive-reference.rs b/src/test/rustdoc/primitive-reference.rs new file mode 100644 index 000000000..ea8d2d166 --- /dev/null +++ b/src/test/rustdoc/primitive-reference.rs @@ -0,0 +1,37 @@ +#![crate_name = "foo"] + +#![feature(rustdoc_internals)] + +// @has foo/index.html +// @has - '//h2[@id="primitives"]' 'Primitive Types' +// @has - '//a[@href="primitive.reference.html"]' 'reference' +// @has - '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' +// @has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' +// @has foo/primitive.reference.html +// @has - '//a[@class="primitive"]' 'reference' +// @has - '//h1[@class="fqn"]' 'Primitive Type reference' +// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' + +// There should be only one implementation listed. +// @count - '//*[@class="impl has-srclink"]' 1 +// @has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ +// 'impl<A, B> Foo<&A> for &B' +#[doc(primitive = "reference")] +/// this is a test! +mod reference {} + +pub struct Bar; + +// This implementation should **not** show up. +impl<T> From<&T> for Bar { + fn from(s: &T) -> Self { + Bar + } +} + +pub trait Foo<T> { + fn stuff(&self, other: &T) {} +} + +// This implementation should show up. +impl<A, B> Foo<&A> for &B {} diff --git a/src/test/rustdoc/primitive-slice-auto-trait.rs b/src/test/rustdoc/primitive-slice-auto-trait.rs index b3f511bc1..cdddd6b65 100644 --- a/src/test/rustdoc/primitive-slice-auto-trait.rs +++ b/src/test/rustdoc/primitive-slice-auto-trait.rs @@ -4,11 +4,11 @@ #![feature(rustdoc_internals)] // @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice' -// @has - '//span[@class="in-band"]' 'Primitive Type slice' +// @has - '//h1[@class="fqn"]' 'Primitive Type slice' // @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T] where T: Send' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T] where T: Sync' +// @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")] /// this is a test! mod slice_prim {} diff --git a/src/test/rustdoc/primitive-tuple-auto-trait.rs b/src/test/rustdoc/primitive-tuple-auto-trait.rs index a2fbbf078..df681457f 100644 --- a/src/test/rustdoc/primitive-tuple-auto-trait.rs +++ b/src/test/rustdoc/primitive-tuple-auto-trait.rs @@ -4,7 +4,7 @@ #![feature(rustdoc_internals)] // @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple' -// @has - '//span[@class="in-band"]' 'Primitive Type tuple' +// @has - '//h1[@class="fqn"]' 'Primitive Type tuple' // @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' diff --git a/src/test/rustdoc/primitive-unit-auto-trait.rs b/src/test/rustdoc/primitive-unit-auto-trait.rs index 76182622e..391e33bea 100644 --- a/src/test/rustdoc/primitive-unit-auto-trait.rs +++ b/src/test/rustdoc/primitive-unit-auto-trait.rs @@ -4,7 +4,7 @@ #![feature(rustdoc_internals)] // @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit' -// @has - '//span[@class="in-band"]' 'Primitive Type unit' +// @has - '//h1[@class="fqn"]' 'Primitive Type unit' // @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' // @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' diff --git a/src/test/rustdoc/primitive.rs b/src/test/rustdoc/primitive.rs index 605ca4d17..6347fdac3 100644 --- a/src/test/rustdoc/primitive.rs +++ b/src/test/rustdoc/primitive.rs @@ -7,7 +7,7 @@ // @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' // @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' // @has foo/primitive.i32.html '//a[@class="primitive"]' 'i32' -// @has foo/primitive.i32.html '//span[@class="in-band"]' 'Primitive Type i32' +// @has foo/primitive.i32.html '//h1[@class="fqn"]' 'Primitive Type i32' // @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' '๐' diff --git a/src/test/rustdoc/primitive/primitive-generic-impl.rs b/src/test/rustdoc/primitive/primitive-generic-impl.rs index eebb2cf5a..7b336b398 100644 --- a/src/test/rustdoc/primitive/primitive-generic-impl.rs +++ b/src/test/rustdoc/primitive/primitive-generic-impl.rs @@ -1,7 +1,7 @@ #![feature(rustdoc_internals)] #![crate_name = "foo"] -// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-i32"]//h3[@class="code-header in-band"]' 'impl<T> ToString for T' +// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-i32"]//h3[@class="code-header"]' 'impl<T> ToString for T' #[doc(primitive = "i32")] /// Some useless docs, wouhou! diff --git a/src/test/rustdoc/recursive-deref.rs b/src/test/rustdoc/recursive-deref.rs index a7504fbcc..aa38485c4 100644 --- a/src/test/rustdoc/recursive-deref.rs +++ b/src/test/rustdoc/recursive-deref.rs @@ -9,7 +9,7 @@ impl C { pub fn c(&self) {} } -// @has recursive_deref/struct.A.html '//h3[@class="code-header in-band"]' 'impl Deref for A' +// @has recursive_deref/struct.A.html '//h3[@class="code-header"]' 'impl Deref for A' // @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' impl Deref for A { type Target = B; @@ -19,7 +19,7 @@ impl Deref for A { } } -// @has recursive_deref/struct.B.html '//h3[@class="code-header in-band"]' 'impl Deref for B' +// @has recursive_deref/struct.B.html '//h3[@class="code-header"]' 'impl Deref for B' // @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' impl Deref for B { type Target = C; @@ -29,7 +29,7 @@ impl Deref for B { } } -// @has recursive_deref/struct.C.html '//h3[@class="code-header in-band"]' 'impl Deref for C' +// @has recursive_deref/struct.C.html '//h3[@class="code-header"]' 'impl Deref for C' impl Deref for C { type Target = B; @@ -49,9 +49,9 @@ impl G { pub fn g() {} } -// @has recursive_deref/struct.D.html '//h3[@class="code-header in-band"]' 'impl Deref for D' +// @has recursive_deref/struct.D.html '//h3[@class="code-header"]' 'impl Deref for D' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for D { type Target = E; @@ -60,9 +60,9 @@ impl Deref for D { } } -// @has recursive_deref/struct.E.html '//h3[@class="code-header in-band"]' 'impl Deref for E' +// @has recursive_deref/struct.E.html '//h3[@class="code-header"]' 'impl Deref for E' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for E { type Target = F; @@ -71,9 +71,9 @@ impl Deref for E { } } -// @has recursive_deref/struct.F.html '//h3[@class="code-header in-band"]' 'impl Deref for F' +// @has recursive_deref/struct.F.html '//h3[@class="code-header"]' 'impl Deref for F' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for F { type Target = G; @@ -82,7 +82,7 @@ impl Deref for F { } } -// @has recursive_deref/struct.G.html '//h3[@class="code-header in-band"]' 'impl Deref for G' +// @has recursive_deref/struct.G.html '//h3[@class="code-header"]' 'impl Deref for G' impl Deref for G { type Target = E; @@ -100,8 +100,8 @@ impl I { pub fn i() {} } -// @has recursive_deref/struct.H.html '//h3[@class="code-header in-band"]' 'impl Deref for H' -// @!has '-' '//*[@id="deref-methods-I"]' +// @has recursive_deref/struct.H.html '//h3[@class="code-header"]' 'impl Deref for H' +// @!has '-' '//*[@id="deref-methods-I"]' '' impl Deref for H { type Target = I; @@ -110,7 +110,7 @@ impl Deref for H { } } -// @has recursive_deref/struct.I.html '//h3[@class="code-header in-band"]' 'impl Deref for I' +// @has recursive_deref/struct.I.html '//h3[@class="code-header"]' 'impl Deref for I' impl Deref for I { type Target = H; diff --git a/src/test/rustdoc/reexport-dep-foreign-fn.rs b/src/test/rustdoc/reexport-dep-foreign-fn.rs index 6e1dc4539..6694c91d1 100644 --- a/src/test/rustdoc/reexport-dep-foreign-fn.rs +++ b/src/test/rustdoc/reexport-dep-foreign-fn.rs @@ -8,5 +8,5 @@ extern crate all_item_types; // @has 'foo/fn.foo_ffn.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' +// @has - '//*[@class="item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' pub use all_item_types::foo_ffn; diff --git a/src/test/rustdoc/reexport-doc.rs b/src/test/rustdoc/reexport-doc.rs new file mode 100644 index 000000000..df2c889b4 --- /dev/null +++ b/src/test/rustdoc/reexport-doc.rs @@ -0,0 +1,8 @@ +// aux-build:reexport-doc-aux.rs + +extern crate reexport_doc_aux as dep; + +// @has 'reexport_doc/struct.Foo.html' +// @count - '//p' 'These are the docs for Foo.' 1 +/// These are the docs for Foo. +pub use dep::Foo; diff --git a/src/test/rustdoc/reexports-priv.rs b/src/test/rustdoc/reexports-priv.rs index aea9b9f2b..11364e7f7 100644 --- a/src/test/rustdoc/reexports-priv.rs +++ b/src/test/rustdoc/reexports-priv.rs @@ -5,7 +5,7 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' +// @has 'foo/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -14,7 +14,7 @@ pub(self) use reexports::addr_of_self; // @!has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' +// @has 'foo/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -23,7 +23,7 @@ pub(self) use reexports::FooSelf; // @!has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' +// @has 'foo/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -50,7 +50,7 @@ pub(self) use reexports::TypeSelf; // @!has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' +// @has 'foo/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; @@ -61,33 +61,33 @@ use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; - // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="docblock item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' pub(crate) use reexports::addr_of_crate; - // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="docblock item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' pub(super) use reexports::addr_of_super; // @!has 'foo/outer/inner/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; // @!has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' + // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; - // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) struct FooCrate;' + // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="item-decl"]' 'pub(crate) struct FooCrate;' pub(crate) use reexports::FooCrate; - // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) struct FooSuper;' + // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="item-decl"]' 'pub(in outer) struct FooSuper;' pub(super) use reexports::FooSuper; // @!has 'foo/outer/inner/struct.FooSelf.html' pub(self) use reexports::FooSelf; // @!has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' + // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; - // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) enum BarCrate {' + // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="item-decl"]' 'pub(crate) enum BarCrate {' pub(crate) use reexports::BarCrate; - // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) enum BarSuper {' + // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="item-decl"]' 'pub(in outer) enum BarSuper {' pub(super) use reexports::BarSuper; // @!has 'foo/outer/inner/enum.BarSelf.html' pub(self) use reexports::BarSelf; @@ -116,11 +116,11 @@ pub mod outer { // @!has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' + // @has 'foo/outer/inner/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; - // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) union UnionCrate {' + // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="item-decl"]' 'pub(crate) union UnionCrate {' pub(crate) use reexports::UnionCrate; - // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) union UnionSuper {' + // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="item-decl"]' 'pub(in outer) union UnionSuper {' pub(super) use reexports::UnionSuper; // @!has 'foo/outer/inner/union.UnionSelf.html' pub(self) use reexports::UnionSelf; diff --git a/src/test/rustdoc/reexports.rs b/src/test/rustdoc/reexports.rs index 7abcbfb61..9aa6d7224 100644 --- a/src/test/rustdoc/reexports.rs +++ b/src/test/rustdoc/reexports.rs @@ -4,7 +4,7 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' +// @has 'foo/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -13,7 +13,7 @@ pub(self) use reexports::addr_of_self; // @!has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' +// @has 'foo/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -22,7 +22,7 @@ pub(self) use reexports::FooSelf; // @!has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' +// @has 'foo/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -49,7 +49,7 @@ pub(self) use reexports::TypeSelf; // @!has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' +// @has 'foo/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; @@ -60,7 +60,7 @@ use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/outer/inner/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -71,7 +71,7 @@ pub mod outer { // @!has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' + // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/outer/inner/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -82,7 +82,7 @@ pub mod outer { // @!has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' + // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/outer/inner/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -115,7 +115,7 @@ pub mod outer { // @!has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' + // @has 'foo/outer/inner/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/outer/inner/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs index e2b232a6e..599c429a6 100644 --- a/src/test/rustdoc/remove-url-from-headings.rs +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] // @has foo/fn.foo.html -// @!has - '//a[@href="http://a.a"]' +// @!has - '//a[@href="http://a.a"]' '' // @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere' // @has - '//a[@href="#another-one-urg"]' 'Another one urg' diff --git a/src/test/rustdoc/rfc-2632-const-trait-impl.rs b/src/test/rustdoc/rfc-2632-const-trait-impl.rs index f3e211e30..602ee1b1b 100644 --- a/src/test/rustdoc/rfc-2632-const-trait-impl.rs +++ b/src/test/rustdoc/rfc-2632-const-trait-impl.rs @@ -18,10 +18,10 @@ pub struct S<T>(T); // @has - '//pre[@class="rust trait"]/code/span[@class="where"]' ': Clone' #[const_trait] pub trait Tr<T> { - // @!has - '//div[@id="method.a"]/h4[@class="code-header"]' '~const' - // @has - '//div[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' - // @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' - // @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' + // @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' + // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' + // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' + // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' fn a<A: ~const Clone + ~const Destruct>() where Option<A>: ~const Clone + ~const Destruct, @@ -30,10 +30,10 @@ pub trait Tr<T> { } // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' -// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone' -// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone' +// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' +// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Clone' +// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' +// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' impl<T: ~const Clone + ~const Destruct> const Tr<T> for T where Option<T>: ~const Clone + ~const Destruct, diff --git a/src/test/rustdoc/rustc-incoherent-impls.rs b/src/test/rustdoc/rustc-incoherent-impls.rs new file mode 100644 index 000000000..3fdefbecc --- /dev/null +++ b/src/test/rustdoc/rustc-incoherent-impls.rs @@ -0,0 +1,28 @@ +// aux-build:incoherent-impl-types.rs +// build-aux-docs + +#![crate_name = "foo"] +#![feature(rustc_attrs)] + +extern crate incoherent_impl_types; + +// The only way this actually shows up is if the type gets inlined. +#[doc(inline)] +pub use incoherent_impl_types::FooTrait; + +// @has foo/trait.FooTrait.html +// @count - '//section[@id="method.do_something"]' 1 +impl dyn FooTrait { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} + +#[doc(inline)] +pub use incoherent_impl_types::FooStruct; + +// @has foo/struct.FooStruct.html +// @count - '//section[@id="method.do_something"]' 1 +impl FooStruct { + #[rustc_allow_incoherent_impl] + pub fn do_something() {} +} diff --git a/src/test/rustdoc/safe-intrinsic.rs b/src/test/rustdoc/safe-intrinsic.rs index d3bb8514b..d08abdaeb 100644 --- a/src/test/rustdoc/safe-intrinsic.rs +++ b/src/test/rustdoc/safe-intrinsic.rs @@ -1,5 +1,6 @@ #![feature(intrinsics)] #![feature(no_core)] +#![feature(rustc_attrs)] #![no_core] #![crate_name = "foo"] @@ -7,6 +8,7 @@ extern "rust-intrinsic" { // @has 'foo/fn.abort.html' // @has - '//pre[@class="rust fn"]' 'pub extern "rust-intrinsic" fn abort() -> !' + #[rustc_safe_intrinsic] pub fn abort() -> !; // @has 'foo/fn.unreachable.html' // @has - '//pre[@class="rust fn"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !' diff --git a/src/test/rustdoc/search-index-summaries.rs b/src/test/rustdoc/search-index-summaries.rs index dd9c1a0b4..efd366405 100644 --- a/src/test/rustdoc/search-index-summaries.rs +++ b/src/test/rustdoc/search-index-summaries.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has 'search-index.js' 'Foo short link.' -// @!has - 'www.example.com' -// @!has - 'More Foo.' +// @hasraw 'search-index.js' 'Foo short link.' +// @!hasraw - 'www.example.com' +// @!hasraw - 'More Foo.' /// Foo short [link](https://www.example.com/). /// diff --git a/src/test/rustdoc/search-index.rs b/src/test/rustdoc/search-index.rs index f1b78f172..d1d05eb88 100644 --- a/src/test/rustdoc/search-index.rs +++ b/src/test/rustdoc/search-index.rs @@ -2,25 +2,25 @@ use std::ops::Deref; -// @has search-index.js Foo +// @hasraw search-index.js Foo pub use private::Foo; mod private { pub struct Foo; impl Foo { - pub fn test_method() {} // @has - test_method - fn priv_method() {} // @!has - priv_method + pub fn test_method() {} // @hasraw - test_method + fn priv_method() {} // @!hasraw - priv_method } pub trait PrivateTrait { - fn trait_method(&self) {} // @!has - priv_method + fn trait_method(&self) {} // @!hasraw - priv_method } } pub struct Bar; impl Deref for Bar { - // @!has search-index.js Target + // @!hasraw search-index.js Target type Target = Bar; fn deref(&self) -> &Bar { self } } diff --git a/src/test/rustdoc/short-docblock-codeblock.rs b/src/test/rustdoc/short-docblock-codeblock.rs index c6b318b06..3c5fa7b36 100644 --- a/src/test/rustdoc/short-docblock-codeblock.rs +++ b/src/test/rustdoc/short-docblock-codeblock.rs @@ -1,8 +1,6 @@ #![crate_name = "foo"] -// @has foo/index.html '//*[@class="item-right docblock-short"]' "" -// @!has foo/index.html '//*[@class="item-right docblock-short"]' "Some text." -// @!has foo/index.html '//*[@class="item-right docblock-short"]' "let x = 12;" +// @count foo/index.html '//*[@class="item-right docblock-short"]' 0 /// ``` /// let x = 12; diff --git a/src/test/rustdoc/short-docblock.rs b/src/test/rustdoc/short-docblock.rs index 17c44eab0..1a8a689be 100644 --- a/src/test/rustdoc/short-docblock.rs +++ b/src/test/rustdoc/short-docblock.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// @has foo/index.html '//*[@class="item-right docblock-short"]/p' 'fooo' -// @!has foo/index.html '//*[@class="item-right docblock-short"]/p/h1' 'fooo' +// @has foo/index.html '//*[@class="item-right docblock-short"]' 'fooo' +// @!has foo/index.html '//*[@class="item-right docblock-short"]/h1' 'fooo' // @has foo/fn.foo.html '//h2[@id="fooo"]/a[@href="#fooo"]' 'fooo' /// # fooo @@ -9,8 +9,8 @@ /// foo pub fn foo() {} -// @has foo/index.html '//*[@class="item-right docblock-short"]/p' 'mooood' -// @!has foo/index.html '//*[@class="item-right docblock-short"]/p/h2' 'mooood' +// @has foo/index.html '//*[@class="item-right docblock-short"]' 'mooood' +// @!has foo/index.html '//*[@class="item-right docblock-short"]/h2' 'mooood' // @has foo/foo/index.html '//h3[@id="mooood"]/a[@href="#mooood"]' 'mooood' /// ## mooood @@ -18,7 +18,7 @@ pub fn foo() {} /// foo mod pub mod foo {} -// @has foo/index.html '//*[@class="item-right docblock-short"]/p/a[@href=\ +// @has foo/index.html '//*[@class="item-right docblock-short"]/a[@href=\ // "https://nougat.world"]/code' 'nougat' /// [`nougat`](https://nougat.world) diff --git a/src/test/rustdoc/show-const-contents.rs b/src/test/rustdoc/show-const-contents.rs index 48b608859..69e742ee7 100644 --- a/src/test/rustdoc/show-const-contents.rs +++ b/src/test/rustdoc/show-const-contents.rs @@ -1,57 +1,57 @@ // Test that the contents of constants are displayed as part of the // documentation. -// @has show_const_contents/constant.CONST_S.html 'show this' -// @!has show_const_contents/constant.CONST_S.html '; //' +// @hasraw show_const_contents/constant.CONST_S.html 'show this' +// @!hasraw show_const_contents/constant.CONST_S.html '; //' pub const CONST_S: &'static str = "show this"; -// @has show_const_contents/constant.CONST_I32.html '= 42;' -// @!has show_const_contents/constant.CONST_I32.html '; //' +// @hasraw show_const_contents/constant.CONST_I32.html '= 42;' +// @!hasraw show_const_contents/constant.CONST_I32.html '; //' pub const CONST_I32: i32 = 42; -// @has show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' -// @!has show_const_contents/constant.CONST_I32_HEX.html '; //' +// @hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' +// @!hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' pub const CONST_I32_HEX: i32 = 0x42; -// @has show_const_contents/constant.CONST_NEG_I32.html '= -42;' -// @!has show_const_contents/constant.CONST_NEG_I32.html '; //' +// @hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' +// @!hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' pub const CONST_NEG_I32: i32 = -42; -// @has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' -// @!has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' +// @hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' +// @!hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; -// @has show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' +// @hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' pub const CONST_CALC_I32: i32 = 42 + 1; -// @!has show_const_contents/constant.CONST_REF_I32.html '= &42;' -// @!has show_const_contents/constant.CONST_REF_I32.html '; //' +// @!hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' +// @!hasraw show_const_contents/constant.CONST_REF_I32.html '; //' pub const CONST_REF_I32: &'static i32 = &42; -// @has show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' +// @hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' pub const CONST_I32_MAX: i32 = i32::MAX; -// @!has show_const_contents/constant.UNIT.html '= ();' -// @!has show_const_contents/constant.UNIT.html '; //' +// @!hasraw show_const_contents/constant.UNIT.html '= ();' +// @!hasraw show_const_contents/constant.UNIT.html '; //' pub const UNIT: () = (); pub struct MyType(i32); -// @!has show_const_contents/constant.MY_TYPE.html '= MyType(42);' -// @!has show_const_contents/constant.MY_TYPE.html '; //' +// @!hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' +// @!hasraw show_const_contents/constant.MY_TYPE.html '; //' pub const MY_TYPE: MyType = MyType(42); pub struct MyTypeWithStr(&'static str); -// @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' -// @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' +// @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' +// @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); -// @has show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;' -// @has show_const_contents/constant.PI.html '; // 3.14159274f32' +// @hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;' +// @hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' pub use std::f32::consts::PI; -// @has show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' +// @hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' #[allow(deprecated, deprecated_in_future)] pub use std::i32::MAX; @@ -61,7 +61,7 @@ macro_rules! int_module { ) } -// @has show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' +// @hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' int_module!(i16); // @has show_const_contents/constant.ESCAPE.html //pre '= r#"<script>alert("ESCAPE");</script>"#;' diff --git a/src/test/rustdoc/sidebar-all-page.rs b/src/test/rustdoc/sidebar-all-page.rs new file mode 100644 index 000000000..e74b981de --- /dev/null +++ b/src/test/rustdoc/sidebar-all-page.rs @@ -0,0 +1,35 @@ +#![crate_name = "foo"] + +#![feature(rustdoc_internals)] + +// @has 'foo/all.html' +// @has - '//*[@class="sidebar-elems"]//li' 'Structs' +// @has - '//*[@class="sidebar-elems"]//li' 'Enums' +// @has - '//*[@class="sidebar-elems"]//li' 'Unions' +// @has - '//*[@class="sidebar-elems"]//li' 'Functions' +// @has - '//*[@class="sidebar-elems"]//li' 'Traits' +// @has - '//*[@class="sidebar-elems"]//li' 'Macros' +// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions' +// @has - '//*[@class="sidebar-elems"]//li' 'Constants' +// @has - '//*[@class="sidebar-elems"]//li' 'Statics' +// @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' + +pub struct Foo; +pub enum Enum { + A, +} +pub union Bar { + a: u8, + b: u16, +} +pub fn foo() {} +pub trait Trait {} +#[macro_export] +macro_rules! foo { + () => {} +} +pub type Type = u8; +pub const FOO: u8 = 0; +pub static BAR: u8 = 0; +#[doc(primitive = "u8")] +mod u8 {} diff --git a/src/test/rustdoc/sidebar-items.rs b/src/test/rustdoc/sidebar-items.rs index b5b681ab0..6f7afa59b 100644 --- a/src/test/rustdoc/sidebar-items.rs +++ b/src/test/rustdoc/sidebar-items.rs @@ -2,17 +2,17 @@ #![crate_name = "foo"] // @has foo/trait.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#required-methods"]' 'Required Methods' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-methods"]' 'Required Methods' // @has - '//*[@class="sidebar-elems"]//section//a' 'bar' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-methods"]' 'Provided Methods' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-methods"]' 'Provided Methods' // @has - '//*[@class="sidebar-elems"]//section//a' 'foo' -// @has - '//*[@class="sidebar-title"]/a[@href="#required-associated-consts"]' 'Required Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-consts"]' 'Required Associated Constants' // @has - '//*[@class="sidebar-elems"]//section//a' 'FOO' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' // @has - '//*[@class="sidebar-elems"]//section//a' 'BAR' -// @has - '//*[@class="sidebar-title"]/a[@href="#required-associated-types"]' 'Required Associated Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-types"]' 'Required Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Output' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-associated-types"]' 'Provided Associated Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Extra' pub trait Foo { const FOO: usize; @@ -25,7 +25,7 @@ pub trait Foo { } // @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u' // @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' @@ -36,7 +36,7 @@ pub struct Bar { } // @has foo/enum.En.html -// @has - '//*[@class="sidebar-title"]/a[@href="#variants"]' 'Variants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#variants"]' 'Variants' // @has - '//*[@class="sidebar-elems"]//section//a' 'Foo' // @has - '//*[@class="sidebar-elems"]//section//a' 'Bar' pub enum En { @@ -45,7 +45,7 @@ pub enum En { } // @has foo/union.MyUnion.html -// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2' // @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' diff --git a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs index 155150396..11e946948 100644 --- a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs +++ b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs @@ -3,12 +3,12 @@ #![crate_name = "foo"] // @has foo/trait.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' // @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' -// @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header in-band"]' 'impl Foo for u32' +// @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str" -// @has - '//*[@id="impl-Foo-for-%26%27a%20str"]//h3[@class="code-header in-band"]' "impl<'a> Foo for &'a str" +// @has - '//*[@id="impl-Foo-for-%26%27a%20str"]//h3[@class="code-header"]' "impl<'a> Foo for &'a str" pub trait Foo {} impl Foo for u32 {} diff --git a/src/test/rustdoc/sized_trait.rs b/src/test/rustdoc/sized_trait.rs index 9d2c19677..feef4de8d 100644 --- a/src/test/rustdoc/sized_trait.rs +++ b/src/test/rustdoc/sized_trait.rs @@ -1,17 +1,17 @@ #![crate_name = "foo"] // @has foo/struct.Bar.html -// @!has - '//*[@id="impl-Sized"]' +// @!has - '//*[@id="impl-Sized"]' '' pub struct Bar { a: u16, } // @has foo/struct.Foo.html -// @!has - '//*[@id="impl-Sized"]' +// @!has - '//*[@id="impl-Sized"]' '' pub struct Foo<T: ?Sized>(T); // @has foo/struct.Unsized.html -// @has - '//*[@id="impl-Sized-for-Unsized"]//h3[@class="code-header in-band"]' 'impl !Sized for Unsized' +// @has - '//*[@id="impl-Sized-for-Unsized"]//h3[@class="code-header"]' 'impl !Sized for Unsized' pub struct Unsized { data: [u8], } diff --git a/src/test/rustdoc/sort-modules-by-appearance.rs b/src/test/rustdoc/sort-modules-by-appearance.rs index 5be6b9826..b5cc8bc83 100644 --- a/src/test/rustdoc/sort-modules-by-appearance.rs +++ b/src/test/rustdoc/sort-modules-by-appearance.rs @@ -9,5 +9,5 @@ pub mod module_c {} pub mod module_a {} -// @matches 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' -// @matches 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' +// @matchesraw 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' +// @matchesraw 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' diff --git a/src/test/rustdoc/source-file.rs b/src/test/rustdoc/source-file.rs index 968899dab..4e1664790 100644 --- a/src/test/rustdoc/source-file.rs +++ b/src/test/rustdoc/source-file.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has source-files.js source-file.rs +// @hasraw source-files.js source-file.rs pub struct Foo; diff --git a/src/test/rustdoc/src-links-auto-impls.rs b/src/test/rustdoc/src-links-auto-impls.rs index 69be9aa8d..953563833 100644 --- a/src/test/rustdoc/src-links-auto-impls.rs +++ b/src/test/rustdoc/src-links-auto-impls.rs @@ -1,12 +1,12 @@ #![crate_name = "foo"] // @has foo/struct.Unsized.html -// @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header in-band"]' 'impl !Sized for Unsized' +// @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' // @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="srclink"]' 'source' -// @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header in-band"]' 'impl Sync for Unsized' +// @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' // @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="srclink"]' 'source' -// @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header in-band"]' 'impl<T> Any for T' -// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink"]' 'source' +// @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl<T> Any for T' +// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink rightside"]' 'source' pub struct Unsized { data: [u8], } diff --git a/src/test/rustdoc/static-root-path.rs b/src/test/rustdoc/static-root-path.rs index f1d49b9fc..08c055c5b 100644 --- a/src/test/rustdoc/static-root-path.rs +++ b/src/test/rustdoc/static-root-path.rs @@ -1,18 +1,18 @@ // compile-flags:-Z unstable-options --static-root-path /cache/ // @has static_root_path/struct.SomeStruct.html -// @matches - '"/cache/main\.js"' -// @!matches - '"\.\./main\.js"' -// @matches - 'data-root-path="\.\./"' -// @!matches - '"/cache/search-index\.js"' +// @matchesraw - '"/cache/main\.js"' +// @!matchesraw - '"\.\./main\.js"' +// @matchesraw - 'data-root-path="\.\./"' +// @!matchesraw - '"/cache/search-index\.js"' pub struct SomeStruct; // @has src/static_root_path/static-root-path.rs.html -// @matches - '"/cache/source-script\.js"' -// @!matches - '"\.\./\.\./source-script\.js"' -// @matches - '"\.\./\.\./source-files.js"' -// @!matches - '"/cache/source-files\.js"' +// @matchesraw - '"/cache/source-script\.js"' +// @!matchesraw - '"\.\./\.\./source-script\.js"' +// @matchesraw - '"\.\./\.\./source-files.js"' +// @!matchesraw - '"/cache/source-files\.js"' // @has settings.html -// @matches - '/cache/settings\.js' -// @!matches - '\./settings\.js' +// @matchesraw - '/cache/settings\.js' +// @!matchesraw - '\./settings\.js' diff --git a/src/test/rustdoc/strip-enum-variant.no-not-shown.html b/src/test/rustdoc/strip-enum-variant.no-not-shown.html index c4ee1a991..782198956 100644 --- a/src/test/rustdoc/strip-enum-variant.no-not-shown.html +++ b/src/test/rustdoc/strip-enum-variant.no-not-shown.html @@ -1 +1 @@ -<ul><li><a href="#variant.Shown">Shown</a></li></ul>
\ No newline at end of file +<ul class="block"><li><a href="#variant.Shown">Shown</a></li></ul>
\ No newline at end of file diff --git a/src/test/rustdoc/strip-enum-variant.rs b/src/test/rustdoc/strip-enum-variant.rs index f82ffdfed..8753a7dc6 100644 --- a/src/test/rustdoc/strip-enum-variant.rs +++ b/src/test/rustdoc/strip-enum-variant.rs @@ -3,7 +3,7 @@ // @!has - '//code' 'NotShown' // @has - '//code' '// some variants omitted' // Also check that `NotShown` isn't displayed in the sidebar. -// @snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block"][1]/ul' +// @snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block"][1]' pub enum MyThing { Shown, #[doc(hidden)] diff --git a/src/test/rustdoc/synthetic_auto/basic.rs b/src/test/rustdoc/synthetic_auto/basic.rs index 54c54fdbf..7c6a38865 100644 --- a/src/test/rustdoc/synthetic_auto/basic.rs +++ b/src/test/rustdoc/synthetic_auto/basic.rs @@ -1,6 +1,6 @@ // @has basic/struct.Foo.html -// @has - '//h3[@class="code-header in-band"]' 'impl<T> Send for Foo<T> where T: Send' -// @has - '//h3[@class="code-header in-band"]' 'impl<T> Sync for Foo<T> where T: Sync' +// @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send' +// @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync' // @count - '//*[@id="implementations-list"]//*[@class="impl has-srclink"]' 0 // @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]' 5 pub struct Foo<T> { diff --git a/src/test/rustdoc/synthetic_auto/complex.rs b/src/test/rustdoc/synthetic_auto/complex.rs index f9017b90c..43393c21f 100644 --- a/src/test/rustdoc/synthetic_auto/complex.rs +++ b/src/test/rustdoc/synthetic_auto/complex.rs @@ -20,8 +20,8 @@ mod foo { } // @has complex/struct.NotOuter.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'a, T, K: ?Sized> Send for Outer<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'a, T, K: ?Sized> Send for Outer<'a, T, K>where K: for<'b> Fn((&'b bool, &'a u8)) \ // -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static" pub use foo::{Foo, Inner as NotInner, MyTrait as NotMyTrait, Outer as NotOuter}; diff --git a/src/test/rustdoc/synthetic_auto/crate-local.rs b/src/test/rustdoc/synthetic_auto/crate-local.rs index 58b787dfa..ed01f63f9 100644 --- a/src/test/rustdoc/synthetic_auto/crate-local.rs +++ b/src/test/rustdoc/synthetic_auto/crate-local.rs @@ -3,7 +3,7 @@ pub auto trait Banana {} // @has crate_local/struct.Peach.html -// @has - '//h3[@class="code-header in-band"]' 'impl Banana for Peach' -// @has - '//h3[@class="code-header in-band"]' 'impl Send for Peach' -// @has - '//h3[@class="code-header in-band"]' 'impl Sync for Peach' +// @has - '//h3[@class="code-header"]' 'impl Banana for Peach' +// @has - '//h3[@class="code-header"]' 'impl Send for Peach' +// @has - '//h3[@class="code-header"]' 'impl Sync for Peach' pub struct Peach; diff --git a/src/test/rustdoc/synthetic_auto/lifetimes.rs b/src/test/rustdoc/synthetic_auto/lifetimes.rs index ee1393f97..33170a844 100644 --- a/src/test/rustdoc/synthetic_auto/lifetimes.rs +++ b/src/test/rustdoc/synthetic_auto/lifetimes.rs @@ -9,11 +9,11 @@ where {} // @has lifetimes/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'c, K> Send for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Send for Foo<'c, K>where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'c, K> Sync for Foo<'c, K> where K: Sync" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Sync for Foo<'c, K>where K: Sync" pub struct Foo<'c, K: 'c> { inner_field: Inner<'c, K>, } diff --git a/src/test/rustdoc/synthetic_auto/manual.rs b/src/test/rustdoc/synthetic_auto/manual.rs index 49bad1622..77c04ad2a 100644 --- a/src/test/rustdoc/synthetic_auto/manual.rs +++ b/src/test/rustdoc/synthetic_auto/manual.rs @@ -1,8 +1,8 @@ // @has manual/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// 'impl<T> Sync for Foo<T> where T: Sync' +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl<T> Sync for Foo<T>where T: Sync' // -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // 'impl<T> Send for Foo<T>' // // @count - '//*[@id="trait-implementations-list"]//*[@class="impl has-srclink"]' 1 diff --git a/src/test/rustdoc/synthetic_auto/negative.rs b/src/test/rustdoc/synthetic_auto/negative.rs index 66e749ac3..2c2c848a5 100644 --- a/src/test/rustdoc/synthetic_auto/negative.rs +++ b/src/test/rustdoc/synthetic_auto/negative.rs @@ -3,10 +3,10 @@ pub struct Inner<T: Copy> { } // @has negative/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Send for Outer<T>" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl<T> !Sync for Outer<T>" pub struct Outer<T: Copy> { inner_field: Inner<T>, diff --git a/src/test/rustdoc/synthetic_auto/nested.rs b/src/test/rustdoc/synthetic_auto/nested.rs index 69edbee61..423bf115a 100644 --- a/src/test/rustdoc/synthetic_auto/nested.rs +++ b/src/test/rustdoc/synthetic_auto/nested.rs @@ -9,11 +9,11 @@ where } // @has nested/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// 'impl<T> Send for Foo<T> where T: Copy' +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl<T> Send for Foo<T>where T: Copy' // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// 'impl<T> Sync for Foo<T> where T: Sync' +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// 'impl<T> Sync for Foo<T>where T: Sync' pub struct Foo<T> { inner_field: Inner<T>, } diff --git a/src/test/rustdoc/synthetic_auto/no-redundancy.rs b/src/test/rustdoc/synthetic_auto/no-redundancy.rs index 16ab876e8..59f336233 100644 --- a/src/test/rustdoc/synthetic_auto/no-redundancy.rs +++ b/src/test/rustdoc/synthetic_auto/no-redundancy.rs @@ -9,8 +9,8 @@ where } // @has no_redundancy/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<T> Send for Outer<T> where T: Send + Copy" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<T> Send for Outer<T>where T: Send + Copy" pub struct Outer<T> { inner_field: Inner<T>, } diff --git a/src/test/rustdoc/synthetic_auto/overflow.rs b/src/test/rustdoc/synthetic_auto/overflow.rs index c132ab6fb..35a487c76 100644 --- a/src/test/rustdoc/synthetic_auto/overflow.rs +++ b/src/test/rustdoc/synthetic_auto/overflow.rs @@ -21,7 +21,7 @@ enum TyData<I: Interner> { struct VariableKind<I: Interner>(I::InternedType); // @has overflow/struct.BoundVarsCollector.html -// @has - '//h3[@class="code-header in-band"]' "impl<'tcx> Send for BoundVarsCollector<'tcx>" +// @has - '//h3[@class="code-header"]' "impl<'tcx> Send for BoundVarsCollector<'tcx>" pub struct BoundVarsCollector<'tcx> { val: VariableKind<RustInterner<'tcx>> } diff --git a/src/test/rustdoc/synthetic_auto/project.rs b/src/test/rustdoc/synthetic_auto/project.rs index 8b0205825..558ff2add 100644 --- a/src/test/rustdoc/synthetic_auto/project.rs +++ b/src/test/rustdoc/synthetic_auto/project.rs @@ -23,11 +23,11 @@ where } // @has project/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'c, K> Send for Foo<'c, K> where K: MyTrait<MyItem = bool>, 'c: 'static" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Send for Foo<'c, K>where K: MyTrait<MyItem = bool>, 'c: 'static" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<'c, K> Sync for Foo<'c, K> where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, \ +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<'c, K> Sync for Foo<'c, K>where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, \ // 'c: 'static," pub struct Foo<'c, K: 'c> { inner_field: Inner<'c, K>, diff --git a/src/test/rustdoc/synthetic_auto/self-referential.rs b/src/test/rustdoc/synthetic_auto/self-referential.rs index ccef901b1..c6ae96de7 100644 --- a/src/test/rustdoc/synthetic_auto/self-referential.rs +++ b/src/test/rustdoc/synthetic_auto/self-referential.rs @@ -23,7 +23,7 @@ impl<T> Pattern for Wrapper<T> { // @has self_referential/struct.WriteAndThen.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<P1> Send for WriteAndThen<P1> where <P1 as Pattern>::Value: Send" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<P1> Send for WriteAndThen<P1>where <P1 as Pattern>::Value: Send" pub struct WriteAndThen<P1>(pub P1::Value,pub <Constrain<P1, Wrapper<P1::Value>> as Pattern>::Value) where P1: Pattern; diff --git a/src/test/rustdoc/synthetic_auto/static-region.rs b/src/test/rustdoc/synthetic_auto/static-region.rs index 36e985144..1a76cb919 100644 --- a/src/test/rustdoc/synthetic_auto/static-region.rs +++ b/src/test/rustdoc/synthetic_auto/static-region.rs @@ -3,8 +3,8 @@ pub trait OwnedTrait<'a> { } // @has static_region/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<T> Send for Owned<T> where <T as OwnedTrait<'static>>::Reader: Send" +// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<T> Send for Owned<T>where <T as OwnedTrait<'static>>::Reader: Send" pub struct Owned<T> where T: OwnedTrait<'static> { marker: <T as OwnedTrait<'static>>::Reader, } diff --git a/src/test/rustdoc/table-in-docblock.rs b/src/test/rustdoc/table-in-docblock.rs index 858b58919..194f49f16 100644 --- a/src/test/rustdoc/table-in-docblock.rs +++ b/src/test/rustdoc/table-in-docblock.rs @@ -2,7 +2,7 @@ // @has foo/struct.Foo.html // @count - '//*[@class="docblock"]/div/table' 2 -// @!has - '//*[@class="docblock"]/table' +// @!has - '//*[@class="docblock"]/table' '' /// | hello | hello2 | /// | ----- | ------ | /// | data | data2 | diff --git a/src/test/rustdoc/toggle-item-contents.rs b/src/test/rustdoc/toggle-item-contents.rs index c1df4613e..47a1d62f5 100644 --- a/src/test/rustdoc/toggle-item-contents.rs +++ b/src/test/rustdoc/toggle-item-contents.rs @@ -55,14 +55,14 @@ pub union Union { // @has 'toggle_item_contents/struct.PrivStruct.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0 -// @has - '//div[@class="docblock item-decl"]' '/* private fields */' +// @has - '//div[@class="item-decl"]' '/* private fields */' pub struct PrivStruct { a: usize, b: usize, } // @has 'toggle_item_contents/enum.Enum.html' -// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' +// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' '' pub enum Enum { A, B, C, D { @@ -72,7 +72,7 @@ pub enum Enum { } // @has 'toggle_item_contents/enum.EnumStructVariant.html' -// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' +// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' '' pub enum EnumStructVariant { A, B, C, D { diff --git a/src/test/rustdoc/toggle-trait-fn.rs b/src/test/rustdoc/toggle-trait-fn.rs index 65e8daeb0..e41422ce7 100644 --- a/src/test/rustdoc/toggle-trait-fn.rs +++ b/src/test/rustdoc/toggle-trait-fn.rs @@ -4,12 +4,12 @@ // summary. Trait methods with no documentation should not be wrapped. // // @has foo/trait.Foo.html -// @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' -// @!has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' -// @has - '//details[@class="rustdoc-toggle"]//*[@class="docblock"]' 'is_documented is documented' -// @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()' -// @!has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()' -// @has - '//details[@class="rustdoc-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented' +// @has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' +// @!has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' +// @has - '//details[@class="rustdoc-toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented' +// @has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()' +// @!has - '//details[@class="rustdoc-toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()' +// @has - '//details[@class="rustdoc-toggle method-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented' pub trait Foo { fn not_documented(); diff --git a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs index b5a97c610..fba594c38 100644 --- a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs +++ b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs @@ -59,7 +59,7 @@ pub struct MyStruct; // We check that associated items with default values aren't generated in the implementors list. impl MyTrait for (u8, u8) { - // @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' + // @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' type Assoc = bool; fn trait_function(&self) {} } diff --git a/src/test/rustdoc/trait-impl.rs b/src/test/rustdoc/trait-impl.rs index 4f7e2dfe3..195cdf009 100644 --- a/src/test/rustdoc/trait-impl.rs +++ b/src/test/rustdoc/trait-impl.rs @@ -21,26 +21,26 @@ pub trait Trait { pub struct Struct; impl Trait for Struct { - // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'Some long docs' - // @!has - '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'link will be added' - // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a' 'Read more' - // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.a' + // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' + // @!has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' + // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' + // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' fn a() {} - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p' 'These docs contain' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'reference link' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'https://example.com' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'Read more' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.b' + // @has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' + // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' + // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' + // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'Read more' + // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.b' fn b() {} - // @!has - '//*[@id="method.c"]/../../div[@class="docblock"]/p' 'code block' + // @!has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' fn c() {} - // @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works' - // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' + // @has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' + // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' fn d() {} // @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' diff --git a/src/test/rustdoc/trait_alias.rs b/src/test/rustdoc/trait_alias.rs index a0c657d9a..791c099cc 100644 --- a/src/test/rustdoc/trait_alias.rs +++ b/src/test/rustdoc/trait_alias.rs @@ -14,13 +14,13 @@ use std::fmt::Debug; // @has foo/index.html '//a[@class="traitalias"]' 'Foo' // @has foo/traitalias.CopyAlias.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait CopyAlias = Copy;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait CopyAlias = Copy;' pub trait CopyAlias = Copy; // @has foo/traitalias.Alias2.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait Alias2 = Copy + Debug;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait Alias2 = Copy + Debug;' pub trait Alias2 = Copy + Debug; // @has foo/traitalias.Foo.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait Foo<T> = Into<T> + Debug;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait Foo<T> = Into<T> + Debug;' pub trait Foo<T> = Into<T> + Debug; // @has foo/fn.bar.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' pub fn bar<T>() where T: Alias2 {} diff --git a/src/test/rustdoc/traits-in-bodies.rs b/src/test/rustdoc/traits-in-bodies.rs index 6d450a625..a65dd7a54 100644 --- a/src/test/rustdoc/traits-in-bodies.rs +++ b/src/test/rustdoc/traits-in-bodies.rs @@ -4,7 +4,7 @@ pub struct Bounded<T: Clone>(T); // @has traits_in_bodies/struct.SomeStruct.html -// @has - '//h3[@class="code-header in-band"]' 'impl Clone for SomeStruct' +// @has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' pub struct SomeStruct; fn asdf() -> Bounded<SomeStruct> { @@ -18,7 +18,7 @@ fn asdf() -> Bounded<SomeStruct> { } // @has traits_in_bodies/struct.Point.html -// @has - '//h3[@class="code-header in-band"]' 'impl Copy for Point' +// @has - '//h3[@class="code-header"]' 'impl Copy for Point' #[derive(Clone)] pub struct Point { x: i32, @@ -31,7 +31,7 @@ const _FOO: () = { }; // @has traits_in_bodies/struct.Inception.html -// @has - '//h3[@class="code-header in-band"]' 'impl Clone for Inception' +// @has - '//h3[@class="code-header"]' 'impl Clone for Inception' pub struct Inception; static _BAR: usize = { diff --git a/src/test/rustdoc/tuple-struct-fields-doc.rs b/src/test/rustdoc/tuple-struct-fields-doc.rs index 31426131b..8ab1143d1 100644 --- a/src/test/rustdoc/tuple-struct-fields-doc.rs +++ b/src/test/rustdoc/tuple-struct-fields-doc.rs @@ -2,10 +2,10 @@ // @has foo/struct.Foo.html // @has - '//h2[@id="fields"]' 'Tuple Fields' -// @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Tuple Fields' // @has - '//*[@id="structfield.0"]' '0: u32' // @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello' -// @!has - '//*[@id="structfield.1"]' +// @!has - '//*[@id="structfield.1"]' '' // @has - '//*[@id="structfield.2"]' '2: char' // @has - '//*[@id="structfield.3"]' '3: i8' // @has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello' diff --git a/src/test/rustdoc/type-layout-flag-required.rs b/src/test/rustdoc/type-layout-flag-required.rs index a01fbd229..6bb5e10f8 100644 --- a/src/test/rustdoc/type-layout-flag-required.rs +++ b/src/test/rustdoc/type-layout-flag-required.rs @@ -1,4 +1,4 @@ // Tests that `--show-type-layout` is required in order to show layout info. -// @!has type_layout_flag_required/struct.Foo.html 'Size: ' +// @!hasraw type_layout_flag_required/struct.Foo.html 'Size: ' pub struct Foo(usize); diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index e5c6e9dc3..5e0a0411a 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -1,84 +1,84 @@ // compile-flags: --show-type-layout -Z unstable-options -// @has type_layout/struct.Foo.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/struct.Foo.html 'Size: ' +// @hasraw - ' bytes' // @has - '//*[@id="layout"]/a[@href="#layout"]' '' pub struct Foo { pub a: usize, b: Vec<String>, } -// @has type_layout/enum.Bar.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/enum.Bar.html 'Size: ' +// @hasraw - ' bytes' pub enum Bar<'a> { A(String), B(&'a str, (std::collections::HashMap<String, usize>, Foo)), } -// @has type_layout/union.Baz.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/union.Baz.html 'Size: ' +// @hasraw - ' bytes' pub union Baz { a: &'static str, b: usize, c: &'static [u8], } -// @has type_layout/struct.X.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/struct.X.html 'Size: ' +// @hasraw - ' bytes' pub struct X(usize); -// @has type_layout/struct.Y.html 'Size: ' -// @has - '1 byte' -// @!has - ' bytes' +// @hasraw type_layout/struct.Y.html 'Size: ' +// @hasraw - '1 byte' +// @!hasraw - ' bytes' pub struct Y(u8); -// @has type_layout/struct.Z.html 'Size: ' -// @has - '0 bytes' +// @hasraw type_layout/struct.Z.html 'Size: ' +// @hasraw - '0 bytes' pub struct Z; // We can't compute layout for generic types. -// @has type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters' -// @!has - 'Size: ' +// @hasraw type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters' +// @!hasraw - 'Size: ' pub struct Generic<T>(T); // We *can*, however, compute layout for types that are only generic over lifetimes, // because lifetimes are a type-system construct. -// @has type_layout/struct.GenericLifetimes.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/struct.GenericLifetimes.html 'Size: ' +// @hasraw - ' bytes' pub struct GenericLifetimes<'a>(&'a str); -// @has type_layout/struct.Unsized.html 'Size: ' -// @has - '(unsized)' +// @hasraw type_layout/struct.Unsized.html 'Size: ' +// @hasraw - '(unsized)' pub struct Unsized([u8]); -// @has type_layout/type.TypeAlias.html 'Size: ' -// @has - ' bytes' +// @hasraw type_layout/type.TypeAlias.html 'Size: ' +// @hasraw - ' bytes' pub type TypeAlias = X; -// @has type_layout/type.GenericTypeAlias.html 'Size: ' -// @has - '8 bytes' +// @hasraw type_layout/type.GenericTypeAlias.html 'Size: ' +// @hasraw - '8 bytes' pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>); // Regression test for the rustdoc equivalent of #85103. -// @has type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' +// @hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>; -// @!has type_layout/trait.MyTrait.html 'Size: ' +// @!hasraw type_layout/trait.MyTrait.html 'Size: ' pub trait MyTrait {} -// @has type_layout/enum.Variants.html 'Size: ' -// @has - '2 bytes' -// @has - '<code>A</code>: 0 bytes' -// @has - '<code>B</code>: 1 byte' +// @hasraw type_layout/enum.Variants.html 'Size: ' +// @hasraw - '2 bytes' +// @hasraw - '<code>A</code>: 0 bytes' +// @hasraw - '<code>B</code>: 1 byte' pub enum Variants { A, B(u8), } -// @has type_layout/enum.WithNiche.html 'Size: ' +// @hasraw type_layout/enum.WithNiche.html 'Size: ' // @has - //p '4 bytes' -// @has - '<code>None</code>: 0 bytes' -// @has - '<code>Some</code>: 4 bytes' +// @hasraw - '<code>None</code>: 0 bytes' +// @hasraw - '<code>Some</code>: 4 bytes' pub enum WithNiche { None, Some(std::num::NonZeroU32), diff --git a/src/test/rustdoc/typedef.rs b/src/test/rustdoc/typedef.rs index 4ecd62cde..d5dfa9484 100644 --- a/src/test/rustdoc/typedef.rs +++ b/src/test/rustdoc/typedef.rs @@ -9,9 +9,9 @@ impl MyStruct { } // @has typedef/type.MyAlias.html -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'impl MyAlias' -// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' 'impl MyTrait for MyAlias' -// @has - 'Alias docstring' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'impl MyAlias' +// @has - '//*[@class="impl has-srclink"]//h3[@class="code-header"]' 'impl MyTrait for MyAlias' +// @hasraw - 'Alias docstring' // @has - '//*[@class="sidebar"]//*[@class="location"]' 'MyAlias' // @has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Methods' // @has - '//*[@class="sidebar"]//a[@href="#trait-implementations"]' 'Trait Implementations' diff --git a/src/test/rustdoc/universal-impl-trait.rs b/src/test/rustdoc/universal-impl-trait.rs index b10b1b865..f5eabda59 100644 --- a/src/test/rustdoc/universal-impl-trait.rs +++ b/src/test/rustdoc/universal-impl-trait.rs @@ -5,15 +5,15 @@ use std::borrow::Borrow; // @has foo/fn.foo.html // @has - //pre 'foo(' -// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"' -// @matches - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html' +// @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"' +// @matchesraw - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html' pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) { } pub trait Trait { // @has foo/trait.Trait.html - // @has - 'method</a>(' - // @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' + // @hasraw - 'method</a>(' + // @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' fn method(&self, _x: impl std::fmt::Debug) { } } @@ -22,30 +22,30 @@ pub struct S<T>(T); impl<T> S<T> { // @has foo/struct.S.html - // @has - 'bar</a>(' - // @matches - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"' + // @hasraw - 'bar</a>(' + // @matchesraw - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"' pub fn bar(_bar: impl Copy) { } - // @has - 'baz</a>(' - // @matches - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' + // @hasraw - 'baz</a>(' + // @matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' pub fn baz(_baz: S<impl Clone>) { } - // @has - 'qux</a>(' - // @matches - 'trait\.Read\.html' + // @hasraw - 'qux</a>(' + // @matchesraw - 'trait\.Read\.html' pub fn qux(_qux: impl IntoIterator<Item = S<impl Read>>) { } } -// @has - 'method</a>(' -// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' +// @hasraw - 'method</a>(' +// @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' impl<T> Trait for S<T> {} // @has foo/fn.much_universe.html -// @matches - 'T:.+Borrow.+impl .+trait\.Trait\.html' -// @matches - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' -// @matches - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' +// @matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' +// @matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' +// @matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' pub fn much_universe< T: Borrow<impl Trait>, U: IntoIterator<Item = impl Iterator<Item = impl Clone>>, diff --git a/src/test/rustdoc/version-separator-without-source.rs b/src/test/rustdoc/version-separator-without-source.rs index ae866deba..04ea46a7f 100644 --- a/src/test/rustdoc/version-separator-without-source.rs +++ b/src/test/rustdoc/version-separator-without-source.rs @@ -16,7 +16,7 @@ pub fn foo() {} pub struct Bar; impl Bar { - // @has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0' + // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0' // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0 ยท' #[stable(feature = "foobar", since = "2.0")] pub fn bar() {} diff --git a/src/test/rustdoc/where-clause-order.rs b/src/test/rustdoc/where-clause-order.rs index 3150a8ea0..b8502e10a 100644 --- a/src/test/rustdoc/where-clause-order.rs +++ b/src/test/rustdoc/where-clause-order.rs @@ -7,7 +7,7 @@ where } // @has 'foo/trait.SomeTrait.html' -// @has - "//*[@id='impl-SomeTrait%3C(A%2C%20B%2C%20C%2C%20D%2C%20E)%3E-for-(A%2C%20B%2C%20C%2C%20D%2C%20E)']/h3" "impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E) where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " +// @has - "//*[@id='impl-SomeTrait%3C(A%2C%20B%2C%20C%2C%20D%2C%20E)%3E-for-(A%2C%20B%2C%20C%2C%20D%2C%20E)']/h3" "impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E) where A: PartialOrd<A> + PartialEq<A>, diff --git a/src/test/rustdoc/where.SWhere_Simd_item-decl.html b/src/test/rustdoc/where.SWhere_Simd_item-decl.html index 0133bcaeb..6c1b5d315 100644 --- a/src/test/rustdoc/where.SWhere_Simd_item-decl.html +++ b/src/test/rustdoc/where.SWhere_Simd_item-decl.html @@ -1 +1 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Simd<T>(_) <br /><span class="where">where<br />    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre></div>
\ No newline at end of file +<div class="item-decl"><pre class="rust struct"><code>pub struct Simd<T>(_)<br /><span class="where">where<br />    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html index 54026ff03..24ab77703 100644 --- a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html +++ b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html @@ -1,3 +1,8 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait TraitWhere { - type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />    <span class="where">where<br />        Self: 'a</span>; +<div class="item-decl"><pre class="rust trait"><code>pub trait TraitWhere { + type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />    <span class="where">where<br />        Self: 'a</span>; + + fn <a href="#method.func" class="fnname">func</a>(self)<br />    <span class="where">where<br />        Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>, + { ... } +<span class="item-spacer" /> fn <a href="#method.lines" class="fnname">lines</a>(self) -> <a class="struct" href="{{channel}}/std/io/struct.Lines.html" title="struct std::io::Lines">Lines</a><Self><br />    <span class="where">where<br />        Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>, + { ... } }</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs index 50a5722fb..8b5bce28f 100644 --- a/src/test/rustdoc/where.rs +++ b/src/test/rustdoc/where.rs @@ -1,19 +1,20 @@ -#![feature(generic_associated_types)] #![crate_name = "foo"] +use std::io::Lines; + pub trait MyTrait { fn dummy(&self) { } } -// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait" +// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_)where A: MyTrait" pub struct Alpha<A>(A) where A: MyTrait; -// @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait" +// @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait" pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); } -// @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait" +// @has foo/fn.charlie.html '//pre' "pub fn charlie<C>()where C: MyTrait" pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>(D); -// @has foo/struct.Delta.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<D> Delta<D> where D: MyTrait" +// @has foo/struct.Delta.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<D> Delta<D>where D: MyTrait" impl<D> Delta<D> where D: MyTrait { pub fn delta() {} } @@ -21,31 +22,41 @@ impl<D> Delta<D> where D: MyTrait { pub struct Echo<E>(E); // @has 'foo/struct.Simd.html' -// @snapshot SWhere_Simd_item-decl - '//div[@class="docblock item-decl"]' +// @snapshot SWhere_Simd_item-decl - '//div[@class="item-decl"]' pub struct Simd<T>([T; 1]) where T: MyTrait; // @has 'foo/trait.TraitWhere.html' -// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="docblock item-decl"]' +// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="item-decl"]' pub trait TraitWhere { type Item<'a> where Self: 'a; + + fn func(self) + where + Self: Sized + {} + + fn lines(self) -> Lines<Self> + where + Self: Sized, + { todo!() } } -// @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<E> MyTrait for Echo<E> where E: MyTrait" -// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header in-band"]' \ -// "impl<E> MyTrait for Echo<E> where E: MyTrait" -impl<E> MyTrait for Echo<E> where E: MyTrait {} +// @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<E> MyTrait for Echo<E>where E: MyTrait" +// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<E> MyTrait for Echo<E>where E: MyTrait" +impl<E> MyTrait for Echo<E>where E: MyTrait {} pub enum Foxtrot<F> { Foxtrot1(F) } -// @has foo/enum.Foxtrot.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl<F> MyTrait for Foxtrot<F> where F: MyTrait" -// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header in-band"]' \ -// "impl<F> MyTrait for Foxtrot<F> where F: MyTrait" -impl<F> MyTrait for Foxtrot<F> where F: MyTrait {} +// @has foo/enum.Foxtrot.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ +// "impl<F> MyTrait for Foxtrot<F>where F: MyTrait" +// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +// "impl<F> MyTrait for Foxtrot<F>where F: MyTrait" +impl<F> MyTrait for Foxtrot<F>where F: MyTrait {} // @has foo/type.Golf.html '//pre[@class="rust typedef"]' \ -// "type Golf<T> where T: Clone, = (T, T)" +// "type Golf<T>where T: Clone, = (T, T)" pub type Golf<T> where T: Clone = (T, T); diff --git a/src/test/rustdoc/whitespace-after-where-clause.enum.html b/src/test/rustdoc/whitespace-after-where-clause.enum.html index 9e5bf45ae..c74866f4a 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.enum.html +++ b/src/test/rustdoc/whitespace-after-where-clause.enum.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust enum"><code>pub enum Cow<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.enum2.html b/src/test/rustdoc/whitespace-after-where-clause.enum2.html index 6bc47beae..ac7d77598 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.enum2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust enum"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.rs b/src/test/rustdoc/whitespace-after-where-clause.rs index c36386a2a..4b740b970 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.rs +++ b/src/test/rustdoc/whitespace-after-where-clause.rs @@ -4,7 +4,7 @@ #![crate_name = "foo"] // @has 'foo/trait.ToOwned.html' -// @snapshot trait - '//*[@class="docblock item-decl"]' +// @snapshot trait - '//*[@class="item-decl"]' pub trait ToOwned<T> where T: Clone { @@ -14,7 +14,7 @@ where T: Clone } // @has 'foo/trait.ToOwned2.html' -// @snapshot trait2 - '//*[@class="docblock item-decl"]' +// @snapshot trait2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub trait ToOwned2<T: Clone> { type Owned; @@ -23,7 +23,7 @@ pub trait ToOwned2<T: Clone> { } // @has 'foo/enum.Cow.html' -// @snapshot enum - '//*[@class="docblock item-decl"]' +// @snapshot enum - '//*[@class="item-decl"]' pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -33,7 +33,7 @@ where } // @has 'foo/enum.Cow2.html' -// @snapshot enum2 - '//*[@class="docblock item-decl"]' +// @snapshot enum2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { Borrowed(&'a B), @@ -41,7 +41,7 @@ pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { } // @has 'foo/struct.Struct.html' -// @snapshot struct - '//*[@class="docblock item-decl"]' +// @snapshot struct - '//*[@class="item-decl"]' pub struct Struct<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -51,7 +51,7 @@ where } // @has 'foo/struct.Struct2.html' -// @snapshot struct2 - '//*[@class="docblock item-decl"]' +// @snapshot struct2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { pub a: &'a B, @@ -59,7 +59,7 @@ pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { } // @has 'foo/union.Union.html' -// @snapshot union - '//*[@class="docblock item-decl"]' +// @snapshot union - '//*[@class="item-decl"]' pub union Union<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -69,7 +69,7 @@ where } // @has 'foo/union.Union2.html' -// @snapshot union2 - '//*[@class="docblock item-decl"]' +// @snapshot union2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub union Union2<'a, B: ?Sized + ToOwned<Clone> + 'a> { a: &'a B, diff --git a/src/test/rustdoc/whitespace-after-where-clause.struct.html b/src/test/rustdoc/whitespace-after-where-clause.struct.html index 236cc3b30..1ba1367d2 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.struct.html +++ b/src/test/rustdoc/whitespace-after-where-clause.struct.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust struct"><code>pub struct Struct<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.struct2.html b/src/test/rustdoc/whitespace-after-where-clause.struct2.html index 47f5c6ba9..fb06b0f77 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.struct2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust struct"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait.html b/src/test/rustdoc/whitespace-after-where-clause.trait.html index 98f03b837..16b558237 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait.html @@ -1,6 +1,6 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned<T> <span class="where fmt-newline">where<br />    T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span>{ +<div class="item-decl"><pre class="rust trait"><code>pub trait ToOwned<T><span class="where fmt-newline">where<br />    T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span>{ type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>; fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> Self::<a class="associatedtype" href="trait.ToOwned.html#associatedtype.Owned" title="type foo::ToOwned::Owned">Owned</a>; <span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&self) -> T; -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait2.html b/src/test/rustdoc/whitespace-after-where-clause.trait2.html index 35052869e..eeca6e1f5 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait2.html @@ -1,6 +1,6 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned2<T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> { +<div class="item-decl"><pre class="rust trait"><code>pub trait ToOwned2<T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> { type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>; fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> Self::<a class="associatedtype" href="trait.ToOwned2.html#associatedtype.Owned" title="type foo::ToOwned2::Owned">Owned</a>; <span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&self) -> T; -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.union.html b/src/test/rustdoc/whitespace-after-where-clause.union.html index 97e1bbcf3..0dfb6407d 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.union.html +++ b/src/test/rustdoc/whitespace-after-where-clause.union.html @@ -1,3 +1,3 @@ -<div class="docblock item-decl"><pre class="rust union"><code>pub union Union<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust union"><code>pub union Union<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ /* private fields */ -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.union2.html b/src/test/rustdoc/whitespace-after-where-clause.union2.html index 6c752a8b4..0d237df53 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.union2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.union2.html @@ -1,3 +1,3 @@ -<div class="docblock item-decl"><pre class="rust union"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust union"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { /* private fields */ -}</code></pre></div> +}</code></pre></div>
\ No newline at end of file |