]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/issue-55364.rs
Rollup merge of #107580 - lenko-d:default_value_for_a_lifetime_generic_parameter_prod...
[rust.git] / tests / rustdoc / issue-55364.rs
1 // First a module with inner documentation
2
3 // @has issue_55364/subone/index.html
4 // These foo/bar links in the module's documentation should refer inside `subone`
5 // @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo'
6 // @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar'
7 pub mod subone {
8     //! See either [foo] or [bar].
9
10     // This should refer to subone's `bar`
11     // @has issue_55364/subone/fn.foo.html
12     // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar'
13     /// See [bar]
14     pub fn foo() {}
15     // This should refer to subone's `foo`
16     // @has issue_55364/subone/fn.bar.html
17     // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo'
18     /// See [foo]
19     pub fn bar() {}
20 }
21
22 // A module with outer documentation
23
24 // @has issue_55364/subtwo/index.html
25 // These foo/bar links in the module's documentation should not reference inside `subtwo`
26 // @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo'
27 // @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar'
28 // Instead it should be referencing the top level functions
29 // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo'
30 // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar'
31 // Though there should be such links later
32 // @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left"]/a[@class="fn"][@href="fn.foo.html"]' 'foo'
33 // @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left"]/a[@class="fn"][@href="fn.bar.html"]' 'bar'
34 /// See either [foo] or [bar].
35 pub mod subtwo {
36
37     // Despite the module's docs referring to the top level foo/bar,
38     // this should refer to subtwo's `bar`
39     // @has issue_55364/subtwo/fn.foo.html
40     // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar'
41     /// See [bar]
42     pub fn foo() {}
43     // Despite the module's docs referring to the top level foo/bar,
44     // this should refer to subtwo's `foo`
45     // @has issue_55364/subtwo/fn.bar.html
46     // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo'
47     /// See [foo]
48     pub fn bar() {}
49 }
50
51 // These are the function referred to by the module above with outer docs
52
53 /// See [bar]
54 pub fn foo() {}
55 /// See [foo]
56 pub fn bar() {}
57
58 // This module refers to the outer foo/bar by means of `super::`
59
60 // @has issue_55364/subthree/index.html
61 // This module should also refer to the top level foo/bar
62 // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo'
63 // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar'
64 pub mod subthree {
65     //! See either [foo][super::foo] or [bar][super::bar]
66 }
67
68 // Next we go *deeper* - In order to ensure it's not just "this or parent"
69 // we test `crate::` and a `super::super::...` chain
70 // @has issue_55364/subfour/subfive/subsix/subseven/subeight/index.html
71 // @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-right docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo'
72 // @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-right docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar'
73 pub mod subfour {
74     pub mod subfive {
75         pub mod subsix {
76             pub mod subseven {
77                 pub mod subeight {
78                     /// See [other foo][crate::subone::foo]
79                     pub fn foo() {}
80                     /// See [other bar][super::super::super::super::super::subtwo::bar]
81                     pub fn bar() {}
82                 }
83             }
84         }
85     }
86 }