summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc/traits-in-bodies.rs
blob: 6d450a625d0bfa9a47e32f24482ceed7e12470f9 (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
//prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it
//didn't see that `SomeStruct` implemented `Clone`

pub struct Bounded<T: Clone>(T);

// @has traits_in_bodies/struct.SomeStruct.html
// @has - '//h3[@class="code-header in-band"]' 'impl Clone for SomeStruct'
pub struct SomeStruct;

fn asdf() -> Bounded<SomeStruct> {
    impl Clone for SomeStruct {
        fn clone(&self) -> SomeStruct {
            SomeStruct
        }
    }

    Bounded(SomeStruct)
}

// @has traits_in_bodies/struct.Point.html
// @has - '//h3[@class="code-header in-band"]' 'impl Copy for Point'
#[derive(Clone)]
pub struct Point {
    x: i32,
    y: i32,
}

const _FOO: () = {
    impl Copy for Point {}
    ()
};

// @has traits_in_bodies/struct.Inception.html
// @has - '//h3[@class="code-header in-band"]' 'impl Clone for Inception'
pub struct Inception;

static _BAR: usize = {
    trait HiddenTrait {
        fn hidden_fn(&self) {
            for _ in 0..5 {
                impl Clone for Inception {
                    fn clone(&self) -> Self {
                        // we need to go deeper
                        Inception
                    }
                }
            }
        }
    }

    5
};