]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/traits-in-bodies.rs
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
[rust.git] / tests / rustdoc / traits-in-bodies.rs
1 //prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it
2 //didn't see that `SomeStruct` implemented `Clone`
3
4 pub struct Bounded<T: Clone>(T);
5
6 // @has traits_in_bodies/struct.SomeStruct.html
7 // @has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct'
8 pub struct SomeStruct;
9
10 fn asdf() -> Bounded<SomeStruct> {
11     impl Clone for SomeStruct {
12         fn clone(&self) -> SomeStruct {
13             SomeStruct
14         }
15     }
16
17     Bounded(SomeStruct)
18 }
19
20 // @has traits_in_bodies/struct.Point.html
21 // @has - '//h3[@class="code-header"]' 'impl Copy for Point'
22 #[derive(Clone)]
23 pub struct Point {
24     x: i32,
25     y: i32,
26 }
27
28 const _FOO: () = {
29     impl Copy for Point {}
30     ()
31 };
32
33 // @has traits_in_bodies/struct.Inception.html
34 // @has - '//h3[@class="code-header"]' 'impl Clone for Inception'
35 pub struct Inception;
36
37 static _BAR: usize = {
38     trait HiddenTrait {
39         fn hidden_fn(&self) {
40             for _ in 0..5 {
41                 impl Clone for Inception {
42                     fn clone(&self) -> Self {
43                         // we need to go deeper
44                         Inception
45                     }
46                 }
47             }
48         }
49     }
50
51     5
52 };