diff options
Diffstat (limited to '')
116 files changed, 1893 insertions, 507 deletions
diff --git a/tests/rustdoc-gui/code-color.goml b/tests/rustdoc-gui/code-color.goml index 833fa05db..92bdfb25b 100644 --- a/tests/rustdoc-gui/code-color.goml +++ b/tests/rustdoc-gui/code-color.goml @@ -19,6 +19,18 @@ define-function: ( }, ) -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)")) +call-function: ("check-colors", { + "theme": "ayu", + "doc_code_color": "#e6e1cf", + "doc_inline_code_color": "#ffb454", +}) +call-function: ("check-colors", { + "theme": "dark", + "doc_code_color": "#ddd", + "doc_inline_code_color": "#ddd", +}) +call-function: ("check-colors", { + "theme": "light", + "doc_code_color": "black", + "doc_inline_code_color": "black", +}) diff --git a/tests/rustdoc-gui/default-settings.goml b/tests/rustdoc-gui/default-settings.goml index 3466f3693..ff4abb65c 100644 --- a/tests/rustdoc-gui/default-settings.goml +++ b/tests/rustdoc-gui/default-settings.goml @@ -5,4 +5,4 @@ go-to: "file://" + |DOC_PATH| + "/settings/index.html" // Wait a bit to be sure the default theme is applied. // If the theme isn't applied, the command will time out. -wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"}) +wait-for-css: ("body", {"background-color": "#0f1419"}) diff --git a/tests/rustdoc-gui/docblock-table.goml b/tests/rustdoc-gui/docblock-table.goml index 011451ef4..678b302f2 100644 --- a/tests/rustdoc-gui/docblock-table.goml +++ b/tests/rustdoc-gui/docblock-table.goml @@ -36,17 +36,17 @@ define-function: ( ) call-function: ("check-colors", { - "theme": "dark", - "border_color": "rgb(224, 224, 224)", - "zebra_stripe_color": "rgb(42, 42, 42)", + "theme": "ayu", + "border_color": "#5c6773", + "zebra_stripe_color": "#191f26", }) call-function: ("check-colors", { - "theme": "ayu", - "border_color": "rgb(92, 103, 115)", - "zebra_stripe_color": "rgb(25, 31, 38)", + "theme": "dark", + "border_color": "#e0e0e0", + "zebra_stripe_color": "#2a2a2a", }) call-function: ("check-colors", { "theme": "light", - "border_color": "rgb(224, 224, 224)", - "zebra_stripe_color": "rgb(245, 245, 245)", + "border_color": "#e0e0e0", + "zebra_stripe_color": "#f5f5f5", }) diff --git a/tests/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml index 6e880302f..84c203555 100644 --- a/tests/rustdoc-gui/help-page.goml +++ b/tests/rustdoc-gui/help-page.goml @@ -33,21 +33,21 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background": "rgb(49, 69, 89)", - "box_shadow": "rgb(92, 103, 115)", + "color": "#c5c5c5", + "background": "#314559", + "box_shadow": "#5c6773", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(0, 0, 0)", - "background": "rgb(250, 251, 252)", - "box_shadow": "rgb(198, 203, 209)", + "color": "#000", + "background": "#fafbfc", + "box_shadow": "#c6cbd1", }) call-function: ("check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "background": "rgb(250, 251, 252)", - "box_shadow": "rgb(198, 203, 209)", + "color": "#000", + "background": "#fafbfc", + "box_shadow": "#c6cbd1", }) // This test ensures that opening the help popover without switching pages works. diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml index 5d1b83b35..aeb3c9b31 100644 --- a/tests/rustdoc-gui/search-corrections.goml +++ b/tests/rustdoc-gui/search-corrections.goml @@ -54,3 +54,53 @@ assert-text: ( ".search-corrections", "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." ) + +// Now, generic correction +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Intentionally wrong spelling of "NotableStructWithLongName" +write: (".search-input", "NotableStructWithLongNamr, NotableStructWithLongNamr") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" + +assert-css: (".search-corrections", { + "display": "block" +}) +assert-text: ( + ".search-corrections", + "Type \"notablestructwithlongnamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." +) + +// Now, generic correction plus error +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Intentionally wrong spelling of "NotableStructWithLongName" +write: (".search-input", "Foo<NotableStructWithLongNamr>,y") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" + +assert-css: (".search-corrections", { + "display": "block" +}) +assert-text: ( + ".search-corrections", + "Type \"notablestructwithlongnamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." +) + +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Intentionally wrong spelling of "NotableStructWithLongName" +write: (".search-input", "generic:NotableStructWithLongNamr<x>,y") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" + +assert-css: (".error", { + "display": "block" +}) +assert-text: ( + ".error", + "Query parser error: \"Generic type parameter notablestructwithlongnamr does not accept generic parameters\"." +) diff --git a/tests/rustdoc-gui/search-no-result.goml b/tests/rustdoc-gui/search-no-result.goml index 46d1856b4..e7c647912 100644 --- a/tests/rustdoc-gui/search-no-result.goml +++ b/tests/rustdoc-gui/search-no-result.goml @@ -21,16 +21,16 @@ define-function: ( call-function: ("check-no-result", { "theme": "ayu", - "link": "rgb(57, 175, 215)", - "link_hover": "rgb(57, 175, 215)", + "link": "#39afd7", + "link_hover": "#39afd7", }) call-function: ("check-no-result", { "theme": "dark", - "link": "rgb(210, 153, 29)", - "link_hover": "rgb(210, 153, 29)", + "link": "#d2991d", + "link_hover": "#d2991d", }) call-function: ("check-no-result", { "theme": "light", - "link": "rgb(56, 115, 173)", - "link_hover": "rgb(56, 115, 173)", + "link": "#3873ad", + "link_hover": "#3873ad", }) diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index f9f81c5ba..44677dfbf 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -151,7 +151,7 @@ assert-css: ( ) assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", - {"color": "#fff", "background-color": "rgb(60, 60, 60)"}, + {"color": "#fff", "background-color": "#3c3c3c"}, ) // Dark theme diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml index 7bbde3ec2..427201e1b 100644 --- a/tests/rustdoc-gui/search-tab.goml +++ b/tests/rustdoc-gui/search-tab.goml @@ -1,5 +1,5 @@ // Checking the colors of the search tab headers. -go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=something" +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo" show-text: true define-function: ( @@ -74,3 +74,87 @@ call-function: ("check-colors", { "border_top_selected": "2px solid #0089ff", "border_top_hover": "2px solid #0089ff", }) + +// set size wide enough that the text is in a single row +set-window-size: (851, 600) + +// Check the size and count in tabs +assert-text: ("#search-tabs > button:nth-child(1) > .count", " (23) ") +assert-text: ("#search-tabs > button:nth-child(2) > .count", " (4) ") +assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0) ") +store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth}) +assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|}) +assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|}) +store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth}) +assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|}) +assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|}) + +// Check that counts are in a row with each other +compare-elements-position: ( + "#search-tabs > button:nth-child(1) > .count", + "#search-tabs > button:nth-child(2) > .count", + ("y") +) +compare-elements-position: ( + "#search-tabs > button:nth-child(2) > .count", + "#search-tabs > button:nth-child(3) > .count", + ("y") +) +// Check that counts are beside the titles and haven't wrapped +compare-elements-position-near: ( + "#search-tabs > button:nth-child(1)", + "#search-tabs > button:nth-child(1) > .count", + {"y": 8} +) +compare-elements-position-near: ( + "#search-tabs > button:nth-child(2)", + "#search-tabs > button:nth-child(2) > .count", + {"y": 8} +) +compare-elements-position-near: ( + "#search-tabs > button:nth-child(2)", + "#search-tabs > button:nth-child(2) > .count", + {"y": 8} +) + +// Set size narrow enough that they wrap. +// When I tested it, it wrapped at 811px, but I added some fudge factor to ensure it +// doesn't prematurely wrap with slightly different font kerning or whatever, with a +// @media query +set-window-size: (850, 600) + +// all counts and buttons still have same size +store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth}) +assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|}) +assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|}) +store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth}) +assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|}) +assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|}) + +// Check that counts are still in a row with each other +compare-elements-position: ( + "#search-tabs > button:nth-child(1) > .count", + "#search-tabs > button:nth-child(2) > .count", + ("y") +) +compare-elements-position: ( + "#search-tabs > button:nth-child(2) > .count", + "#search-tabs > button:nth-child(3) > .count", + ("y") +) +// Check that counts are NOT beside the titles; now they have wrapped +compare-elements-position-near-false: ( + "#search-tabs > button:nth-child(1)", + "#search-tabs > button:nth-child(1) > .count", + {"y": 8} +) +compare-elements-position-near-false: ( + "#search-tabs > button:nth-child(2)", + "#search-tabs > button:nth-child(2) > .count", + {"y": 8} +) +compare-elements-position-near-false: ( + "#search-tabs > button:nth-child(2)", + "#search-tabs > button:nth-child(2) > .count", + {"y": 8} +) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 69c589741..92b9045b7 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 9) +assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 10) // We now switch to mobile mode. set-window-size: (600, 600) diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 574cc629a..520481d3b 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -25,24 +25,24 @@ call-function: ( "check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background_color": "rgb(20, 25, 31)", + "color": "#c5c5c5", + "background_color": "#14191f", } ) call-function: ( "check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "background_color": "rgb(80, 80, 80)", + "color": "#ddd", + "background_color": "#505050", } ) call-function: ( "check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "background_color": "rgb(245, 245, 245)", + "color": "black", + "background_color": "#f5f5f5", } ) @@ -55,7 +55,7 @@ assert-text: (".sidebar > .location", "Crate test_docs") 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)"}) +assert-css: ("#all-types", {"color": "#356da4"}) // We check that we have the crates list and that the "current" on is "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. @@ -67,7 +67,7 @@ assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums") 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(9)", "Type Aliases") 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-name > a", "Foo") @@ -88,7 +88,7 @@ assert-property: ("html", {"scrollTop": "0"}) // We now go back to the crate page to click on the "lib2" crate link. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) -assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"}) +assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "#356da4"}) click: ".sidebar-elems ul.crate > li:first-child > a" // PAGE: lib2/index.html @@ -102,7 +102,7 @@ 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: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Aliases") assert-text: ("#functions + .item-table .item-name > a", "foobar") click: "#functions + .item-table .item-name > a" @@ -140,7 +140,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-property: (".sidebar", {"clientWidth": "200"}) click: "//ul[@class='block mod']/preceding-sibling::h3/a" // PAGE: index.html -assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"}) +assert-css: ("#modules", {"background-color": "#fdffd3"}) // Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width. click: "#toggle-all-docs" diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 49484ee08..38180aef7 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -65,6 +65,18 @@ impl Foo { pub fn must_use(&self) -> bool { true } + + /// hello + /// + /// <div id="doc-warning-1" class="warning">this is a warning</div> + /// + /// done + pub fn warning1() {} + + /// Checking there is no bottom margin if "warning" is the last element. + /// + /// <div id="doc-warning-2" class="warning">this is a warning</div> + pub fn warning2() {} } impl AsRef<str> for Foo { diff --git a/tests/rustdoc-gui/src/theme_css/Cargo.lock b/tests/rustdoc-gui/src/theme_css/Cargo.lock new file mode 100644 index 000000000..7ad6737a4 --- /dev/null +++ b/tests/rustdoc-gui/src/theme_css/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "theme_css" +version = "0.1.0" diff --git a/tests/rustdoc-gui/src/theme_css/Cargo.toml b/tests/rustdoc-gui/src/theme_css/Cargo.toml new file mode 100644 index 000000000..798e64f93 --- /dev/null +++ b/tests/rustdoc-gui/src/theme_css/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "theme_css" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/tests/rustdoc-gui/src/theme_css/custom-theme.css b/tests/rustdoc-gui/src/theme_css/custom-theme.css new file mode 100644 index 000000000..260ef87f6 --- /dev/null +++ b/tests/rustdoc-gui/src/theme_css/custom-theme.css @@ -0,0 +1,99 @@ +:root { + --main-background-color: red; + --main-color: black; + --settings-input-color: #2196f3; + --settings-input-border-color: #717171; + --settings-button-color: #000; + --settings-button-border-focus: #717171; + --sidebar-background-color: #f5f5f5; + --sidebar-background-color-hover: #e0e0e0; + --code-block-background-color: #f5f5f5; + --scrollbar-track-background-color: #dcdcdc; + --scrollbar-thumb-background-color: rgba(36, 37, 39, 0.6); + --scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9; + --headings-border-bottom-color: #ddd; + --border-color: #e0e0e0; + --button-background-color: #fff; + --right-side-color: grey; + --code-attribute-color: #999; + --toggles-color: #999; + --toggle-filter: none; + --search-input-focused-border-color: #66afe9; + --copy-path-button-color: #999; + --copy-path-img-filter: invert(50%); + --copy-path-img-hover-filter: invert(35%); + --codeblock-error-hover-color: rgb(255, 0, 0); + --codeblock-error-color: rgba(255, 0, 0, .5); + --codeblock-ignore-hover-color: rgb(255, 142, 0); + --codeblock-ignore-color: rgba(255, 142, 0, .6); + --warning-border-color: #ff8e00; + --type-link-color: #ad378a; + --trait-link-color: #6e4fc9; + --assoc-item-link-color: #3873ad; + --function-link-color: #ad7c37; + --macro-link-color: #068000; + --keyword-link-color: #3873ad; + --mod-link-color: #3873ad; + --link-color: #3873ad; + --sidebar-link-color: #356da4; + --sidebar-current-link-background-color: #fff; + --search-result-link-focus-background-color: #ccc; + --search-result-border-color: #aaa3; + --search-color: #000; + --search-error-code-background-color: #d0cccc; + --search-results-alias-color: #000; + --search-results-grey-color: #999; + --search-tab-title-count-color: #888; + --search-tab-button-not-selected-border-top-color: #e6e6e6; + --search-tab-button-not-selected-background: #e6e6e6; + --search-tab-button-selected-border-top-color: #0089ff; + --search-tab-button-selected-background: #fff; + --stab-background-color: #fff5d6; + --stab-code-color: #000; + --code-highlight-kw-color: #8959a8; + --code-highlight-kw-2-color: #4271ae; + --code-highlight-lifetime-color: #b76514; + --code-highlight-prelude-color: #4271ae; + --code-highlight-prelude-val-color: #c82829; + --code-highlight-number-color: #718c00; + --code-highlight-string-color: #718c00; + --code-highlight-literal-color: #c82829; + --code-highlight-attribute-color: #c82829; + --code-highlight-self-color: #c82829; + --code-highlight-macro-color: #3e999f; + --code-highlight-question-mark-color: #ff9011; + --code-highlight-comment-color: #8e908c; + --code-highlight-doc-comment-color: #4d4d4c; + --src-line-numbers-span-color: #c67e2d; + --src-line-number-highlighted-background-color: #fdffd3; + --test-arrow-color: #f5f5f5; + --test-arrow-background-color: rgba(78, 139, 202, 0.2); + --test-arrow-hover-color: #f5f5f5; + --test-arrow-hover-background-color: rgb(78, 139, 202); + --target-background-color: #fdffd3; + --target-border-color: #ad7c37; + --kbd-color: #000; + --kbd-background: #fafbfc; + --kbd-box-shadow-color: #c6cbd1; + --rust-logo-filter: initial; + /* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */ + --crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg) + brightness(114%) contrast(76%); + --crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) + brightness(96%) contrast(93%); + --crate-search-hover-border: #717171; + --src-sidebar-background-selected: #fff; + --src-sidebar-background-hover: #e0e0e0; + --table-alt-row-background-color: #f5f5f5; + --codeblock-link-background: #eee; + --scrape-example-toggle-line-background: #ccc; + --scrape-example-toggle-line-hover-background: #999; + --scrape-example-code-line-highlight: #fcffd6; + --scrape-example-code-line-highlight-focus: #f6fdb0; + --scrape-example-help-border-color: #555; + --scrape-example-help-color: #333; + --scrape-example-help-hover-border-color: #000; + --scrape-example-help-hover-color: #000; + --scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1); + --scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0); +} diff --git a/tests/rustdoc-gui/src/theme_css/lib.rs b/tests/rustdoc-gui/src/theme_css/lib.rs new file mode 100644 index 000000000..e9f3265fa --- /dev/null +++ b/tests/rustdoc-gui/src/theme_css/lib.rs @@ -0,0 +1,2 @@ +// compile-flags: --theme custom-theme.css +//! <div class="custom-text">custom text</div> diff --git a/tests/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml index e4b031b73..fdaf9d628 100644 --- a/tests/rustdoc-gui/theme-change.goml +++ b/tests/rustdoc-gui/theme-change.goml @@ -65,3 +65,36 @@ assert-local-storage: { "rustdoc-theme": "light" } reload: wait-for: "#settings" assert: "#preferred-light-theme.setting-line.hidden" + +// Ensures that the custom theme feature is working as expected. +go-to: "file://" + |DOC_PATH| + "/theme_css/index.html" +set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} +reload: + +store-value: (background_light, "white") +store-value: (background_dark, "#353535") +store-value: (background_ayu, "#0f1419") +store-value: (background_custom_theme, "red") + +click: "#settings-menu" +wait-for: "#theme-ayu" +click: "#theme-ayu" +// should be the ayu theme so let's check the color. +wait-for-css: ("body", { "background-color": |background_ayu| }) +assert-local-storage: { "rustdoc-theme": "ayu" } +assert-text: (".custom-text", "custom text") +click: "#theme-light" +// should be the light theme so let's check the color. +wait-for-css: ("body", { "background-color": |background_light| }) +assert-local-storage: { "rustdoc-theme": "light" } +assert-text: (".custom-text", "custom text") +click: "#theme-dark" +// Should be the dark theme so let's check the color. +wait-for-css: ("body", { "background-color": |background_dark| }) +assert-local-storage: { "rustdoc-theme": "dark" } +assert-text: (".custom-text", "custom text") +click: "#theme-custom-theme" +// Should be the custom theme so let's check the color. +wait-for-css: ("body", { "background-color": |background_custom_theme| }) +assert-local-storage: { "rustdoc-theme": "custom-theme" } +assert-text: (".custom-text", "custom text") diff --git a/tests/rustdoc-gui/warning-block.goml b/tests/rustdoc-gui/warning-block.goml new file mode 100644 index 000000000..8832b65c4 --- /dev/null +++ b/tests/rustdoc-gui/warning-block.goml @@ -0,0 +1,42 @@ +// Test to check that the "warning blocks" are displayed as expected. +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +show-text: true + +define-function: ( + "check-warning", + (theme, color, border_color), + block { + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + + // The IDs are added directly into the DOM to make writing this test easier. + assert-css: ("#doc-warning-1", { + "margin-bottom": "12px", + "color": |color|, + "border-left": "2px solid " + |border_color|, + "background-color": "transparent", + }) + assert-css: ("#doc-warning-2", { + "margin-bottom": "0px", + "color": |color|, + "border-left": "2px solid " + |border_color|, + "background-color": "transparent", + }) + }, +) + +call-function: ("check-warning", { + "theme": "ayu", + "color": "#c5c5c5", + "border_color": "#ff8e00", +}) +call-function: ("check-warning", { + "theme": "dark", + "color": "#ddd", + "border_color": "#ff8e00", +}) +call-function: ("check-warning", { + "theme": "light", + "color": "black", + "border_color": "#ff8e00", +}) diff --git a/tests/rustdoc-js-std/full-path-function.js b/tests/rustdoc-js-std/full-path-function.js new file mode 100644 index 000000000..ac157b3aa --- /dev/null +++ b/tests/rustdoc-js-std/full-path-function.js @@ -0,0 +1,7 @@ +const EXPECTED = { + 'query': 'vec::vec -> usize', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'len' }, + { 'path': 'std::vec::Vec', 'name': 'capacity' }, + ], +}; diff --git a/tests/rustdoc-js-std/option-type-signatures.js b/tests/rustdoc-js-std/option-type-signatures.js index 259978506..e154fa707 100644 --- a/tests/rustdoc-js-std/option-type-signatures.js +++ b/tests/rustdoc-js-std/option-type-signatures.js @@ -1,3 +1,7 @@ +// ignore-order + +const FILTER_CRATE = "std"; + const EXPECTED = [ { 'query': 'option, fnonce -> option', @@ -19,4 +23,62 @@ const EXPECTED = [ { 'path': 'std::option::Option', 'name': 'as_mut_slice' }, ], }, + { + 'query': 'option<t>, option<t> -> option<t>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'or' }, + { 'path': 'std::option::Option', 'name': 'xor' }, + ], + }, + { + 'query': 'option<t>, option<u> -> option<u>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'and' }, + { 'path': 'std::option::Option', 'name': 'zip' }, + ], + }, + { + 'query': 'option<t>, option<u> -> option<t>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'and' }, + { 'path': 'std::option::Option', 'name': 'zip' }, + ], + }, + { + 'query': 'option<t>, option<u> -> option<t, u>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'zip' }, + ], + }, + { + 'query': 'option<t>, e -> result<t, e>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'ok_or' }, + { 'path': 'std::result::Result', 'name': 'transpose' }, + ], + }, + { + 'query': 'result<option<t>, e> -> option<result<t, e>>', + 'others': [ + { 'path': 'std::result::Result', 'name': 'transpose' }, + ], + }, + { + 'query': 'option<t>, option<t> -> bool', + 'others': [ + { 'path': 'std::option::Option', 'name': 'eq' }, + ], + }, + { + 'query': 'option<option<t>> -> option<t>', + 'others': [ + { 'path': 'std::option::Option', 'name': 'flatten' }, + ], + }, + { + 'query': 'option<t>', + 'returned': [ + { 'path': 'std::result::Result', 'name': 'ok' }, + ], + }, ]; diff --git a/tests/rustdoc-js-std/vec-type-signatures.js b/tests/rustdoc-js-std/vec-type-signatures.js new file mode 100644 index 000000000..18cf9d6ef --- /dev/null +++ b/tests/rustdoc-js-std/vec-type-signatures.js @@ -0,0 +1,22 @@ +// ignore-order + +const FILTER_CRATE = "std"; + +const EXPECTED = [ + { + 'query': 'vec::intoiter<T> -> [T]', + 'others': [ + { 'path': 'std::vec::IntoIter', 'name': 'as_slice' }, + { 'path': 'std::vec::IntoIter', 'name': 'as_mut_slice' }, + { 'path': 'std::vec::IntoIter', 'name': 'next_chunk' }, + ], + }, + { + 'query': 'vec::intoiter<T> -> []', + 'others': [ + { 'path': 'std::vec::IntoIter', 'name': 'as_slice' }, + { 'path': 'std::vec::IntoIter', 'name': 'as_mut_slice' }, + { 'path': 'std::vec::IntoIter', 'name': 'next_chunk' }, + ], + }, +]; diff --git a/tests/rustdoc-js/full-path-function.js b/tests/rustdoc-js/full-path-function.js new file mode 100644 index 000000000..48be51b15 --- /dev/null +++ b/tests/rustdoc-js/full-path-function.js @@ -0,0 +1,43 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'sac -> usize', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, + { 'path': 'full_path_function::b::Sac', 'name': 'len' }, + { 'path': 'full_path_function::sac::Sac', 'name': 'len' }, + ], + }, + { + 'query': 'b::sac -> usize', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, + { 'path': 'full_path_function::b::Sac', 'name': 'len' }, + ], + }, + { + 'query': 'b::sac -> u32', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar2' }, + ], + }, + { + 'query': 'string::string -> u32', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'string' }, + ], + }, + { + 'query': 'alloc::string::string -> u32', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'string' }, + ], + }, + { + 'query': 'alloc::string -> u32', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'string' }, + ], + }, +]; diff --git a/tests/rustdoc-js/full-path-function.rs b/tests/rustdoc-js/full-path-function.rs new file mode 100644 index 000000000..8dcc3f2b6 --- /dev/null +++ b/tests/rustdoc-js/full-path-function.rs @@ -0,0 +1,17 @@ +pub mod sac { + pub struct Sac; + + impl Sac { + pub fn len(&self) -> usize { 0 } + } +} + +pub mod b { + pub struct Sac; + impl Sac { + pub fn len(&self) -> usize { 0 } + pub fn bar(&self, w: u32) -> usize { 0 } + pub fn bar2(&self, w: u32) -> u32 { 0 } + pub fn string(w: String) -> u32 { 0 } + } +} diff --git a/tests/rustdoc-js/generics-match-ambiguity.js b/tests/rustdoc-js/generics-match-ambiguity.js index a9932a16c..edce4268c 100644 --- a/tests/rustdoc-js/generics-match-ambiguity.js +++ b/tests/rustdoc-js/generics-match-ambiguity.js @@ -79,6 +79,7 @@ const EXPECTED = [ { 'path': 'generics_match_ambiguity', 'name': 'baac' }, { 'path': 'generics_match_ambiguity', 'name': 'baaf' }, { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, ], }, { diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js index 4ccfb8f4e..a71393b5e 100644 --- a/tests/rustdoc-js/generics-trait.js +++ b/tests/rustdoc-js/generics-trait.js @@ -12,12 +12,16 @@ const EXPECTED = [ ], }, { - 'query': 'Result<SomeTraiz>', - 'correction': null, + 'query': 'Resulx<SomeTrait>', 'in_args': [], 'returned': [], }, { + 'query': 'Result<SomeTraiz>', + 'proposeCorrectionFrom': 'SomeTraiz', + 'proposeCorrectionTo': 'SomeTrait', + }, + { 'query': 'OtherThingxxxxxxxx', 'correction': null, 'in_args': [ diff --git a/tests/rustdoc-js/generics-unbox.js b/tests/rustdoc-js/generics-unbox.js new file mode 100644 index 000000000..9cdfc7ac8 --- /dev/null +++ b/tests/rustdoc-js/generics-unbox.js @@ -0,0 +1,38 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'Inside<T> -> Out1<T>', + 'others': [ + { 'path': 'generics_unbox', 'name': 'alpha' }, + ], + }, + { + 'query': 'Inside<T> -> Out3<T>', + 'others': [ + { 'path': 'generics_unbox', 'name': 'beta' }, + { 'path': 'generics_unbox', 'name': 'gamma' }, + ], + }, + { + 'query': 'Inside<T> -> Out4<T>', + 'others': [ + { 'path': 'generics_unbox', 'name': 'beta' }, + { 'path': 'generics_unbox', 'name': 'gamma' }, + ], + }, + { + 'query': 'Inside<T> -> Out3<U, T>', + 'others': [ + { 'path': 'generics_unbox', 'name': 'beta' }, + { 'path': 'generics_unbox', 'name': 'gamma' }, + ], + }, + { + 'query': 'Inside<T> -> Out4<U, T>', + 'others': [ + { 'path': 'generics_unbox', 'name': 'beta' }, + { 'path': 'generics_unbox', 'name': 'gamma' }, + ], + }, +]; diff --git a/tests/rustdoc-js/generics-unbox.rs b/tests/rustdoc-js/generics-unbox.rs new file mode 100644 index 000000000..bef34f891 --- /dev/null +++ b/tests/rustdoc-js/generics-unbox.rs @@ -0,0 +1,36 @@ +pub struct Out<A, B = ()> { + a: A, + b: B, +} + +pub struct Out1<A, const N: usize> { + a: [A; N], +} + +pub struct Out2<A, const N: usize> { + a: [A; N], +} + +pub struct Out3<A, B> { + a: A, + b: B, +} + +pub struct Out4<A, B> { + a: A, + b: B, +} + +pub struct Inside<T>(T); + +pub fn alpha<const N: usize, T>(_: Inside<T>) -> Out<Out1<T, N>, Out2<T, N>> { + loop {} +} + +pub fn beta<T, U>(_: Inside<T>) -> Out<Out3<T, U>, Out4<U, T>> { + loop {} +} + +pub fn gamma<T, U>(_: Inside<T>) -> Out<Out3<U, T>, Out4<T, U>> { + loop {} +} diff --git a/tests/rustdoc-js/type-parameters.js b/tests/rustdoc-js/type-parameters.js new file mode 100644 index 000000000..e695f189b --- /dev/null +++ b/tests/rustdoc-js/type-parameters.js @@ -0,0 +1,87 @@ +// exact-check +// ignore-order + +const EXPECTED = [ + { + query: '-> trait:Some', + others: [ + { path: 'foo', name: 'alef' }, + { path: 'foo', name: 'alpha' }, + ], + }, + { + query: '-> generic:T', + others: [ + { path: 'foo', name: 'bet' }, + { path: 'foo', name: 'alef' }, + { path: 'foo', name: 'beta' }, + ], + }, + { + query: 'A -> B', + others: [ + { path: 'foo', name: 'bet' }, + ], + }, + { + query: 'A -> A', + others: [ + { path: 'foo', name: 'beta' }, + ], + }, + { + query: 'A, A', + others: [ + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'A, B', + others: [ + { path: 'foo', name: 'other' }, + ], + }, + { + query: 'Other, Other', + others: [ + { path: 'foo', name: 'other' }, + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'generic:T', + in_args: [ + { path: 'foo', name: 'bet' }, + { path: 'foo', name: 'beta' }, + { path: 'foo', name: 'other' }, + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'generic:Other', + in_args: [ + { path: 'foo', name: 'bet' }, + { path: 'foo', name: 'beta' }, + { path: 'foo', name: 'other' }, + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'trait:Other', + in_args: [ + { path: 'foo', name: 'other' }, + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'Other', + in_args: [ + { path: 'foo', name: 'other' }, + { path: 'foo', name: 'alternate' }, + ], + }, + { + query: 'trait:T', + in_args: [], + }, +]; diff --git a/tests/rustdoc-js/type-parameters.rs b/tests/rustdoc-js/type-parameters.rs new file mode 100644 index 000000000..cda5e2617 --- /dev/null +++ b/tests/rustdoc-js/type-parameters.rs @@ -0,0 +1,15 @@ +#![crate_name="foo"] + +pub trait Some {} +impl Some for () {} +pub trait Other {} +impl Other for () {} + +pub fn alef<T: Some>() -> T { loop {} } +pub fn alpha() -> impl Some { } + +pub fn bet<T, U>(t: T) -> U { loop {} } +pub fn beta<T>(t: T) -> T {} + +pub fn other<T: Other, U: Other>(t: T, u: U) { loop {} } +pub fn alternate<T: Other>(t: T, u: T) { loop {} } diff --git a/tests/rustdoc-json/fn_pointer/abi.rs b/tests/rustdoc-json/fn_pointer/abi.rs index 77c0e8233..dbe316f57 100644 --- a/tests/rustdoc-json/fn_pointer/abi.rs +++ b/tests/rustdoc-json/fn_pointer/abi.rs @@ -2,23 +2,23 @@ #![feature(abi_vectorcall)] -// @is "$.index[*][?(@.name=='AbiRust')].inner.typedef.type.function_pointer.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='AbiRust')].inner.type_alias.type.function_pointer.header.abi" \"Rust\" pub type AbiRust = fn(); -// @is "$.index[*][?(@.name=='AbiC')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiC')].inner.type_alias.type.function_pointer.header.abi" '{"C": {"unwind": false}}' pub type AbiC = extern "C" fn(); -// @is "$.index[*][?(@.name=='AbiSystem')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiSystem')].inner.type_alias.type.function_pointer.header.abi" '{"System": {"unwind": false}}' pub type AbiSystem = extern "system" fn(); -// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.type_alias.type.function_pointer.header.abi" '{"C": {"unwind": true}}' pub type AbiCUnwind = extern "C-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type_alias.type.function_pointer.header.abi" '{"System": {"unwind": true}}' pub type AbiSystemUnwind = extern "system-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall\""' pub type AbiVecorcall = extern "vectorcall" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn(); diff --git a/tests/rustdoc-json/fn_pointer/generics.rs b/tests/rustdoc-json/fn_pointer/generics.rs index 48672f12d..3b82561ec 100644 --- a/tests/rustdoc-json/fn_pointer/generics.rs +++ b/tests/rustdoc-json/fn_pointer/generics.rs @@ -3,11 +3,11 @@ #![feature(no_core)] #![no_core] -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][0]" '"val"' -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.output.primitive" \"i32\" -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].name" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][0]" '"val"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.output.primitive" \"i32\" +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[0].name" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/tests/rustdoc-json/fn_pointer/qualifiers.rs b/tests/rustdoc-json/fn_pointer/qualifiers.rs index 0ab776c21..1a62eb2ba 100644 --- a/tests/rustdoc-json/fn_pointer/qualifiers.rs +++ b/tests/rustdoc-json/fn_pointer/qualifiers.rs @@ -1,11 +1,11 @@ // ignore-tidy-linelength -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.unsafe" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.const" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.async" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.unsafe" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.async" false pub type FnPointer = fn(); -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.unsafe" true -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.const" false -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.async" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.unsafe" true +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.async" false pub type UnsafePointer = unsafe fn(); diff --git a/tests/rustdoc-json/primitives/primitive_type.rs b/tests/rustdoc-json/primitives/primitive_type.rs index 5f251b3b8..89c5d06c0 100644 --- a/tests/rustdoc-json/primitives/primitive_type.rs +++ b/tests/rustdoc-json/primitives/primitive_type.rs @@ -1,17 +1,17 @@ #![feature(never_type)] // @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" -// @is "$.index[*][?(@.name=='PrimNever')].inner.typedef.type.primitive" \"never\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type_alias.type.primitive" \"never\" pub type PrimNever = !; -// @is "$.index[*][?(@.name=='PrimStr')].inner.typedef.type.primitive" \"str\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type_alias.type.primitive" \"str\" pub type PrimStr = str; -// @is "$.index[*][?(@.name=='PrimBool')].inner.typedef.type.primitive" \"bool\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type_alias.type.primitive" \"bool\" pub type PrimBool = bool; -// @is "$.index[*][?(@.name=='PrimChar')].inner.typedef.type.primitive" \"char\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type_alias.type.primitive" \"char\" pub type PrimChar = char; -// @is "$.index[*][?(@.name=='PrimU8')].inner.typedef.type.primitive" \"u8\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type_alias.type.primitive" \"u8\" pub type PrimU8 = u8; diff --git a/tests/rustdoc-json/type/dyn.rs b/tests/rustdoc-json/type/dyn.rs index e5ee60fad..4db65b61d 100644 --- a/tests/rustdoc-json/type/dyn.rs +++ b/tests/rustdoc-json/type/dyn.rs @@ -7,40 +7,40 @@ use std::fmt::Debug; // @set weird_order = "$.index[*][?(@.name=='WeirdOrder')].id" // @ismany "$.index[*][?(@.name=='dyn')].inner.module.items[*]" $sync_int_gen $ref_fn $weird_order -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.generics" '{"params": [], "where_predicates": []}' -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.name" \"Box\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args" 1 -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.lifetime" \"\'static\" -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[*]" 3 -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Fn"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].trait.name" '"Sync"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"primitive": "i32"}}}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.generics" '{"params": [], "where_predicates": []}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.name" \"Box\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.bindings" [] +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args" 1 +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.lifetime" \"\'static\" +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[*]" 3 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].trait.name" '"Sync"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"primitive": "i32"}}}' pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>; -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.mutable" 'false' -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.lifetime" "\"'a\"" -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.lifetime" null -// @count "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[*]" 1 -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref.lifetime" "\"'b\"" -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.mutable" 'false' +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.lifetime" "\"'a\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.lifetime" null +// @count "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[*]" 1 +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref.lifetime" "\"'b\"" pub type RefFn<'a> = &'a dyn for<'b> Fn(&'b i32) -> &'b i32; -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Debug"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Debug"' pub type WeirdOrder = Box<dyn Send + Debug>; diff --git a/tests/rustdoc-json/type/fn_lifetime.rs b/tests/rustdoc-json/type/fn_lifetime.rs index 424c5dce2..4aca303e6 100644 --- a/tests/rustdoc-json/type/fn_lifetime.rs +++ b/tests/rustdoc-json/type/fn_lifetime.rs @@ -1,26 +1,26 @@ // ignore-tidy-linelength -// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef" +// @has "$.index[*][?(@.name=='GenericFn')].inner.type_alias" -// @ismany "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.generic_params[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" +// @ismany "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.generic_params[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type GenericFn<'a> = fn(&'a i32) -> &'a i32; -// @has "$.index[*][?(@.name=='ForAll')].inner.typedef" -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.params[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type_alias" +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.generics.params[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type ForAll = for<'a> fn(&'a i32) -> &'a i32; diff --git a/tests/rustdoc-json/type/generic_default.rs b/tests/rustdoc-json/type/generic_default.rs index b46428745..30817a42e 100644 --- a/tests/rustdoc-json/type/generic_default.rs +++ b/tests/rustdoc-json/type/generic_default.rs @@ -9,25 +9,25 @@ pub enum Result<T, E> { // @set my_error = "$.index[*][?(@.name=='MyError')].id" pub struct MyError {} -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef" -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[*]" 2 -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].name" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].name" \"E\" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type" -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.bounds[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.bounds[*]" 0 -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.default" null -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.id" $my_error -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.name" \"MyError\" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.id" $result -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.name" \"Result\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias" +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[*]" 2 +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].name" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type" +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type.bounds[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.bounds[*]" 0 +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type.default" null +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path.id" $my_error +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path.name" \"MyError\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.id" $result +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.name" \"Result\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.bindings" [] +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.generic" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[1].type.generic" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.generic" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[1].type.generic" \"E\" pub type MyResult<T, E = MyError> = Result<T, E>; diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs new file mode 100644 index 000000000..5398d5833 --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs @@ -0,0 +1,83 @@ +// This test ensures that warnings are working as expected for "custom_code_classes_in_docs" +// feature. + +#![feature(custom_code_classes_in_docs)] +#![deny(warnings)] +#![feature(no_core)] +#![no_core] + +/// ```{. } +/// main; +/// ``` +//~^^^ ERROR unexpected ` ` character after `.` +pub fn foo() {} + +/// ```{class= a} +/// main; +/// ``` +//~^^^ ERROR unexpected ` ` character after `=` +pub fn foo2() {} + +/// ```{#id} +/// main; +/// ``` +//~^^^ ERROR unexpected character `#` +pub fn foo3() {} + +/// ```{{ +/// main; +/// ``` +//~^^^ ERROR unexpected character `{` +pub fn foo4() {} + +/// ```} +/// main; +/// ``` +//~^^^ ERROR unexpected character `}` +pub fn foo5() {} + +/// ```) +/// main; +/// ``` +//~^^^ ERROR unexpected character `)` +pub fn foo6() {} + +/// ```{class=} +/// main; +/// ``` +//~^^^ ERROR unexpected `}` character after `=` +pub fn foo7() {} + +/// ```( +/// main; +/// ``` +//~^^^ ERROR unclosed comment: missing `)` at the end +pub fn foo8() {} + +/// ```{class=one=two} +/// main; +/// ``` +//~^^^ ERROR unexpected `=` character +pub fn foo9() {} + +/// ```{.one.two} +/// main; +/// ``` +pub fn foo10() {} + +/// ```{class=(one} +/// main; +/// ``` +//~^^^ ERROR unexpected `(` character after `=` +pub fn foo11() {} + +/// ```{class=one.two} +/// main; +/// ``` +pub fn foo12() {} + +/// ```{(comment)} +/// main; +/// ``` +//~^^^ ERROR unexpected character `(` +pub fn foo13() {} diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr new file mode 100644 index 000000000..14b4b3bab --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr @@ -0,0 +1,97 @@ +error: unexpected ` ` character after `.` + --> $DIR/custom_code_classes_in_docs-warning.rs:9:1 + | +LL | / /// ```{. } +LL | | /// main; +LL | | /// ``` + | |_______^ + | +note: the lint level is defined here + --> $DIR/custom_code_classes_in_docs-warning.rs:5:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` + +error: unexpected ` ` character after `=` + --> $DIR/custom_code_classes_in_docs-warning.rs:15:1 + | +LL | / /// ```{class= a} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected character `#` + --> $DIR/custom_code_classes_in_docs-warning.rs:21:1 + | +LL | / /// ```{#id} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected character `{` + --> $DIR/custom_code_classes_in_docs-warning.rs:27:1 + | +LL | / /// ```{{ +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected character `}` + --> $DIR/custom_code_classes_in_docs-warning.rs:33:1 + | +LL | / /// ```} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected character `)` + --> $DIR/custom_code_classes_in_docs-warning.rs:39:1 + | +LL | / /// ```) +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected `}` character after `=` + --> $DIR/custom_code_classes_in_docs-warning.rs:45:1 + | +LL | / /// ```{class=} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unclosed comment: missing `)` at the end + --> $DIR/custom_code_classes_in_docs-warning.rs:51:1 + | +LL | / /// ```( +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected `=` character + --> $DIR/custom_code_classes_in_docs-warning.rs:57:1 + | +LL | / /// ```{class=one=two} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected `(` character after `=` + --> $DIR/custom_code_classes_in_docs-warning.rs:68:1 + | +LL | / /// ```{class=(one} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: unexpected character `(` + --> $DIR/custom_code_classes_in_docs-warning.rs:79:1 + | +LL | / /// ```{(comment)} +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: aborting due to 11 previous errors + diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs new file mode 100644 index 000000000..57d9038cb --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs @@ -0,0 +1,17 @@ +// This test ensures that warnings are working as expected for "custom_code_classes_in_docs" +// feature. + +#![feature(custom_code_classes_in_docs)] +#![deny(warnings)] +#![feature(no_core)] +#![no_core] + +/// ```{class="} +/// main; +/// ``` +//~^^^ ERROR unclosed quote string +//~| ERROR unclosed quote string +/// ```" +/// main; +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr new file mode 100644 index 000000000..4f2ded78c --- /dev/null +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr @@ -0,0 +1,33 @@ +error: unclosed quote string `"` + --> $DIR/custom_code_classes_in_docs-warning3.rs:9:1 + | +LL | / /// ```{class="} +LL | | /// main; +LL | | /// ``` +LL | | +... | +LL | | /// main; +LL | | /// ``` + | |_______^ + | +note: the lint level is defined here + --> $DIR/custom_code_classes_in_docs-warning3.rs:5:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` + +error: unclosed quote string `"` + --> $DIR/custom_code_classes_in_docs-warning3.rs:9:1 + | +LL | / /// ```{class="} +LL | | /// main; +LL | | /// ``` +LL | | +... | +LL | | /// main; +LL | | /// ``` + | |_______^ + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs new file mode 100644 index 000000000..99263a944 --- /dev/null +++ b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs @@ -0,0 +1,15 @@ +// check-pass + +/// ```{class=language-c} +/// int main(void) { return 0; } +/// ``` +//~^^^ WARNING custom classes in code blocks will change behaviour +//~| NOTE found these custom classes: class=language-c +//~| NOTE see issue #79483 <https://github.com/rust-lang/rust/issues/79483> +//~| HELP add `#![feature(custom_code_classes_in_docs)]` to the crate attributes to enable +pub struct Bar; + +/// ```ASN.1 +/// int main(void) { return 0; } +/// ``` +pub struct Bar2; diff --git a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr new file mode 100644 index 000000000..1a2360d9b --- /dev/null +++ b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.stderr @@ -0,0 +1,14 @@ +warning: custom classes in code blocks will change behaviour + --> $DIR/feature-gate-custom_code_classes_in_docs.rs:3:1 + | +LL | / /// ```{class=language-c} +LL | | /// int main(void) { return 0; } +LL | | /// ``` + | |_______^ + | + = note: see issue #79483 <https://github.com/rust-lang/rust/issues/79483> for more information + = help: add `#![feature(custom_code_classes_in_docs)]` to the crate attributes to enable + = note: found these custom classes: class=language-c + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/issue-102467.rs b/tests/rustdoc-ui/issue-102467.rs new file mode 100644 index 000000000..bff876e41 --- /dev/null +++ b/tests/rustdoc-ui/issue-102467.rs @@ -0,0 +1,15 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/102467>. +// It ensures that the expected error is displayed. + +#![feature(associated_const_equality)] + +trait T { + type A: S<C<X = 0i32> = 34>; + //~^ ERROR associated type bindings are not allowed here +} + +trait S { + const C: i32; +} + +fn main() {} diff --git a/tests/rustdoc-ui/issue-102467.stderr b/tests/rustdoc-ui/issue-102467.stderr new file mode 100644 index 000000000..a337293f7 --- /dev/null +++ b/tests/rustdoc-ui/issue-102467.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/issue-102467.rs:7:17 + | +LL | type A: S<C<X = 0i32> = 34>; + | ^^^^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/tests/rustdoc-ui/issues/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout index 167835243..bbea7e5c2 100644 --- a/tests/rustdoc-ui/issues/issue-91713.stdout +++ b/tests/rustdoc-ui/issues/issue-91713.stdout @@ -1,4 +1,5 @@ Available passes for running rustdoc: +check-custom-code-classes - check for custom code classes without the feature-gate enabled check_doc_test_visibility - run various visibility-related lints on doctests strip-hidden - strips all `#[doc(hidden)]` items from the output strip-private - strips all private items from a crate which cannot be seen externally, implies strip-priv-imports @@ -10,6 +11,7 @@ calculate-doc-coverage - counts the number of items with and without documentati run-lints - runs some of rustdoc's lints Default passes for rustdoc: +check-custom-code-classes collect-trait-impls check_doc_test_visibility strip-hidden (when not --document-hidden-items) diff --git a/tests/rustdoc/anchor-id-trait-method-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs new file mode 100644 index 000000000..26bb59c18 --- /dev/null +++ b/tests/rustdoc/anchor-id-trait-method-15169.rs @@ -0,0 +1,7 @@ +// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' + +// https://github.com/rust-lang/rust/issues/15169 +#![crate_name="issue_15169"] + +#[derive(PartialEq)] +pub struct Foo; diff --git a/tests/rustdoc/assoc-type-bindings-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs new file mode 100644 index 000000000..375b5b5b2 --- /dev/null +++ b/tests/rustdoc/assoc-type-bindings-20646.rs @@ -0,0 +1,28 @@ +// aux-build:issue-20646.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20646 +#![crate_name="issue_20646"] +#![feature(associated_types)] + +extern crate issue_20646; + +// @has issue_20646/trait.Trait.html \ +// '//*[@id="associatedtype.Output"]' \ +// 'type Output' +pub trait Trait { + type Output; +} + +// @has issue_20646/fn.fun.html \ +// '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' +pub fn fun<T>(_: T) where T: Trait<Output=i32> {} + +pub mod reexport { + // @has issue_20646/reexport/trait.Trait.html \ + // '//*[@id="associatedtype.Output"]' \ + // 'type Output' + // @has issue_20646/reexport/fn.fun.html \ + // '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' + pub use issue_20646::{Trait, fun}; +} diff --git a/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs b/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs new file mode 100644 index 000000000..f4e020b3b --- /dev/null +++ b/tests/rustdoc/auxiliary/cross_crate_generic_typedef.rs @@ -0,0 +1,5 @@ +pub struct InlineOne<A> { + pub inline: A +} + +pub type InlineU64 = InlineOne<u64>; diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs new file mode 100644 index 000000000..f50a9b96d --- /dev/null +++ b/tests/rustdoc/const-effect-param.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] +#![feature(effects, const_trait_impl)] + +#[const_trait] +pub trait Tr { + fn f(); +} + +// @has foo/fn.g.html +// @has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()' +/// foo +pub const fn g<T: ~const Tr>() {} diff --git a/tests/rustdoc/const-fn-effects.rs b/tests/rustdoc/const-fn-effects.rs new file mode 100644 index 000000000..7c19b4b2c --- /dev/null +++ b/tests/rustdoc/const-fn-effects.rs @@ -0,0 +1,19 @@ +#![crate_name = "foo"] +#![feature(effects)] + +// @has foo/fn.bar.html +// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' +/// foo +pub const fn bar() -> usize { + 2 +} + +// @has foo/struct.Foo.html +// @has - '//*[@class="method"]' 'const fn new()' +pub struct Foo(usize); + +impl Foo { + pub const fn new() -> Foo { + Foo(0) + } +} diff --git a/tests/rustdoc/const-generics/const-generic-defaults.rs b/tests/rustdoc/const-generics/const-generic-defaults.rs index f781c6a62..7a0a79411 100644 --- a/tests/rustdoc/const-generics/const-generic-defaults.rs +++ b/tests/rustdoc/const-generics/const-generic-defaults.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] // @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ -// 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(_);' +// 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(' pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(T); diff --git a/tests/rustdoc/const-generics/const-generics-docs.rs b/tests/rustdoc/const-generics/const-generics-docs.rs index 828486a41..70a9518f0 100644 --- a/tests/rustdoc/const-generics/const-generics-docs.rs +++ b/tests/rustdoc/const-generics/const-generics-docs.rs @@ -33,7 +33,7 @@ impl<const N: usize> Trait<N> for [u8; N] {} // @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ // 'pub struct Foo<const N: usize> where u8: Trait<N>' pub struct Foo<const N: usize> where u8: Trait<N>; -// @has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(_)' +// @has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(' pub struct Bar<T, const N: usize>([T; N]); // @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Foo<M>where u8: Trait<M>' @@ -92,7 +92,7 @@ macro_rules! define_me { } // @has foo/struct.Foz.html '//pre[@class="rust item-decl"]' \ -// 'pub struct Foz<const N: usize>(_);' +// 'pub struct Foz<const N: usize>(/* private fields */);' define_me!(Foz<N>); trait Q { diff --git a/tests/rustdoc/custom_code_classes.rs b/tests/rustdoc/custom_code_classes.rs new file mode 100644 index 000000000..cd20d8b7d --- /dev/null +++ b/tests/rustdoc/custom_code_classes.rs @@ -0,0 +1,28 @@ +// Test for `custom_code_classes_in_docs` feature. + +#![feature(custom_code_classes_in_docs)] +#![crate_name = "foo"] +#![feature(no_core)] +#![no_core] + +// @has 'foo/struct.Bar.html' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever hoho-c"]' 'main;' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever2 haha-c"]' 'main;' +// @has - '//*[@id="main-content"]//pre[@class="language-whatever4 huhu-c"]' 'main;' + +/// ```{class=hoho-c},whatever +/// main; +/// ``` +/// +/// Testing multiple kinds of orders. +/// +/// ```whatever2 {class=haha-c} +/// main; +/// ``` +/// +/// Testing with multiple "unknown". Only the first should be used. +/// +/// ```whatever4,{.huhu-c} whatever5 +/// main; +/// ``` +pub struct Bar; diff --git a/tests/rustdoc/deref-methods-19190-foreign-type.rs b/tests/rustdoc/deref-methods-19190-foreign-type.rs new file mode 100644 index 000000000..c83269921 --- /dev/null +++ b/tests/rustdoc/deref-methods-19190-foreign-type.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/19190 + +#![crate_name="issue_19190_2"] + +use std::ops::Deref; + +pub struct Bar; + +impl Deref for Bar { + type Target = String; + fn deref(&self) -> &String { loop {} } +} + +// @has issue_19190_2/struct.Bar.html +// @!has - '//*[@id="method.new"]' 'fn new() -> String' +// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' diff --git a/tests/rustdoc/deref-methods-19190-inline.rs b/tests/rustdoc/deref-methods-19190-inline.rs new file mode 100644 index 000000000..619b268d6 --- /dev/null +++ b/tests/rustdoc/deref-methods-19190-inline.rs @@ -0,0 +1,30 @@ +// aux-build:issue-19190-3.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190_3"] + +extern crate issue_19190_3; + +use std::ops::Deref; +use issue_19190_3::Baz; + +// @has issue_19190_3/struct.Foo.html +// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' +// @!has - '//*[@id="method.new"]' 'fn new() -> String' +pub use issue_19190_3::Foo; + +// @has issue_19190_3/struct.Bar.html +// @has - '//*[@id="method.baz"]' 'fn baz(&self)' +// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' +pub use issue_19190_3::Bar; + +// @has issue_19190_3/struct.MyBar.html +// @has - '//*[@id="method.baz"]' 'fn baz(&self)' +// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' +pub struct MyBar; + +impl Deref for MyBar { + type Target = Baz; + fn deref(&self) -> &Baz { loop {} } +} diff --git a/tests/rustdoc/deref-methods-19190.rs b/tests/rustdoc/deref-methods-19190.rs new file mode 100644 index 000000000..4c274d82f --- /dev/null +++ b/tests/rustdoc/deref-methods-19190.rs @@ -0,0 +1,23 @@ +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190"] + +use std::ops::Deref; + +pub struct Foo; +pub struct Bar; + +impl Foo { + pub fn foo(&self) {} + pub fn static_foo() {} +} + +impl Deref for Bar { + type Target = Foo; + fn deref(&self) -> &Foo { loop {} } +} + +// @has issue_19190/struct.Bar.html +// @has - '//*[@id="method.foo"]//h4[@class="code-header"]' 'fn foo(&self)' +// @has - '//*[@id="method.foo"]' 'fn foo(&self)' +// @!has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' +// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' diff --git a/tests/rustdoc/doc-hidden-method-13698.rs b/tests/rustdoc/doc-hidden-method-13698.rs new file mode 100644 index 000000000..f1bd6e73b --- /dev/null +++ b/tests/rustdoc/doc-hidden-method-13698.rs @@ -0,0 +1,19 @@ +// aux-build:issue-13698.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/13698 +#![crate_name="issue_13698"] + +extern crate issue_13698; + +pub struct Foo; +// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo' +impl issue_13698::Foo for Foo {} + +pub trait Bar { + #[doc(hidden)] + fn bar(&self) {} +} + +// @!has issue_13698/struct.Foo.html '//*[@id="method.bar"]' 'fn bar' +impl Bar for Foo {} diff --git a/tests/rustdoc/doc-test-attr-18199.rs b/tests/rustdoc/doc-test-attr-18199.rs new file mode 100644 index 000000000..c9d223532 --- /dev/null +++ b/tests/rustdoc/doc-test-attr-18199.rs @@ -0,0 +1,11 @@ +// compile-flags:--test +// https://github.com/rust-lang/rust/issues/18199 + +#![doc(test(attr(feature(staged_api))))] + +/// ``` +/// #![allow(internal_features)] +/// #![unstable(feature="test", issue="18199")] +/// fn main() {} +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/document-hidden-items-15347.rs b/tests/rustdoc/document-hidden-items-15347.rs new file mode 100644 index 000000000..d8a760e56 --- /dev/null +++ b/tests/rustdoc/document-hidden-items-15347.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z unstable-options --document-hidden-items +// https://github.com/rust-lang/rust/issues/15347 + +#![crate_name="issue_15347"] + +// @has issue_15347/fn.foo.html +#[doc(hidden)] +pub fn foo() {} diff --git a/tests/rustdoc/highlight-invalid-rust-12834.rs b/tests/rustdoc/highlight-invalid-rust-12834.rs new file mode 100644 index 000000000..f8acc5002 --- /dev/null +++ b/tests/rustdoc/highlight-invalid-rust-12834.rs @@ -0,0 +1,14 @@ +// Tests that failing to syntax highlight a rust code-block doesn't cause +// rustdoc to fail, while still rendering the code-block (without highlighting). +// https://github.com/rust-lang/rust/issues/12834 + +#![crate_name="issue_12834"] +#![allow(rustdoc::invalid_rust_codeblocks)] + +// @has issue_12834/fn.foo.html +// @has - //pre 'a + b ' + +/// ``` +/// a + b ∈ Self ∀ a, b ∈ Self +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs new file mode 100644 index 000000000..25615a73c --- /dev/null +++ b/tests/rustdoc/html-no-source.rs @@ -0,0 +1,30 @@ +// compile-flags: -Zunstable-options --html-no-source + +// This test ensures that the `--html-no-source` flag disables +// the creation of the `src` folder. + +#![feature(staged_api)] +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] + +// Ensures that there is no items in the corresponding "src" folder. +// @files 'src/foo' '[]' + +// @has foo/fn.foo.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +// @has foo/struct.Bar.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0' + // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +} diff --git a/tests/rustdoc/ice-type-error-19181.rs b/tests/rustdoc/ice-type-error-19181.rs new file mode 100644 index 000000000..3ced61366 --- /dev/null +++ b/tests/rustdoc/ice-type-error-19181.rs @@ -0,0 +1,6 @@ +// compile-flags:--test +// https://github.com/rust-lang/rust/issues/19181 + +// rustdoc should not panic when target crate has compilation errors + +fn main() { 0 } diff --git a/tests/rustdoc/impl-ref-20175.rs b/tests/rustdoc/impl-ref-20175.rs new file mode 100644 index 000000000..a92db2d0a --- /dev/null +++ b/tests/rustdoc/impl-ref-20175.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/20175 + +#![crate_name="issue_20175"] + +pub trait Foo { + fn foo(&self) {} +} + +pub struct Bar; + +// @has issue_20175/struct.Bar.html \ +// '//*[@id="method.foo"]' \ +// 'fn foo' +impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/infinite-redirection-16265-1.rs b/tests/rustdoc/infinite-redirection-16265-1.rs new file mode 100644 index 000000000..7d72469bd --- /dev/null +++ b/tests/rustdoc/infinite-redirection-16265-1.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_1"] + +pub struct Foo; + +// @hasraw issue_16265_1/traits/index.html 'source' +pub mod traits { + impl PartialEq for super::Foo { + fn eq(&self, _: &super::Foo) -> bool { + true + } + } +} diff --git a/tests/rustdoc/infinite-redirection-16265-2.rs b/tests/rustdoc/infinite-redirection-16265-2.rs new file mode 100644 index 000000000..7a4791c5f --- /dev/null +++ b/tests/rustdoc/infinite-redirection-16265-2.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_2"] + +// @hasraw issue_16265_2/index.html 'source' + +trait Y {} +impl Y for Option<u32> {} diff --git a/tests/rustdoc/inline-assoc-type-20727-bindings.rs b/tests/rustdoc/inline-assoc-type-20727-bindings.rs new file mode 100644 index 000000000..e59dec29d --- /dev/null +++ b/tests/rustdoc/inline-assoc-type-20727-bindings.rs @@ -0,0 +1,25 @@ +// aux-build:issue-20727.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_2"] + +extern crate issue_20727; + +// @has issue_20727_2/trait.Add.html +pub trait Add<RHS = Self> { + // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' + // @has - '//pre[@class="rust item-decl"]' 'type Output;' + type Output; + + // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + fn add(self, rhs: RHS) -> Self::Output; +} + +// @has issue_20727_2/reexport/trait.Add.html +pub mod reexport { + // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' + // @has - '//pre[@class="rust item-decl"]' 'type Output;' + // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + pub use issue_20727::Add; +} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs new file mode 100644 index 000000000..005ee3e32 --- /dev/null +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs @@ -0,0 +1,27 @@ +// aux-build:issue-20727.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_3"] + +extern crate issue_20727; + +pub trait Bar {} + +// @has issue_20727_3/trait.Deref2.html +pub trait Deref2 { + // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + type Target: Bar; + + // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + fn deref(&self) -> Self::Target; +} + +// @has issue_20727_3/reexport/trait.Deref2.html +pub mod reexport { + // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + pub use issue_20727::Deref2; +} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs new file mode 100644 index 000000000..1a3f4cd20 --- /dev/null +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs @@ -0,0 +1,43 @@ +// aux-build:issue-20727.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_4"] + +extern crate issue_20727; + +// @has issue_20727_4/trait.Index.html +pub trait Index<Idx: ?Sized> { + // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx: ?Sized> {' + // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + type Output: ?Sized; + + // @has - '//pre[@class="rust item-decl"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + fn index(&self, index: Idx) -> &Self::Output; +} + +// @has issue_20727_4/trait.IndexMut.html +pub trait IndexMut<Idx: ?Sized>: Index<Idx> { + // @has - '//pre[@class="rust item-decl"]' \ + // 'trait IndexMut<Idx: ?Sized>: Index<Idx> {' + // @has - '//pre[@class="rust item-decl"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + fn index_mut(&mut self, index: Idx) -> &mut Self::Output; +} + +pub mod reexport { + // @has issue_20727_4/reexport/trait.Index.html + // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx>where Idx: ?Sized,{' + // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + // @has - '//pre[@class="rust item-decl"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + pub use issue_20727::Index; + + // @has issue_20727_4/reexport/trait.IndexMut.html + // @has - '//pre[@class="rust item-decl"]' \ + // 'trait IndexMut<Idx>: Index<Idx>where Idx: ?Sized,{' + // @has - '//pre[@class="rust item-decl"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + pub use issue_20727::IndexMut; +} diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds.rs b/tests/rustdoc/inline-assoc-type-20727-bounds.rs new file mode 100644 index 000000000..7cbc8d381 --- /dev/null +++ b/tests/rustdoc/inline-assoc-type-20727-bounds.rs @@ -0,0 +1,27 @@ +// aux-build:issue-20727.rs +// ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727"] + +extern crate issue_20727; + +// @has issue_20727/trait.Deref.html +pub trait Deref { + // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' + // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + type Target: ?Sized; + + // @has - '//pre[@class="rust item-decl"]' \ + // "fn deref<'a>(&'a self) -> &'a Self::Target;" + fn deref<'a>(&'a self) -> &'a Self::Target; +} + +// @has issue_20727/reexport/trait.Deref.html +pub mod reexport { + // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' + // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + // @has - '//pre[@class="rust item-decl"]' \ + // "fn deref<'a>(&'a self) -> &'a Self::Target;" + pub use issue_20727::Deref; +} diff --git a/tests/rustdoc/inline_cross/async-fn.rs b/tests/rustdoc/inline_cross/async-fn.rs new file mode 100644 index 000000000..95e175aab --- /dev/null +++ b/tests/rustdoc/inline_cross/async-fn.rs @@ -0,0 +1,19 @@ +// Regression test for issue #115760. +// Check that we render the correct return type of free and +// associated async functions reexported from external crates. + +// aux-crate:async_fn=async-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" +pub use async_fn::load; + +// @has user/trait.Load.html +// @has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Load; + +// @has user/struct.Loader.html +// @has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Loader; diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs new file mode 100644 index 000000000..767564ed1 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -0,0 +1,18 @@ +#![feature(async_fn_in_trait)] +// edition: 2021 + +pub async fn load() -> i32 { + 0 +} + +pub trait Load { + async fn run(&self) -> i32; +} + +pub struct Loader; + +impl Load for Loader { + async fn run(&self) -> i32 { + 1 + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/const-fn.rs b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs new file mode 100644 index 000000000..26332b419 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/const-fn.rs @@ -0,0 +1,5 @@ +#![feature(effects)] + +pub const fn load() -> i32 { + 0 +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 19433c968..42cfc3dc3 100644 --- a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -33,9 +33,3 @@ pub struct Foo; impl Foo { pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} } - -pub struct Bar; - -impl Bar { - pub async fn async_foo(&self) {} -} diff --git a/tests/rustdoc/inline_cross/const-fn.rs b/tests/rustdoc/inline_cross/const-fn.rs new file mode 100644 index 000000000..24934b873 --- /dev/null +++ b/tests/rustdoc/inline_cross/const-fn.rs @@ -0,0 +1,10 @@ +// Regression test for issue #116629. +// Check that we render the correct generic params of const fn + +// aux-crate:const_fn=const-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub const fn load() -> i32" +pub use const_fn::load; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index b6a1552bc..5c802c514 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -33,15 +33,7 @@ pub use impl_trait_aux::func4; // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; -// @has impl_trait/fn.async_fn.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn async_fn()" -pub use impl_trait_aux::async_fn; - // @has impl_trait/struct.Foo.html // @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; - -// @has impl_trait/struct.Bar.html -// @has - '//*[@id="method.async_foo"]' "pub async fn async_foo(" -pub use impl_trait_aux::Bar; diff --git a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs index 910824839..5d2c553d8 100644 --- a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs +++ b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs @@ -8,7 +8,7 @@ // @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' // We also ensure we don't have another item displayed. // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 2 -// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' mod other { diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs index b0c225401..3b836a219 100644 --- a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs +++ b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs @@ -104,7 +104,7 @@ pub mod glob_reexport { // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' - // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' // Now we check we have 1 re-export and 2 inlined items. // If not item from a glob re-export is visible, we don't show the re-export. @@ -135,9 +135,9 @@ pub mod doc_hidden_reexport { // @has - '//a[@class="struct"]' 'Reexport' // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. // @has - '//*[@class="desc docblock-short"]' 'Visible. Original.' + /// Visible. + pub use self::Bar3 as Reexport; /// Hidden. #[doc(hidden)] pub use crate::private::Bar3; - /// Visible. - pub use self::Bar3 as Reexport; } diff --git a/tests/rustdoc/issue-12834.rs b/tests/rustdoc/issue-12834.rs deleted file mode 100644 index 9605a1e78..000000000 --- a/tests/rustdoc/issue-12834.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Tests that failing to syntax highlight a rust code-block doesn't cause -// rustdoc to fail, while still rendering the code-block (without highlighting). - -#![allow(rustdoc::invalid_rust_codeblocks)] - -// @has issue_12834/fn.foo.html -// @has - //pre 'a + b ' - -/// ``` -/// a + b ∈ Self ∀ a, b ∈ Self -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/issue-13698.rs b/tests/rustdoc/issue-13698.rs deleted file mode 100644 index 3046a8a28..000000000 --- a/tests/rustdoc/issue-13698.rs +++ /dev/null @@ -1,16 +0,0 @@ -// aux-build:issue-13698.rs -// ignore-cross-compile - -extern crate issue_13698; - -pub struct Foo; -// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo' -impl issue_13698::Foo for Foo {} - -pub trait Bar { - #[doc(hidden)] - fn bar(&self) {} -} - -// @!has issue_13698/struct.Foo.html '//*[@id="method.bar"]' 'fn bar' -impl Bar for Foo {} diff --git a/tests/rustdoc/issue-15169.rs b/tests/rustdoc/issue-15169.rs deleted file mode 100644 index e525d85e2..000000000 --- a/tests/rustdoc/issue-15169.rs +++ /dev/null @@ -1,3 +0,0 @@ -// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' -#[derive(PartialEq)] -pub struct Foo; diff --git a/tests/rustdoc/issue-15318-2.rs b/tests/rustdoc/issue-15318-2.rs deleted file mode 100644 index 614f2c1c0..000000000 --- a/tests/rustdoc/issue-15318-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// aux-build:issue-15318.rs -// ignore-cross-compile -#![no_std] - -extern crate issue_15318; - -pub use issue_15318::ptr; - -// @!has issue_15318_2/fn.bar.html \ -// '//*[@href="primitive.pointer.html"]' \ -// '*mut T' -pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/issue-15318-3.rs b/tests/rustdoc/issue-15318-3.rs deleted file mode 100644 index 2dab8f948..000000000 --- a/tests/rustdoc/issue-15318-3.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(rustc_attrs)] - -// @has issue_15318_3/primitive.pointer.html - -/// dox -#[rustc_doc_primitive = "pointer"] -pub mod ptr {} diff --git a/tests/rustdoc/issue-15318.rs b/tests/rustdoc/issue-15318.rs deleted file mode 100644 index 0349fe285..000000000 --- a/tests/rustdoc/issue-15318.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:issue-15318.rs -// ignore-cross-compile - -#![no_std] - -extern crate issue_15318; - -// @has issue_15318/fn.bar.html \ -// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ -// '*mut T' -pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/issue-15347.rs b/tests/rustdoc/issue-15347.rs deleted file mode 100644 index e93d74011..000000000 --- a/tests/rustdoc/issue-15347.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags: -Z unstable-options --document-hidden-items - -// @has issue_15347/fn.foo.html -#[doc(hidden)] -pub fn foo() {} diff --git a/tests/rustdoc/issue-16019.rs b/tests/rustdoc/issue-16019.rs deleted file mode 100644 index 239d92378..000000000 --- a/tests/rustdoc/issue-16019.rs +++ /dev/null @@ -1,9 +0,0 @@ -macro_rules! define_struct { - ($rounds:expr) => ( - struct Struct { - sk: [u32; $rounds + 1] - } - ) -} - -define_struct!(2); diff --git a/tests/rustdoc/issue-16265-1.rs b/tests/rustdoc/issue-16265-1.rs deleted file mode 100644 index 2fda637a6..000000000 --- a/tests/rustdoc/issue-16265-1.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub struct Foo; - -// @hasraw issue_16265_1/traits/index.html 'source' -pub mod traits { - impl PartialEq for super::Foo { - fn eq(&self, _: &super::Foo) -> bool { - true - } - } -} diff --git a/tests/rustdoc/issue-16265-2.rs b/tests/rustdoc/issue-16265-2.rs deleted file mode 100644 index c3eb35617..000000000 --- a/tests/rustdoc/issue-16265-2.rs +++ /dev/null @@ -1,4 +0,0 @@ -// @hasraw issue_16265_2/index.html 'source' - -trait Y {} -impl Y for Option<u32> {} diff --git a/tests/rustdoc/issue-17476.rs b/tests/rustdoc/issue-17476.rs deleted file mode 100644 index a5b484c98..000000000 --- a/tests/rustdoc/issue-17476.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:issue-17476.rs -// ignore-cross-compile - -extern crate issue_17476; - -pub struct Foo; - -// @has issue_17476/struct.Foo.html \ -// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ -// 'foo' -impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/issue-18199.rs b/tests/rustdoc/issue-18199.rs deleted file mode 100644 index 9cc58b162..000000000 --- a/tests/rustdoc/issue-18199.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags:--test - -#![doc(test(attr(feature(staged_api))))] - -/// ``` -/// #![allow(internal_features)] -/// #![unstable(feature="test", issue="18199")] -/// fn main() {} -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/issue-19181.rs b/tests/rustdoc/issue-19181.rs deleted file mode 100644 index 3dea152fc..000000000 --- a/tests/rustdoc/issue-19181.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags:--test - -// rustdoc should not panic when target crate has compilation errors - -fn main() { 0 } diff --git a/tests/rustdoc/issue-19190-2.rs b/tests/rustdoc/issue-19190-2.rs deleted file mode 100644 index b6416e2e5..000000000 --- a/tests/rustdoc/issue-19190-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::ops::Deref; - -pub struct Bar; - -impl Deref for Bar { - type Target = String; - fn deref(&self) -> &String { loop {} } -} - -// @has issue_19190_2/struct.Bar.html -// @!has - '//*[@id="method.new"]' 'fn new() -> String' -// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' diff --git a/tests/rustdoc/issue-19190-3.rs b/tests/rustdoc/issue-19190-3.rs deleted file mode 100644 index 4d34ce650..000000000 --- a/tests/rustdoc/issue-19190-3.rs +++ /dev/null @@ -1,27 +0,0 @@ -// aux-build:issue-19190-3.rs -// ignore-cross-compile - -extern crate issue_19190_3; - -use std::ops::Deref; -use issue_19190_3::Baz; - -// @has issue_19190_3/struct.Foo.html -// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' -// @!has - '//*[@id="method.new"]' 'fn new() -> String' -pub use issue_19190_3::Foo; - -// @has issue_19190_3/struct.Bar.html -// @has - '//*[@id="method.baz"]' 'fn baz(&self)' -// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' -pub use issue_19190_3::Bar; - -// @has issue_19190_3/struct.MyBar.html -// @has - '//*[@id="method.baz"]' 'fn baz(&self)' -// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' -pub struct MyBar; - -impl Deref for MyBar { - type Target = Baz; - fn deref(&self) -> &Baz { loop {} } -} diff --git a/tests/rustdoc/issue-19190.rs b/tests/rustdoc/issue-19190.rs deleted file mode 100644 index 2046273e2..000000000 --- a/tests/rustdoc/issue-19190.rs +++ /dev/null @@ -1,20 +0,0 @@ -use std::ops::Deref; - -pub struct Foo; -pub struct Bar; - -impl Foo { - pub fn foo(&self) {} - pub fn static_foo() {} -} - -impl Deref for Bar { - type Target = Foo; - fn deref(&self) -> &Foo { loop {} } -} - -// @has issue_19190/struct.Bar.html -// @has - '//*[@id="method.foo"]//h4[@class="code-header"]' 'fn foo(&self)' -// @has - '//*[@id="method.foo"]' 'fn foo(&self)' -// @!has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' -// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' diff --git a/tests/rustdoc/issue-20175.rs b/tests/rustdoc/issue-20175.rs deleted file mode 100644 index 6a42e2afb..000000000 --- a/tests/rustdoc/issue-20175.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub trait Foo { - fn foo(&self) {} -} - -pub struct Bar; - -// @has issue_20175/struct.Bar.html \ -// '//*[@id="method.foo"]' \ -// 'fn foo' -impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/issue-20646.rs b/tests/rustdoc/issue-20646.rs deleted file mode 100644 index b2ee9c260..000000000 --- a/tests/rustdoc/issue-20646.rs +++ /dev/null @@ -1,26 +0,0 @@ -// aux-build:issue-20646.rs -// ignore-cross-compile - -#![feature(associated_types)] - -extern crate issue_20646; - -// @has issue_20646/trait.Trait.html \ -// '//*[@id="associatedtype.Output"]' \ -// 'type Output' -pub trait Trait { - type Output; -} - -// @has issue_20646/fn.fun.html \ -// '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' -pub fn fun<T>(_: T) where T: Trait<Output=i32> {} - -pub mod reexport { - // @has issue_20646/reexport/trait.Trait.html \ - // '//*[@id="associatedtype.Output"]' \ - // 'type Output' - // @has issue_20646/reexport/fn.fun.html \ - // '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' - pub use issue_20646::{Trait, fun}; -} diff --git a/tests/rustdoc/issue-20727-2.rs b/tests/rustdoc/issue-20727-2.rs deleted file mode 100644 index c1aa9617b..000000000 --- a/tests/rustdoc/issue-20727-2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// aux-build:issue-20727.rs -// ignore-cross-compile - -extern crate issue_20727; - -// @has issue_20727_2/trait.Add.html -pub trait Add<RHS = Self> { - // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output;' - type Output; - - // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' - fn add(self, rhs: RHS) -> Self::Output; -} - -// @has issue_20727_2/reexport/trait.Add.html -pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output;' - // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' - pub use issue_20727::Add; -} diff --git a/tests/rustdoc/issue-20727-3.rs b/tests/rustdoc/issue-20727-3.rs deleted file mode 100644 index 2f9d91fc5..000000000 --- a/tests/rustdoc/issue-20727-3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// aux-build:issue-20727.rs -// ignore-cross-compile - -extern crate issue_20727; - -pub trait Bar {} - -// @has issue_20727_3/trait.Deref2.html -pub trait Deref2 { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' - type Target: Bar; - - // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' - fn deref(&self) -> Self::Target; -} - -// @has issue_20727_3/reexport/trait.Deref2.html -pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' - // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' - pub use issue_20727::Deref2; -} diff --git a/tests/rustdoc/issue-20727-4.rs b/tests/rustdoc/issue-20727-4.rs deleted file mode 100644 index ec9f18fc3..000000000 --- a/tests/rustdoc/issue-20727-4.rs +++ /dev/null @@ -1,40 +0,0 @@ -// aux-build:issue-20727.rs -// ignore-cross-compile - -extern crate issue_20727; - -// @has issue_20727_4/trait.Index.html -pub trait Index<Idx: ?Sized> { - // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx: ?Sized> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' - type Output: ?Sized; - - // @has - '//pre[@class="rust item-decl"]' \ - // 'fn index(&self, index: Idx) -> &Self::Output' - fn index(&self, index: Idx) -> &Self::Output; -} - -// @has issue_20727_4/trait.IndexMut.html -pub trait IndexMut<Idx: ?Sized>: Index<Idx> { - // @has - '//pre[@class="rust item-decl"]' \ - // 'trait IndexMut<Idx: ?Sized>: Index<Idx> {' - // @has - '//pre[@class="rust item-decl"]' \ - // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' - fn index_mut(&mut self, index: Idx) -> &mut Self::Output; -} - -pub mod reexport { - // @has issue_20727_4/reexport/trait.Index.html - // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx>where Idx: ?Sized,{' - // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' - // @has - '//pre[@class="rust item-decl"]' \ - // 'fn index(&self, index: Idx) -> &Self::Output' - pub use issue_20727::Index; - - // @has issue_20727_4/reexport/trait.IndexMut.html - // @has - '//pre[@class="rust item-decl"]' \ - // 'trait IndexMut<Idx>: Index<Idx>where Idx: ?Sized,{' - // @has - '//pre[@class="rust item-decl"]' \ - // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' - pub use issue_20727::IndexMut; -} diff --git a/tests/rustdoc/issue-20727.rs b/tests/rustdoc/issue-20727.rs deleted file mode 100644 index 266848bee..000000000 --- a/tests/rustdoc/issue-20727.rs +++ /dev/null @@ -1,24 +0,0 @@ -// aux-build:issue-20727.rs -// ignore-cross-compile - -extern crate issue_20727; - -// @has issue_20727/trait.Deref.html -pub trait Deref { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' - type Target: ?Sized; - - // @has - '//pre[@class="rust item-decl"]' \ - // "fn deref<'a>(&'a self) -> &'a Self::Target;" - fn deref<'a>(&'a self) -> &'a Self::Target; -} - -// @has issue_20727/reexport/trait.Deref.html -pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' - // @has - '//pre[@class="rust item-decl"]' \ - // "fn deref<'a>(&'a self) -> &'a Self::Target;" - pub use issue_20727::Deref; -} diff --git a/tests/rustdoc/issue-32077-type-alias-impls.rs b/tests/rustdoc/issue-32077-type-alias-impls.rs new file mode 100644 index 000000000..ac486c36a --- /dev/null +++ b/tests/rustdoc/issue-32077-type-alias-impls.rs @@ -0,0 +1,66 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/32077>. + +#![crate_name = "foo"] + +pub struct GenericStruct<T>(T); + +impl<T> GenericStruct<T> { + pub fn on_gen(arg: T) {} +} + +impl GenericStruct<u32> { + pub fn on_u32(arg: u32) {} +} + +pub trait Foo {} +pub trait Bar {} + +impl<T> Foo for GenericStruct<T> {} +impl Bar for GenericStruct<u32> {} + +// @has 'foo/type.TypedefStruct.html' +// We check that "Aliased type" is also present as a title in the sidebar. +// @has - '//*[@class="sidebar-elems"]//h3/a[@href="#aliased-type"]' 'Aliased type' +// We check that we have the implementation of the type alias itself. +// @has - '//*[@id="impl-TypedefStruct"]/h3' 'impl TypedefStruct' +// @has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()' +// @has - '//*[@id="impl-GenericStruct%3CT%3E"]/h3' 'impl<T> GenericStruct<T>' +// @has - '//*[@id="method.on_gen"]/h4' 'pub fn on_gen(arg: T)' +// @has - '//*[@id="impl-Foo-for-GenericStruct%3CT%3E"]/h3' 'impl<T> Foo for GenericStruct<T>' +// This trait implementation doesn't match the type alias parameters so shouldn't appear in docs. +// @!has - '//h3' 'impl Bar for GenericStruct<u32> {}' +// Same goes for the `Deref` impl. +// @!has - '//h2' 'Methods from Deref<Target = u32>' +// @count - '//nav[@class="sidebar"]//a' 'on_alias' 1 +// @count - '//nav[@class="sidebar"]//a' 'on_gen' 1 +// @count - '//nav[@class="sidebar"]//a' 'Foo' 1 +// @!has - '//nav[@class="sidebar"]//a' 'Bar' +// @!has - '//nav[@class="sidebar"]//a' 'on_u32' +pub type TypedefStruct = GenericStruct<u8>; + +impl TypedefStruct { + pub fn on_alias() {} +} + +impl std::ops::Deref for GenericStruct<u32> { + type Target = u32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +pub struct Wrap<T>(GenericStruct<T>); + +// @has 'foo/type.Alias.html' +// @has - '//h2' 'Methods from Deref<Target = u32>' +// @has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl<T> Deref for Wrap<T>' +pub type Alias = Wrap<u32>; + +impl<T> std::ops::Deref for Wrap<T> { + type Target = GenericStruct<T>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/tests/rustdoc/issue-88600.rs b/tests/rustdoc/issue-88600.rs index db0d102b7..f89af472f 100644 --- a/tests/rustdoc/issue-88600.rs +++ b/tests/rustdoc/issue-88600.rs @@ -8,10 +8,10 @@ pub struct S; // @has issue_88600/enum.FooEnum.html pub enum FooEnum { - // @has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(_)' + // @has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(/* private fields */)' // @count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0 HiddenTupleItem(#[doc(hidden)] H), - // @has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(_, _)' + // @has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(/* private fields */)' // @count - '//*[@id="variant.MultipleHidden.field.0"]' 0 // @count - '//*[@id="variant.MultipleHidden.field.1"]' 0 MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H), diff --git a/tests/rustdoc/macro-ice-16019.rs b/tests/rustdoc/macro-ice-16019.rs new file mode 100644 index 000000000..d0f82e0a3 --- /dev/null +++ b/tests/rustdoc/macro-ice-16019.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/16019 + +macro_rules! define_struct { + ($rounds:expr) => ( + struct Struct { + sk: [u32; $rounds + 1] + } + ) +} + +define_struct!(2); diff --git a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs new file mode 100644 index 000000000..e52ab6f38 --- /dev/null +++ b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs @@ -0,0 +1,14 @@ +// aux-build:issue-17476.rs +// ignore-cross-compile +// https://github.com/rust-lang/rust/issues/17476 + +#![crate_name="issue_17476"] + +extern crate issue_17476; + +pub struct Foo; + +// @has issue_17476/struct.Foo.html \ +// '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ +// 'foo' +impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/no-crate-filter.rs b/tests/rustdoc/no-crate-filter.rs deleted file mode 100644 index b2f899064..000000000 --- a/tests/rustdoc/no-crate-filter.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_name = "foo"] - -// compile-flags: -Z unstable-options --disable-per-crate-search - -// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' '' -pub struct Foo; diff --git a/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs new file mode 100644 index 000000000..80c559756 --- /dev/null +++ b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/15318 +#![crate_name="issue_15318_3"] +#![feature(rustc_attrs)] + +// @has issue_15318_3/primitive.pointer.html + +/// dox +#[rustc_doc_primitive = "pointer"] +pub mod ptr {} diff --git a/tests/rustdoc/primitive-raw-pointer-link-15318.rs b/tests/rustdoc/primitive-raw-pointer-link-15318.rs new file mode 100644 index 000000000..77f25ff4c --- /dev/null +++ b/tests/rustdoc/primitive-raw-pointer-link-15318.rs @@ -0,0 +1,13 @@ +// aux-build:issue-15318.rs +// ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 + +#![crate_name="issue_15318"] +#![no_std] + +extern crate issue_15318; + +// @has issue_15318/fn.bar.html \ +// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ +// '*mut T' +pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs new file mode 100644 index 000000000..1b35bb185 --- /dev/null +++ b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs @@ -0,0 +1,15 @@ +// aux-build:issue-15318.rs +// ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 + +#![crate_name="issue_15318_2"] +#![no_std] + +extern crate issue_15318; + +pub use issue_15318::ptr; + +// @!has issue_15318_2/fn.bar.html \ +// '//*[@href="primitive.pointer.html"]' \ +// '*mut T' +pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/private-fields-tuple-struct.rs b/tests/rustdoc/private-fields-tuple-struct.rs new file mode 100644 index 000000000..c6989dd8c --- /dev/null +++ b/tests/rustdoc/private-fields-tuple-struct.rs @@ -0,0 +1,15 @@ +// This test checks the diplay of "/* private fields */" sentence in tuple structs. +#![crate_name = "foo"] + +// @has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);' +pub struct A(pub u8, u8); +// @has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);' +pub struct B(u8, pub u8); +// @has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);' +pub struct C(u8, pub u8, u8); +// @has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);' +pub struct D(pub u8, u8, pub u8); +// @has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);' +pub struct E(u8); +// @has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);' +pub struct F(u8, u8); diff --git a/tests/rustdoc/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs index 5d742dc39..7f56b2ffe 100644 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/rfc-2632-const-trait-impl.rs @@ -5,6 +5,8 @@ // To future blessers: make sure that `const_trait_impl` is // stabilized when changing `@!has` to `@has`, and please do // not remove this test. +// +// FIXME(effects) add `const_trait` to `Fn` so we use `~const` #![feature(const_trait_impl)] #![crate_name = "foo"] @@ -22,9 +24,9 @@ pub trait Tr<T> { // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' - fn a<A: ~const Fn() + ~const Destruct>() + fn a<A: /* ~const */ Fn() + ~const Destruct>() where - Option<A>: ~const Fn() + ~const Destruct, + Option<A>: /* ~const */ Fn() + ~const Destruct, { } } @@ -34,13 +36,13 @@ pub trait Tr<T> { // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' -impl<T: ~const Fn() + ~const Destruct> const Tr<T> for T +impl<T: /* ~const */ Fn() + ~const Destruct> const Tr<T> for T where - Option<T>: ~const Fn() + ~const Destruct, + Option<T>: /* ~const */ Fn() + ~const Destruct, { - fn a<A: ~const Fn() + ~const Destruct>() + fn a<A: /* ~const */ Fn() + ~const Destruct>() where - Option<A>: ~const Fn() + ~const Destruct, + Option<A>: /* ~const */ Fn() + ~const Destruct, { } } @@ -49,9 +51,9 @@ where // @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' '~const' // @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Fn' -pub const fn foo<F: ~const Fn() + ~const Destruct>() +pub const fn foo<F: /* ~const */ Fn() + ~const Destruct>() where - Option<F>: ~const Fn() + ~const Destruct, + Option<F>: /* ~const */ Fn() + ~const Destruct, { F::a() } @@ -61,9 +63,9 @@ impl<T> S<T> { // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' - pub const fn foo<B, C: ~const Fn() + ~const Destruct>() + pub const fn foo<B, C: /* ~const */ Fn() + ~const Destruct>() where - B: ~const Fn() + ~const Destruct, + B: /* ~const */ Fn() + ~const Destruct, { B::a() } diff --git a/tests/rustdoc/show-const-contents.rs b/tests/rustdoc/show-const-contents.rs index 69e742ee7..91df03adb 100644 --- a/tests/rustdoc/show-const-contents.rs +++ b/tests/rustdoc/show-const-contents.rs @@ -47,7 +47,7 @@ pub struct MyTypeWithStr(&'static str); // @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); -// @hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;' +// @hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' // @hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' pub use std::f32::consts::PI; diff --git a/tests/rustdoc/sidebar-all-page.rs b/tests/rustdoc/sidebar-all-page.rs index 45a6ba8ed..4c8a0f543 100644 --- a/tests/rustdoc/sidebar-all-page.rs +++ b/tests/rustdoc/sidebar-all-page.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] - #![feature(rustc_attrs)] // @has 'foo/all.html' @@ -9,7 +8,7 @@ // @has - '//*[@class="sidebar-elems"]//li' 'Functions' // @has - '//*[@class="sidebar-elems"]//li' 'Traits' // @has - '//*[@class="sidebar-elems"]//li' 'Macros' -// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions' +// @has - '//*[@class="sidebar-elems"]//li' 'Type Aliases' // @has - '//*[@class="sidebar-elems"]//li' 'Constants' // @has - '//*[@class="sidebar-elems"]//li' 'Statics' // @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' @@ -26,7 +25,7 @@ pub fn foo() {} pub trait Trait {} #[macro_export] macro_rules! foo { - () => {} + () => {}; } pub type Type = u8; pub const FOO: u8 = 0; diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index e1feb1cd6..f6a059de6 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -30,7 +30,7 @@ pub struct FooStruct; // @matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum' pub enum FooEnum {} -// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType' +// @matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType' // @matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType' pub type FooType = FooStruct; diff --git a/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs new file mode 100644 index 000000000..ff84352d7 --- /dev/null +++ b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs @@ -0,0 +1,34 @@ +#![crate_name = "inner_types_lazy"] + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +// @has 'inner_types_lazy/struct.Pair.html' +pub struct Pair<A, B> { + pub first: A, + pub second: B, +} + +// @has 'inner_types_lazy/type.ReversedTypesPair.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 0 +pub type ReversedTypesPair<Q, R> = Pair<R, Q>; + +// @has 'inner_types_lazy/type.ReadWrite.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 2 +pub type ReadWrite<R, W> = Pair<R, W> +where + R: std::io::Read, + W: std::io::Write; + +// @has 'inner_types_lazy/type.VecPair.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//span[@class="where fmt-newline"]' 0 +pub type VecPair<U, V> = Pair<Vec<U>, Vec<V>>; diff --git a/tests/rustdoc/typedef-inner-variants.rs b/tests/rustdoc/typedef-inner-variants.rs new file mode 100644 index 000000000..b734714fd --- /dev/null +++ b/tests/rustdoc/typedef-inner-variants.rs @@ -0,0 +1,119 @@ +// This test checks different combinations of structs, enums, and unions +// for the "Show Aliased Type" feature on type definition. + +#![crate_name = "inner_variants"] + +// aux-build:cross_crate_generic_typedef.rs +extern crate cross_crate_generic_typedef; + +pub struct Adt; +pub struct Ty; +pub struct TyCtxt; + +pub trait Interner { + type Adt; + type Ty; +} + +impl Interner for TyCtxt { + type Adt = Adt; + type Ty = Ty; +} + +// @has 'inner_variants/type.AliasTy.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +pub type AliasTy = Ty; + +// @has 'inner_variants/enum.IrTyKind.html' +pub enum IrTyKind<A, I: Interner> { + /// Doc comment for AdtKind + AdtKind(I::Adt), + /// and another one for TyKind + TyKind(I::Adt, <I as Interner>::Ty), + // no comment + StructKind { a: A, }, + #[doc(hidden)] + Unspecified, +} + +// @has 'inner_variants/type.NearlyTyKind.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 1 +// @count - '//*[@id="fields"]' 0 +pub type NearlyTyKind<A> = IrTyKind<A, TyCtxt>; + +// @has 'inner_variants/type.TyKind.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 1 +// @count - '//*[@id="fields"]' 0 +// @count - '//*[@class="variant"]' 3 +// @matches - '//pre[@class="rust item-decl"]//code' "enum TyKind" +// @has - '//pre[@class="rust item-decl"]//code/a[1]' "Adt" +// @has - '//pre[@class="rust item-decl"]//code/a[2]' "Adt" +// @has - '//pre[@class="rust item-decl"]//code/a[3]' "Ty" +// @has - '//pre[@class="rust item-decl"]//code/a[4]' "i64" +pub type TyKind = IrTyKind<i64, TyCtxt>; + +// @has 'inner_variants/union.OneOr.html' +pub union OneOr<A: Copy> { + pub one: i64, + pub or: A, +} + +// @has 'inner_variants/type.OneOrF64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 2 +// @matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64" +pub type OneOrF64 = OneOr<f64>; + +// @has 'inner_variants/struct.One.html' +pub struct One<T> { + pub val: T, + #[doc(hidden)] + pub __hidden: T, + __private: T, +} + +// @has 'inner_variants/type.OneU64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct OneU64" +// @matches - '//pre[@class="rust item-decl"]//code' "pub val" +pub type OneU64 = One<u64>; + +// @has 'inner_variants/struct.OnceA.html' +pub struct OnceA<'a, A> { + pub a: &'a A, +} + +// @has 'inner_variants/type.Once.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>" +// @matches - '//pre[@class="rust item-decl"]//code' "&'a" +pub type Once<'a> = OnceA<'a, i64>; + +// @has 'inner_variants/struct.HighlyGenericStruct.html' +pub struct HighlyGenericStruct<A, B, C, D> { + pub z: (A, B, C, D) +} + +// @has 'inner_variants/type.HighlyGenericAABB.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>" +// @matches - '//pre[@class="rust item-decl"]//code' "pub z" +pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>; + +// @has 'inner_variants/type.InlineU64.html' +// @count - '//*[@id="aliased-type"]' 1 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +pub use cross_crate_generic_typedef::InlineU64; diff --git a/tests/rustdoc/where.SWhere_Simd_item-decl.html b/tests/rustdoc/where.SWhere_Simd_item-decl.html index 3e72ba2b7..46708b9e4 100644 --- a/tests/rustdoc/where.SWhere_Simd_item-decl.html +++ b/tests/rustdoc/where.SWhere_Simd_item-decl.html @@ -1,3 +1,3 @@ -<pre class="rust item-decl"><code>pub struct Simd<T>(_) +<pre class="rust item-decl"><code>pub struct Simd<T>(/* private fields */) <span class="where">where T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre> diff --git a/tests/rustdoc/where.alpha_trait_decl.html b/tests/rustdoc/where.alpha_trait_decl.html index a7700055c..0c0b2d1ce 100644 --- a/tests/rustdoc/where.alpha_trait_decl.html +++ b/tests/rustdoc/where.alpha_trait_decl.html @@ -1,3 +1,3 @@ -<code>pub struct Alpha<A>(_) +<code>pub struct Alpha<A>(/* private fields */) <span class="where">where A: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code>
\ No newline at end of file diff --git a/tests/rustdoc/where.rs b/tests/rustdoc/where.rs index 2aa9c8b54..aea02c140 100644 --- a/tests/rustdoc/where.rs +++ b/tests/rustdoc/where.rs @@ -4,7 +4,7 @@ use std::io::Lines; pub trait MyTrait { fn dummy(&self) { } } -// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait" +// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(/* private fields */) where A: MyTrait" // @snapshot alpha_trait_decl - '//*[@class="rust item-decl"]/code' pub struct Alpha<A>(A) where A: MyTrait; // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait" |