|
| 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 inline it. |
| 25 | +pub mod single_reexport { |
| 26 | + // @has 'foo/single_reexport/index.html' |
| 27 | + |
| 28 | + // First we check that we have all 6 items: 3 structs and 3 type aliases. |
| 29 | + // @count - '//a[@class="struct"]' 3 |
| 30 | + // @count - '//a[@class="type"]' 3 |
| 31 | + |
| 32 | + // Then we check that we have the correct link for each re-export. |
| 33 | + |
| 34 | + // @has - '//*[@href="struct.Foo.html"]' 'Foo' |
| 35 | + pub use crate::private_module::Public as Foo; |
| 36 | + // @has - '//*[@href="type.Foo2.html"]' 'Foo2' |
| 37 | + pub use crate::private_module::Bar as Foo2; |
| 38 | + // @has - '//*[@href="type.Yo.html"]' 'Yo' |
| 39 | + pub use crate::Bar3 as Yo; |
| 40 | + // @has - '//*[@href="struct.Yo2.html"]' 'Yo2' |
| 41 | + pub use crate::FooFoo as Yo2; |
| 42 | + // @has - '//*[@href="struct.Foo3.html"]' 'Foo3' |
| 43 | + pub use crate::module::Public2 as Foo3; |
| 44 | + // @has - '//*[@href="type.Foo4.html"]' 'Foo4' |
| 45 | + pub use crate::module::Bar2 as Foo4; |
| 46 | + |
| 47 | + // Checking that each file is also created as expected. |
| 48 | + // @has 'foo/single_reexport/struct.Foo.html' |
| 49 | + // @has 'foo/single_reexport/type.Foo2.html' |
| 50 | + // @has 'foo/single_reexport/type.Yo.html' |
| 51 | + // @has 'foo/single_reexport/struct.Yo2.html' |
| 52 | + // @has 'foo/single_reexport/struct.Foo3.html' |
| 53 | + // @has 'foo/single_reexport/type.Foo4.html' |
| 54 | +} |
| 55 | + |
| 56 | +// Checking that re-exporting a `#[doc(hidden)]` item with `#[doc(no_inline)]` will not inline |
| 57 | +// it but will still display a re-export in the documentation. |
| 58 | +pub mod single_reexport_no_inline { |
| 59 | + // First we ensure that we only have re-exports and no inlined items. |
| 60 | + // @has 'foo/single_reexport_no_inline/index.html' |
| 61 | + // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 |
| 62 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' |
| 63 | + |
| 64 | + // Now we check that we don't have links to the items, just `pub use`. |
| 65 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' |
| 66 | + // @!has - '//*[@id="main-content"]//a' 'XFoo' |
| 67 | + #[doc(no_inline)] |
| 68 | + pub use crate::private_module::Public as XFoo; |
| 69 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' |
| 70 | + // @!has - '//*[@id="main-content"]//a' 'Foo2' |
| 71 | + #[doc(no_inline)] |
| 72 | + pub use crate::private_module::Bar as Foo2; |
| 73 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' |
| 74 | + // @!has - '//*[@id="main-content"]//a' 'Yo' |
| 75 | + #[doc(no_inline)] |
| 76 | + pub use crate::Bar3 as Yo; |
| 77 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' |
| 78 | + // @!has - '//*[@id="main-content"]//a' 'Yo2' |
| 79 | + #[doc(no_inline)] |
| 80 | + pub use crate::FooFoo as Yo2; |
| 81 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' |
| 82 | + // @!has - '//*[@id="main-content"]//a' 'Foo3' |
| 83 | + #[doc(no_inline)] |
| 84 | + pub use crate::module::Public2 as Foo3; |
| 85 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' |
| 86 | + // @!has - '//*[@id="main-content"]//a' 'Foo4' |
| 87 | + #[doc(no_inline)] |
| 88 | + pub use crate::module::Bar2 as Foo4; |
| 89 | +} |
| 90 | + |
| 91 | +// Checking that glob re-exports don't inline `#[doc(hidden)]` items. |
| 92 | +pub mod glob_reexport { |
| 93 | + // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items |
| 94 | + // should be inlined. |
| 95 | + // @has 'foo/glob_reexport/index.html' |
| 96 | + // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 |
| 97 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' |
| 98 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' |
| 99 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' |
| 100 | + |
| 101 | + // Now we check we have 2 re-exports and 2 inlined items. |
| 102 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' |
| 103 | + pub use crate::private_module::*; |
| 104 | + // @has - '//*[@id="main-content"]//*' 'pub use crate::*;' |
| 105 | + pub use crate::*; |
| 106 | + // This one should be inlined. |
| 107 | + // @!has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' |
| 108 | + // @has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' |
| 109 | + // @has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' |
| 110 | + // And we check that the two files were created too. |
| 111 | + // @has 'foo/glob_reexport/struct.Public2.html' |
| 112 | + // @has 'foo/glob_reexport/type.Bar2.html' |
| 113 | + pub use crate::module::*; |
| 114 | +} |
0 commit comments