Skip to content

Commit 2e4a36b

Browse files
Add GUI test to ensure that implementations on foreign types are in the expected order
1 parent aa9d1d8 commit 2e4a36b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This test ensures that the "implementations on foreign types" of a trait are correctly sorted.
2+
go-to: "file://" + |DOC_PATH| + "/test_docs/foreign_impl_order/trait.Foo.html"
3+
assert-text: ("details:nth-of-type(1) h3", "impl Foo<1> for [u8; 1]")
4+
assert-text: ("details:nth-of-type(2) h3", "impl Foo<2> for [u8; 2]")
5+
assert-text: ("details:nth-of-type(3) h3", "impl Foo<3> for [u8; 3]")
6+
assert-text: ("details:nth-of-type(4) h3", "impl Foo<4> for [u8; 4]")

tests/rustdoc-gui/search-tab.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ call-function: ("check-colors", {
7979
set-window-size: (851, 600)
8080

8181
// Check the size and count in tabs
82-
assert-text: ("#search-tabs > button:nth-child(1) > .count", " (24) ")
82+
assert-text: ("#search-tabs > button:nth-child(1) > .count", " (25) ")
8383
assert-text: ("#search-tabs > button:nth-child(2) > .count", " (5)  ")
8484
assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
8585
store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})

tests/rustdoc-gui/src/test_docs/lib.rs

+19
Original file line numberDiff line numberDiff line change
@@ -574,3 +574,22 @@ impl ZyxwvutTrait for ZyxwvutMethodDisambiguation {
574574
x
575575
}
576576
}
577+
578+
pub mod foreign_impl_order {
579+
pub trait Foo<const W: usize> {
580+
fn f(&mut self, with: [u8; W]);
581+
}
582+
583+
impl Foo<4> for [u8; 4] {
584+
fn f(&mut self, fg: [u8; 4]) {}
585+
}
586+
impl Foo<2> for [u8; 2] {
587+
fn f(&mut self, fg: [u8; 2]) {}
588+
}
589+
impl Foo<1> for [u8; 1] {
590+
fn f(&mut self, fg: [u8; 1]) {}
591+
}
592+
impl Foo<3> for [u8; 3] {
593+
fn f(&mut self, fg: [u8; 3]) {}
594+
}
595+
}

0 commit comments

Comments
 (0)