Skip to content

Commit 9524645

Browse files
Add rustdoc test to check duplicated bounds with parents
1 parent 37f3525 commit 9524645

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This test ensures that if a child item's bounds are duplicated with the parent, they are not
2+
// generated in the documentation.
3+
4+
#![crate_name = "foo"]
5+
6+
pub trait Bar {}
7+
pub trait Bar2 {}
8+
pub trait Bar3 {}
9+
pub trait Bar4 {}
10+
11+
// @has 'foo/trait.Foo.html'
12+
pub trait Foo<'a, T: Bar + 'a> where T: Bar2 {
13+
// @has - '//*[@id="method.foo"]/h4' 'fn foo()'
14+
// `Bar` shouldn't appear in the bounds.
15+
// @!has - '//*[@id="method.foo"]/h4' 'Bar'
16+
fn foo() where T: Bar {}
17+
// @has - '//*[@id="method.foo2"]/h4' 'fn foo2()'
18+
// `Bar2` shouldn't appear in the bounds.
19+
// @!has - '//*[@id="method.foo2"]/h4' 'Bar2'
20+
fn foo2() where T: Bar2 {}
21+
// @has - '//*[@id="method.foo3"]/h4' "fn foo3<'b>()where T: Bar3, 'a: 'b,"
22+
fn foo3<'b>() where T: Bar3, 'a: 'b {}
23+
// @has - '//*[@id="method.foo4"]/h4' "fn foo4()where T: Bar3,"
24+
fn foo4() where T: Bar2 + Bar3 {}
25+
}
26+
27+
pub struct X;
28+
29+
// @has 'foo/struct.X.html'
30+
impl<'a, T: Bar> X where T: Bar2 {
31+
// @has - '//*[@id="method.foo"]/h4' 'fn foo()'
32+
// @!has - '//*[@id="method.foo"]/h4' 'Bar'
33+
// `Bar` shouldn't appear in the bounds.
34+
pub fn foo() where T: Bar {}
35+
// @has - '//*[@id="method.foo2"]/h4' 'fn foo2()'
36+
// `Bar2` shouldn't appear in the bounds.
37+
// @!has - '//*[@id="method.foo2"]/h4' 'Bar2'
38+
pub fn foo2() where T: Bar2 {}
39+
// @has - '//*[@id="method.foo3"]/h4' "fn foo3<'b>()where T: Bar3, 'a: 'b,"
40+
pub fn foo3<'b>() where 'a: 'b, T: Bar3 {}
41+
// @has - '//*[@id="method.foo4"]/h4' "fn foo4()where T: Bar3,"
42+
pub fn foo4() where T: Bar2 + Bar3 {}
43+
}

0 commit comments

Comments
 (0)