]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/recursive-deref.rs
Don't display "Methods from Deref<...>" if no method is display (the ones which don...
[rust.git] / src / test / rustdoc / recursive-deref.rs
1 use std::ops::Deref;
2
3 // Cyclic deref with the parent (which is not the top parent).
4 pub struct A;
5 pub struct B;
6 pub struct C;
7
8 impl C {
9     pub fn c(&self) {}
10 }
11
12 // @has recursive_deref/struct.A.html '//h3[@class="code-header in-band"]' 'impl Deref for A'
13 // @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)'
14 impl Deref for A {
15     type Target = B;
16
17     fn deref(&self) -> &Self::Target {
18         panic!()
19     }
20 }
21
22 // @has recursive_deref/struct.B.html '//h3[@class="code-header in-band"]' 'impl Deref for B'
23 // @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)'
24 impl Deref for B {
25     type Target = C;
26
27     fn deref(&self) -> &Self::Target {
28         panic!()
29     }
30 }
31
32 // @has recursive_deref/struct.C.html '//h3[@class="code-header in-band"]' 'impl Deref for C'
33 impl Deref for C {
34     type Target = B;
35
36     fn deref(&self) -> &Self::Target {
37         panic!()
38     }
39 }
40
41 // Cyclic deref with the grand-parent (which is not the top parent).
42 pub struct D;
43 pub struct E;
44 pub struct F;
45 pub struct G;
46
47 impl G {
48     // There is no "self" parameter so it shouldn't be listed!
49     pub fn g() {}
50 }
51
52 // @has recursive_deref/struct.D.html '//h3[@class="code-header in-band"]' 'impl Deref for D'
53 // @!has '-' '//*[@id="deref-methods-G"]'
54 impl Deref for D {
55     type Target = E;
56
57     fn deref(&self) -> &Self::Target {
58         panic!()
59     }
60 }
61
62 // @has recursive_deref/struct.E.html '//h3[@class="code-header in-band"]' 'impl Deref for E'
63 // @!has '-' '//*[@id="deref-methods-G"]'
64 impl Deref for E {
65     type Target = F;
66
67     fn deref(&self) -> &Self::Target {
68         panic!()
69     }
70 }
71
72 // @has recursive_deref/struct.F.html '//h3[@class="code-header in-band"]' 'impl Deref for F'
73 // @!has '-' '//*[@id="deref-methods-G"]'
74 impl Deref for F {
75     type Target = G;
76
77     fn deref(&self) -> &Self::Target {
78         panic!()
79     }
80 }
81
82 // @has recursive_deref/struct.G.html '//h3[@class="code-header in-band"]' 'impl Deref for G'
83 impl Deref for G {
84     type Target = E;
85
86     fn deref(&self) -> &Self::Target {
87         panic!()
88     }
89 }
90
91 // Cyclic deref with top parent.
92 pub struct H;
93 pub struct I;
94
95 impl I {
96     // There is no "self" parameter so it shouldn't be listed!
97     pub fn i() {}
98 }
99
100 // @has recursive_deref/struct.H.html '//h3[@class="code-header in-band"]' 'impl Deref for H'
101 // @!has '-' '//*[@id="deref-methods-I"]'
102 impl Deref for H {
103     type Target = I;
104
105     fn deref(&self) -> &Self::Target {
106         panic!()
107     }
108 }
109
110 // @has recursive_deref/struct.I.html '//h3[@class="code-header in-band"]' 'impl Deref for I'
111 impl Deref for I {
112     type Target = H;
113
114     fn deref(&self) -> &Self::Target {
115         panic!()
116     }
117 }