]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/deref-recursive.rs
Rollup merge of #82484 - bugadani:docfix, r=jyn514
[rust.git] / src / test / rustdoc / deref-recursive.rs
1 // ignore-tidy-linelength
2
3 // #26207: Show all methods reachable via Deref impls, recursing through multiple dereferencing
4 // levels if needed.
5
6 // @has 'foo/struct.Foo.html'
7 // @has '-' '//*[@id="deref-methods-Bar"]' 'Methods from Deref<Target = Bar>'
8 // @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)'
9 // @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>'
10 // @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)'
11 // @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>'
12 // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.bar"]' 'bar'
13 // @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>'
14 // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.baz"]' 'baz'
15
16 #![crate_name = "foo"]
17
18 use std::ops::Deref;
19
20 pub struct Foo(Bar);
21 pub struct Bar(Baz);
22 pub struct Baz;
23
24 impl Deref for Foo {
25     type Target = Bar;
26     fn deref(&self) -> &Bar { &self.0 }
27 }
28
29 impl Deref for Bar {
30     type Target = Baz;
31     fn deref(&self) -> &Baz { &self.0 }
32 }
33
34 impl Bar {
35     /// This appears under `Foo` methods
36     pub fn bar(&self) {}
37 }
38
39 impl Baz {
40     /// This should also appear in `Foo` methods when recursing
41     pub fn baz(&self) {}
42 }