summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-gui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/rustdoc-gui/anchors.goml2
-rw-r--r--tests/rustdoc-gui/code-tags.goml2
-rw-r--r--tests/rustdoc-gui/huge-logo.goml4
-rw-r--r--tests/rustdoc-gui/impl_on_foreign_order.goml6
-rw-r--r--tests/rustdoc-gui/item-decl-colors.goml2
-rw-r--r--tests/rustdoc-gui/no-docblock.goml2
-rw-r--r--tests/rustdoc-gui/rust-logo.goml15
-rw-r--r--tests/rustdoc-gui/search-result-impl-disambiguation.goml43
-rw-r--r--tests/rustdoc-gui/search-tab.goml4
-rw-r--r--tests/rustdoc-gui/setting-auto-hide-content-large-items.goml2
-rw-r--r--tests/rustdoc-gui/sidebar-mobile.goml4
-rw-r--r--tests/rustdoc-gui/sidebar-source-code-display.goml4
-rw-r--r--tests/rustdoc-gui/sidebar.goml37
-rw-r--r--tests/rustdoc-gui/source-anchor-scroll.goml8
-rw-r--r--tests/rustdoc-gui/source-code-page.goml21
-rw-r--r--tests/rustdoc-gui/src/lib2/lib.rs9
-rw-r--r--tests/rustdoc-gui/src/staged_api/lib.rs2
-rw-r--r--tests/rustdoc-gui/src/test_docs/lib.rs64
-rw-r--r--tests/rustdoc-gui/trait-sidebar-item-order.goml2
-rw-r--r--tests/rustdoc-gui/type-declation-overflow.goml2
-rw-r--r--tests/rustdoc-gui/type-impls.goml86
21 files changed, 280 insertions, 41 deletions
diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml
index 30b83f0da..72e0bcd77 100644
--- a/tests/rustdoc-gui/anchors.goml
+++ b/tests/rustdoc-gui/anchors.goml
@@ -56,7 +56,7 @@ define-function: (
assert-css: ("#top-doc-prose-title", {"color": |title_color|})
- assert-css: (".sidebar a", {"color": |sidebar_link_color|})
+ assert-css: (".sidebar .block a", {"color": |sidebar_link_color|})
assert-css: (".main-heading h1 a", {"color": |title_color|})
// We move the cursor over the "Implementations" title so the anchor is displayed.
diff --git a/tests/rustdoc-gui/code-tags.goml b/tests/rustdoc-gui/code-tags.goml
index 3405d3295..577f932e5 100644
--- a/tests/rustdoc-gui/code-tags.goml
+++ b/tests/rustdoc-gui/code-tags.goml
@@ -1,6 +1,6 @@
// This test ensures that items and documentation code blocks are wrapped in <pre><code>
-// We need to disable this check because `implementors/test_docs/trait.AnotherOne.js`
+// We need to disable this check because `trait.impl/test_docs/trait.AnotherOne.js`
// doesn't exist.
fail-on-request-error: false
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
diff --git a/tests/rustdoc-gui/huge-logo.goml b/tests/rustdoc-gui/huge-logo.goml
index 6d3eb6606..bfc24c326 100644
--- a/tests/rustdoc-gui/huge-logo.goml
+++ b/tests/rustdoc-gui/huge-logo.goml
@@ -4,8 +4,8 @@ go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html"
set-window-size: (1280, 1024)
// offsetWidth = width of sidebar
-assert-property: (".sidebar .logo-container", {"offsetWidth": "200", "offsetHeight": 100})
-assert-property: (".sidebar .logo-container img", {"offsetWidth": "100", "offsetHeight": 100})
+assert-property: (".sidebar-crate .logo-container", {"offsetWidth": "48", "offsetHeight": 48})
+assert-property: (".sidebar-crate .logo-container img", {"offsetWidth": "48", "offsetHeight": 48})
set-window-size: (400, 600)
// offset = size + margin
diff --git a/tests/rustdoc-gui/impl_on_foreign_order.goml b/tests/rustdoc-gui/impl_on_foreign_order.goml
new file mode 100644
index 000000000..a6f5343be
--- /dev/null
+++ b/tests/rustdoc-gui/impl_on_foreign_order.goml
@@ -0,0 +1,6 @@
+// This test ensures that the "implementations on foreign types" of a trait are correctly sorted.
+go-to: "file://" + |DOC_PATH| + "/test_docs/foreign_impl_order/trait.Foo.html"
+assert-text: ("details:nth-of-type(1) h3", "impl Foo<1> for [u8; 1]")
+assert-text: ("details:nth-of-type(2) h3", "impl Foo<2> for [u8; 2]")
+assert-text: ("details:nth-of-type(3) h3", "impl Foo<3> for [u8; 3]")
+assert-text: ("details:nth-of-type(4) h3", "impl Foo<4> for [u8; 4]")
diff --git a/tests/rustdoc-gui/item-decl-colors.goml b/tests/rustdoc-gui/item-decl-colors.goml
index a77784273..7bbd20c4e 100644
--- a/tests/rustdoc-gui/item-decl-colors.goml
+++ b/tests/rustdoc-gui/item-decl-colors.goml
@@ -1,6 +1,6 @@
// This test ensures that the color of the items in the type decl are working as expected.
-// We need to disable this check because `implementors/test_docs/trait.TraitWithoutGenerics.js`
+// We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js`
// doesn't exist.
fail-on-request-error: false
diff --git a/tests/rustdoc-gui/no-docblock.goml b/tests/rustdoc-gui/no-docblock.goml
index 1b4638ef0..2115b6f53 100644
--- a/tests/rustdoc-gui/no-docblock.goml
+++ b/tests/rustdoc-gui/no-docblock.goml
@@ -1,6 +1,6 @@
// This test checks that there are margins applied to methods with no docblocks.
-// We need to disable this check because `implementors/test_docs/trait.TraitWithNoDocblock.js`
+// We need to disable this check because `trait.impl/test_docs/trait.TraitWithNoDocblock.js`
// doesn't exist.
fail-on-request-error: false
diff --git a/tests/rustdoc-gui/rust-logo.goml b/tests/rustdoc-gui/rust-logo.goml
index cd453aea2..696cab34d 100644
--- a/tests/rustdoc-gui/rust-logo.goml
+++ b/tests/rustdoc-gui/rust-logo.goml
@@ -1,18 +1,18 @@
// This test ensures that the correct style is applied to the rust logo in the sidebar.
-go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
define-function: (
"check-logo",
(theme, filter),
block {
// Going to the doc page.
- go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+ go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
// Changing theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
assert-css: (".rust-logo", {"filter": |filter|})
// Going to the source code page.
- go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
+ go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
// Changing theme (since it's local files, the local storage works by folder).
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
@@ -26,6 +26,15 @@ define-function: (
assert-false: ".rust-logo"
// Check there is no filter.
assert-css: (".sidebar .logo-container img", {"filter": "none"})
+ // Now we check that this page has no logo at all
+ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+ assert-false: ".rust-logo"
+ assert-false: ".logo-container"
+ assert-false: ".sub-logo-container"
+ go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
+ assert-false: ".rust-logo"
+ assert-false: ".logo-container"
+ assert-false: ".sub-logo-container"
},
)
diff --git a/tests/rustdoc-gui/search-result-impl-disambiguation.goml b/tests/rustdoc-gui/search-result-impl-disambiguation.goml
new file mode 100644
index 000000000..6d12032e8
--- /dev/null
+++ b/tests/rustdoc-gui/search-result-impl-disambiguation.goml
@@ -0,0 +1,43 @@
+// ignore-tidy-linelength
+
+// Checks that, if a type has two methods with the same name, they both get
+// linked correctly.
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+
+// This should link to the inherent impl
+write: (".search-input", "ZyxwvutMethodDisambiguation -> bool")
+// To be SURE that the search will be run.
+press-key: 'Enter'
+// Waiting for the search results to appear...
+wait-for: "#search-tabs"
+// Check the disambiguated link.
+assert-count: ("a.result-method", 1)
+assert-attribute: ("a.result-method", {
+ "href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation"
+})
+click: "a.result-method"
+wait-for: "#impl-ZyxwvutMethodDisambiguation"
+assert-document-property: ({
+ "URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation"
+}, ENDS_WITH)
+assert: "section:target"
+
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+
+// This should link to the trait impl
+write: (".search-input", "ZyxwvutMethodDisambiguation, usize -> usize")
+// To be SURE that the search will be run.
+press-key: 'Enter'
+// Waiting for the search results to appear...
+wait-for: "#search-tabs"
+// Check the disambiguated link.
+assert-count: ("a.result-method", 1)
+assert-attribute: ("a.result-method", {
+ "href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutTrait-for-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation"
+})
+click: "a.result-method"
+wait-for: "#impl-ZyxwvutMethodDisambiguation"
+assert-document-property: ({
+ "URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"
+}, ENDS_WITH)
+assert: "section:target"
diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml
index 427201e1b..db1605ff2 100644
--- a/tests/rustdoc-gui/search-tab.goml
+++ b/tests/rustdoc-gui/search-tab.goml
@@ -79,8 +79,8 @@ call-function: ("check-colors", {
set-window-size: (851, 600)
// Check the size and count in tabs
-assert-text: ("#search-tabs > button:nth-child(1) > .count", " (23) ")
-assert-text: ("#search-tabs > button:nth-child(2) > .count", " (4)  ")
+assert-text: ("#search-tabs > button:nth-child(1) > .count", " (25) ")
+assert-text: ("#search-tabs > button:nth-child(2) > .count", " (5)  ")
assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|})
diff --git a/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml b/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml
index 6cd725043..b55a1cfd9 100644
--- a/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml
+++ b/tests/rustdoc-gui/setting-auto-hide-content-large-items.goml
@@ -1,7 +1,7 @@
// This test ensures that the "Auto-hide item contents for large items" setting is working as
// expected.
-// We need to disable this check because `implementors/test_docs/trait.Iterator.js` doesn't exist.
+// We need to disable this check because `trait.impl/test_docs/trait.Iterator.js` doesn't exist.
fail-on-request-error: false
define-function: (
diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml
index 4b8337ace..d3a82d9eb 100644
--- a/tests/rustdoc-gui/sidebar-mobile.goml
+++ b/tests/rustdoc-gui/sidebar-mobile.goml
@@ -26,7 +26,7 @@ assert-css: (".sidebar", {"left": "0px"})
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
// Make sure the global navigation is still here.
-assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"})
+assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In crate test_docs']/parent::h2", {"display": "block"})
// Click elsewhere.
click: "body"
@@ -50,7 +50,7 @@ assert-position: ("#method\.must_use", {"y": 46})
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
click: ".sidebar-menu-toggle"
scroll-to: ".block.keyword li:nth-child(1)"
-compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19})
+compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 544})
// Now checking the background color of the sidebar.
show-text: true
diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml
index 88546ed25..cea4db146 100644
--- a/tests/rustdoc-gui/sidebar-source-code-display.goml
+++ b/tests/rustdoc-gui/sidebar-source-code-display.goml
@@ -174,14 +174,14 @@ click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "-1000px"})
// We scroll to line 117 to change the scroll position.
scroll-to: '//*[@id="117"]'
-assert-window-property: {"pageYOffset": "2542"}
+assert-window-property: {"pageYOffset": "2516"}
// Expanding the sidebar...
click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "0px"})
click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "-1000px"})
// The "scrollTop" property should be the same.
-assert-window-property: {"pageYOffset": "2542"}
+assert-window-property: {"pageYOffset": "2516"}
// We now check that opening the sidebar and clicking a link will close it.
// The behavior here on mobile is different than the behavior on desktop,
diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml
index 520481d3b..eff66d803 100644
--- a/tests/rustdoc-gui/sidebar.goml
+++ b/tests/rustdoc-gui/sidebar.goml
@@ -50,9 +50,9 @@ set-local-storage: {"rustdoc-theme": "light"}
// We reload the page so the local storage settings are being used.
reload:
-assert-text: (".sidebar > .location", "Crate test_docs")
-// In modules, we only have one "location" element.
-assert-count: (".sidebar .location", 1)
+assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs")
+// Crate root has no "location" element
+assert-count: (".sidebar .location", 0)
assert-count: (".sidebar h2", 1)
assert-text: ("#all-types", "All Items")
assert-css: ("#all-types", {"color": "#356da4"})
@@ -74,8 +74,9 @@ assert-text: ("#structs + .item-table .item-name > a", "Foo")
click: "#structs + .item-table .item-name > a"
// PAGE: struct.Foo.html
+assert-count: (".sidebar .sidebar-crate", 1)
assert-count: (".sidebar .location", 1)
-assert-count: (".sidebar h2", 2)
+assert-count: (".sidebar h2", 3)
// We check that there is no crate listed outside of the top level.
assert-false: ".sidebar-elems > .crate"
@@ -94,7 +95,8 @@ click: ".sidebar-elems ul.crate > li:first-child > a"
// PAGE: lib2/index.html
go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
assert-property: (".sidebar", {"clientWidth": "200"})
-assert-text: (".sidebar > .location", "Crate lib2")
+assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
+assert-count: (".sidebar .location", 0)
// We check that we have the crates list and that the "current" on is now "lib2".
assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
// We now go to the "foobar" function page.
@@ -108,22 +110,39 @@ click: "#functions + .item-table .item-name > a"
// PAGE: fn.foobar.html
// In items containing no items (like functions or constants) and in modules, we have no
-// "location" elements. Only the parent module h2.
+// "location" elements. Only the crate and optional parent module.
+// This page, being directly below the crate, only has its heading.
+assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
assert-count: (".sidebar .location", 0)
assert-count: (".sidebar h2", 1)
-assert-text: (".sidebar .sidebar-elems h2", "In lib2")
// We check that we don't have the crate list.
assert-false: ".sidebar-elems > .crate"
go-to: "./module/index.html"
assert-property: (".sidebar", {"clientWidth": "200"})
+assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
assert-text: (".sidebar > .location", "Module module")
+assert-count: (".sidebar .location", 1)
+// Module page requires three headings:
+// - Presistent crate branding (name and version)
+// - Module name, followed by TOC for module headings
+// - "In crate [name]" parent pointer, followed by sibling navigation
+assert-count: (".sidebar h2", 3)
+assert-text: (".sidebar > .sidebar-elems > h2", "In crate lib2")
+assert-property: (".sidebar > .sidebar-elems > h2 > a", {
+ "href": "/lib2/index.html",
+}, ENDS_WITH)
// We check that we don't have the crate list.
assert-false: ".sidebar-elems > .crate"
go-to: "./sub_module/sub_sub_module/index.html"
assert-property: (".sidebar", {"clientWidth": "200"})
+assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2")
assert-text: (".sidebar > .location", "Module sub_sub_module")
+assert-text: (".sidebar > .sidebar-elems > h2", "In lib2::module::sub_module")
+assert-property: (".sidebar > .sidebar-elems > h2 > a", {
+ "href": "/module/sub_module/index.html",
+}, ENDS_WITH)
// We check that we don't have the crate list.
assert-false: ".sidebar-elems .crate"
assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
@@ -152,14 +171,14 @@ assert-property: (".sidebar", {"clientWidth": "200"})
// Checks that all.html and index.html have their sidebar link in the same place.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
-store-property: (".sidebar .location a", {
+store-property: (".sidebar .sidebar-crate h2 a", {
"clientWidth": index_sidebar_width,
"clientHeight": index_sidebar_height,
"offsetTop": index_sidebar_y,
"offsetLeft": index_sidebar_x,
})
go-to: "file://" + |DOC_PATH| + "/test_docs/all.html"
-assert-property: (".sidebar .location a", {
+assert-property: (".sidebar .sidebar-crate h2 a", {
"clientWidth": |index_sidebar_width|,
"clientHeight": |index_sidebar_height|,
"offsetTop": |index_sidebar_y|,
diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml
index 0e4913caf..940851ea1 100644
--- a/tests/rustdoc-gui/source-anchor-scroll.goml
+++ b/tests/rustdoc-gui/source-anchor-scroll.goml
@@ -8,13 +8,13 @@ set-window-size: (600, 800)
assert-property: ("html", {"scrollTop": "0"})
click: '//a[text() = "barbar" and @href="#5-7"]'
-assert-property: ("html", {"scrollTop": "149"})
+assert-property: ("html", {"scrollTop": "123"})
click: '//a[text() = "bar" and @href="#28-36"]'
-assert-property: ("html", {"scrollTop": "180"})
+assert-property: ("html", {"scrollTop": "154"})
click: '//a[text() = "sub_fn" and @href="#2-4"]'
-assert-property: ("html", {"scrollTop": "77"})
+assert-property: ("html", {"scrollTop": "51"})
// We now check that clicking on lines doesn't change the scroll
// Extra information: the "sub_fn" function header is on line 1.
click: '//*[@id="6"]'
-assert-property: ("html", {"scrollTop": "77"})
+assert-property: ("html", {"scrollTop": "51"})
diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml
index f19e3ce80..ad57380ae 100644
--- a/tests/rustdoc-gui/source-code-page.goml
+++ b/tests/rustdoc-gui/source-code-page.goml
@@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
// do anything (and certainly not add a `#NaN` to the URL!).
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// We use this assert-position to know where we will click.
-assert-position: ("//*[@id='1']", {"x": 88, "y": 112})
+assert-position: ("//*[@id='1']", {"x": 88, "y": 86})
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
-click: (87, 103)
+click: (87, 77)
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
// Checking the source code sidebar.
@@ -163,16 +163,16 @@ assert-css: ("nav.sub", {"flex-direction": "row"})
// To check this, we maintain the invariant:
//
// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
-assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34})
-assert-property: ("#main-content", {"offsetTop": 90})
-// 28 = 90 - 34 - 28
+assert-property: ("nav.sub form", {"offsetTop": 15, "offsetHeight": 34})
+assert-property: ("#main-content", {"offsetTop": 64})
+// 15 = 64 - 34 - 15
// Now do the same check on moderately-sized, tablet mobile.
set-window-size: (700, 700)
assert-css: ("nav.sub", {"flex-direction": "row"})
-assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34})
-assert-property: ("#main-content", {"offsetTop": 76})
-// 21 = 76 - 34 - 21
+assert-property: ("nav.sub form", {"offsetTop": 8, "offsetHeight": 34})
+assert-property: ("#main-content", {"offsetTop": 50})
+// 8 = 50 - 34 - 8
// Check the sidebar directory entries have a marker and spacing (tablet).
store-property: ("#src-sidebar > .title", {
@@ -198,7 +198,12 @@ call-function: ("check-sidebar-dir-entry", {
"y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
})
+// The logo is not present on this page.
+assert-false: ".sub-logo-container > img"
+
+// Check the staged-api page instead, which does.
// Now we check that the logo has a bottom margin so it's not stuck to the search input.
+go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"})
store-property: (".sub-logo-container", {"clientHeight": logo_height})
assert-position: (".search-form", {"y": |logo_height| + 8})
diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs
index 34e67d9d2..a2a3c3187 100644
--- a/tests/rustdoc-gui/src/lib2/lib.rs
+++ b/tests/rustdoc-gui/src/lib2/lib.rs
@@ -147,13 +147,13 @@ pub struct LongItemInfo2;
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
impl SimpleTrait for LongItemInfo2 {}
-pub struct WhereWhitespace<T>;
+pub struct WhereWhitespace<T>(T);
impl<T> WhereWhitespace<T> {
pub fn new<F>(f: F) -> Self
where
F: FnMut() -> i32,
- {}
+ {todo!()}
}
impl<K, T> Whitespace<&K> for WhereWhitespace<T>
@@ -187,6 +187,11 @@ impl ItemInfoAlignmentTest {
pub mod scroll_traits {
use std::iter::*;
+ struct Intersperse<T>(T);
+ struct IntersperseWith<T, U>(T, U);
+ struct Flatten<T>(T);
+ struct Peekable<T>(T);
+
/// Shamelessly (partially) copied from `std::iter::Iterator`.
/// It allows us to check that the scroll is working as expected on "hidden" items.
pub trait Iterator {
diff --git a/tests/rustdoc-gui/src/staged_api/lib.rs b/tests/rustdoc-gui/src/staged_api/lib.rs
index 0c914470e..9b5ad1c5f 100644
--- a/tests/rustdoc-gui/src/staged_api/lib.rs
+++ b/tests/rustdoc-gui/src/staged_api/lib.rs
@@ -1,6 +1,8 @@
#![feature(staged_api)]
+#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![stable(feature = "some_feature", since = "1.3.5")]
+#![doc(rust_logo)]
#[stable(feature = "some_feature", since = "1.3.5")]
pub struct Foo {}
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index 38180aef7..c7d115bdb 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -160,6 +160,33 @@ pub mod keyword {}
/// Just some type alias.
pub type SomeType = u32;
+/// Another type alias, this time with methods.
+pub type SomeOtherTypeWithMethodsAndInlining = Foo;
+
+impl SomeOtherTypeWithMethodsAndInlining {
+ pub fn some_other_method_directly(&self) {}
+}
+
+/// Another type alias, this time with methods.
+pub struct UnderlyingFooBarBaz;
+pub type SomeOtherTypeWithMethodsAndInliningAndTraits = UnderlyingFooBarBaz;
+
+impl AsRef<str> for UnderlyingFooBarBaz {
+ fn as_ref(&self) -> &str {
+ "hello"
+ }
+}
+
+impl UnderlyingFooBarBaz {
+ pub fn inherent_fn(&self) {}
+}
+
+impl AsRef<u8> for SomeOtherTypeWithMethodsAndInliningAndTraits {
+ fn as_ref(&self) -> &u8 {
+ b"hello"
+ }
+}
+
pub mod huge_amount_of_consts {
include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
}
@@ -529,3 +556,40 @@ pub mod cfgs {
/// Some docs.
pub mod cfgs {}
}
+
+pub struct ZyxwvutMethodDisambiguation;
+
+impl ZyxwvutMethodDisambiguation {
+ pub fn method_impl_disambiguation(&self) -> bool {
+ true
+ }
+}
+
+pub trait ZyxwvutTrait {
+ fn method_impl_disambiguation(&self, x: usize) -> usize;
+}
+
+impl ZyxwvutTrait for ZyxwvutMethodDisambiguation {
+ fn method_impl_disambiguation(&self, x: usize) -> usize {
+ x
+ }
+}
+
+pub mod foreign_impl_order {
+ pub trait Foo<const W: usize> {
+ fn f(&mut self, with: [u8; W]);
+ }
+
+ impl Foo<4> for [u8; 4] {
+ fn f(&mut self, fg: [u8; 4]) {}
+ }
+ impl Foo<2> for [u8; 2] {
+ fn f(&mut self, fg: [u8; 2]) {}
+ }
+ impl Foo<1> for [u8; 1] {
+ fn f(&mut self, fg: [u8; 1]) {}
+ }
+ impl Foo<3> for [u8; 3] {
+ fn f(&mut self, fg: [u8; 3]) {}
+ }
+}
diff --git a/tests/rustdoc-gui/trait-sidebar-item-order.goml b/tests/rustdoc-gui/trait-sidebar-item-order.goml
index 9330ef040..73e362ca8 100644
--- a/tests/rustdoc-gui/trait-sidebar-item-order.goml
+++ b/tests/rustdoc-gui/trait-sidebar-item-order.goml
@@ -1,6 +1,6 @@
// Checks that the elements in the sidebar are alphabetically sorted.
-// We need to disable this check because `implementors/test_docs/trait.AnotherOne.js`
+// We need to disable this check because `trait.impl/test_docs/trait.AnotherOne.js`
// doesn't exist.
fail-on-request-error: false
diff --git a/tests/rustdoc-gui/type-declation-overflow.goml b/tests/rustdoc-gui/type-declation-overflow.goml
index f212781e9..5780f5c88 100644
--- a/tests/rustdoc-gui/type-declation-overflow.goml
+++ b/tests/rustdoc-gui/type-declation-overflow.goml
@@ -2,7 +2,7 @@
// This test ensures that the items declaration content overflow is handled inside the <pre> directly.
// We need to disable this check because
-// `implementors/test_docs/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.js`
+// `trait.impl/test_docs/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.js`
// doesn't exist.
fail-on-request-error: false
diff --git a/tests/rustdoc-gui/type-impls.goml b/tests/rustdoc-gui/type-impls.goml
new file mode 100644
index 000000000..870a9cbe5
--- /dev/null
+++ b/tests/rustdoc-gui/type-impls.goml
@@ -0,0 +1,86 @@
+// The goal of this test is to check that the inlined type alias impls, generated with JS,
+// have the same display than the "local" ones.
+go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeOtherTypeWithMethodsAndInlining.html"
+
+// method directly on type alias
+wait-for: "//*[@id='method.some_other_method_directly']"
+
+// methods on foo
+assert: "//*[@id='method.as_ref']"
+assert: "//*[@id='method.must_use']"
+assert: "//*[@id='method.warning1']"
+assert: "//*[@id='method.warning2']"
+
+// sidebar items
+assert: "//*[@class='sidebar-elems']//li/a[@href='#method.must_use']"
+assert: "//*[@class='sidebar-elems']//li/a[@href='#method.some_other_method_directly']"
+assert: "//*[@class='sidebar-elems']//li/a[@href='#method.warning1']"
+assert: "//*[@class='sidebar-elems']//li/a[@href='#method.warning2']"
+assert: "//*[@class='sidebar-elems']//li/a[@href='#impl-AsRef%3Cstr%3E-for-Foo']"
+
+// sorting
+assert-text: (".block.method li:nth-child(1)", 'must_use')
+assert-text: (".block.method li:nth-child(2)", 'some_other_method_directly')
+assert-text: (".block.method li:nth-child(3)", 'warning1')
+assert-text: (".block.method li:nth-child(4)", 'warning2')
+
+// Now try trait implementation merging and duplicate renumbering
+go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeOtherTypeWithMethodsAndInliningAndTraits.html"
+
+// method directly on type alias
+assert: "//*[@id='method.as_ref']"
+assert-count: ("//*[@id='method.as_ref']", 1)
+// method on underlying type
+assert: "//*[@id='method.as_ref-1']"
+
+// sidebar items
+assert-count: (
+ "//*[@class='sidebar-elems']//h3/a[@href='#trait-implementations']",
+ 1
+)
+assert-text: ("//*[@class='sidebar-elems']//li/a[@href='#impl-AsRef%3Cstr%3E-for-UnderlyingFooBarBaz']", "AsRef<str>")
+assert-text: (
+ "//*[@class='sidebar-elems']//li/a[@href='#impl-AsRef%3Cu8%3E-for-UnderlyingFooBarBaz']",
+ "AsRef<u8>"
+)
+assert-count: ("#trait-implementations-list", 1)
+assert-count: ("#trait-implementations-list > details", 2)
+// Both links point at the underlying trait
+store-property: ("//*[@id='method.as_ref']//a[@class='fn']", {"href": href})
+assert-property: ("//*[@id='method.as_ref-1']//a[@class='fn']", {"href": |href|})
+// Both links have a self-anchor
+assert: "//*[@id='method.as_ref']//a[@class='anchor'][@href='#method.as_ref']"
+assert: "//*[@id='method.as_ref-1']//a[@class='anchor'][@href='#method.as_ref-1']"
+
+///////////////////////////////////////////////////////////////////////////
+// Now, if JavaScript is disabled, only the first method will be present //
+///////////////////////////////////////////////////////////////////////////
+javascript: false
+go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeOtherTypeWithMethodsAndInlining.html"
+
+// method directly on type alias
+wait-for: "//*[@id='method.some_other_method_directly']"
+
+// methods on foo
+assert-false: "//*[@id='method.must_use']"
+assert-false: "//*[@id='method.warning1']"
+assert-false: "//*[@id='method.warning2']"
+
+// Now try trait implementation merging and duplicate renumbering
+go-to: "file://" + |DOC_PATH| + "/test_docs/type.SomeOtherTypeWithMethodsAndInliningAndTraits.html"
+
+// methods directly on type alias
+assert: "//*[@id='method.as_ref']"
+assert-count: ("//*[@id='method.as_ref']", 1)
+// method on target type
+assert-false: "//*[@id='method.as_ref-1']"
+
+// sidebar items
+assert-count: (
+ "//*[@class='sidebar-elems']//h3/a[@href='#trait-implementations']",
+ 1
+)
+assert-false: "//a[@href='#impl-AsRef%3Cstr%3E-for-UnderlyingFooBarBaz']"
+assert: "//a[@href='#impl-AsRef%3Cu8%3E-for-UnderlyingFooBarBaz']"
+assert-count: ("#trait-implementations-list", 1)
+assert-count: ("#trait-implementations-list > details", 1)