]>
Commit | Line | Data |
---|---|---|
fe692bf9 FG |
1 | // Test to enforce rules over re-exports inlining from |
2 | // <https://github.com/rust-lang/rust/issues/109449>. | |
3 | ||
4 | #![crate_name = "foo"] | |
5 | ||
6 | mod private_module { | |
7 | #[doc(hidden)] | |
8 | pub struct Public; | |
9 | #[doc(hidden)] | |
10 | pub type Bar = (); | |
11 | } | |
12 | ||
13 | #[doc(hidden)] | |
14 | mod module { | |
15 | pub struct Public2; | |
16 | pub type Bar2 = (); | |
17 | } | |
18 | ||
19 | #[doc(hidden)] | |
20 | pub type Bar3 = (); | |
21 | #[doc(hidden)] | |
22 | pub struct FooFoo; | |
23 | ||
24 | // Checking that re-exporting a `#[doc(hidden)]` item will NOT inline it. | |
25 | pub mod single_reexport { | |
26 | // @has 'foo/single_reexport/index.html' | |
27 | ||
28 | // First we check that we have 4 type aliases. | |
29 | // @count - '//*[@id="main-content"]/*[@class="item-table"]//code' 4 | |
30 | ||
31 | // Then we check that we have the correct link for each re-export. | |
32 | ||
33 | // @!has - '//*[@href="struct.Foo.html"]' 'Foo' | |
34 | // @has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' | |
35 | pub use crate::private_module::Public as Foo; | |
36 | // @!has - '//*[@href="type.Foo2.html"]' 'Foo2' | |
37 | // @has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' | |
38 | pub use crate::private_module::Bar as Foo2; | |
39 | // @!has - '//*[@href="type.Yo.html"]' 'Yo' | |
40 | // @has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' | |
41 | pub use crate::Bar3 as Yo; | |
42 | // @!has - '//*[@href="struct.Yo2.html"]' 'Yo2' | |
43 | // @has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' | |
44 | pub use crate::FooFoo as Yo2; | |
45 | ||
46 | // Checking that each file is also created as expected. | |
47 | // @!has 'foo/single_reexport/struct.Foo.html' | |
48 | // @!has 'foo/single_reexport/type.Foo2.html' | |
49 | // @!has 'foo/single_reexport/type.Yo.html' | |
50 | // @!has 'foo/single_reexport/struct.Yo2.html' | |
51 | } | |
52 | ||
53 | // However, re-exporting an item inheriting `#[doc(hidden)]` will inline it. | |
54 | pub mod single_reexport_inherit_hidden { | |
55 | // @has 'foo/single_reexport_inherit_hidden/index.html' | |
56 | ||
57 | // @has - '//*[@href="struct.Foo3.html"]' 'Foo3' | |
58 | pub use crate::module::Public2 as Foo3; | |
59 | // @has - '//*[@href="type.Foo4.html"]' 'Foo4' | |
60 | pub use crate::module::Bar2 as Foo4; | |
61 | ||
62 | // @has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' | |
63 | // @has 'foo/single_reexport_inherit_hidden/type.Foo4.html' | |
64 | } | |
65 | ||
66 | pub mod single_reexport_no_inline { | |
67 | // First we ensure that we only have re-exports and no inlined items. | |
68 | // @has 'foo/single_reexport_no_inline/index.html' | |
69 | // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 | |
70 | // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' | |
71 | ||
72 | // Now we check that we don't have links to the items, just `pub use`. | |
73 | // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' | |
74 | // @!has - '//*[@id="main-content"]//a' 'XFoo' | |
75 | #[doc(no_inline)] | |
76 | pub use crate::private_module::Public as XFoo; | |
77 | // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' | |
78 | // @!has - '//*[@id="main-content"]//a' 'Foo2' | |
79 | #[doc(no_inline)] | |
80 | pub use crate::private_module::Bar as Foo2; | |
81 | // @has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' | |
82 | // @!has - '//*[@id="main-content"]//a' 'Yo' | |
83 | #[doc(no_inline)] | |
84 | pub use crate::Bar3 as Yo; | |
85 | // @has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' | |
86 | // @!has - '//*[@id="main-content"]//a' 'Yo2' | |
87 | #[doc(no_inline)] | |
88 | pub use crate::FooFoo as Yo2; | |
89 | // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' | |
90 | // @!has - '//*[@id="main-content"]//a' 'Foo3' | |
91 | #[doc(no_inline)] | |
92 | pub use crate::module::Public2 as Foo3; | |
93 | // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' | |
94 | // @!has - '//*[@id="main-content"]//a' 'Foo4' | |
95 | #[doc(no_inline)] | |
96 | pub use crate::module::Bar2 as Foo4; | |
97 | } | |
98 | ||
99 | // Checking that glob re-exports don't inline `#[doc(hidden)]` items. | |
100 | pub mod glob_reexport { | |
101 | // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items | |
102 | // should be inlined. | |
103 | // @has 'foo/glob_reexport/index.html' | |
104 | // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 | |
105 | // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' | |
106 | // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' | |
781aab86 | 107 | // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' |
fe692bf9 FG |
108 | |
109 | // Now we check we have 1 re-export and 2 inlined items. | |
110 | // If not item from a glob re-export is visible, we don't show the re-export. | |
111 | // @!has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' | |
112 | pub use crate::private_module::*; | |
113 | // @has - '//*[@id="main-content"]//*' 'pub use crate::*;' | |
114 | pub use crate::*; | |
115 | // This one should be inlined. | |
116 | // @!has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' | |
117 | // @has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' | |
118 | // @has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' | |
119 | // And we check that the two files were created too. | |
120 | // @has 'foo/glob_reexport/struct.Public2.html' | |
121 | // @has 'foo/glob_reexport/type.Bar2.html' | |
122 | pub use crate::module::*; | |
123 | } | |
124 | ||
125 | mod private { | |
126 | /// Original. | |
127 | pub struct Bar3; | |
128 | } | |
129 | ||
130 | // Checking that `#[doc(hidden)]` re-exports documentation isn't generated. | |
131 | pub mod doc_hidden_reexport { | |
132 | // @has 'foo/doc_hidden_reexport/index.html' | |
133 | // Ensure there is only one item in this page and that it's a struct. | |
134 | // @count - '//*[@class="item-name"]' 1 | |
135 | // @has - '//a[@class="struct"]' 'Reexport' | |
136 | // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. | |
137 | // @has - '//*[@class="desc docblock-short"]' 'Visible. Original.' | |
781aab86 FG |
138 | /// Visible. |
139 | pub use self::Bar3 as Reexport; | |
fe692bf9 FG |
140 | /// Hidden. |
141 | #[doc(hidden)] | |
142 | pub use crate::private::Bar3; | |
fe692bf9 | 143 | } |