Skip to content

Commit b9e60a2

Browse files
committed
add testcase for traitParent deduplication
1 parent d903ede commit b9e60a2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/rustdoc-js/trait-methods.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,24 @@ const EXPECTED = [
99
{ 'path': 'trait_methods::MyTrait', 'name': 'next' },
1010
],
1111
},
12+
// the traitParent deduplication pass should remove
13+
// Empty::next, as it would be redundant
14+
{
15+
'query': 'next',
16+
'correction': null,
17+
'in_args': [],
18+
'others': [
19+
{ 'path': 'trait_methods::MyTrait', 'name': 'next' },
20+
],
21+
},
22+
// if the trait does not match, no deduplication happens
23+
{
24+
'query': '-> option<()>',
25+
'correction': null,
26+
'in_args': [],
27+
'others': [
28+
{ 'path': 'trait_methods::Empty', 'name': 'next' },
29+
{ 'path': 'trait_methods::Void', 'name': 'next' },
30+
],
31+
},
1232
];

tests/rustdoc-js/trait-methods.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,21 @@ pub trait MyTrait {
22
type Item;
33
fn next(&mut self) -> Option<Self::Item>;
44
}
5+
6+
pub struct Empty;
7+
8+
impl MyTrait for Empty {
9+
type Item = ();
10+
fn next(&mut self) -> Option<()> {
11+
None
12+
}
13+
}
14+
15+
pub struct Void;
16+
17+
impl MyTrait for Void {
18+
type Item = ();
19+
fn next(&mut self) -> Option<()> {
20+
Some(())
21+
}
22+
}

0 commit comments

Comments
 (0)