summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc/deref/recursive-deref.rs
blob: aa38485c44558b7658d0e0100fdaaa7105597222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use std::ops::Deref;

// Cyclic deref with the parent (which is not the top parent).
pub struct A;
pub struct B;
pub struct C;

impl C {
    pub fn c(&self) {}
}

// @has recursive_deref/struct.A.html '//h3[@class="code-header"]' 'impl Deref for A'
// @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)'
impl Deref for A {
    type Target = B;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.B.html '//h3[@class="code-header"]' 'impl Deref for B'
// @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)'
impl Deref for B {
    type Target = C;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.C.html '//h3[@class="code-header"]' 'impl Deref for C'
impl Deref for C {
    type Target = B;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// Cyclic deref with the grand-parent (which is not the top parent).
pub struct D;
pub struct E;
pub struct F;
pub struct G;

impl G {
    // There is no "self" parameter so it shouldn't be listed!
    pub fn g() {}
}

// @has recursive_deref/struct.D.html '//h3[@class="code-header"]' 'impl Deref for D'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for D {
    type Target = E;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.E.html '//h3[@class="code-header"]' 'impl Deref for E'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for E {
    type Target = F;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.F.html '//h3[@class="code-header"]' 'impl Deref for F'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for F {
    type Target = G;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.G.html '//h3[@class="code-header"]' 'impl Deref for G'
impl Deref for G {
    type Target = E;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// Cyclic deref with top parent.
pub struct H;
pub struct I;

impl I {
    // There is no "self" parameter so it shouldn't be listed!
    pub fn i() {}
}

// @has recursive_deref/struct.H.html '//h3[@class="code-header"]' 'impl Deref for H'
// @!has '-' '//*[@id="deref-methods-I"]' ''
impl Deref for H {
    type Target = I;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}

// @has recursive_deref/struct.I.html '//h3[@class="code-header"]' 'impl Deref for I'
impl Deref for I {
    type Target = H;

    fn deref(&self) -> &Self::Target {
        panic!()
    }
}