]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/recursive-deref.rs
Rollup merge of #106958 - jyn514:labels, r=m-ou-se
[rust.git] / tests / 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"]' '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"]' '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"]' '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"]' 'impl Deref for D'
53 // We also check that `G::g` method isn't rendered because there is no `self` argument.
54 // @!has '-' '//*[@id="deref-methods-G"]' ''
55 impl Deref for D {
56     type Target = E;
57
58     fn deref(&self) -> &Self::Target {
59         panic!()
60     }
61 }
62
63 // @has recursive_deref/struct.E.html '//h3[@class="code-header"]' 'impl Deref for E'
64 // We also check that `G::g` method isn't rendered because there is no `self` argument.
65 // @!has '-' '//*[@id="deref-methods-G"]' ''
66 impl Deref for E {
67     type Target = F;
68
69     fn deref(&self) -> &Self::Target {
70         panic!()
71     }
72 }
73
74 // @has recursive_deref/struct.F.html '//h3[@class="code-header"]' 'impl Deref for F'
75 // We also check that `G::g` method isn't rendered because there is no `self` argument.
76 // @!has '-' '//*[@id="deref-methods-G"]' ''
77 impl Deref for F {
78     type Target = G;
79
80     fn deref(&self) -> &Self::Target {
81         panic!()
82     }
83 }
84
85 // @has recursive_deref/struct.G.html '//h3[@class="code-header"]' 'impl Deref for G'
86 impl Deref for G {
87     type Target = E;
88
89     fn deref(&self) -> &Self::Target {
90         panic!()
91     }
92 }
93
94 // Cyclic deref with top parent.
95 pub struct H;
96 pub struct I;
97
98 impl I {
99     // There is no "self" parameter so it shouldn't be listed!
100     pub fn i() {}
101 }
102
103 // @has recursive_deref/struct.H.html '//h3[@class="code-header"]' 'impl Deref for H'
104 // @!has '-' '//*[@id="deref-methods-I"]' ''
105 impl Deref for H {
106     type Target = I;
107
108     fn deref(&self) -> &Self::Target {
109         panic!()
110     }
111 }
112
113 // @has recursive_deref/struct.I.html '//h3[@class="code-header"]' 'impl Deref for I'
114 impl Deref for I {
115     type Target = H;
116
117     fn deref(&self) -> &Self::Target {
118         panic!()
119     }
120 }