diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /tests/rustdoc | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
137 files changed, 2147 insertions, 710 deletions
diff --git a/tests/rustdoc-gui/codeblock-tooltip.goml b/tests/rustdoc-gui/codeblock-tooltip.goml index e1c81ed79..7be5e39ba 100644 --- a/tests/rustdoc-gui/codeblock-tooltip.goml +++ b/tests/rustdoc-gui/codeblock-tooltip.goml @@ -40,6 +40,7 @@ define-function: ( "background-color": |background|, "border-color": |border|, }) + click: ".docblock .example-wrap.compile_fail .tooltip" // should_panic block assert-css: ( @@ -71,6 +72,7 @@ define-function: ( "background-color": |background|, "border-color": |border|, }) + click: ".docblock .example-wrap.should_panic .tooltip" // ignore block assert-css: ( diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index 4c36394a3..a50449e17 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -37,15 +37,15 @@ define-function: ( ) call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(92, 103, 115)", + "color": "#5c6773", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(59, 145, 226)", + "color": "#3b91e2", }) call-function: ("check-colors", { "theme": "light", - "color": "rgb(198, 126, 45)", + "color": "#c67e2d", }) // The first code block has two lines so let's check its `<pre>` elements lists both of them. diff --git a/tests/rustdoc-gui/fields.goml b/tests/rustdoc-gui/fields.goml new file mode 100644 index 000000000..b8139a2ed --- /dev/null +++ b/tests/rustdoc-gui/fields.goml @@ -0,0 +1,18 @@ +// This test checks that fields are displayed as expected (one by line). +go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html" +store-position: ("#structfield\.a", {"y": a_y}) +store-position: ("#structfield\.b", {"y": b_y}) +assert: |a_y| < |b_y| + +go-to: "file://" + |DOC_PATH| + "/test_docs/fields/union.Union.html" +store-position: ("#structfield\.a", {"y": a_y}) +store-position: ("#structfield\.b", {"y": b_y}) +assert: |a_y| < |b_y| + +go-to: "file://" + |DOC_PATH| + "/test_docs/fields/enum.Enum.html" +store-position: ("#variant\.A\.field\.a", {"y": a_y}) +store-position: ("#variant\.A\.field\.b", {"y": b_y}) +assert: |a_y| < |b_y| +store-position: ("#variant\.B\.field\.a", {"y": a_y}) +store-position: ("#variant\.B\.field\.b", {"y": b_y}) +assert: |a_y| < |b_y| diff --git a/tests/rustdoc-gui/headers-color.goml b/tests/rustdoc-gui/headers-color.goml index 7d83833a8..a7ac94c49 100644 --- a/tests/rustdoc-gui/headers-color.goml +++ b/tests/rustdoc-gui/headers-color.goml @@ -42,29 +42,29 @@ call-function: ( "check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "code_header_color": "rgb(230, 225, 207)", + "color": "#c5c5c5", + "code_header_color": "#e6e1cf", "focus_background_color": "rgba(255, 236, 164, 0.06)", - "headings_color": "rgb(57, 175, 215)", + "headings_color": "#39afd7", }, ) call-function: ( "check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "code_header_color": "rgb(221, 221, 221)", - "focus_background_color": "rgb(73, 74, 61)", - "headings_color": "rgb(210, 153, 29)", + "color": "#ddd", + "code_header_color": "#ddd", + "focus_background_color": "#494a3d", + "headings_color": "#d2991d", }, ) call-function: ( "check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "code_header_color": "rgb(0, 0, 0)", - "focus_background_color": "rgb(253, 255, 211)", - "headings_color": "rgb(56, 115, 173)", + "color": "black", + "code_header_color": "black", + "focus_background_color": "#fdffd3", + "headings_color": "#3873ad", }, ) diff --git a/tests/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml index 1a1c1b28f..6e880302f 100644 --- a/tests/rustdoc-gui/help-page.goml +++ b/tests/rustdoc-gui/help-page.goml @@ -67,5 +67,5 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" set-window-size: (1000, 1000) // Popover only appears when the screen width is >700px. assert-false: "#help" click: "#help-button > a" -click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" -wait-for-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} +click: "//*[@id='help']//a[text()='the rustdoc book']" +wait-for-document-property: ({"URL": "https://doc.rust-lang.org/"}, STARTS_WITH) diff --git a/tests/rustdoc-gui/label-next-to-symbol.goml b/tests/rustdoc-gui/label-next-to-symbol.goml index 6c6380256..eb603d6c6 100644 --- a/tests/rustdoc-gui/label-next-to-symbol.goml +++ b/tests/rustdoc-gui/label-next-to-symbol.goml @@ -37,7 +37,6 @@ compare-elements-position: ( ("y"), ) - // Mobile view set-window-size: (600, 600) // staggered layout with 2em spacing @@ -64,3 +63,14 @@ compare-elements-position-false: ( "//*[@class='desc docblock-short'][text()='a thing with a label']", ("y"), ) + +// Ensure it doesn't expand. +set-window-size: (800, 800) +go-to: "file://" + |DOC_PATH| + "/test_docs/cfgs/index.html" +// This part of the tags should not be on the same line as the beginning since the width +// is too small for that. +compare-elements-position-false: ( + "//*[@class='stab portability']/code[text()='appservice-api-c']", + "//*[@class='stab portability']/code[text()='server']", + ("y"), +) diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index ecb57c274..e10bb538f 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -122,7 +122,7 @@ assert-count: ("//*[@class='tooltip popover']", 0) // Now check the colors. define-function: ( "check-colors", - (theme, header_color, content_color, type_color, trait_color), + (theme, header_color, content_color, type_color, trait_color, link_color), block { go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" // This is needed to ensure that the text color is computed. @@ -133,8 +133,20 @@ define-function: ( // We reload the page so the local storage settings are being used. reload: + assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"color": |content_color|}, + ALL, + ) + move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" - assert-count: (".tooltip.popover", 1) + wait-for-count: (".tooltip.popover", 1) + + assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"color": |link_color|}, + ALL, + ) assert-css: ( ".tooltip.popover h3", @@ -163,10 +175,11 @@ call-function: ( "check-colors", { "theme": "ayu", - "content_color": "rgb(230, 225, 207)", - "header_color": "rgb(255, 255, 255)", - "type_color": "rgb(255, 160, 165)", - "trait_color": "rgb(57, 175, 215)", + "link_color": "#39afd7", + "content_color": "#e6e1cf", + "header_color": "#fff", + "type_color": "#ffa0a5", + "trait_color": "#39afd7", }, ) @@ -174,10 +187,11 @@ call-function: ( "check-colors", { "theme": "dark", - "content_color": "rgb(221, 221, 221)", - "header_color": "rgb(221, 221, 221)", - "type_color": "rgb(45, 191, 184)", - "trait_color": "rgb(183, 140, 242)", + "link_color": "#d2991d", + "content_color": "#ddd", + "header_color": "#ddd", + "type_color": "#2dbfb8", + "trait_color": "#b78cf2", }, ) @@ -185,10 +199,11 @@ call-function: ( "check-colors", { "theme": "light", - "content_color": "rgb(0, 0, 0)", - "header_color": "rgb(0, 0, 0)", - "type_color": "rgb(173, 55, 138)", - "trait_color": "rgb(110, 79, 201)", + "link_color": "#3873ad", + "content_color": "black", + "header_color": "black", + "type_color": "#ad378a", + "trait_color": "#6e4fc9", }, ) diff --git a/tests/rustdoc-gui/search-filter.goml b/tests/rustdoc-gui/search-filter.goml index d739471a6..9e2855b5e 100644 --- a/tests/rustdoc-gui/search-filter.goml +++ b/tests/rustdoc-gui/search-filter.goml @@ -65,9 +65,9 @@ reload: set-timeout: 2000 wait-for: "#crate-search" assert-css: ("#crate-search", { - "border": "1px solid rgb(224, 224, 224)", - "color": "rgb(0, 0, 0)", - "background-color": "rgb(255, 255, 255)", + "border": "1px solid #e0e0e0", + "color": "black", + "background-color": "white", }) // We now check the dark theme. @@ -75,15 +75,15 @@ click: "#settings-menu" wait-for: "#settings" click: "#theme-dark" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(224, 224, 224)", - "color": "rgb(221, 221, 221)", - "background-color": "rgb(53, 53, 53)", + "border": "1px solid #e0e0e0", + "color": "#ddd", + "background-color": "#353535", }) // And finally we check the ayu theme. click: "#theme-ayu" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(92, 103, 115)", - "color": "rgb(255, 255, 255)", - "background-color": "rgb(15, 20, 25)", + "border": "1px solid #5c6773", + "color": "#fff", + "background-color": "#0f1419", }) diff --git a/tests/rustdoc-gui/search-reexport.goml b/tests/rustdoc-gui/search-reexport.goml index fd817b589..6ea6d53e2 100644 --- a/tests/rustdoc-gui/search-reexport.goml +++ b/tests/rustdoc-gui/search-reexport.goml @@ -14,10 +14,10 @@ assert-attribute: ( "//a[@class='result-import']", {"href": "../test_docs/index.html#reexport.TheStdReexport"}, ) -assert-text: ("//a[@class='result-import']", "test_docs::TheStdReexport") +assert-text: ("a.result-import .result-name", "re-export test_docs::TheStdReexport") click: "//a[@class='result-import']" // We check that it has the background modified thanks to the focus. -wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"}) +wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a3d"}) // We now check that the alias is working as well on the reexport. // To be SURE that the search will be run. @@ -25,9 +25,9 @@ press-key: 'Enter' write: (".search-input", "AliasForTheStdReexport") wait-for: "//a[@class='result-import']" assert-text: ( - "//a[@class='result-import']", - "AliasForTheStdReexport - see test_docs::TheStdReexport", + "a.result-import .result-name", + "AliasForTheStdReexport - see re-export test_docs::TheStdReexport", ) // Same thing again, we click on it to ensure the background is once again set as expected. click: "//a[@class='result-import']" -wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"}) +wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a3d"}) diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index 90f7160b7..7a7785fd9 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -28,6 +28,12 @@ define-function: ( ".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}, ) + // color of the typename (struct, module, method, ...) before search results + assert-css: ( + ".result-name .typename", + {"color": |grey|}, + ALL, + ) }, ) @@ -55,7 +61,7 @@ assert-css: ( {"color": "#c5c5c5"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#0096cf"}, ) @@ -65,16 +71,11 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color of "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#788797"}, -) - store-value: (entry_color, "#0096cf") // color of the search entry store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#3c3c3c") // hover background color +store-value: (grey, "#999") call-function: ( "check-result-color", ( @@ -137,7 +138,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#0096cf", "background-color": "transparent"}, ALL, ) @@ -145,11 +146,11 @@ assert-css: ( // Checking color and background on hover. move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']" assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#fff"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#fff", "background-color": "rgb(60, 60, 60)"}, ) @@ -172,7 +173,7 @@ assert-css: ( {"color": "#ddd"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#ddd"}, ) @@ -182,16 +183,11 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color for "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#ddd"}, -) - store-value: (entry_color, "#ddd") // color of the search entry store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#616161") // hover background color +store-value: (grey, "#ccc") call-function: ( "check-result-color", ( @@ -254,7 +250,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#ddd", "background-color": "transparent"}, ) @@ -274,7 +270,7 @@ assert-css: ( {"color": "#000"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#000"}, ) @@ -284,16 +280,11 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color for "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#000"}, -) - store-value: (entry_color, "#000") // color of the search entry store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#ccc") // hover background color +store-value: (grey, "#999") call-function: ( "check-result-color", ( @@ -356,7 +347,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#000", "background-color": "transparent"}, ) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index ee5598e4b..6ce13b8c3 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // Checks that the search results have the expected width. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" set-window-size: (900, 1000) @@ -7,14 +8,41 @@ press-key: 'Enter' wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... -assert-css: (".search-results div.desc", {"width": "310px"}) +assert-size: (".search-results div.desc", {"width": 248}) +store-size: (".search-results .result-name .typename", {"width": width}) set-window-size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. -assert-css: (".search-results div.desc", {"width": "566px"}) +assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. -assert-css: (".search-results .result-name > span", {"display": "inline"}) +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2}, +) +compare-elements-position-near-false: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"x": 5}, +) +// The width of the "typename" isn't fixed anymore in this display mode. +store-size: (".search-results .result-name .typename", {"width": new_width}) +assert: |new_width| < |width| - 10 + +// Check that if the search is too long on mobile, it'll go under the "typename". +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName" +wait-for: "#crate-search" +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2, "x": 0}, +) +compare-elements-size-near: ( + ".search-results .result-name", + ".search-results .result-name .path", + {"width": 8, "height": 8}, +) // Check that the crate filter `<select>` is correctly handled when it goes to next line. // To do so we need to update the length of one of its `<option>`. @@ -57,22 +85,22 @@ define-function: ( call-function: ("check-filter", { "theme": "ayu", - "border": "rgb(92, 103, 115)", + "border": "#5c6773", "filter": "invert(0.41) sepia(0.12) saturate(4.87) hue-rotate(171deg) brightness(0.94) contrast(0.94)", - "hover_border": "rgb(224, 224, 224)", + "hover_border": "#e0e0e0", "hover_filter": "invert(0.98) sepia(0.12) saturate(0.81) hue-rotate(343deg) brightness(1.13) contrast(0.76)", }) call-function: ("check-filter", { "theme": "dark", - "border": "rgb(224, 224, 224)", + "border": "#e0e0e0", "filter": "invert(0.94) sepia(0) saturate(7.21) hue-rotate(255deg) brightness(0.9) contrast(0.9)", - "hover_border": "rgb(33, 150, 243)", + "hover_border": "#2196f3", "hover_filter": "invert(0.69) sepia(0.6) saturate(66.13) hue-rotate(184deg) brightness(1) contrast(0.91)", }) call-function: ("check-filter", { "theme": "light", - "border": "rgb(224, 224, 224)", + "border": "#e0e0e0", "filter": "invert(1) sepia(0) saturate(42.23) hue-rotate(289deg) brightness(1.14) contrast(0.76)", - "hover_border": "rgb(113, 113, 113)", + "hover_border": "#717171", "hover_filter": "invert(0.44) sepia(0.18) saturate(0.23) hue-rotate(317deg) brightness(0.96) contrast(0.93)", }) diff --git a/tests/rustdoc-gui/search-result-keyword.goml b/tests/rustdoc-gui/search-result-keyword.goml index 5d56e9d9c..1b2be6d4e 100644 --- a/tests/rustdoc-gui/search-result-keyword.goml +++ b/tests/rustdoc-gui/search-result-keyword.goml @@ -5,9 +5,4 @@ write: (".search-input", "CookieMonster") press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#search-tabs" -// Note: The two next assert commands could be merged as one but readability would be -// less good. -// -// Checking that the CSS is displaying " (keyword)" in italic. -assert-text: (".result-name span.keyword > i", "(keyword)") -assert-text: (".result-name span.keyword", "CookieMonster (keyword)") +assert-text: (".result-keyword .result-name", "keyword CookieMonster") diff --git a/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml index b3f9ae928..156d8d03c 100644 --- a/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml +++ b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml @@ -55,7 +55,7 @@ assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Return Types" // Try with a search-by-parameter go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -write: (".search-input", "usize pattern") +write: (".search-input", "usize,pattern") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... diff --git a/tests/rustdoc-gui/setting-go-to-only-result.goml b/tests/rustdoc-gui/setting-go-to-only-result.goml index c5720b4bf..45e0b3490 100644 --- a/tests/rustdoc-gui/setting-go-to-only-result.goml +++ b/tests/rustdoc-gui/setting-go-to-only-result.goml @@ -34,7 +34,14 @@ go-to: "file://" + |DOC_PATH| + "/lib2/index.html" // We enter it into the search. write: (".search-input", "HasALongTraitWithParams") wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} -assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) +assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) + +// Regression test for <https://github.com/rust-lang/rust/issues/112676>. +// If "go-to-only-result" is enabled and you go back to history, it should not lead you back to the +// page result again automatically. +history-go-back: +wait-for-document-property: {"title": "lib2 - Rust"} +assert-window-property: ({"location": "/lib2/index.html"}, ENDS_WITH) // We try again to see if it goes to the only result go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index c37d96932..e40c637dc 100644 --- a/tests/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -56,19 +56,19 @@ move-cursor-to: "#settings-menu > a" assert-css: ( "#theme-dark", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-color": "#999", + "box-shadow": "#353535 0px 0px 0px 3px inset", "border-width": "2px", }, ) -assert-css: ("#theme-light", {"border-color": "rgb(153, 153, 153)", "box-shadow": "none"}) +assert-css: ("#theme-light", {"border-color": "#999", "box-shadow": "none"}) // Let's start with the hover for radio buttons. move-cursor-to: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-color": "#2196f3", + "box-shadow": "#353535 0px 0px 0px 3px inset", "border-width": "2px", }, ) @@ -76,7 +76,7 @@ move-cursor-to: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(33, 150, 243)", + "border-color": "#2196f3", "box-shadow": "none", "border-width": "2px", } @@ -87,8 +87,8 @@ focus: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-color": "#999", + "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px", "border-width": "2px", }, ) @@ -96,8 +96,8 @@ focus: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", "border-width": "2px", }, ) @@ -107,8 +107,8 @@ focus: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-color": "#2196f3", + "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px", "border-width": "2px", }, ) @@ -117,8 +117,8 @@ focus: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", "border-width": "2px", }, ) @@ -154,8 +154,8 @@ compare-elements-position-near: ( assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(153, 153, 153)", + "background-color": "#2196f3", + "border-color": "#999", // 1px border when checked "border-width": "1px", }, @@ -164,7 +164,7 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(153, 153, 153)", + "border-color": "#999", // 2px border when unchecked "border-width": "2px", }, @@ -174,8 +174,8 @@ move-cursor-to: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(33, 150, 243)", + "background-color": "#2196f3", + "border-color": "#2196f3", // 1px border when checked "border-width": "1px", }, @@ -185,7 +185,7 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(33, 150, 243)", + "border-color": "#2196f3", // 2px border when unchecked "border-width": "2px", }, @@ -196,9 +196,9 @@ focus: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "background-color": "#2196f3", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 1px border when checked "border-width": "1px", }, @@ -208,8 +208,8 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 2px border when unchecked "border-width": "2px", }, @@ -220,9 +220,9 @@ focus: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "background-color": "#2196f3", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 1px border when checked "border-width": "1px", }, @@ -233,8 +233,8 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 2px border when unchecked "border-width": "2px", }, diff --git a/tests/rustdoc-gui/shortcuts.goml b/tests/rustdoc-gui/shortcuts.goml index 667df89ec..2c61ee542 100644 --- a/tests/rustdoc-gui/shortcuts.goml +++ b/tests/rustdoc-gui/shortcuts.goml @@ -13,7 +13,7 @@ press-key: "Escape" assert-css: ("#help-button .popover", {"display": "none"}) // Checking doc collapse and expand. // It should be displaying a "-": -assert-text: ("#toggle-all-docs", "[\u2212]") +assert-text: ("#toggle-all-docs", "[โ]") press-key: "-" wait-for-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) @@ -23,9 +23,9 @@ assert-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) // Expanding now. press-key: "+" -wait-for-text: ("#toggle-all-docs", "[\u2212]") +wait-for-text: ("#toggle-all-docs", "[โ]") assert-attribute: ("#toggle-all-docs", {"class": ""}) // Pressing it again shouldn't do anything. press-key: "+" -assert-text: ("#toggle-all-docs", "[\u2212]") +assert-text: ("#toggle-all-docs", "[โ]") assert-attribute: ("#toggle-all-docs", {"class": ""}) diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 3b022c7e9..4b8337ace 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -73,16 +73,16 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background": "rgb(20, 25, 31)", + "color": "#c5c5c5", + "background": "#14191f", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "background": "rgb(80, 80, 80)", + "color": "#ddd", + "background": "#505050", }) call-function: ("check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "background": "rgb(245, 245, 245)", + "color": "black", + "background": "#F5F5F5", }) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 520b2c59b..2cb888178 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.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", } ) diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index d5dd511b1..f8f73398d 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -64,23 +64,23 @@ call-function: ("check-colors", { compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) // Check the `href` property so that users can treat anchors as links. assert-property: (".src-line-numbers > a:nth-child(1)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#1" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#1" +}, ENDS_WITH) assert-property: (".src-line-numbers > a:nth-child(2)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#2" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#2" +}, ENDS_WITH) assert-property: (".src-line-numbers > a:nth-child(3)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#3" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#3" +}, ENDS_WITH) assert-property: (".src-line-numbers > a:nth-child(4)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#4" +}, ENDS_WITH) assert-property: (".src-line-numbers > a:nth-child(5)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#5" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#5" +}, ENDS_WITH) assert-property: (".src-line-numbers > a:nth-child(6)", { - "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#6" -}) + "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#6" +}, ENDS_WITH) // Assert that the line numbers text is aligned to the right. assert-css: (".src-line-numbers", {"text-align": "right"}) diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 6ad1e8b4f..ecf3a7cc1 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -486,3 +486,33 @@ pub mod search_results { } } + +pub mod fields { + pub struct Struct { + pub a: u8, + pub b: u32, + } + pub union Union { + pub a: u8, + pub b: u32, + } + pub enum Enum { + A { + a: u8, + b: u32, + }, + B { + a: u8, + b: u32, + }, + } +} + +pub mod cfgs { + #[doc(cfg(all( + any(not(feature = "appservice-api-c"), not(feature = "appservice-api-s")), + any(not(feature = "client"), not(feature = "server")), + )))] + /// Some docs. + pub mod cfgs {} +} diff --git a/tests/rustdoc-gui/target.goml b/tests/rustdoc-gui/target.goml index 0c514fc68..c5e7f813d 100644 --- a/tests/rustdoc-gui/target.goml +++ b/tests/rustdoc-gui/target.goml @@ -25,11 +25,11 @@ call-function: ("check-style", { }) call-function: ("check-style", { "theme": "dark", - "background": "rgb(73, 74, 61)", - "border": "rgb(187, 116, 16)", + "background": "#494a3d", + "border": "#bb7410", }) call-function: ("check-style", { "theme": "light", - "background": "rgb(253, 255, 211)", - "border": "rgb(173, 124, 55)", + "background": "#fdffd3", + "border": "#ad7c37", }) diff --git a/tests/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml index ae6947213..e4b031b73 100644 --- a/tests/rustdoc-gui/theme-change.goml +++ b/tests/rustdoc-gui/theme-change.goml @@ -3,9 +3,9 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} reload: -store-value: (background_light, "rgb(255, 255, 255)") -store-value: (background_dark, "rgb(53, 53, 53)") -store-value: (background_ayu, "rgb(15, 20, 25)") +store-value: (background_light, "white") +store-value: (background_dark, "#353535") +store-value: (background_ayu, "#0f1419") click: "#settings-menu" wait-for: "#theme-ayu" diff --git a/tests/rustdoc-gui/theme-in-history.goml b/tests/rustdoc-gui/theme-in-history.goml index 8fcd0ecd3..42c5b5e6e 100644 --- a/tests/rustdoc-gui/theme-in-history.goml +++ b/tests/rustdoc-gui/theme-in-history.goml @@ -7,7 +7,7 @@ set-local-storage: { } // We reload the page so the local storage settings are being used. reload: -assert-css: ("body", { "background-color": "rgb(53, 53, 53)" }) +assert-css: ("body", { "background-color": "#353535" }) assert-local-storage: { "rustdoc-theme": "dark" } // Now we go to the settings page. @@ -15,7 +15,7 @@ go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" // We change the theme to "light". click: "#theme-light" -wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" }) +wait-for-css: ("body", { "background-color": "white" }) assert-local-storage: { "rustdoc-theme": "light" } // We go back in history. @@ -23,5 +23,5 @@ history-go-back: // Confirm that we're not on the settings page. assert-false: "#settings" // Check that the current theme is still "light". -assert-css: ("body", { "background-color": "rgb(255, 255, 255)" }) +assert-css: ("body", { "background-color": "white" }) assert-local-storage: { "rustdoc-theme": "light" } diff --git a/tests/rustdoc-js-std/alias-1.js b/tests/rustdoc-js-std/alias-1.js index 7c6327fcd..b27b3da21 100644 --- a/tests/rustdoc-js-std/alias-1.js +++ b/tests/rustdoc-js-std/alias-1.js @@ -1,6 +1,5 @@ -const QUERY = '&'; - const EXPECTED = { + 'query': '&', 'others': [ { 'path': 'std', 'name': 'reference' }, ], diff --git a/tests/rustdoc-js-std/alias-2.js b/tests/rustdoc-js-std/alias-2.js index 798fa29ef..5735b573b 100644 --- a/tests/rustdoc-js-std/alias-2.js +++ b/tests/rustdoc-js-std/alias-2.js @@ -1,6 +1,5 @@ -const QUERY = '+'; - const EXPECTED = { + 'query': '+', 'others': [ { 'path': 'std::ops', 'name': 'AddAssign' }, { 'path': 'std::ops', 'name': 'Add' }, diff --git a/tests/rustdoc-js-std/alias-3.js b/tests/rustdoc-js-std/alias-3.js index 392b1e818..ed3776b3c 100644 --- a/tests/rustdoc-js-std/alias-3.js +++ b/tests/rustdoc-js-std/alias-3.js @@ -1,6 +1,5 @@ -const QUERY = '!'; - const EXPECTED = { + 'query': '!', 'others': [ { 'path': 'std', 'name': 'never' }, ], diff --git a/tests/rustdoc-js-std/alias-4.js b/tests/rustdoc-js-std/alias-4.js index bf2bb4d29..35840a472 100644 --- a/tests/rustdoc-js-std/alias-4.js +++ b/tests/rustdoc-js-std/alias-4.js @@ -1,6 +1,5 @@ -const QUERY = '<'; - const EXPECTED = { + 'query': '<', 'others': [ { 'name': 'Ord' }, ], diff --git a/tests/rustdoc-js-std/alias.js b/tests/rustdoc-js-std/alias.js index 2b709c991..bf707fa03 100644 --- a/tests/rustdoc-js-std/alias.js +++ b/tests/rustdoc-js-std/alias.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = '['; - const EXPECTED = { + 'query': '[', 'others': [ { 'path': 'std', 'name': 'slice' }, { 'path': 'std::ops', 'name': 'IndexMut' }, diff --git a/tests/rustdoc-js-std/asrawfd.js b/tests/rustdoc-js-std/asrawfd.js index 369a34f9c..5b3cfeabb 100644 --- a/tests/rustdoc-js-std/asrawfd.js +++ b/tests/rustdoc-js-std/asrawfd.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'RawFd::as_raw_fd'; - const EXPECTED = { + 'query': 'RawFd::as_raw_fd', 'others': [ // Reproduction test for https://github.com/rust-lang/rust/issues/78724 // Validate that type alias methods get the correct path. diff --git a/tests/rustdoc-js-std/basic.js b/tests/rustdoc-js-std/basic.js index 824cac710..baff24b0a 100644 --- a/tests/rustdoc-js-std/basic.js +++ b/tests/rustdoc-js-std/basic.js @@ -1,6 +1,5 @@ -const QUERY = 'String'; - const EXPECTED = { + 'query': 'String', 'others': [ { 'path': 'std::string', 'name': 'String' }, { 'path': 'std::ffi', 'name': 'CString' }, diff --git a/tests/rustdoc-js-std/bufread-fill-buf.js b/tests/rustdoc-js-std/bufread-fill-buf.js new file mode 100644 index 000000000..3828cf760 --- /dev/null +++ b/tests/rustdoc-js-std/bufread-fill-buf.js @@ -0,0 +1,13 @@ +// ignore-order + +const EXPECTED = [ + { + 'query': 'bufread -> result<u8>', + 'others': [ + { 'path': 'std::io::Split', 'name': 'next' }, + { 'path': 'std::boxed::Box', 'name': 'fill_buf' }, + { 'path': 'std::io::Chain', 'name': 'fill_buf' }, + { 'path': 'std::io::Take', 'name': 'fill_buf' }, + ], + }, +]; diff --git a/tests/rustdoc-js-std/deduplication.js b/tests/rustdoc-js-std/deduplication.js index f02f6cf55..51279dd5e 100644 --- a/tests/rustdoc-js-std/deduplication.js +++ b/tests/rustdoc-js-std/deduplication.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'is_nan'; - const EXPECTED = { + 'query': 'is_nan', 'others': [ { 'path': 'std::f32', 'name': 'is_nan' }, { 'path': 'std::f64', 'name': 'is_nan' }, diff --git a/tests/rustdoc-js-std/enum-option.js b/tests/rustdoc-js-std/enum-option.js index 902e09069..216dafe3b 100644 --- a/tests/rustdoc-js-std/enum-option.js +++ b/tests/rustdoc-js-std/enum-option.js @@ -1,6 +1,5 @@ -const QUERY = 'enum:Option'; - const EXPECTED = { + 'query': 'enum:Option', 'others': [ { 'path': 'std::option', 'name': 'Option' }, ], diff --git a/tests/rustdoc-js-std/filter-crate.js b/tests/rustdoc-js-std/filter-crate.js index b47a1fefa..95f2969d2 100644 --- a/tests/rustdoc-js-std/filter-crate.js +++ b/tests/rustdoc-js-std/filter-crate.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = '"hashmap"'; const FILTER_CRATE = 'core'; const EXPECTED = { + 'query': 'hashmap', 'others': [ ], }; diff --git a/tests/rustdoc-js-std/fn-forget.js b/tests/rustdoc-js-std/fn-forget.js index 66a5fcaa7..addecf4e4 100644 --- a/tests/rustdoc-js-std/fn-forget.js +++ b/tests/rustdoc-js-std/fn-forget.js @@ -1,6 +1,5 @@ -const QUERY = 'fn:forget'; - const EXPECTED = { + 'query': 'fn:forget', 'others': [ { 'path': 'std::mem', 'name': 'forget' }, { 'path': 'std::fmt', 'name': 'format' }, diff --git a/tests/rustdoc-js-std/from_u.js b/tests/rustdoc-js-std/from_u.js index e3f3cd436..7c9375ba5 100644 --- a/tests/rustdoc-js-std/from_u.js +++ b/tests/rustdoc-js-std/from_u.js @@ -1,6 +1,5 @@ -const QUERY = 'from_u'; - const EXPECTED = { + 'query': 'from_u', 'others': [ { 'path': 'std::char', 'name': 'from_u32' }, { 'path': 'std::str', 'name': 'from_utf8' }, diff --git a/tests/rustdoc-js-std/keyword.js b/tests/rustdoc-js-std/keyword.js index 868ddd7b6..b85ba3413 100644 --- a/tests/rustdoc-js-std/keyword.js +++ b/tests/rustdoc-js-std/keyword.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'fn'; - const EXPECTED = { + 'query': 'fn', 'others': [ { 'path': 'std', 'name': 'fn', ty: 15 }, // 15 is for primitive types { 'path': 'std', 'name': 'fn', ty: 21 }, // 21 is for keywords diff --git a/tests/rustdoc-js-std/macro-check.js b/tests/rustdoc-js-std/macro-check.js index 242e0cbf5..c22b1753f 100644 --- a/tests/rustdoc-js-std/macro-check.js +++ b/tests/rustdoc-js-std/macro-check.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'panic'; - const EXPECTED = { + 'query': 'panic', 'others': [ { 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros { 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules diff --git a/tests/rustdoc-js-std/macro-print.js b/tests/rustdoc-js-std/macro-print.js index 1b4c7b405..2ef1c89e4 100644 --- a/tests/rustdoc-js-std/macro-print.js +++ b/tests/rustdoc-js-std/macro-print.js @@ -1,6 +1,5 @@ -const QUERY = 'macro:print'; - const EXPECTED = { + 'query': 'macro:print', 'others': [ { 'path': 'std', 'name': 'print' }, { 'path': 'std', 'name': 'println' }, diff --git a/tests/rustdoc-js-std/never.js b/tests/rustdoc-js-std/never.js index 392b1e818..27d415b5e 100644 --- a/tests/rustdoc-js-std/never.js +++ b/tests/rustdoc-js-std/never.js @@ -1,7 +1,14 @@ -const QUERY = '!'; - -const EXPECTED = { - 'others': [ - { 'path': 'std', 'name': 'never' }, - ], -}; +const EXPECTED = [ + { + 'query': '!', + 'others': [ + { 'path': 'std', 'name': 'never' }, + ], + }, + { + 'query': '!::clone', + 'others': [ + { 'path': 'std::never', 'name': 'clone' }, + ], + }, +]; diff --git a/tests/rustdoc-js-std/option-type-signatures.js b/tests/rustdoc-js-std/option-type-signatures.js index 6bf421a21..259978506 100644 --- a/tests/rustdoc-js-std/option-type-signatures.js +++ b/tests/rustdoc-js-std/option-type-signatures.js @@ -1,18 +1,22 @@ -const QUERY = [ - 'option, fnonce -> option', - 'option -> default', -]; - const EXPECTED = [ { + 'query': 'option, fnonce -> option', 'others': [ { 'path': 'std::option::Option', 'name': 'map' }, ], }, { + 'query': 'option -> default', 'others': [ { 'path': 'std::option::Option', 'name': 'unwrap_or_default' }, { 'path': 'std::option::Option', 'name': 'get_or_insert_default' }, ], }, + { + 'query': 'option -> []', + 'others': [ + { 'path': 'std::option::Option', 'name': 'as_slice' }, + { 'path': 'std::option::Option', 'name': 'as_mut_slice' }, + ], + }, ]; diff --git a/tests/rustdoc-js-std/osstring-to-string.js b/tests/rustdoc-js-std/osstring-to-string.js new file mode 100644 index 000000000..17bb602a5 --- /dev/null +++ b/tests/rustdoc-js-std/osstring-to-string.js @@ -0,0 +1,9 @@ +// exact-match + +// https://github.com/rust-lang/rust/issues/60485#issuecomment-663900624 +const EXPECTED = { + 'query': 'OsString -> String', + 'others': [ + { 'path': 'std::ffi::OsString', 'name': 'into_string' }, + ] +}; diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js index d1aa840ab..b32bfea54 100644 --- a/tests/rustdoc-js-std/parser-errors.js +++ b/tests/rustdoc-js-std/parser-errors.js @@ -1,50 +1,6 @@ -const QUERY = [ - '<P>', - '-> <P>', - 'a<"P">', - '"P" "P"', - 'P "P"', - '"p" p', - '"const": p', - "a<:a>", - "a<::a>", - "((a))", - "(p -> p", - "::a::b", - "a::::b", - "a::b::", - ":a", - "a b:", - "a (b:", - "_:", - "_:a", - "a-bb", - "a>bb", - "ab'", - "a->", - '"p" <a>', - '"p" a<a>', - "a,<", - "aaaaa<>b", - "fn:aaaaa<>b", - "->a<>b", - "a<->", - "a:: a", - "a ::a", - "a<a>:", - "a<>:", - "a,:", - " a<> :", - "mod : :", - "a!a", - "a!!", - "mod:a!", - "a!::a", - "a<", -]; - const PARSED = [ { + query: '<P>', elems: [], foundElems: 0, original: "<P>", @@ -53,6 +9,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: '-> <P>', elems: [], foundElems: 0, original: "-> <P>", @@ -61,6 +18,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: 'a<"P">', elems: [], foundElems: 0, original: "a<\"P\">", @@ -69,38 +27,61 @@ const PARSED = [ error: "Unexpected `\"` in generics", }, { + query: '"P" "P"', elems: [], foundElems: 0, original: "\"P\" \"P\"", returned: [], userQuery: "\"p\" \"p\"", + error: "Cannot have more than one element if you use quotes", + }, + { + query: '"P","P"', + elems: [], + foundElems: 0, + original: "\"P\",\"P\"", + returned: [], + userQuery: "\"p\",\"p\"", error: "Cannot have more than one literal search element", }, { + query: "P,\"P\"", elems: [], foundElems: 0, - original: "P \"P\"", + original: "P,\"P\"", returned: [], - userQuery: "p \"p\"", + userQuery: "p,\"p\"", error: "Cannot use literal search when there is more than one element", }, { + query: '"p" p', elems: [], foundElems: 0, original: "\"p\" p", returned: [], userQuery: "\"p\" p", - error: "You cannot have more than one element if you use quotes", + error: "Cannot have more than one element if you use quotes", + }, + { + query: '"p",p', + elems: [], + foundElems: 0, + original: "\"p\",p", + returned: [], + userQuery: "\"p\",p", + error: "Cannot have more than one element if you use quotes", }, { + query: '"const": p', elems: [], foundElems: 0, original: "\"const\": p", returned: [], userQuery: "\"const\": p", - error: "You cannot use quotes on type filter", + error: "Cannot use quotes on type filter", }, { + query: "a<:a>", elems: [], foundElems: 0, original: "a<:a>", @@ -109,6 +90,7 @@ const PARSED = [ error: "Expected type filter before `:`", }, { + query: "a<::a>", elems: [], foundElems: 0, original: "a<::a>", @@ -117,6 +99,7 @@ const PARSED = [ error: "Unexpected `::`: paths cannot start with `::`", }, { + query: "((a))", elems: [], foundElems: 0, original: "((a))", @@ -125,6 +108,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "(p -> p", elems: [], foundElems: 0, original: "(p -> p", @@ -133,6 +117,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "::a::b", elems: [], foundElems: 0, original: "::a::b", @@ -141,6 +126,16 @@ const PARSED = [ error: "Paths cannot start with `::`", }, { + query: " ::a::b", + elems: [], + foundElems: 0, + original: "::a::b", + returned: [], + userQuery: "::a::b", + error: "Paths cannot start with `::`", + }, + { + query: "a::::b", elems: [], foundElems: 0, original: "a::::b", @@ -149,6 +144,7 @@ const PARSED = [ error: "Unexpected `::::`", }, { + query: "a::b::", elems: [], foundElems: 0, original: "a::b::", @@ -157,6 +153,7 @@ const PARSED = [ error: "Paths cannot end with `::`", }, { + query: ":a", elems: [], foundElems: 0, original: ":a", @@ -165,14 +162,16 @@ const PARSED = [ error: "Expected type filter before `:`", }, { + query: "a,b:", elems: [], foundElems: 0, - original: "a b:", + original: "a,b:", returned: [], - userQuery: "a b:", - error: "Unexpected `:` (expected path after type filter)", + userQuery: "a,b:", + error: "Unexpected `:` (expected path after type filter `b:`)", }, { + query: "a (b:", elems: [], foundElems: 0, original: "a (b:", @@ -181,14 +180,16 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "_:", elems: [], foundElems: 0, original: "_:", returned: [], userQuery: "_:", - error: "Unexpected `:` (expected path after type filter)", + error: "Unexpected `:` (expected path after type filter `_:`)", }, { + query: "_:a", elems: [], foundElems: 0, original: "_:a", @@ -197,6 +198,7 @@ const PARSED = [ error: "Unknown type filter `_`", }, { + query: "a-bb", elems: [], foundElems: 0, original: "a-bb", @@ -205,6 +207,7 @@ const PARSED = [ error: "Unexpected `-` (did you mean `->`?)", }, { + query: "a>bb", elems: [], foundElems: 0, original: "a>bb", @@ -213,6 +216,7 @@ const PARSED = [ error: "Unexpected `>` (did you mean `->`?)", }, { + query: "ab'", elems: [], foundElems: 0, original: "ab'", @@ -221,6 +225,7 @@ const PARSED = [ error: "Unexpected `'`", }, { + query: "a->", elems: [], foundElems: 0, original: "a->", @@ -229,22 +234,43 @@ const PARSED = [ error: "Expected at least one item after `->`", }, { + query: '"p" <a>', elems: [], foundElems: 0, original: '"p" <a>', returned: [], userQuery: '"p" <a>', + error: "Cannot have more than one element if you use quotes", + }, + { + query: '"p",<a>', + elems: [], + foundElems: 0, + original: '"p",<a>', + returned: [], + userQuery: '"p",<a>', error: "Found generics without a path", }, { + query: '"p" a<a>', elems: [], foundElems: 0, original: '"p" a<a>', returned: [], userQuery: '"p" a<a>', - error: "You cannot have more than one element if you use quotes", + error: "Cannot have more than one element if you use quotes", + }, + { + query: '"p",a<a>', + elems: [], + foundElems: 0, + original: '"p",a<a>', + returned: [], + userQuery: '"p",a<a>', + error: "Cannot have more than one element if you use quotes", }, { + query: "a,<", elems: [], foundElems: 0, original: 'a,<', @@ -253,30 +279,34 @@ const PARSED = [ error: 'Found generics without a path', }, { + query: "aaaaa<>b", elems: [], foundElems: 0, original: 'aaaaa<>b', returned: [], userQuery: 'aaaaa<>b', - error: 'Expected `,`, ` `, `:` or `->`, found `b`', + error: 'Expected `,`, `:` or `->` after `>`, found `b`', }, { + query: "fn:aaaaa<>b", elems: [], foundElems: 0, original: 'fn:aaaaa<>b', returned: [], userQuery: 'fn:aaaaa<>b', - error: 'Expected `,`, ` `, `:` or `->`, found `b`', + error: 'Expected `,`, `:` or `->` after `>`, found `b`', }, { + query: "->a<>b", elems: [], foundElems: 0, original: '->a<>b', returned: [], userQuery: '->a<>b', - error: 'Expected `,` or ` `, found `b`', + error: 'Expected `,` after `>`, found `b`', }, { + query: "a<->", elems: [], foundElems: 0, original: 'a<->', @@ -285,62 +315,79 @@ const PARSED = [ error: 'Unexpected `-` after `<`', }, { + query: "a:: a", elems: [], foundElems: 0, original: 'a:: a', returned: [], userQuery: 'a:: a', - error: 'Paths cannot end with `::`', + error: 'Unexpected `:: `', }, { + query: "a ::a", elems: [], foundElems: 0, original: 'a ::a', returned: [], userQuery: 'a ::a', - error: 'Paths cannot start with `::`', + error: 'Unexpected ` ::`', }, { + query: "a<a>:", elems: [], foundElems: 0, original: "a<a>:", returned: [], userQuery: "a<a>:", - error: 'Unexpected `<` in type filter', + error: 'Unexpected `<` in type filter (before `:`)', }, { + query: "a<>:", elems: [], foundElems: 0, original: "a<>:", returned: [], userQuery: "a<>:", - error: 'Unexpected `<` in type filter', + error: 'Unexpected `<` in type filter (before `:`)', }, { + query: "a,:", elems: [], foundElems: 0, original: "a,:", returned: [], userQuery: "a,:", - error: 'Unexpected `,` in type filter', + error: 'Unexpected `,` in type filter (before `:`)', }, { + query: " a<> :", elems: [], foundElems: 0, original: "a<> :", returned: [], userQuery: "a<> :", - error: 'Unexpected `<` in type filter', + error: 'Unexpected `<` in type filter (before `:`)', }, { + query: "mod : :", elems: [], foundElems: 0, original: "mod : :", returned: [], userQuery: "mod : :", - error: 'Unexpected `:`', + error: 'Unexpected `:` (expected path after type filter `mod:`)', + }, + { + query: "mod: :", + elems: [], + foundElems: 0, + original: "mod: :", + returned: [], + userQuery: "mod: :", + error: 'Unexpected `:` (expected path after type filter `mod:`)', }, { + query: "a!a", elems: [], foundElems: 0, original: "a!a", @@ -349,6 +396,7 @@ const PARSED = [ error: 'Unexpected `!`: it can only be at the end of an ident', }, { + query: "a!!", elems: [], foundElems: 0, original: "a!!", @@ -357,6 +405,7 @@ const PARSED = [ error: 'Cannot have more than one `!` in an ident', }, { + query: "mod:a!", elems: [], foundElems: 0, original: "mod:a!", @@ -365,6 +414,16 @@ const PARSED = [ error: 'Invalid search type: macro `!` and `mod` both specified', }, { + query: "mod:!", + elems: [], + foundElems: 0, + original: "mod:!", + returned: [], + userQuery: "mod:!", + error: 'Invalid search type: primitive never type `!` and `mod` both specified', + }, + { + query: "a!::a", elems: [], foundElems: 0, original: "a!::a", @@ -373,6 +432,7 @@ const PARSED = [ error: 'Cannot have associated items in macros', }, { + query: "a<", elems: [], foundElems: 0, original: "a<", @@ -380,4 +440,108 @@ const PARSED = [ userQuery: "a<", error: "Unclosed `<`", }, + { + query: "p<x> , y", + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [ + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: -1, + }, + { + name: "y", + fullPath: ["y"], + pathWithoutLast: [], + pathLast: "y", + generics: [], + typeFilter: -1, + }, + ], + foundElems: 2, + original: "p<x> , y", + returned: [], + userQuery: "p<x> , y", + error: null, + }, + { + query: "p<x , y>", + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [ + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + typeFilter: -1, + }, + { + name: "y", + fullPath: ["y"], + pathWithoutLast: [], + pathLast: "y", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: -1, + }, + ], + foundElems: 1, + original: "p<x , y>", + returned: [], + userQuery: "p<x , y>", + error: null, + }, + { + query: "p ,x , y", + elems: [ + { + name: "p", + fullPath: ["p"], + pathWithoutLast: [], + pathLast: "p", + generics: [], + typeFilter: -1, + }, + { + name: "x", + fullPath: ["x"], + pathWithoutLast: [], + pathLast: "x", + generics: [], + typeFilter: -1, + }, + { + name: "y", + fullPath: ["y"], + pathWithoutLast: [], + pathLast: "y", + generics: [], + typeFilter: -1, + }, + ], + foundElems: 3, + original: "p ,x , y", + returned: [], + userQuery: "p ,x , y", + error: null, + }, ]; diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js index e23447ab7..3b9cc5b1b 100644 --- a/tests/rustdoc-js-std/parser-filter.js +++ b/tests/rustdoc-js-std/parser-filter.js @@ -1,17 +1,6 @@ -const QUERY = [ - 'fn:foo', - 'enum : foo', - 'macro<f>:foo', - 'macro!', - 'macro:mac!', - 'a::mac!', - '-> fn:foo', - '-> fn:foo<fn:bar>', - '-> fn:foo<fn:bar, enum : baz::fuzz>', -]; - const PARSED = [ { + query: 'fn:foo', elems: [{ name: "foo", fullPath: ["foo"], @@ -27,6 +16,7 @@ const PARSED = [ error: null, }, { + query: 'enum : foo', elems: [{ name: "foo", fullPath: ["foo"], @@ -42,14 +32,16 @@ const PARSED = [ error: null, }, { + query: 'macro<f>:foo', elems: [], foundElems: 0, original: "macro<f>:foo", returned: [], userQuery: "macro<f>:foo", - error: "Unexpected `<` in type filter", + error: "Unexpected `<` in type filter (before `:`)", }, { + query: 'macro!', elems: [{ name: "macro", fullPath: ["macro"], @@ -65,6 +57,7 @@ const PARSED = [ error: null, }, { + query: 'macro:mac!', elems: [{ name: "mac", fullPath: ["mac"], @@ -80,6 +73,7 @@ const PARSED = [ error: null, }, { + query: 'a::mac!', elems: [{ name: "a::mac", fullPath: ["a", "mac"], @@ -95,6 +89,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo', elems: [], foundElems: 1, original: "-> fn:foo", @@ -110,6 +105,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo<fn:bar>', elems: [], foundElems: 1, original: "-> fn:foo<fn:bar>", @@ -134,6 +130,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo<fn:bar, enum : baz::fuzz>', elems: [], foundElems: 1, original: "-> fn:foo<fn:bar, enum : baz::fuzz>", diff --git a/tests/rustdoc-js-std/parser-generics.js b/tests/rustdoc-js-std/parser-generics.js index 5a2266dbe..726ee56c2 100644 --- a/tests/rustdoc-js-std/parser-generics.js +++ b/tests/rustdoc-js-std/parser-generics.js @@ -1,14 +1,6 @@ -const QUERY = [ - 'A<B<C<D>, E>', - 'p<> u8', - '"p"<a>', - 'p<u<x>>', - 'p<u<x>, r>', - 'p<u<x, r>>', -]; - const PARSED = [ { + query: 'A<B<C<D>, E>', elems: [], foundElems: 0, original: 'A<B<C<D>, E>', @@ -17,6 +9,7 @@ const PARSED = [ error: 'Unclosed `<`', }, { + query: 'p<>,u8', elems: [ { name: "p", @@ -36,12 +29,13 @@ const PARSED = [ }, ], foundElems: 2, - original: "p<> u8", + original: "p<>,u8", returned: [], - userQuery: "p<> u8", + userQuery: "p<>,u8", error: null, }, { + query: '"p"<a>', elems: [ { name: "p", @@ -67,6 +61,7 @@ const PARSED = [ error: null, }, { + query: 'p<u<x>>', elems: [ { name: "p", @@ -100,6 +95,7 @@ const PARSED = [ error: null, }, { + query: 'p<u<x>, r>', elems: [ { name: "p", @@ -140,6 +136,7 @@ const PARSED = [ error: null, }, { + query: 'p<u<x, r>>', elems: [ { name: "p", diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js index be42b7aa4..f65a7ce66 100644 --- a/tests/rustdoc-js-std/parser-ident.js +++ b/tests/rustdoc-js-std/parser-ident.js @@ -1,14 +1,6 @@ -const QUERY = [ - "R<!>", - "!", - "a!", - "a!::b", - "!::b", - "a!::b!", -]; - const PARSED = [ { + query: "R<!>", elems: [{ name: "r", fullPath: ["r"], @@ -16,11 +8,12 @@ const PARSED = [ pathLast: "r", generics: [ { - name: "!", - fullPath: ["!"], + name: "never", + fullPath: ["never"], pathWithoutLast: [], - pathLast: "!", + pathLast: "never", generics: [], + typeFilter: 15, }, ], typeFilter: -1, @@ -32,13 +25,14 @@ const PARSED = [ error: null, }, { + query: "!", elems: [{ - name: "!", - fullPath: ["!"], + name: "never", + fullPath: ["never"], pathWithoutLast: [], - pathLast: "!", + pathLast: "never", generics: [], - typeFilter: -1, + typeFilter: 15, }], foundElems: 1, original: "!", @@ -47,6 +41,7 @@ const PARSED = [ error: null, }, { + query: "a!", elems: [{ name: "a", fullPath: ["a"], @@ -62,6 +57,7 @@ const PARSED = [ error: null, }, { + query: "a!::b", elems: [], foundElems: 0, original: "a!::b", @@ -70,10 +66,20 @@ const PARSED = [ error: "Cannot have associated items in macros", }, { + query: "!<T>", + elems: [], + foundElems: 0, + original: "!<T>", + returned: [], + userQuery: "!<t>", + error: "Never type `!` does not accept generic parameters", + }, + { + query: "!::b", elems: [{ name: "!::b", - fullPath: ["!", "b"], - pathWithoutLast: ["!"], + fullPath: ["never", "b"], + pathWithoutLast: ["never"], pathLast: "b", generics: [], typeFilter: -1, @@ -85,6 +91,59 @@ const PARSED = [ error: null, }, { + query: "b::!", + elems: [], + foundElems: 0, + original: "b::!", + returned: [], + userQuery: "b::!", + error: "Never type `!` is not associated item", + }, + { + query: "!::!", + elems: [], + foundElems: 0, + original: "!::!", + returned: [], + userQuery: "!::!", + error: "Never type `!` is not associated item", + }, + { + query: "b::!::c", + elems: [], + foundElems: 0, + original: "b::!::c", + returned: [], + userQuery: "b::!::c", + error: "Never type `!` is not associated item", + }, + { + query: "!::b<T>", + elems: [{ + name: "!::b", + fullPath: ["never", "b"], + pathWithoutLast: ["never"], + pathLast: "b", + generics: [ + { + name: "t", + fullPath: ["t"], + pathWithoutLast: [], + pathLast: "t", + generics: [], + typeFilter: -1, + } + ], + typeFilter: -1, + }], + foundElems: 1, + original: "!::b<T>", + returned: [], + userQuery: "!::b<t>", + error: null, + }, + { + query: "a!::b!", elems: [], foundElems: 0, original: "a!::b!", diff --git a/tests/rustdoc-js-std/parser-literal.js b/tests/rustdoc-js-std/parser-literal.js index 3a31d1bdd..87c06224d 100644 --- a/tests/rustdoc-js-std/parser-literal.js +++ b/tests/rustdoc-js-std/parser-literal.js @@ -1,7 +1,6 @@ -const QUERY = ['R<P>']; - const PARSED = [ { + query: 'R<P>', elems: [{ name: "r", fullPath: ["r"], diff --git a/tests/rustdoc-js-std/parser-paths.js b/tests/rustdoc-js-std/parser-paths.js index f3e421f5f..8d4dedf3f 100644 --- a/tests/rustdoc-js-std/parser-paths.js +++ b/tests/rustdoc-js-std/parser-paths.js @@ -1,7 +1,6 @@ -const QUERY = ['A::B', 'A::B,C', 'A::B<f>,C', 'mod::a']; - const PARSED = [ { + query: 'A::B', elems: [{ name: "a::b", fullPath: ["a", "b"], @@ -17,6 +16,7 @@ const PARSED = [ error: null, }, { + query: 'A::B,C', elems: [ { name: "a::b", @@ -42,6 +42,7 @@ const PARSED = [ error: null, }, { + query: 'A::B<f>,C', elems: [ { name: "a::b", @@ -75,6 +76,7 @@ const PARSED = [ error: null, }, { + query: 'mod::a', elems: [{ name: "mod::a", fullPath: ["mod", "a"], diff --git a/tests/rustdoc-js-std/parser-quote.js b/tests/rustdoc-js-std/parser-quote.js index d5d67cac8..731673cf4 100644 --- a/tests/rustdoc-js-std/parser-quote.js +++ b/tests/rustdoc-js-std/parser-quote.js @@ -1,15 +1,6 @@ -const QUERY = [ - '-> "p"', - '"p",', - '"p" -> a', - '"a" -> "p"', - '->"-"', - '"a', - '""', -]; - const PARSED = [ { + query: '-> "p"', elems: [], foundElems: 1, original: '-> "p"', @@ -25,6 +16,7 @@ const PARSED = [ error: null, }, { + query: '"p",', elems: [{ name: "p", fullPath: ["p"], @@ -40,14 +32,16 @@ const PARSED = [ error: null, }, { + query: '"p" -> a', elems: [], foundElems: 0, original: '"p" -> a', returned: [], userQuery: '"p" -> a', - error: "You cannot have more than one element if you use quotes", + error: "Cannot have more than one element if you use quotes", }, { + query: '"a" -> "p"', elems: [], foundElems: 0, original: '"a" -> "p"', @@ -56,6 +50,7 @@ const PARSED = [ error: "Cannot have more than one literal search element", }, { + query: '->"-"', elems: [], foundElems: 0, original: '->"-"', @@ -64,6 +59,7 @@ const PARSED = [ error: 'Unexpected `-` in a string element', }, { + query: '"a', elems: [], foundElems: 0, original: '"a', @@ -72,6 +68,7 @@ const PARSED = [ error: 'Unclosed `"`', }, { + query: '""', elems: [], foundElems: 0, original: '""', diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js index c29813190..6ea866091 100644 --- a/tests/rustdoc-js-std/parser-returned.js +++ b/tests/rustdoc-js-std/parser-returned.js @@ -1,13 +1,6 @@ -const QUERY = [ - "-> F<P>", - "-> P", - "->,a", - "aaaaa->a", - "-> !", -]; - const PARSED = [ { + query: "-> F<P>", elems: [], foundElems: 1, original: "-> F<P>", @@ -31,6 +24,7 @@ const PARSED = [ error: null, }, { + query: "-> P", elems: [], foundElems: 1, original: "-> P", @@ -46,6 +40,7 @@ const PARSED = [ error: null, }, { + query: "->,a", elems: [], foundElems: 1, original: "->,a", @@ -61,6 +56,7 @@ const PARSED = [ error: null, }, { + query: "aaaaa->a", elems: [{ name: "aaaaa", fullPath: ["aaaaa"], @@ -83,16 +79,17 @@ const PARSED = [ error: null, }, { + query: "-> !", elems: [], foundElems: 1, original: "-> !", returned: [{ - name: "!", - fullPath: ["!"], + name: "never", + fullPath: ["never"], pathWithoutLast: [], - pathLast: "!", + pathLast: "never", generics: [], - typeFilter: -1, + typeFilter: 15, }], userQuery: "-> !", error: null, diff --git a/tests/rustdoc-js-std/parser-separators.js b/tests/rustdoc-js-std/parser-separators.js index fc8c5114c..00c489b51 100644 --- a/tests/rustdoc-js-std/parser-separators.js +++ b/tests/rustdoc-js-std/parser-separators.js @@ -1,17 +1,26 @@ // ignore-tidy-tab -const QUERY = [ - 'aaaaaa b', - 'a b', - 'a,b', - 'a\tb', - 'a<b c>', - 'a<b,c>', - 'a<b\tc>', -]; - const PARSED = [ { + query: 'aaaaaa b', + elems: [ + { + name: 'aaaaaa\tb', + fullPath: ['aaaaaa', 'b'], + pathWithoutLast: ['aaaaaa'], + pathLast: 'b', + generics: [], + typeFilter: -1, + }, + ], + foundElems: 1, + original: "aaaaaa b", + returned: [], + userQuery: "aaaaaa b", + error: null, + }, + { + query: "aaaaaa, b", elems: [ { name: 'aaaaaa', @@ -31,37 +40,31 @@ const PARSED = [ }, ], foundElems: 2, - original: "aaaaaa b", + original: "aaaaaa, b", returned: [], - userQuery: "aaaaaa b", + userQuery: "aaaaaa, b", error: null, }, { + query: 'a b', elems: [ { - name: 'a', - fullPath: ['a'], - pathWithoutLast: [], - pathLast: 'a', - generics: [], - typeFilter: -1, - }, - { - name: 'b', - fullPath: ['b'], - pathWithoutLast: [], + name: 'a b', + fullPath: ['a', 'b'], + pathWithoutLast: ['a'], pathLast: 'b', generics: [], typeFilter: -1, }, ], - foundElems: 2, + foundElems: 1, original: "a b", returned: [], userQuery: "a b", error: null, }, { + query: 'a,b', elems: [ { name: 'a', @@ -87,31 +90,25 @@ const PARSED = [ error: null, }, { + query: 'a\tb', elems: [ { - name: 'a', - fullPath: ['a'], - pathWithoutLast: [], - pathLast: 'a', - generics: [], - typeFilter: -1, - }, - { - name: 'b', - fullPath: ['b'], - pathWithoutLast: [], + name: 'a\tb', + fullPath: ['a', 'b'], + pathWithoutLast: ['a'], pathLast: 'b', generics: [], typeFilter: -1, }, ], - foundElems: 2, + foundElems: 1, original: "a\tb", returned: [], userQuery: "a\tb", error: null, }, { + query: 'a<b c>', elems: [ { name: 'a', @@ -120,16 +117,9 @@ const PARSED = [ pathLast: 'a', generics: [ { - name: 'b', - fullPath: ['b'], - pathWithoutLast: [], - pathLast: 'b', - generics: [], - }, - { - name: 'c', - fullPath: ['c'], - pathWithoutLast: [], + name: 'b c', + fullPath: ['b', 'c'], + pathWithoutLast: ['b'], pathLast: 'c', generics: [], }, @@ -144,6 +134,7 @@ const PARSED = [ error: null, }, { + query: 'a<b,c>', elems: [ { name: 'a', @@ -176,6 +167,7 @@ const PARSED = [ error: null, }, { + query: 'a<b\tc>', elems: [ { name: 'a', @@ -184,16 +176,9 @@ const PARSED = [ pathLast: 'a', generics: [ { - name: 'b', - fullPath: ['b'], - pathWithoutLast: [], - pathLast: 'b', - generics: [], - }, - { - name: 'c', - fullPath: ['c'], - pathWithoutLast: [], + name: 'b\tc', + fullPath: ['b', 'c'], + pathWithoutLast: ['b'], pathLast: 'c', generics: [], }, diff --git a/tests/rustdoc-js-std/parser-slice-array.js b/tests/rustdoc-js-std/parser-slice-array.js new file mode 100644 index 000000000..c22b7870d --- /dev/null +++ b/tests/rustdoc-js-std/parser-slice-array.js @@ -0,0 +1,305 @@ +const PARSED = [ + { + query: '[[[D, []]]', + elems: [], + foundElems: 0, + original: '[[[D, []]]', + returned: [], + userQuery: '[[[d, []]]', + error: 'Unclosed `[`', + }, + { + query: '[[[D, []]]]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "d", + fullPath: ["d"], + pathWithoutLast: [], + pathLast: "d", + generics: [], + typeFilter: -1, + }, + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [], + typeFilter: 15, + }, + ], + typeFilter: 15, + }, + ], + typeFilter: 15, + }, + ], + typeFilter: 15, + }, + ], + foundElems: 1, + original: '[[[D, []]]]', + returned: [], + userQuery: '[[[d, []]]]', + error: null, + }, + { + query: '[],u8', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [], + typeFilter: 15, + }, + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + ], + foundElems: 2, + original: "[],u8", + returned: [], + userQuery: "[],u8", + error: null, + }, + { + query: '[u8]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: 15, + }, + ], + foundElems: 1, + original: "[u8]", + returned: [], + userQuery: "[u8]", + error: null, + }, + { + query: '[u8,u8]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: 15, + }, + ], + foundElems: 1, + original: "[u8,u8]", + returned: [], + userQuery: "[u8,u8]", + error: null, + }, + { + query: '[u8<u8>]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [ + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: -1, + }, + ], + typeFilter: 15, + }, + ], + foundElems: 1, + original: "[u8<u8>]", + returned: [], + userQuery: "[u8<u8>]", + error: null, + }, + { + query: '[]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [], + typeFilter: 15, + }, + ], + foundElems: 1, + original: "[]", + returned: [], + userQuery: "[]", + error: null, + }, + { + query: '[>', + elems: [], + foundElems: 0, + original: "[>", + returned: [], + userQuery: "[>", + error: "Unexpected `>` after `[`", + }, + { + query: '[<', + elems: [], + foundElems: 0, + original: "[<", + returned: [], + userQuery: "[<", + error: "Found generics without a path", + }, + { + query: '[a>', + elems: [], + foundElems: 0, + original: "[a>", + returned: [], + userQuery: "[a>", + error: "Unexpected `>` after `[`", + }, + { + query: '[a<', + elems: [], + foundElems: 0, + original: "[a<", + returned: [], + userQuery: "[a<", + error: "Unclosed `<`", + }, + { + query: '[a', + elems: [], + foundElems: 0, + original: "[a", + returned: [], + userQuery: "[a", + error: "Unclosed `[`", + }, + { + query: '[', + elems: [], + foundElems: 0, + original: "[", + returned: [], + userQuery: "[", + error: "Unclosed `[`", + }, + { + query: ']', + elems: [], + foundElems: 0, + original: "]", + returned: [], + userQuery: "]", + error: "Unexpected `]`", + }, + { + query: 'primitive:[u8]', + elems: [ + { + name: "[]", + fullPath: ["[]"], + pathWithoutLast: [], + pathLast: "[]", + generics: [ + { + name: "u8", + fullPath: ["u8"], + pathWithoutLast: [], + pathLast: "u8", + generics: [], + typeFilter: -1, + }, + ], + typeFilter: 15, + }, + ], + foundElems: 1, + original: "primitive:[u8]", + returned: [], + userQuery: "primitive:[u8]", + error: null, + }, + { + query: 'macro:[u8]', + elems: [], + foundElems: 0, + original: "macro:[u8]", + returned: [], + userQuery: "macro:[u8]", + error: "Invalid search type: primitive `[]` and `macro` both specified", + }, +]; diff --git a/tests/rustdoc-js-std/parser-weird-queries.js b/tests/rustdoc-js-std/parser-weird-queries.js index dc1049a70..720ef66c1 100644 --- a/tests/rustdoc-js-std/parser-weird-queries.js +++ b/tests/rustdoc-js-std/parser-weird-queries.js @@ -1,68 +1,44 @@ // This test is mostly to check that the parser still kinda outputs something // (and doesn't enter an infinite loop!) even though the query is completely // invalid. -const QUERY = [ - 'a b', - 'a b', - 'a,b(c)', - 'aaa,a', - ',,,,', - 'mod :', - 'mod\t:', -]; const PARSED = [ { + query: 'a b', elems: [ { - name: "a", - fullPath: ["a"], - pathWithoutLast: [], - pathLast: "a", - generics: [], - typeFilter: -1, - }, - { - name: "b", - fullPath: ["b"], - pathWithoutLast: [], + name: "a b", + fullPath: ["a", "b"], + pathWithoutLast: ["a"], pathLast: "b", generics: [], - typeFilter: -1, }, ], - foundElems: 2, + foundElems: 1, original: "a b", returned: [], userQuery: "a b", error: null, }, { + query: 'a b', elems: [ { - name: "a", - fullPath: ["a"], - pathWithoutLast: [], - pathLast: "a", - generics: [], - typeFilter: -1, - }, - { - name: "b", - fullPath: ["b"], - pathWithoutLast: [], + name: "a b", + fullPath: ["a", "b"], + pathWithoutLast: ["a"], pathLast: "b", generics: [], - typeFilter: -1, }, ], - foundElems: 2, + foundElems: 1, original: "a b", returned: [], userQuery: "a b", error: null, }, { + query: 'a,b(c)', elems: [], foundElems: 0, original: "a,b(c)", @@ -71,6 +47,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: 'aaa,a', elems: [ { name: "aaa", @@ -78,7 +55,6 @@ const PARSED = [ pathWithoutLast: [], pathLast: "aaa", generics: [], - typeFilter: -1, }, { name: "a", @@ -86,7 +62,6 @@ const PARSED = [ pathWithoutLast: [], pathLast: "a", generics: [], - typeFilter: -1, }, ], foundElems: 2, @@ -96,6 +71,7 @@ const PARSED = [ error: null, }, { + query: ',,,,', elems: [], foundElems: 0, original: ",,,,", @@ -104,19 +80,21 @@ const PARSED = [ error: null, }, { + query: 'mod :', elems: [], foundElems: 0, original: 'mod :', returned: [], userQuery: 'mod :', - error: "Unexpected `:` (expected path after type filter)", + error: "Unexpected `:` (expected path after type filter `mod:`)", }, { + query: 'mod\t:', elems: [], foundElems: 0, original: 'mod\t:', returned: [], userQuery: 'mod\t:', - error: "Unexpected `:` (expected path after type filter)", + error: "Unexpected `:` (expected path after type filter `mod:`)", }, ]; diff --git a/tests/rustdoc-js-std/path-ordering.js b/tests/rustdoc-js-std/path-ordering.js index 7dcdd4023..c3d61d238 100644 --- a/tests/rustdoc-js-std/path-ordering.js +++ b/tests/rustdoc-js-std/path-ordering.js @@ -1,7 +1,6 @@ -const QUERY = 'hashset::insert'; - const EXPECTED = { - 'others': [ + query: 'hashset::insert', + others: [ // ensure hashset::insert comes first { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, diff --git a/tests/rustdoc-js-std/primitive.js b/tests/rustdoc-js-std/primitive.js index e5690383e..737e429bf 100644 --- a/tests/rustdoc-js-std/primitive.js +++ b/tests/rustdoc-js-std/primitive.js @@ -1,15 +1,6 @@ -const QUERY = [ - 'i8', - 'u32', - 'str', - 'char', - 'unit', - 'tuple', - 'fn', -]; - const EXPECTED = [ { + 'query': 'i8', 'others': [ { 'path': 'std', @@ -19,6 +10,7 @@ const EXPECTED = [ ] }, { + 'query': 'u32', 'others': [ { 'path': 'std', @@ -28,6 +20,7 @@ const EXPECTED = [ ] }, { + 'query': 'str', 'others': [ { 'path': 'std', @@ -37,6 +30,7 @@ const EXPECTED = [ ] }, { + 'query': 'char', 'others': [ { 'path': 'std', @@ -46,6 +40,7 @@ const EXPECTED = [ ] }, { + 'query': 'unit', 'others': [ { 'path': 'std', @@ -55,6 +50,7 @@ const EXPECTED = [ ] }, { + 'query': 'tuple', 'others': [ { 'path': 'std', @@ -64,6 +60,7 @@ const EXPECTED = [ ] }, { + 'query': 'fn', 'others': [ { 'path': 'std', diff --git a/tests/rustdoc-js-std/println-typo.js b/tests/rustdoc-js-std/println-typo.js index 7ca3ab8e5..a4dd90a44 100644 --- a/tests/rustdoc-js-std/println-typo.js +++ b/tests/rustdoc-js-std/println-typo.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = 'prinltn'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': 'prinltn', 'others': [ { 'path': 'std', 'name': 'println' }, { 'path': 'std', 'name': 'print' }, diff --git a/tests/rustdoc-js-std/quoted.js b/tests/rustdoc-js-std/quoted.js index aec8484a4..8a9275019 100644 --- a/tests/rustdoc-js-std/quoted.js +++ b/tests/rustdoc-js-std/quoted.js @@ -1,9 +1,9 @@ // ignore-order -const QUERY = '"error"'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': '"error"', 'others': [ { 'path': 'std', 'name': 'error' }, { 'path': 'std::fmt', 'name': 'Error' }, diff --git a/tests/rustdoc-js-std/reference-shrink.js b/tests/rustdoc-js-std/reference-shrink.js index f90be6d1b..b602bbdca 100644 --- a/tests/rustdoc-js-std/reference-shrink.js +++ b/tests/rustdoc-js-std/reference-shrink.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'reference::shrink'; - const EXPECTED = { + 'query': 'reference::shrink', // avoid including the method that's not going to be in the HTML 'others': [], }; diff --git a/tests/rustdoc-js-std/regex.js b/tests/rustdoc-js-std/regex.js index a6843c595..7dc38939a 100644 --- a/tests/rustdoc-js-std/regex.js +++ b/tests/rustdoc-js-std/regex.js @@ -1,9 +1,8 @@ // exact-check // https://github.com/rust-lang/rust/issues/103357 -const QUERY = 'regex'; - const EXPECTED = { + 'query': 'regex', 'others': [], 'in_args': [], 'returned': [], diff --git a/tests/rustdoc-js-std/return-specific-literal.js b/tests/rustdoc-js-std/return-specific-literal.js index c7c347240..86ed3aceb 100644 --- a/tests/rustdoc-js-std/return-specific-literal.js +++ b/tests/rustdoc-js-std/return-specific-literal.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:"string"'; - const EXPECTED = { + 'query': 'struct:"string"', 'in_args': [ { 'path': 'std::string::String', 'name': 'ne' }, ], diff --git a/tests/rustdoc-js-std/return-specific.js b/tests/rustdoc-js-std/return-specific.js index d9a910553..be54a1c97 100644 --- a/tests/rustdoc-js-std/return-specific.js +++ b/tests/rustdoc-js-std/return-specific.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:string'; - const EXPECTED = { + 'query': 'struct:string', 'in_args': [ { 'path': 'std::string::String', 'name': 'ne' }, ], diff --git a/tests/rustdoc-js-std/should-fail.js b/tests/rustdoc-js-std/should-fail.js index b85a47dc0..94f82efd9 100644 --- a/tests/rustdoc-js-std/should-fail.js +++ b/tests/rustdoc-js-std/should-fail.js @@ -1,8 +1,7 @@ // should-fail -const QUERY = 'fn'; - const EXPECTED = { + 'query': 'fn', 'others': [ { 'path': 'std', 'name': 'fn', ty: 14 }, ], diff --git a/tests/rustdoc-js-std/string-from_ut.js b/tests/rustdoc-js-std/string-from_ut.js index f9edf4408..1fff6ee28 100644 --- a/tests/rustdoc-js-std/string-from_ut.js +++ b/tests/rustdoc-js-std/string-from_ut.js @@ -1,6 +1,5 @@ -const QUERY = 'String::from_ut'; - const EXPECTED = { + 'query': 'String::from_ut', 'others': [ { 'path': 'std::string::String', 'name': 'from_utf8' }, { 'path': 'std::string::String', 'name': 'from_utf8' }, diff --git a/tests/rustdoc-js-std/struct-vec.js b/tests/rustdoc-js-std/struct-vec.js index 29609904b..dd72aaa1a 100644 --- a/tests/rustdoc-js-std/struct-vec.js +++ b/tests/rustdoc-js-std/struct-vec.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:VecD'; - const EXPECTED = { + 'query': 'struct:VecD', 'others': [ { 'path': 'std::collections', 'name': 'VecDeque' }, { 'path': 'std::vec', 'name': 'Vec' }, diff --git a/tests/rustdoc-js-std/typed-query.js b/tests/rustdoc-js-std/typed-query.js index eeb3e1888..8e8464588 100644 --- a/tests/rustdoc-js-std/typed-query.js +++ b/tests/rustdoc-js-std/typed-query.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = 'macro:print'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': 'macro:print', 'others': [ { 'path': 'std', 'name': 'print' }, { 'path': 'std', 'name': 'println' }, diff --git a/tests/rustdoc-js-std/vec-new.js b/tests/rustdoc-js-std/vec-new.js index fc44a566a..9823a417a 100644 --- a/tests/rustdoc-js-std/vec-new.js +++ b/tests/rustdoc-js-std/vec-new.js @@ -1,10 +1,20 @@ -const QUERY = 'Vec::new'; - -const EXPECTED = { - 'others': [ - { 'path': 'std::vec::Vec', 'name': 'new' }, - { 'path': 'alloc::vec::Vec', 'name': 'new' }, - { 'path': 'std::vec::Vec', 'name': 'new_in' }, - { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, - ], -}; +const EXPECTED = [ + { + 'query': 'Vec::new', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'new' }, + { 'path': 'alloc::vec::Vec', 'name': 'new' }, + { 'path': 'std::vec::Vec', 'name': 'new_in' }, + { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'Vec new', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'new' }, + { 'path': 'alloc::vec::Vec', 'name': 'new' }, + { 'path': 'std::vec::Vec', 'name': 'new_in' }, + { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, + ], + }, +]; diff --git a/tests/rustdoc-js/basic.js b/tests/rustdoc-js/basic.js index d99b23468..e186d5108 100644 --- a/tests/rustdoc-js/basic.js +++ b/tests/rustdoc-js/basic.js @@ -1,6 +1,5 @@ -const QUERY = 'Fo'; - const EXPECTED = { + 'query': 'Fo', 'others': [ { 'path': 'basic', 'name': 'Foo' }, ], diff --git a/tests/rustdoc-js/doc-alias-filter-out.js b/tests/rustdoc-js/doc-alias-filter-out.js index 46a089d06..fd25370df 100644 --- a/tests/rustdoc-js/doc-alias-filter-out.js +++ b/tests/rustdoc-js/doc-alias-filter-out.js @@ -1,9 +1,8 @@ // exact-check -const QUERY = 'true'; - const FILTER_CRATE = 'some_other_crate'; const EXPECTED = { + 'query': 'true', 'others': [], }; diff --git a/tests/rustdoc-js/doc-alias-filter.js b/tests/rustdoc-js/doc-alias-filter.js index e06047ba7..1d2dd8b9a 100644 --- a/tests/rustdoc-js/doc-alias-filter.js +++ b/tests/rustdoc-js/doc-alias-filter.js @@ -1,10 +1,9 @@ // exact-check -const QUERY = '"true"'; - const FILTER_CRATE = 'doc_alias_filter'; const EXPECTED = { + 'query': '"true"', 'others': [ { 'path': 'doc_alias_filter', diff --git a/tests/rustdoc-js/doc-alias-whitespace.js b/tests/rustdoc-js/doc-alias-whitespace.js index c9fc0c431..64784b569 100644 --- a/tests/rustdoc-js/doc-alias-whitespace.js +++ b/tests/rustdoc-js/doc-alias-whitespace.js @@ -1,11 +1,8 @@ // exact-check -const QUERY = [ - 'Demon Lord', -]; - const EXPECTED = [ { + 'query': 'Demon Lord', 'others': [ { 'path': 'doc_alias_whitespace', diff --git a/tests/rustdoc-js/doc-alias.js b/tests/rustdoc-js/doc-alias.js index 62c8e7a74..7e4e8a776 100644 --- a/tests/rustdoc-js/doc-alias.js +++ b/tests/rustdoc-js/doc-alias.js @@ -1,31 +1,6 @@ -const QUERY = [ - 'StructItem', - 'StructFieldItem', - 'StructMethodItem', - 'ImplTraitItem', - 'StructImplConstItem', - 'ImplTraitFunction', - 'EnumItem', - 'VariantItem', - 'EnumMethodItem', - 'TypedefItem', - 'TraitItem', - 'TraitTypeItem', - 'AssociatedConstItem', - 'TraitFunctionItem', - 'FunctionItem', - 'ModuleItem', - 'ConstItem', - 'StaticItem', - 'UnionItem', - 'UnionFieldItem', - 'UnionMethodItem', - 'MacroItem', -]; - const EXPECTED = [ { - // StructItem + 'query': 'StructItem', 'others': [ { 'path': 'doc_alias', @@ -37,7 +12,7 @@ const EXPECTED = [ ], }, { - // StructFieldItem + 'query': 'StructFieldItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -49,7 +24,7 @@ const EXPECTED = [ ], }, { - // StructMethodItem + 'query': 'StructMethodItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -61,11 +36,11 @@ const EXPECTED = [ ], }, { - // ImplTraitItem + 'query': 'ImplTraitItem', 'others': [], }, { - // StructImplConstItem + 'query': 'StructImplConstItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -77,7 +52,7 @@ const EXPECTED = [ ], }, { - // ImplTraitFunction + 'query': 'ImplTraitFunction', 'others': [ { 'path': 'doc_alias::Struct', @@ -89,7 +64,7 @@ const EXPECTED = [ ], }, { - // EnumItem + 'query': 'EnumItem', 'others': [ { 'path': 'doc_alias', @@ -101,7 +76,7 @@ const EXPECTED = [ ], }, { - // VariantItem + 'query': 'VariantItem', 'others': [ { 'path': 'doc_alias::Enum', @@ -113,7 +88,7 @@ const EXPECTED = [ ], }, { - // EnumMethodItem + 'query': 'EnumMethodItem', 'others': [ { 'path': 'doc_alias::Enum', @@ -125,7 +100,7 @@ const EXPECTED = [ ], }, { - // TypedefItem + 'query': 'TypedefItem', 'others': [ { 'path': 'doc_alias', @@ -137,7 +112,7 @@ const EXPECTED = [ ], }, { - // TraitItem + 'query': 'TraitItem', 'others': [ { 'path': 'doc_alias', @@ -149,7 +124,7 @@ const EXPECTED = [ ], }, { - // TraitTypeItem + 'query': 'TraitTypeItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -161,7 +136,7 @@ const EXPECTED = [ ], }, { - // AssociatedConstItem + 'query': 'AssociatedConstItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -173,7 +148,7 @@ const EXPECTED = [ ], }, { - // TraitFunctionItem + 'query': 'TraitFunctionItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -185,7 +160,7 @@ const EXPECTED = [ ], }, { - // FunctionItem + 'query': 'FunctionItem', 'others': [ { 'path': 'doc_alias', @@ -197,7 +172,7 @@ const EXPECTED = [ ], }, { - // ModuleItem + 'query': 'ModuleItem', 'others': [ { 'path': 'doc_alias', @@ -209,7 +184,7 @@ const EXPECTED = [ ], }, { - // ConstItem + 'query': 'ConstItem', 'others': [ { 'path': 'doc_alias', @@ -225,7 +200,7 @@ const EXPECTED = [ ], }, { - // StaticItem + 'query': 'StaticItem', 'others': [ { 'path': 'doc_alias', @@ -237,7 +212,7 @@ const EXPECTED = [ ], }, { - // UnionItem + 'query': 'UnionItem', 'others': [ { 'path': 'doc_alias', @@ -255,7 +230,7 @@ const EXPECTED = [ ], }, { - // UnionFieldItem + 'query': 'UnionFieldItem', 'others': [ { 'path': 'doc_alias::Union', @@ -267,7 +242,7 @@ const EXPECTED = [ ], }, { - // UnionMethodItem + 'query': 'UnionMethodItem', 'others': [ { 'path': 'doc_alias::Union', @@ -279,7 +254,7 @@ const EXPECTED = [ ], }, { - // MacroItem + 'query': 'MacroItem', 'others': [ { 'path': 'doc_alias', diff --git a/tests/rustdoc-js/exact-match.js b/tests/rustdoc-js/exact-match.js index b0a411bee..ce3a76f9b 100644 --- a/tests/rustdoc-js/exact-match.js +++ b/tests/rustdoc-js/exact-match.js @@ -1,6 +1,5 @@ -const QUERY = 'si::pc'; - const EXPECTED = { + 'query': 'si::pc', 'others': [ { 'path': 'exact_match::Si', 'name': 'pc' }, { 'path': 'exact_match::Psi', 'name': 'pc' }, diff --git a/tests/rustdoc-js/foreign-type-path.js b/tests/rustdoc-js/foreign-type-path.js index 334761bad..b11123d3e 100644 --- a/tests/rustdoc-js/foreign-type-path.js +++ b/tests/rustdoc-js/foreign-type-path.js @@ -1,6 +1,5 @@ -const QUERY = 'MyForeignType::my_method'; - const EXPECTED = { + 'query': 'MyForeignType::my_method', 'others': [ // Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358 // Validates that the parent path for a foreign type method is correct. diff --git a/tests/rustdoc-js/generics-impl.js b/tests/rustdoc-js/generics-impl.js index 5051743bd..5e33e2248 100644 --- a/tests/rustdoc-js/generics-impl.js +++ b/tests/rustdoc-js/generics-impl.js @@ -1,68 +1,56 @@ // exact-check -const QUERY = [ - 'Aaaaaaa -> u32', - 'Aaaaaaa -> bool', - 'Aaaaaaa -> usize', - 'Read -> u64', - 'trait:Read -> u64', - 'struct:Read -> u64', - 'bool -> u64', - 'Ddddddd -> u64', - '-> Ddddddd' -]; - const EXPECTED = [ { - // Aaaaaaa -> u32 + 'query': 'Aaaaaaa -> u32', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'bbbbbbb' }, ], }, { - // Aaaaaaa -> bool + 'query': 'Aaaaaaa -> bool', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'ccccccc' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'read' }, ], }, { - // Read -> u64 + 'query': 'Read -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' }, { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // trait:Read -> u64 + 'query': 'trait:Read -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' }, { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // struct:Read -> u64 + 'query': 'struct:Read -> u64', 'others': [], }, { - // bool -> u64 + 'query': 'bool -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'fffffff' }, ], }, { - // Ddddddd -> u64 + 'query': 'Ddddddd -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // -> Ddddddd + 'query': '-> Ddddddd', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'hhhhhhh' }, ], diff --git a/tests/rustdoc-js/generics-match-ambiguity.js b/tests/rustdoc-js/generics-match-ambiguity.js new file mode 100644 index 000000000..a9932a16c --- /dev/null +++ b/tests/rustdoc-js/generics-match-ambiguity.js @@ -0,0 +1,91 @@ +// ignore-order +// exact-check + +// Make sure that results are order-agnostic, even when there's search items that only differ +// by generics. + +const EXPECTED = [ + { + 'query': 'Wrap', + 'in_args': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap<i32>', + 'in_args': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap<i32>, Wrap<i32, u32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap<i32, u32>, Wrap<i32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'W3<i32>, W3<i32, u32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baaa' }, + { 'path': 'generics_match_ambiguity', 'name': 'baab' }, + { 'path': 'generics_match_ambiguity', 'name': 'baac' }, + { 'path': 'generics_match_ambiguity', 'name': 'baad' }, + { 'path': 'generics_match_ambiguity', 'name': 'baae' }, + { 'path': 'generics_match_ambiguity', 'name': 'baaf' }, + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, + ], + }, + { + 'query': 'W3<i32, u32>, W3<i32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baaa' }, + { 'path': 'generics_match_ambiguity', 'name': 'baab' }, + { 'path': 'generics_match_ambiguity', 'name': 'baac' }, + { 'path': 'generics_match_ambiguity', 'name': 'baad' }, + { 'path': 'generics_match_ambiguity', 'name': 'baae' }, + { 'path': 'generics_match_ambiguity', 'name': 'baaf' }, + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, + ], + }, + { + 'query': 'W2<i32>, W2<i32, u32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, + ], + }, + { + 'query': 'W2<i32, u32>, W2<i32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, + ], + }, + { + 'query': 'W2<i32>, W3<i32, u32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baac' }, + { 'path': 'generics_match_ambiguity', 'name': 'baaf' }, + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + ], + }, + { + 'query': 'W2<i32>, W2<i32>', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baag' }, + { 'path': 'generics_match_ambiguity', 'name': 'baah' }, + ], + }, +]; diff --git a/tests/rustdoc-js/generics-match-ambiguity.rs b/tests/rustdoc-js/generics-match-ambiguity.rs new file mode 100644 index 000000000..79c493856 --- /dev/null +++ b/tests/rustdoc-js/generics-match-ambiguity.rs @@ -0,0 +1,17 @@ +pub struct Wrap<T, U = ()>(pub T, pub U); + +pub fn foo(a: Wrap<i32>, b: Wrap<i32, u32>) {} +pub fn bar(a: Wrap<i32, u32>, b: Wrap<i32>) {} + +pub struct W2<T>(pub T); +pub struct W3<T, U = ()>(pub T, pub U); + +pub fn baaa(a: W3<i32>, b: W3<i32, u32>) {} +pub fn baab(a: W3<i32, u32>, b: W3<i32>) {} +pub fn baac(a: W2<W3<i32>>, b: W3<i32, u32>) {} +pub fn baad(a: W2<W3<i32, u32>>, b: W3<i32>) {} +pub fn baae(a: W3<i32>, b: W2<W3<i32, u32>>) {} +pub fn baaf(a: W3<i32, u32>, b: W2<W3<i32>>) {} +pub fn baag(a: W2<W3<i32>>, b: W2<W3<i32, u32>>) {} +pub fn baah(a: W2<W3<i32, u32>>, b: W2<W3<i32>>) {} +// diff --git a/tests/rustdoc-js/generics-multi-trait.js b/tests/rustdoc-js/generics-multi-trait.js index e7fcea876..7097cabe7 100644 --- a/tests/rustdoc-js/generics-multi-trait.js +++ b/tests/rustdoc-js/generics-multi-trait.js @@ -1,14 +1,9 @@ // exact-check -const QUERY = [ - 'Result<SomeTrait>', - 'Zzzzzzzzzzzzzzzzzz', - 'Nonononononononono', -]; - const EXPECTED = [ // check one of the generic items { + 'query': 'Result<SomeTrait>', 'in_args': [ { 'path': 'generics_multi_trait', 'name': 'beta' }, ], @@ -17,6 +12,7 @@ const EXPECTED = [ ], }, { + 'query': 'Zzzzzzzzzzzzzzzzzz', 'in_args': [ { 'path': 'generics_multi_trait', 'name': 'beta' }, ], @@ -26,6 +22,7 @@ const EXPECTED = [ }, // ignore the name of the generic itself { + 'query': 'Nonononononononono', 'in_args': [], 'returned': [], }, diff --git a/tests/rustdoc-js/generics-nested.js b/tests/rustdoc-js/generics-nested.js index 8701f2d49..294c19490 100644 --- a/tests/rustdoc-js/generics-nested.js +++ b/tests/rustdoc-js/generics-nested.js @@ -1,31 +1,24 @@ // exact-check -const QUERY = [ - '-> Out<First<Second>>', - '-> Out<Second<First>>', - '-> Out<First, Second>', - '-> Out<Second, First>', -]; - const EXPECTED = [ { - // -> Out<First<Second>> + 'query': '-> Out<First<Second>>', 'others': [ { 'path': 'generics_nested', 'name': 'alef' }, ], }, { - // -> Out<Second<First>> + 'query': '-> Out<Second<First>>', 'others': [], }, { - // -> Out<First, Second> + 'query': '-> Out<First, Second>', 'others': [ { 'path': 'generics_nested', 'name': 'bet' }, ], }, { - // -> Out<Second, First> + 'query': '-> Out<Second, First>', 'others': [ { 'path': 'generics_nested', 'name': 'bet' }, ], diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js index 0e8475160..4ccfb8f4e 100644 --- a/tests/rustdoc-js/generics-trait.js +++ b/tests/rustdoc-js/generics-trait.js @@ -1,22 +1,9 @@ // exact-check -const QUERY = [ - 'Result<SomeTrait>', - 'Result<SomeTraiz>', - 'OtherThingxxxxxxxx', - 'OtherThingxxxxxxxy', -]; - -const CORRECTIONS = [ - null, - null, - null, - 'OtherThingxxxxxxxx', -]; - const EXPECTED = [ - // Result<SomeTrait> { + 'query': 'Result<SomeTrait>', + 'correction': null, 'in_args': [ { 'path': 'generics_trait', 'name': 'beta' }, ], @@ -24,13 +11,15 @@ const EXPECTED = [ { 'path': 'generics_trait', 'name': 'bet' }, ], }, - // Result<SomeTraiz> { + 'query': 'Result<SomeTraiz>', + 'correction': null, 'in_args': [], 'returned': [], }, - // OtherThingxxxxxxxx { + 'query': 'OtherThingxxxxxxxx', + 'correction': null, 'in_args': [ { 'path': 'generics_trait', 'name': 'alpha' }, ], @@ -38,8 +27,9 @@ const EXPECTED = [ { 'path': 'generics_trait', 'name': 'alef' }, ], }, - // OtherThingxxxxxxxy { + 'query': 'OtherThingxxxxxxxy', + 'correction': 'OtherThingxxxxxxxx', 'in_args': [ { 'path': 'generics_trait', 'name': 'alpha' }, ], diff --git a/tests/rustdoc-js/generics.js b/tests/rustdoc-js/generics.js index f79c709ad..ebc92ccfc 100644 --- a/tests/rustdoc-js/generics.js +++ b/tests/rustdoc-js/generics.js @@ -1,20 +1,8 @@ // exact-check -const QUERY = [ - 'R<P>', - 'R<struct:P>', - 'R<enum:P>', - '"P"', - 'P', - 'ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>', - 'TraitCat', - 'TraitDog', - 'Result<String>', -]; - const EXPECTED = [ { - // R<P> + 'query': 'R<P>', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -23,7 +11,7 @@ const EXPECTED = [ ], }, { - // R<struct:P> + 'query': 'R<struct:P>', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -32,12 +20,12 @@ const EXPECTED = [ ], }, { - // R<enum:P> + 'query': 'R<enum:P>', 'returned': [], 'in_args': [], }, { - // "P" + 'query': '"P"', 'others': [ { 'path': 'generics', 'name': 'P' }, ], @@ -49,7 +37,7 @@ const EXPECTED = [ ], }, { - // P + 'query': 'P', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -58,26 +46,26 @@ const EXPECTED = [ ], }, { - // "ExtraCreditStructMulti"<ExtraCreditInnerMulti, ExtraCreditInnerMulti> + 'query': '"ExtraCreditStructMulti"<ExtraCreditInnerMulti, ExtraCreditInnerMulti>', 'in_args': [ { 'path': 'generics', 'name': 'extracreditlabhomework' }, ], 'returned': [], }, { - // TraitCat + 'query': 'TraitCat', 'in_args': [ { 'path': 'generics', 'name': 'gamma' }, ], }, { - // TraitDog + 'query': 'TraitDog', 'in_args': [ { 'path': 'generics', 'name': 'gamma' }, ], }, { - // Result<String> + 'query': 'Result<String>', 'others': [], 'returned': [ { 'path': 'generics', 'name': 'super_soup' }, diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js index 8d594bf8a..710e594b5 100644 --- a/tests/rustdoc-js/impl-trait.js +++ b/tests/rustdoc-js/impl-trait.js @@ -1,32 +1,24 @@ // ignore-order -const QUERY = [ - 'Aaaaaaa -> i32', - 'Aaaaaaa -> Aaaaaaa', - 'Aaaaaaa -> usize', - '-> Aaaaaaa', - 'Aaaaaaa', -]; - const EXPECTED = [ { - // Aaaaaaa -> i32 + 'query': 'Aaaaaaa -> i32', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, ], }, { - // Aaaaaaa -> Aaaaaaa + 'query': 'Aaaaaaa -> Aaaaaaa', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [], }, { - // -> Aaaaaaa + 'query': '-> Aaaaaaa', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, @@ -34,7 +26,7 @@ const EXPECTED = [ ], }, { - // Aaaaaaa + 'query': 'Aaaaaaa', 'others': [ { 'path': 'impl_trait', 'name': 'Aaaaaaa' }, ], diff --git a/tests/rustdoc-js/macro-search.js b/tests/rustdoc-js/macro-search.js index 2b179ce14..241f7f172 100644 --- a/tests/rustdoc-js/macro-search.js +++ b/tests/rustdoc-js/macro-search.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'abracadabra!'; - const EXPECTED = { + 'query': 'abracadabra!', 'others': [ { 'path': 'macro_search', 'name': 'abracadabra' }, { 'path': 'macro_search', 'name': 'abracadabra_b' }, diff --git a/tests/rustdoc-js/module-substring.js b/tests/rustdoc-js/module-substring.js index f17a97f13..7a10397eb 100644 --- a/tests/rustdoc-js/module-substring.js +++ b/tests/rustdoc-js/module-substring.js @@ -1,6 +1,5 @@ -const QUERY = 'ig::pc'; - const EXPECTED = { + 'query': 'ig::pc', 'others': [ { 'path': 'module_substring::Sig', 'name': 'pc' }, { 'path': 'module_substring::Si', 'name': 'pc' }, diff --git a/tests/rustdoc-js/nested-unboxed.js b/tests/rustdoc-js/nested-unboxed.js new file mode 100644 index 000000000..44f784eb1 --- /dev/null +++ b/tests/rustdoc-js/nested-unboxed.js @@ -0,0 +1,68 @@ +// exact-check + +const EXPECTED = [ + { + 'query': '-> Result<Object, bool>', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Result<Object<i32, u32>, bool>', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Object, bool', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Object<i32, u32>, bool', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> i32, u32, bool', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Result<i32, u32, bool>', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Result<Object<i32>, bool>', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Result<Object<u32>, bool>', + 'others': [ + { 'path': 'nested_unboxed', 'name': 'something' }, + ], + }, + { + 'query': '-> Result<Object<i32>, u32, bool>', + 'others': [], + }, + { + 'query': '-> Result<i32, Object<u32>, bool>', + 'others': [], + }, + { + 'query': '-> Result<i32, u32, Object<bool>>', + 'others': [], + }, + { + 'query': '-> Result<Object<i32>, Object<u32>, bool>', + 'others': [], + }, +]; diff --git a/tests/rustdoc-js/nested-unboxed.rs b/tests/rustdoc-js/nested-unboxed.rs new file mode 100644 index 000000000..57f9592b7 --- /dev/null +++ b/tests/rustdoc-js/nested-unboxed.rs @@ -0,0 +1,5 @@ +pub struct Object<T, U>(T, U); + +pub fn something() -> Result<Object<i32, u32>, bool> { + loop {} +} diff --git a/tests/rustdoc-js/never-search.js b/tests/rustdoc-js/never-search.js new file mode 100644 index 000000000..ed24d6931 --- /dev/null +++ b/tests/rustdoc-js/never-search.js @@ -0,0 +1,46 @@ +// exact-check + +const EXPECTED = [ + { + 'query': '-> !', + 'others': [ + { 'path': 'never_search', 'name': 'loops' }, + ], + }, + { + 'query': '-> never', + 'others': [ + { 'path': 'never_search', 'name': 'loops' }, + { 'path': 'never_search', 'name': 'returns' }, + ], + }, + { + 'query': '!', + 'in_args': [ + { 'path': 'never_search', 'name': 'impossible' }, + { 'path': 'never_search', 'name': 'box_impossible' }, + ], + }, + { + 'query': 'never', + 'in_args': [ + { 'path': 'never_search', 'name': 'impossible' }, + { 'path': 'never_search', 'name': 'uninteresting' }, + { 'path': 'never_search', 'name': 'box_impossible' }, + { 'path': 'never_search', 'name': 'box_uninteresting' }, + ], + }, + { + 'query': 'box<!>', + 'in_args': [ + { 'path': 'never_search', 'name': 'box_impossible' }, + ], + }, + { + 'query': 'box<never>', + 'in_args': [ + { 'path': 'never_search', 'name': 'box_impossible' }, + { 'path': 'never_search', 'name': 'box_uninteresting' }, + ], + }, +]; diff --git a/tests/rustdoc-js/never-search.rs b/tests/rustdoc-js/never-search.rs new file mode 100644 index 000000000..299b4660d --- /dev/null +++ b/tests/rustdoc-js/never-search.rs @@ -0,0 +1,13 @@ +#![feature(never_type)] + +#[allow(nonstandard_style)] +pub struct never; + +pub fn loops() -> ! { loop {} } +pub fn returns() -> never { never } + +pub fn impossible(x: !) { match x {} } +pub fn uninteresting(x: never) { match x { never => {} } } + +pub fn box_impossible(x: Box<!>) { match *x {} } +pub fn box_uninteresting(x: Box<never>) { match *x { never => {} } } diff --git a/tests/rustdoc-js/path-ordering.js b/tests/rustdoc-js/path-ordering.js index 4aee569b0..f2e6fe2fa 100644 --- a/tests/rustdoc-js/path-ordering.js +++ b/tests/rustdoc-js/path-ordering.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'b::ccccccc'; - const EXPECTED = { + 'query': 'b::ccccccc', 'others': [ // `ccccccc` is an exact match for all three of these. // However `b` is a closer match for `bb` than for any diff --git a/tests/rustdoc-js/primitive.js b/tests/rustdoc-js/primitive.js index 4aec98c34..ad8f6663a 100644 --- a/tests/rustdoc-js/primitive.js +++ b/tests/rustdoc-js/primitive.js @@ -1,33 +1,30 @@ // exact-check -const QUERY = [ - "i32", - "str", - "primitive:str", - "struct:str", - "TotoIsSomewhere", -]; - const EXPECTED = [ { + 'query': 'i32', 'in_args': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'str', 'returned': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'primitive:str', 'returned': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'struct:str', 'returned': [], }, { + 'query': 'TotoIsSomewhere', 'others': [], 'in_args': [], 'returned': [], diff --git a/tests/rustdoc-js/prototype.js b/tests/rustdoc-js/prototype.js index 2f1d841c3..da72fdce3 100644 --- a/tests/rustdoc-js/prototype.js +++ b/tests/rustdoc-js/prototype.js @@ -1,14 +1,14 @@ // exact-check -const QUERY = ['constructor', '__proto__']; - const EXPECTED = [ { + 'query': 'constructor', 'others': [], 'returned': [], 'in_args': [], }, { + 'query': '__proto__', 'others': [], 'returned': [], 'in_args': [], diff --git a/tests/rustdoc-js/raw-pointer.js b/tests/rustdoc-js/raw-pointer.js index 140b955ea..f2b1294ee 100644 --- a/tests/rustdoc-js/raw-pointer.js +++ b/tests/rustdoc-js/raw-pointer.js @@ -1,33 +1,25 @@ // ignore-order -const QUERY = [ - 'Aaaaaaa -> i32', - 'Aaaaaaa -> Aaaaaaa', - 'Aaaaaaa -> usize', - '-> Aaaaaaa', - 'Aaaaaaa', -]; - const EXPECTED = [ { - // Aaaaaaa -> i32 + 'query': 'Aaaaaaa -> i32', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'eeeeeee' }, ], }, { - // Aaaaaaa -> Aaaaaaa + 'query': 'Aaaaaaa -> Aaaaaaa', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' }, { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [], }, { - // -> Aaaaaaa + 'query': '-> Aaaaaaa', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' }, { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' }, @@ -36,7 +28,7 @@ const EXPECTED = [ ], }, { - // Aaaaaaa + 'query': 'Aaaaaaa', 'others': [ { 'path': 'raw_pointer', 'name': 'Aaaaaaa' }, ], diff --git a/tests/rustdoc-js/reexport.js b/tests/rustdoc-js/reexport.js index 871e75d9b..9021cc2e9 100644 --- a/tests/rustdoc-js/reexport.js +++ b/tests/rustdoc-js/reexport.js @@ -1,15 +1,15 @@ // exact-check -const QUERY = ['Subscriber', 'AnotherOne']; - const EXPECTED = [ { + 'query': 'Subscriber', 'others': [ { 'path': 'reexport::fmt', 'name': 'Subscriber' }, { 'path': 'reexport', 'name': 'FmtSubscriber' }, ], }, { + 'query': 'AnotherOne', 'others': [ { 'path': 'reexport', 'name': 'AnotherOne' }, ], diff --git a/tests/rustdoc-js/search-bag-semantics.js b/tests/rustdoc-js/search-bag-semantics.js index c56a3df5f..4b598cd80 100644 --- a/tests/rustdoc-js/search-bag-semantics.js +++ b/tests/rustdoc-js/search-bag-semantics.js @@ -1,18 +1,15 @@ // exact-check -const QUERY = [ - 'P', - 'P, P', -]; - const EXPECTED = [ { + 'query': 'P', 'in_args': [ { 'path': 'search_bag_semantics', 'name': 'alacazam' }, { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, ], }, { + 'query': 'P, P', 'others': [ { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, ], diff --git a/tests/rustdoc-js/search-short-types.js b/tests/rustdoc-js/search-short-types.js index 3b2f15a40..5048e0443 100644 --- a/tests/rustdoc-js/search-short-types.js +++ b/tests/rustdoc-js/search-short-types.js @@ -1,6 +1,5 @@ -const QUERY = 'P'; - const EXPECTED = { + 'query': 'P', 'others': [ { 'path': 'search_short_types', 'name': 'P' }, { 'path': 'search_short_types::VeryLongTypeName', 'name': 'p' }, diff --git a/tests/rustdoc-js/slice-array.js b/tests/rustdoc-js/slice-array.js index 8c21e06dc..d676d0577 100644 --- a/tests/rustdoc-js/slice-array.js +++ b/tests/rustdoc-js/slice-array.js @@ -1,65 +1,73 @@ // exact-check -const QUERY = [ - 'R<primitive:slice<P>>', - 'primitive:slice<R<P>>', - 'R<primitive:slice<Q>>', - 'primitive:slice<R<Q>>', - 'R<primitive:array<Q>>', - 'primitive:array<R<Q>>', - 'primitive:array<TraitCat>', - 'primitive:array<TraitDog>', -]; - const EXPECTED = [ { - // R<primitive:slice<P>> + 'query': 'R<primitive:slice<P>>', 'returned': [], 'in_args': [ { 'path': 'slice_array', 'name': 'alpha' }, ], }, { - // primitive:slice<R<P>> + 'query': 'primitive:slice<R<P>>', 'returned': [ { 'path': 'slice_array', 'name': 'alef' }, ], 'in_args': [], }, { - // R<primitive:slice<Q>> + 'query': 'R<primitive:slice<Q>>', 'returned': [], 'in_args': [], }, { - // primitive:slice<R<Q>> + 'query': 'primitive:slice<R<Q>>', 'returned': [], 'in_args': [], }, { - // R<primitive:array<Q>> + 'query': 'R<primitive:array<Q>>', 'returned': [ { 'path': 'slice_array', 'name': 'bet' }, ], 'in_args': [], }, { - // primitive:array<R<Q>> + 'query': 'primitive:array<R<Q>>', 'returned': [], 'in_args': [ { 'path': 'slice_array', 'name': 'beta' }, ], }, { - // primitive::array<TraitCat> + 'query': 'primitive:array<TraitCat>', 'in_args': [ { 'path': 'slice_array', 'name': 'gamma' }, ], }, { - // primitive::array<TraitDog> + 'query': 'primitive:array<TraitDog>', 'in_args': [ { 'path': 'slice_array', 'name': 'gamma' }, ], }, + { + 'query': '[TraitCat]', + 'in_args': [ + { 'path': 'slice_array', 'name': 'gamma' }, + { 'path': 'slice_array', 'name': 'epsilon' }, + ], + }, + { + 'query': 'R<[Q]>', + 'returned': [ + { 'path': 'slice_array', 'name': 'bet' }, + ], + }, + { + 'query': 'R<[P]>', + 'in_args': [ + { 'path': 'slice_array', 'name': 'alpha' }, + ], + }, ]; diff --git a/tests/rustdoc-js/slice-array.rs b/tests/rustdoc-js/slice-array.rs index 2523b21cf..15ac4294f 100644 --- a/tests/rustdoc-js/slice-array.rs +++ b/tests/rustdoc-js/slice-array.rs @@ -14,3 +14,5 @@ pub trait TraitCat {} pub trait TraitDog {} pub fn gamma<T: TraitCat + TraitDog>(t: [T; 32]) {} + +pub fn epsilon<T: TraitCat + TraitDog>(t: &[T]) {} diff --git a/tests/rustdoc-js/struct-like-variant.js b/tests/rustdoc-js/struct-like-variant.js index f6deea51e..7b9bec7ae 100644 --- a/tests/rustdoc-js/struct-like-variant.js +++ b/tests/rustdoc-js/struct-like-variant.js @@ -1,6 +1,5 @@ -const QUERY = 'name'; - const EXPECTED = { + 'query': 'name', 'others': [ { 'path': 'struct_like_variant::Enum::Bar', 'name': 'name', 'desc': 'This is a name.' }, ], diff --git a/tests/rustdoc-js/substring.js b/tests/rustdoc-js/substring.js index af05cd1ad..96efa992b 100644 --- a/tests/rustdoc-js/substring.js +++ b/tests/rustdoc-js/substring.js @@ -1,6 +1,5 @@ -const QUERY = 'waker_from'; - const EXPECTED = { + 'query': 'waker_from', 'others': [ { 'path': 'substring::SuperWaker', 'name': 'local_waker_from_nonlocal' }, { 'path': 'substring::SuperWakerTask', 'name': 'local_waker_from_nonlocal' }, diff --git a/tests/rustdoc-js/summaries.js b/tests/rustdoc-js/summaries.js index dfb11e804..ae3aefb0c 100644 --- a/tests/rustdoc-js/summaries.js +++ b/tests/rustdoc-js/summaries.js @@ -1,19 +1,20 @@ // ignore-tidy-linelength -const QUERY = ['summaries', 'summaries::Sidebar', 'summaries::Sidebar2']; - const EXPECTED = [ { + 'query': 'summaries', 'others': [ { 'path': '', 'name': 'summaries', 'desc': 'This <em>summary</em> has a link, [<code>code</code>], and <code>Sidebar2</code> intra-doc.' }, ], }, { + 'query': 'summaries::Sidebar', 'others': [ { 'path': 'summaries', 'name': 'Sidebar', 'desc': 'This <code>code</code> will be rendered in a code tag.' }, ], }, { + 'query': 'summaries::Sidebar2', 'others': [ { 'path': 'summaries', 'name': 'Sidebar2', 'desc': '' }, ], diff --git a/tests/rustdoc-js/where-clause.js b/tests/rustdoc-js/where-clause.js index 86254a80e..8dccf197b 100644 --- a/tests/rustdoc-js/where-clause.js +++ b/tests/rustdoc-js/where-clause.js @@ -1,28 +1,31 @@ -const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam', 'drizzel -> shazam']; - const EXPECTED = [ { + 'query': 'trait<nested>', 'in_args': [ { 'path': 'where_clause', 'name': 'abracadabra' }, ], }, { + 'query': '-> trait<nested>', 'others': [ { 'path': 'where_clause', 'name': 'alacazam' }, ], }, { + 'query': 't1, t2', 'others': [ { 'path': 'where_clause', 'name': 'presto' }, ], }, { + 'query': '-> shazam', 'others': [ { 'path': 'where_clause', 'name': 'bippety' }, { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, ], }, { + 'query': 'drizzel -> shazam', 'others': [ { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, ], diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs new file mode 100644 index 000000000..a2a8e651c --- /dev/null +++ b/tests/rustdoc/alias-reexport.rs @@ -0,0 +1,16 @@ +// aux-build:alias-reexport.rs +// aux-build:alias-reexport2.rs + +#![crate_name = "foo"] +#![feature(lazy_type_alias)] + +extern crate alias_reexport2; + +// @has 'foo/reexport/fn.foo.html' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +// @has 'foo/reexport/fn.foo2.html' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +// @has 'foo/reexport/type.Reexported.html' +// @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' +#[doc(inline)] +pub use alias_reexport2 as reexport; diff --git a/tests/rustdoc/alias-reexport2.rs b/tests/rustdoc/alias-reexport2.rs new file mode 100644 index 000000000..85d3cdad9 --- /dev/null +++ b/tests/rustdoc/alias-reexport2.rs @@ -0,0 +1,16 @@ +// gate-test-lazy_type_alias +// aux-build:alias-reexport.rs + +#![crate_name = "foo"] +#![feature(lazy_type_alias)] + +extern crate alias_reexport; + +use alias_reexport::Reexported; + +// @has 'foo/fn.foo.html' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +pub fn foo() -> Reexported { 0 } +// @has 'foo/fn.foo2.html' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +pub fn foo2() -> Result<Reexported, ()> { Ok(0) } diff --git a/tests/rustdoc/anchors.no_type_anchor2.html b/tests/rustdoc/anchors.no_type_anchor2.html index f8b59160f..71e93990e 100644 --- a/tests/rustdoc/anchors.no_type_anchor2.html +++ b/tests/rustdoc/anchors.no_type_anchor2.html @@ -1 +1 @@ -<section id="associatedtype.Y" class="associatedtype"><h4 class="code-header">type <a href="#associatedtype.Y" class="associatedtype">Y</a> = <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
\ No newline at end of file +<section id="associatedtype.Y" class="associatedtype"><h4 class="code-header">pub type <a href="#associatedtype.Y" class="associatedtype">Y</a> = <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
\ No newline at end of file diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs index 68a11c57b..08dfa879d 100644 --- a/tests/rustdoc/assoc-consts.rs +++ b/tests/rustdoc/assoc-consts.rs @@ -46,7 +46,6 @@ pub fn f(_: &(ToString + 'static)) {} impl Bar { // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ // "const F: fn(_: &(dyn ToString + 'static))" - // FIXME(fmease): Hide default lifetime, render "const F: fn(_: &dyn ToString)" pub const F: fn(_: &(ToString + 'static)) = f; } diff --git a/tests/rustdoc/auxiliary/alias-reexport.rs b/tests/rustdoc/auxiliary/alias-reexport.rs new file mode 100644 index 000000000..14fafc02d --- /dev/null +++ b/tests/rustdoc/auxiliary/alias-reexport.rs @@ -0,0 +1,3 @@ +#![feature(lazy_type_alias)] + +pub type Reexported = u8; diff --git a/tests/rustdoc/auxiliary/alias-reexport2.rs b/tests/rustdoc/auxiliary/alias-reexport2.rs new file mode 100644 index 000000000..9f6910572 --- /dev/null +++ b/tests/rustdoc/auxiliary/alias-reexport2.rs @@ -0,0 +1,12 @@ +#![feature(lazy_type_alias)] + +extern crate alias_reexport; + +pub use alias_reexport::Reexported; + +// @has 'foo/fn.foo.html' +// @has - '//*[@class="docblock item-decl"]' 'pub fn foo() -> Reexported' +pub fn foo() -> Reexported { 0 } +// @has 'foo/fn.foo2.html' +// @has - '//*[@class="docblock item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +pub fn foo2() -> Result<Reexported, ()> { Ok(0) } diff --git a/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html b/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html new file mode 100644 index 000000000..29c08c5bd --- /dev/null +++ b/tests/rustdoc/decl-line-wrapping-empty-arg-list.decl.html @@ -0,0 +1,2 @@ +<pre class="rust item-decl"><code>pub fn create( +) -> <a class="struct" href="struct.Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000.html" title="struct decl_line_wrapping_empty_arg_list::Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000">Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000</a></code></pre>
\ No newline at end of file diff --git a/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs new file mode 100644 index 000000000..4cfb87496 --- /dev/null +++ b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs @@ -0,0 +1,12 @@ +// Ensure that we don't add an extra line containing nothing but whitespace in between the two +// parentheses of an empty argument list when line-wrapping a function declaration. + +// ignore-tidy-linelength + +pub struct Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000; + +// @has 'decl_line_wrapping_empty_arg_list/fn.create.html' +// @snapshot decl - '//pre[@class="rust item-decl"]' +pub fn create() -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000 { + loop {} +} diff --git a/tests/rustdoc/double-hyphen-to-dash.rs b/tests/rustdoc/double-hyphen-to-dash.rs new file mode 100644 index 000000000..66905f90c --- /dev/null +++ b/tests/rustdoc/double-hyphen-to-dash.rs @@ -0,0 +1,9 @@ +// This test ensures that `--` (double-hyphen) is correctly converted into `โ` (dash). + +#![crate_name = "foo"] + +// @has 'foo/index.html' '//*[@class="desc docblock-short"]' 'โ' +// @has 'foo/struct.Bar.html' '//*[@class="docblock"]' 'โ' + +/// -- +pub struct Bar; diff --git a/tests/rustdoc/files-creation-hidden.rs b/tests/rustdoc/files-creation-hidden.rs new file mode 100644 index 000000000..498d9cdae --- /dev/null +++ b/tests/rustdoc/files-creation-hidden.rs @@ -0,0 +1,24 @@ +#![crate_name="foo"] + +// @files foo '["index.html", "all.html", "sidebar-items.js"]' +// @!has "foo/struct.Foo.html" +#[doc(hidden)] +pub struct Foo; + +// @!has "foo/struct.Bar.html" +pub use crate::Foo as Bar; + +// @!has "foo/struct.Baz.html" +#[doc(hidden)] +pub use crate::Foo as Baz; + +// @!has "foo/foo/index.html" +#[doc(hidden)] +pub mod foo {} + +// @!has "foo/bar/index.html" +pub use crate::foo as bar; + +// @!has "foo/baz/index.html" +#[doc(hidden)] +pub use crate::foo as baz; diff --git a/tests/rustdoc/files-creation-private.rs b/tests/rustdoc/files-creation-private.rs new file mode 100644 index 000000000..e2fdbc068 --- /dev/null +++ b/tests/rustdoc/files-creation-private.rs @@ -0,0 +1,22 @@ +#![crate_name="foo"] + +// @files "foo" \ +// '["index.html", "all.html", "sidebar-items.js", "foo", "bar", "private", "struct.Bar.html"]' +// @files "foo/bar" '["index.html", "sidebar-items.js"]' + +// @!has "foo/priv/index.html" +// @!has "foo/priv/struct.Foo.html" +mod private { + pub struct Foo; +} + +// @has "foo/struct.Bar.html" +pub use crate::private::Foo as Bar; + +// @!has "foo/foo/index.html" +mod foo { + pub mod subfoo {} +} + +// @has "foo/bar/index.html" +pub use crate::foo::subfoo as bar; diff --git a/tests/rustdoc/generic-associated-types/gats.rs b/tests/rustdoc/generic-associated-types/gats.rs index 7ab82bb58..605176e5f 100644 --- a/tests/rustdoc/generic-associated-types/gats.rs +++ b/tests/rustdoc/generic-associated-types/gats.rs @@ -23,9 +23,9 @@ impl LendingIterator for () { pub struct Infinite<T>(T); // @has foo/trait.LendingIterator.html -// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T" +// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> = &'a T where Self: 'a" impl<T> LendingIterator for Infinite<T> { - type Item<'a> where Self: 'a = &'a T; + type Item<'a> = &'a T where Self: 'a; fn next<'a>(&'a self) -> Self::Item<'a> { &self.0 diff --git a/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs b/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs new file mode 100644 index 000000000..e382940a4 --- /dev/null +++ b/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs @@ -0,0 +1,23 @@ +// This test ensures that if a private item is re-exported with an intermediate +// `#[doc(hidden)]` re-export, it'll still be inlined (and not include any attribute +// from the doc hidden re-export. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// There should only be one struct displayed. +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' +// @has - '//*[@id="main-content"]//a[@href="struct.Reexport.html"]' 'Reexport' +// @has - '//*[@id="main-content"]//*[@class="desc docblock-short"]' 'Visible. Original.' + +mod private { + /// Original. + pub struct Bar3; +} + +/// Hidden. +#[doc(hidden)] +pub use crate::private::Bar3; +/// Visible. +pub use self::Bar3 as Reexport; diff --git a/tests/rustdoc/inline_cross/assoc-const-equality.rs b/tests/rustdoc/inline_cross/assoc-const-equality.rs new file mode 100644 index 000000000..1d3ce9e31 --- /dev/null +++ b/tests/rustdoc/inline_cross/assoc-const-equality.rs @@ -0,0 +1,8 @@ +// aux-crate:assoc_const_equality=assoc-const-equality.rs +// edition:2021 + +#![crate_name = "user"] + +// @has user/fn.accept.html +// @has - '//pre[@class="rust item-decl"]' 'fn accept(_: impl Trait<K = 0>)' +pub use assoc_const_equality::accept; diff --git a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs index db2491b87..74ceb697a 100644 --- a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -42,3 +42,15 @@ pub use aux::Main; // @has main/trait.Aid.html // @has - '//*[@id="associatedtype.Result"]' "type Result<'inter: 'src>" pub use aux::Aid; + +// Below, ensure that we correctly display generic parameters and where-clauses on +// associated types inside trait *impls*. More particularly, check that we don't render +// any bounds (here `Self::Alias<T>: ...`) as item bounds unlike all the trait test cases above. + +// @has main/struct.Implementor.html +// @has - '//*[@id="associatedtype.Alias"]' \ +// "type Alias<T: Eq> = T \ +// where \ +// String: From<T>, \ +// <Implementor as Implementee>::Alias<T>: From<<Implementor as Implementee>::Alias<T>>" +pub use aux::Implementor; diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs b/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs new file mode 100644 index 000000000..6a25dcea6 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/assoc-const-equality.rs @@ -0,0 +1,7 @@ +#![feature(associated_const_equality)] + +pub fn accept(_: impl Trait<K = 0>) {} + +pub trait Trait { + const K: i32; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs index 6644c8e41..551e97a2f 100644 --- a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -44,3 +44,20 @@ pub trait Helper { pub trait Aid<'src> { type Result<'inter: 'src>; } + +pub trait Implementee { + type Alias<T: Eq> + where + String: From<T>; +} + +pub struct Implementor; + +impl Implementee for Implementor { + type Alias<T: Eq> = T + where + String: From<T>, + // We will check that this bound doesn't get turned into an item bound since + // associated types in impls are not allowed to have any. + Self::Alias<T>: From<Self::Alias<T>>; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs index 9ac2e3d96..df8853007 100644 --- a/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs @@ -1,3 +1,5 @@ +// ignore-tidy-linelength + pub type Ty0 = dyn for<'any> FnOnce(&'any str) -> bool; pub type Ty1<'obj> = dyn std::fmt::Display + 'obj; @@ -6,12 +8,79 @@ pub type Ty2 = dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>; pub type Ty3<'s> = &'s dyn ToString; -pub fn func0(_: &(dyn Fn() + '_)) {} - -pub fn func1<'func>(_: &(dyn Fn() + 'func)) {} - pub trait Container<'r> { type Item<'a, 'ctx>; } -pub trait Shape<'a> {} +// Trait-object types inside of a container type that has lifetime bounds ("wrapped"). + +pub fn late_bound_wrapped_elided(_: &(dyn Fn() + '_)) {} +pub fn late_bound_wrapped_late0<'f>(_: &mut (dyn Fn() + 'f)) {} +pub fn late_bound_wrapped_defaulted0<'f>(_: &'f mut dyn Fn()) {} +pub type EarlyBoundWrappedDefaulted0<'x> = std::cell::Ref<'x, dyn Trait>; +pub type EarlyBoundWrappedDefaulted1<'x> = &'x dyn Trait; +pub type EarlyBoundWrappedEarly<'x, 'y> = std::cell::Ref<'x, dyn Trait + 'y>; +pub type EarlyBoundWrappedStatic<'x> = std::cell::Ref<'x, dyn Trait + 'static>; +pub fn late_bound_wrapped_defaulted1<'l>(_: std::cell::Ref<'l, dyn Trait>) {} +pub fn late_bound_wrapped_late1<'l, 'm>(_: std::cell::Ref<'l, dyn Trait + 'm>) {} +pub fn late_bound_wrapped_early<'e, 'l>(_: std::cell::Ref<'l, dyn Trait + 'e>) where 'e: {} // `'e` is early-bound +pub fn elided_bound_wrapped_defaulted(_: std::cell::Ref<'_, dyn Trait>) {} +pub type StaticBoundWrappedDefaulted0 = std::cell::Ref<'static, dyn Trait>; +pub type StaticBoundWrappedDefaulted1 = &'static dyn Trait; +pub type AmbiguousBoundWrappedEarly0<'r, 's> = AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>; +pub type AmbiguousBoundWrappedEarly1<'r, 's> = AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>; +pub type AmbiguousBoundWrappedStatic<'q> = AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>; + +// Trait-object types inside of a container type that doesn't have lifetime bounds ("wrapped"). + +pub type NoBoundsWrappedDefaulted = Box<dyn Trait>; +pub type NoBoundsWrappedEarly<'e> = Box<dyn Trait + 'e>; +pub fn no_bounds_wrapped_late<'l>(_: Box<dyn Trait + 'l>) {} +pub fn no_bounds_wrapped_elided(_: Box<dyn Trait + '_>) {} + +// Trait-object types outside of a container (โbareโ). + +pub type BareNoBoundsDefaulted = dyn Trait; +pub type BareNoBoundsEarly<'p> = dyn Trait + 'p; +pub type BareEarlyBoundDefaulted0<'u> = dyn EarlyBoundTrait0<'u>; +pub type BareEarlyBoundDefaulted1 = dyn for<'any> EarlyBoundTrait0<'any>; +pub type BareEarlyBoundDefaulted2<'w> = dyn EarlyBoundTrait1<'static, 'w>; +pub type BareEarlyBoundEarly<'i, 'j> = dyn EarlyBoundTrait0<'i> + 'j; +pub type BareEarlyBoundStatic<'i> = dyn EarlyBoundTrait0<'i> + 'static; +pub type BareStaticBoundDefaulted = dyn StaticBoundTrait; +pub type BareHigherRankedBoundDefaulted0 = dyn HigherRankedBoundTrait0; +pub type BareHigherRankedBoundDefaulted1<'r> = dyn HigherRankedBoundTrait1<'r>; +pub type BareAmbiguousBoundEarly0<'m, 'n> = dyn AmbiguousBoundTrait<'m, 'n> + 'm; +pub type BareAmbiguousBoundEarly1<'m, 'n> = dyn AmbiguousBoundTrait<'m, 'n> + 'n; +pub type BareAmbiguousBoundStatic<'o> = dyn AmbiguousBoundTrait<'o, 'o> + 'static; + +// Trait and container definitions. + +pub trait Trait {} // no bounds +pub trait EarlyBoundTrait0<'b>: 'b {} +pub trait EarlyBoundTrait1<'unused, 'c>: 'c {} +pub trait StaticBoundTrait: 'static {} +pub trait HigherRankedBoundTrait0 where for<'a> Self: 'a {} +pub trait HigherRankedBoundTrait1<'e> where for<'l> Self: 'e + 'l {} +pub trait AmbiguousBoundTrait<'a, 'b>: 'a + 'b {} + +pub struct AmbiguousBoundWrapper<'a, 'b, T: ?Sized + 'a + 'b>(&'a T, &'b T); + +// Trait objects inside of another trait object, a trait bound or an associated type. + +pub trait Inner {} +pub trait Outer<T: ?Sized> {} +pub trait Base { + type Type<T: ?Sized>; +} +impl Base for () { + type Type<T: ?Sized> = (); +} + +pub type NestedTraitObjects = dyn Outer<dyn Inner>; + +pub fn apit_rpit(o: impl Outer<dyn Inner>) -> impl Outer<dyn Inner> { + o +} + +pub type AssocTy = <() as Base>::Type<dyn Inner>; diff --git a/tests/rustdoc/inline_cross/dyn_trait.rs b/tests/rustdoc/inline_cross/dyn_trait.rs index 649d98f71..679972f03 100644 --- a/tests/rustdoc/inline_cross/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/dyn_trait.rs @@ -1,31 +1,145 @@ #![crate_name = "user"] +// In each test case, we include the trailing semicolon to ensure that nothing extra comes +// after the type like an unwanted outlives-bound. + // aux-crate:dyn_trait=dyn_trait.rs // edition:2021 // @has user/type.Ty0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool + 'static" -// FIXME(fmease): Hide default lifetime bound `'static` +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool;" pub use dyn_trait::Ty0; // @has user/type.Ty1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj" +// @has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj;" pub use dyn_trait::Ty1; // @has user/type.Ty2.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>" +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>;" pub use dyn_trait::Ty2; // @has user/type.Ty3.html -// @has - '//*[@class="rust item-decl"]//code' "&'s (dyn ToString + 's)" -// FIXME(fmease): Hide default lifetime bound, render "&'s dyn ToString" +// @has - '//*[@class="rust item-decl"]//code' "&'s dyn ToString;" pub use dyn_trait::Ty3; -// @has user/fn.func0.html -// @has - '//pre[@class="rust item-decl"]' "func0(_: &dyn Fn())" -// FIXME(fmease): Show placeholder-lifetime bound, render "func0(_: &(dyn Fn() + '_))" -pub use dyn_trait::func0; +// Below we check if we correctly elide trait-object lifetime bounds if they coincide with their +// default (known as "object lifetime default" or "default trait object lifetime"). + +// @has user/fn.lbwel.html +// @has - '//pre[@class="rust item-decl"]' "lbwel(_: &dyn Fn())" +pub use dyn_trait::late_bound_wrapped_elided as lbwel; +// @has user/fn.lbwl0.html +// has - '//pre[@class="rust item-decl"]' "lbwl0<'f>(_: &mut (dyn Fn() + 'f))" +pub use dyn_trait::late_bound_wrapped_late0 as lbwl0; +// @has user/fn.lbwd0.html +// has - '//pre[@class="rust item-decl"]' "lbwd0<'f>(_: &'f mut dyn Fn())" +pub use dyn_trait::late_bound_wrapped_defaulted0 as lbwd0; +// @has user/type.EarlyBoundWrappedDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait>;" +pub use dyn_trait::EarlyBoundWrappedDefaulted0; +// @has user/type.EarlyBoundWrappedDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "&'x dyn Trait;" +pub use dyn_trait::EarlyBoundWrappedDefaulted1; +// @has user/type.EarlyBoundWrappedEarly.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'y>" +pub use dyn_trait::EarlyBoundWrappedEarly; +// @has user/type.EarlyBoundWrappedStatic.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'static>" +pub use dyn_trait::EarlyBoundWrappedStatic; +// @has user/fn.lbwd1.html +// @has - '//pre[@class="rust item-decl"]' "lbwd1<'l>(_: Ref<'l, dyn Trait>)" +pub use dyn_trait::late_bound_wrapped_defaulted1 as lbwd1; +// @has user/fn.lbwl1.html +// @has - '//pre[@class="rust item-decl"]' "lbwl1<'l, 'm>(_: Ref<'l, dyn Trait + 'm>)" +pub use dyn_trait::late_bound_wrapped_late1 as lbwl1; +// @has user/fn.lbwe.html +// @has - '//pre[@class="rust item-decl"]' "lbwe<'e, 'l>(_: Ref<'l, dyn Trait + 'e>)" +pub use dyn_trait::late_bound_wrapped_early as lbwe; +// @has user/fn.ebwd.html +// @has - '//pre[@class="rust item-decl"]' "ebwd(_: Ref<'_, dyn Trait>)" +pub use dyn_trait::elided_bound_wrapped_defaulted as ebwd; +// @has user/type.StaticBoundWrappedDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "Ref<'static, dyn Trait>;" +pub use dyn_trait::StaticBoundWrappedDefaulted0; +// @has user/type.StaticBoundWrappedDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "&'static dyn Trait;" +pub use dyn_trait::StaticBoundWrappedDefaulted1; +// @has user/type.AmbiguousBoundWrappedEarly0.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>;" +pub use dyn_trait::AmbiguousBoundWrappedEarly0; +// @has user/type.AmbiguousBoundWrappedEarly1.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>;" +pub use dyn_trait::AmbiguousBoundWrappedEarly1; +// @has user/type.AmbiguousBoundWrappedStatic.html +// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>;" +pub use dyn_trait::AmbiguousBoundWrappedStatic; + +// @has user/type.NoBoundsWrappedDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait, Global>;" +pub use dyn_trait::NoBoundsWrappedDefaulted; +// @has user/type.NoBoundsWrappedEarly.html +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e, Global>;" +pub use dyn_trait::NoBoundsWrappedEarly; +// @has user/fn.nbwl.html +// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l, Global>)" +pub use dyn_trait::no_bounds_wrapped_late as nbwl; +// @has user/fn.nbwel.html +// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_, Global>)" +// NB: It might seem counterintuitive to display the explicitly elided lifetime `'_` here instead of +// eliding it but this behavior is correct: The default is `'static` here which != `'_`. +pub use dyn_trait::no_bounds_wrapped_elided as nbwel; + +// @has user/type.BareNoBoundsDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait;" +pub use dyn_trait::BareNoBoundsDefaulted; +// @has user/type.BareNoBoundsEarly.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait + 'p;" +pub use dyn_trait::BareNoBoundsEarly; +// @has user/type.BareEarlyBoundDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'u>;" +pub use dyn_trait::BareEarlyBoundDefaulted0; +// @has user/type.BareEarlyBoundDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> EarlyBoundTrait0<'any>;" +pub use dyn_trait::BareEarlyBoundDefaulted1; +// @has user/type.BareEarlyBoundDefaulted2.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait1<'static, 'w>;" +pub use dyn_trait::BareEarlyBoundDefaulted2; +// @has user/type.BareEarlyBoundEarly.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'j;" +pub use dyn_trait::BareEarlyBoundEarly; +// @has user/type.BareEarlyBoundStatic.html +// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'static;" +pub use dyn_trait::BareEarlyBoundStatic; +// @has user/type.BareStaticBoundDefaulted.html +// @has - '//*[@class="rust item-decl"]//code' "dyn StaticBoundTrait;" +pub use dyn_trait::BareStaticBoundDefaulted; +// @has user/type.BareHigherRankedBoundDefaulted0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait0;" +pub use dyn_trait::BareHigherRankedBoundDefaulted0; +// @has user/type.BareHigherRankedBoundDefaulted1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait1<'r>;" +pub use dyn_trait::BareHigherRankedBoundDefaulted1; +// @has user/type.BareAmbiguousBoundEarly0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'm;" +pub use dyn_trait::BareAmbiguousBoundEarly0; +// @has user/type.BareAmbiguousBoundEarly1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'n;" +pub use dyn_trait::BareAmbiguousBoundEarly1; +// @has user/type.BareAmbiguousBoundStatic.html +// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'o, 'o> + 'static;" +pub use dyn_trait::BareAmbiguousBoundStatic; + +// Regression test for issue #115179: + +// @has user/type.NestedTraitObjects.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Outer<dyn Inner>;" +pub use dyn_trait::NestedTraitObjects; + +// @has user/fn.apit_rpit.html +// @has - '//pre[@class="rust item-decl"]' \ +// "apit_rpit(o: impl Outer<dyn Inner>) -> impl Outer<dyn Inner>" +pub use dyn_trait::apit_rpit; -// @has user/fn.func1.html -// @has - '//pre[@class="rust item-decl"]' "func1<'func>(_: &(dyn Fn() + 'func))" -pub use dyn_trait::func1; +// @has user/type.AssocTy.html +// @has - '//*[@class="rust item-decl"]//code' "<() as Base>::Type<dyn Inner>" +pub use dyn_trait::AssocTy; diff --git a/tests/rustdoc/intra-doc/issue-108459.rs b/tests/rustdoc/intra-doc/issue-108459.rs new file mode 100644 index 000000000..eb1c7a05e --- /dev/null +++ b/tests/rustdoc/intra-doc/issue-108459.rs @@ -0,0 +1,37 @@ +#![deny(rustdoc::broken_intra_doc_links)] + +pub struct S; +pub mod char {} + +// Ensure this doesn't ICE due to trying to slice off non-existent backticks from "S" + +/// See [S] and [`S`] +pub struct MyStruct1; + +// Ensure that link texts are replaced correctly even if there are multiple links with +// the same target but different text + +/// See also [crate::char] and [mod@char] and [prim@char] +// @has issue_108459/struct.MyStruct2.html '//*[@href="char/index.html"]' 'crate::char' +// @has - '//*[@href="char/index.html"]' 'char' +// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub struct MyStruct2; + +/// See also [mod@char] and [prim@char] and [crate::char] +// @has issue_108459/struct.MyStruct3.html '//*[@href="char/index.html"]' 'crate::char' +// @has - '//*[@href="char/index.html"]' 'char' +// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub struct MyStruct3; + +// Ensure that links are correct even if there are multiple links with the same text but +// different targets + +/// See also [char][mod@char] and [char][prim@char] +// @has issue_108459/struct.MyStruct4.html '//*[@href="char/index.html"]' 'char' +// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub struct MyStruct4; + +/// See also [char][prim@char] and [char][crate::char] +// @has issue_108459/struct.MyStruct5.html '//*[@href="char/index.html"]' 'char' +// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +pub struct MyStruct5; diff --git a/tests/rustdoc/intra-doc/prim-precedence.rs b/tests/rustdoc/intra-doc/prim-precedence.rs index 25625b952..c5a64e42a 100644 --- a/tests/rustdoc/intra-doc/prim-precedence.rs +++ b/tests/rustdoc/intra-doc/prim-precedence.rs @@ -12,5 +12,5 @@ pub struct MyString; /// See also [crate::char] and [mod@char] // @has prim_precedence/struct.MyString2.html '//*[@href="char/index.html"]' 'crate::char' -// @has - '//*[@href="char/index.html"]' 'mod@char' +// @has - '//*[@href="char/index.html"]' 'char' pub struct MyString2; diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs new file mode 100644 index 000000000..b0c225401 --- /dev/null +++ b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs @@ -0,0 +1,143 @@ +// Test to enforce rules over re-exports inlining from +// <https://github.com/rust-lang/rust/issues/109449>. + +#![crate_name = "foo"] + +mod private_module { + #[doc(hidden)] + pub struct Public; + #[doc(hidden)] + pub type Bar = (); +} + +#[doc(hidden)] +mod module { + pub struct Public2; + pub type Bar2 = (); +} + +#[doc(hidden)] +pub type Bar3 = (); +#[doc(hidden)] +pub struct FooFoo; + +// Checking that re-exporting a `#[doc(hidden)]` item will NOT inline it. +pub mod single_reexport { + // @has 'foo/single_reexport/index.html' + + // First we check that we have 4 type aliases. + // @count - '//*[@id="main-content"]/*[@class="item-table"]//code' 4 + + // Then we check that we have the correct link for each re-export. + + // @!has - '//*[@href="struct.Foo.html"]' 'Foo' + // @has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' + pub use crate::private_module::Public as Foo; + // @!has - '//*[@href="type.Foo2.html"]' 'Foo2' + // @has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' + pub use crate::private_module::Bar as Foo2; + // @!has - '//*[@href="type.Yo.html"]' 'Yo' + // @has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' + pub use crate::Bar3 as Yo; + // @!has - '//*[@href="struct.Yo2.html"]' 'Yo2' + // @has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' + pub use crate::FooFoo as Yo2; + + // Checking that each file is also created as expected. + // @!has 'foo/single_reexport/struct.Foo.html' + // @!has 'foo/single_reexport/type.Foo2.html' + // @!has 'foo/single_reexport/type.Yo.html' + // @!has 'foo/single_reexport/struct.Yo2.html' +} + +// However, re-exporting an item inheriting `#[doc(hidden)]` will inline it. +pub mod single_reexport_inherit_hidden { + // @has 'foo/single_reexport_inherit_hidden/index.html' + + // @has - '//*[@href="struct.Foo3.html"]' 'Foo3' + pub use crate::module::Public2 as Foo3; + // @has - '//*[@href="type.Foo4.html"]' 'Foo4' + pub use crate::module::Bar2 as Foo4; + + // @has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' + // @has 'foo/single_reexport_inherit_hidden/type.Foo4.html' +} + +pub mod single_reexport_no_inline { + // First we ensure that we only have re-exports and no inlined items. + // @has 'foo/single_reexport_no_inline/index.html' + // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' + + // Now we check that we don't have links to the items, just `pub use`. + // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' + // @!has - '//*[@id="main-content"]//a' 'XFoo' + #[doc(no_inline)] + pub use crate::private_module::Public as XFoo; + // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' + // @!has - '//*[@id="main-content"]//a' 'Foo2' + #[doc(no_inline)] + pub use crate::private_module::Bar as Foo2; + // @has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' + // @!has - '//*[@id="main-content"]//a' 'Yo' + #[doc(no_inline)] + pub use crate::Bar3 as Yo; + // @has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' + // @!has - '//*[@id="main-content"]//a' 'Yo2' + #[doc(no_inline)] + pub use crate::FooFoo as Yo2; + // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' + // @!has - '//*[@id="main-content"]//a' 'Foo3' + #[doc(no_inline)] + pub use crate::module::Public2 as Foo3; + // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' + // @!has - '//*[@id="main-content"]//a' 'Foo4' + #[doc(no_inline)] + pub use crate::module::Bar2 as Foo4; +} + +// Checking that glob re-exports don't inline `#[doc(hidden)]` items. +pub mod glob_reexport { + // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items + // should be inlined. + // @has 'foo/glob_reexport/index.html' + // @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' + + // 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. + // @!has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' + pub use crate::private_module::*; + // @has - '//*[@id="main-content"]//*' 'pub use crate::*;' + pub use crate::*; + // This one should be inlined. + // @!has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' + // @has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' + // @has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' + // And we check that the two files were created too. + // @has 'foo/glob_reexport/struct.Public2.html' + // @has 'foo/glob_reexport/type.Bar2.html' + pub use crate::module::*; +} + +mod private { + /// Original. + pub struct Bar3; +} + +// Checking that `#[doc(hidden)]` re-exports documentation isn't generated. +pub mod doc_hidden_reexport { + // @has 'foo/doc_hidden_reexport/index.html' + // Ensure there is only one item in this page and that it's a struct. + // @count - '//*[@class="item-name"]' 1 + // @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.' + /// Hidden. + #[doc(hidden)] + pub use crate::private::Bar3; + /// Visible. + pub use self::Bar3 as Reexport; +} diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs index 8e1029a1c..65c26d6a8 100644 --- a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs +++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs @@ -2,11 +2,17 @@ #![no_core] #![crate_name = "foo"] +// @files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ +// 'visible']" +// @files "foo/hidden" "['inner']" +// @files "foo/hidden/inner" "['trait.Foo.html']" +// @files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" + // @!has 'foo/hidden/index.html' -// FIXME: add missing `@` for the two next tests once issue is fixed! -// To be done in <https://github.com/rust-lang/rust/issues/111249>. -// !has 'foo/hidden/inner/index.html' -// !has 'foo/hidden/inner/trait.Foo.html' +// @!has 'foo/hidden/inner/index.html' +// FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 +// @has 'foo/hidden/inner/trait.Foo.html' +// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' #[doc(hidden)] pub mod hidden { pub mod inner { diff --git a/tests/rustdoc/issue-111249-file-creation.rs b/tests/rustdoc/issue-111249-file-creation.rs new file mode 100644 index 000000000..afd65ddaf --- /dev/null +++ b/tests/rustdoc/issue-111249-file-creation.rs @@ -0,0 +1,40 @@ +#![crate_name = "foo"] +#![feature(no_core)] +#![no_core] + +// @files "foo" "['all.html', 'visible', 'index.html', 'sidebar-items.js', 'hidden', \ +// 'struct.Bar.html']" +// @files "foo/visible" "['trait.Foo.html', 'index.html', 'sidebar-items.js']" +// @files "foo/hidden" "['inner']" +// @files "foo/hidden/inner" "['trait.Foo.html']" + +// The following five should not fail! +// @!has 'foo/hidden/index.html' +// @!has 'foo/hidden/inner/index.html' +// FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 +// @has 'foo/hidden/inner/trait.Foo.html' +// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' +// @!has 'foo/hidden/inner/inner_hidden/index.html' +// @!has 'foo/hidden/inner/inner_hidden/trait.HiddenFoo.html' +#[doc(hidden)] +pub mod hidden { + pub mod inner { + pub trait Foo {} + + #[doc(hidden)] + pub mod inner_hidden { + pub trait HiddenFoo {} + } + } +} + +// @has 'foo/visible/index.html' +// @has 'foo/visible/trait.Foo.html' +#[doc(inline)] +pub use hidden::inner as visible; + +// @has 'foo/struct.Bar.html' +// @count - '//*[@id="impl-Foo-for-Bar"]' 1 +pub struct Bar; + +impl visible::Foo for Bar {} diff --git a/tests/rustdoc/issue-112515-impl-ty-alias.rs b/tests/rustdoc/issue-112515-impl-ty-alias.rs new file mode 100644 index 000000000..161188ee5 --- /dev/null +++ b/tests/rustdoc/issue-112515-impl-ty-alias.rs @@ -0,0 +1,30 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/112515>. +// It's to ensure that this code doesn't have infinite loop in rustdoc when +// trying to retrive type alias implementations. + +// ignore-tidy-linelength + +pub type Boom = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<u64, u8>, ()>, ()>, ()>, u8>, ()>, u8>, ()>, u8>, u8>, ()>, ()>, ()>, u8>, u8>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, u8>, ()>, ()>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, ()>, ()>, ()>, u8>, ()>, ()>, u8>, u8>, u8>, u8>, ()>, u8>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>, ()>; +pub struct S<T, U>(T, U); + +pub trait A {} + +pub trait B<T> { + type P; +} + +impl A for u64 {} + +impl<T, U> A for S<T, U> {} + +impl<T> B<u8> for S<T, ()> +where + T: B<u8>, + <T as B<u8>>::P: A, +{ + type P = (); +} + +impl<T: A, U, V> B<T> for S<U, V> { + type P = (); +} diff --git a/tests/rustdoc/redirect.rs b/tests/rustdoc/redirect.rs index 5b7a76e1a..4fb81c23d 100644 --- a/tests/rustdoc/redirect.rs +++ b/tests/rustdoc/redirect.rs @@ -10,7 +10,9 @@ pub trait Foo {} // @has - '//code' 'pub use reexp_stripped::Bar' // @has - '//code/a' 'Bar' // @has - '//a[@href="../reexp_stripped/hidden/struct.Bar.html"]' 'Bar' +// FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 // @has reexp_stripped/hidden/struct.Bar.html +// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../reexp_stripped/struct.Bar.html">' // @has 'reexp_stripped/struct.Bar.html' // @has - '//a[@href="struct.Bar.html"]' 'Bar' #[doc(no_inline)] diff --git a/tests/rustdoc/reexport-attr-merge.rs b/tests/rustdoc/reexport-attr-merge.rs index f6c23a136..6cc054e7a 100644 --- a/tests/rustdoc/reexport-attr-merge.rs +++ b/tests/rustdoc/reexport-attr-merge.rs @@ -19,9 +19,9 @@ pub use Foo1 as Foo2; // First we ensure that only the reexport `Bar2` and the inlined struct `Bar` // are inlined. // @count - '//a[@class="struct"]' 2 -// Then we check that both `cfg` are displayed. +// Then we check that `cfg` is displayed for base item, but not for intermediate re-exports. // @has - '//*[@class="stab portability"]' 'foo' -// @has - '//*[@class="stab portability"]' 'bar' +// @!has - '//*[@class="stab portability"]' 'bar' // And finally we check that the only element displayed is `Bar`. // @has - '//a[@class="struct"]' 'Bar' #[doc(inline)] diff --git a/tests/rustdoc/reexport-doc-hidden-inside-private.rs b/tests/rustdoc/reexport-doc-hidden-inside-private.rs new file mode 100644 index 000000000..e9d243d8a --- /dev/null +++ b/tests/rustdoc/reexport-doc-hidden-inside-private.rs @@ -0,0 +1,16 @@ +// This test ensures that a re-export of `#[doc(hidden)]` item inside a private +// module will still be displayed (the re-export, not the item). + +#![crate_name = "foo"] + +mod private_module { + #[doc(hidden)] + pub struct Public; +} + +// @has 'foo/index.html' +// @has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' +pub use crate::private_module::Public as Foo; +// Glob re-exports with no visible items should not be displayed. +// @count - '//*[@class="item-table"]/li' 1 +pub use crate::private_module::*; diff --git a/tests/rustdoc/union-fields-html.rs b/tests/rustdoc/union-fields-html.rs new file mode 100644 index 000000000..1ac01232c --- /dev/null +++ b/tests/rustdoc/union-fields-html.rs @@ -0,0 +1,11 @@ +#![crate_name = "foo"] + +// @has 'foo/union.Union.html' +// Checking that there is a whitespace after `:`. +// @has - '//*[@id="structfield.a"]/code' 'a: u8' +// @has - '//*[@id="structfield.b"]/code' 'b: u32' +pub union Union { + pub a: u8, + /// tadam + pub b: u32, +} diff --git a/tests/rustdoc/visibility.rs b/tests/rustdoc/visibility.rs index 4099b54f0..4f9b06fd7 100644 --- a/tests/rustdoc/visibility.rs +++ b/tests/rustdoc/visibility.rs @@ -1,6 +1,8 @@ // compile-flags: --document-private-items #![crate_name = "foo"] +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] // @!has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic ๐' // @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' @@ -103,3 +105,26 @@ impl PubTrait for FooPublic { const CONST: usize = 0; fn function() {} } + +pub struct Assoc; + +// @has foo/struct.Assoc.html +impl Assoc { + // @has - '//*[@id="associatedtype.TypePub"]' 'pub type TypePub' + pub type TypePub = usize; + + // @has - '//*[@id="associatedtype.TypePriv"]' 'pub(crate) type TypePriv' + type TypePriv = usize; + + // @has - '//*[@id="associatedconstant.CONST_PUB"]' 'pub const CONST_PUB' + pub const CONST_PUB: usize = 0; + + // @has - '//*[@id="associatedconstant.CONST_PRIV"]' 'pub(crate) const CONST_PRIV' + const CONST_PRIV: usize = 0; + + // @has - '//*[@id="method.function_pub"]' 'pub fn function_pub()' + pub fn function_pub() {} + + // @has - '//*[@id="method.function_priv"]' 'pub(crate) fn function_priv()' + fn function_priv() {} +} diff --git a/tests/rustdoc/where.SWhere_Echo_impl.html b/tests/rustdoc/where.SWhere_Echo_impl.html new file mode 100644 index 000000000..7517eb090 --- /dev/null +++ b/tests/rustdoc/where.SWhere_Echo_impl.html @@ -0,0 +1,2 @@ +<h3 class="code-header">impl<D> <a class="struct" href="struct.Delta.html" title="struct foo::Delta">Delta</a><D><span class="where fmt-newline">where + D: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a>,</span></h3>
\ No newline at end of file diff --git a/tests/rustdoc/where.SWhere_Simd_item-decl.html b/tests/rustdoc/where.SWhere_Simd_item-decl.html index ef4294c8f..3e72ba2b7 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>(_) <span class="where">where - T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre>
\ No newline at end of file + 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 new file mode 100644 index 000000000..a7700055c --- /dev/null +++ b/tests/rustdoc/where.alpha_trait_decl.html @@ -0,0 +1,3 @@ +<code>pub struct Alpha<A>(_) +<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.bravo_trait_decl.html b/tests/rustdoc/where.bravo_trait_decl.html new file mode 100644 index 000000000..00524201a --- /dev/null +++ b/tests/rustdoc/where.bravo_trait_decl.html @@ -0,0 +1,5 @@ +<code>pub trait Bravo<B><span class="where fmt-newline">where + B: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a>,</span>{ + // Required method + fn <a href="#tymethod.get" class="fn">get</a>(&self, B: B); +}</code>
\ No newline at end of file diff --git a/tests/rustdoc/where.charlie_fn_decl.html b/tests/rustdoc/where.charlie_fn_decl.html new file mode 100644 index 000000000..8e3bc8b01 --- /dev/null +++ b/tests/rustdoc/where.charlie_fn_decl.html @@ -0,0 +1,2 @@ +<code>pub fn charlie<C>()<span class="where fmt-newline">where + C: <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.golf_type_alias_decl.html b/tests/rustdoc/where.golf_type_alias_decl.html new file mode 100644 index 000000000..8da5402f9 --- /dev/null +++ b/tests/rustdoc/where.golf_type_alias_decl.html @@ -0,0 +1,2 @@ +<code>pub type Golf<T><span class="where fmt-newline">where + T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span> = <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T, T)</a>;</code>
\ No newline at end of file diff --git a/tests/rustdoc/where.rs b/tests/rustdoc/where.rs index 8b8a126e8..2aa9c8b54 100644 --- a/tests/rustdoc/where.rs +++ b/tests/rustdoc/where.rs @@ -5,16 +5,20 @@ use std::io::Lines; pub trait MyTrait { fn dummy(&self) { } } // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) 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" +// @snapshot bravo_trait_decl - '//*[@class="rust item-decl"]/code' pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); } // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>()where C: MyTrait" +// @snapshot charlie_fn_decl - '//*[@class="rust item-decl"]/code' pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>(D); // @has foo/struct.Delta.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<D> Delta<D>where D: MyTrait" +// @snapshot SWhere_Echo_impl - '//*[@id="impl-Delta%3CD%3E"]/h3[@class="code-header"]' impl<D> Delta<D> where D: MyTrait { pub fn delta() {} } @@ -65,4 +69,5 @@ impl<F> MyTrait for Foxtrot<F>where F: MyTrait {} // @has foo/type.Golf.html '//pre[@class="rust item-decl"]' \ // "type Golf<T>where T: Clone, = (T, T)" +// @snapshot golf_type_alias_decl - '//*[@class="rust item-decl"]/code' pub type Golf<T> where T: Clone = (T, T); |