|
| 1 | +// Regression test for <https://github.com/rust-lang/rust/issues/110422>. |
| 2 | +// This test ensures that inner items (except for implementations and macros) |
| 3 | +// don't appear in documentation. |
| 4 | + |
| 5 | +// compile-flags: --document-private-items |
| 6 | + |
| 7 | +#![crate_name = "foo"] |
| 8 | + |
| 9 | +// @has 'foo/index.html' |
| 10 | +// Checking there is no "trait" entry. |
| 11 | +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 4 |
| 12 | +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' |
| 13 | +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' |
| 14 | +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Functions' |
| 15 | +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Macros' |
| 16 | + |
| 17 | +// @has - '//a[@href="fn.foo.html"]' 'foo' |
| 18 | +fn foo() { |
| 19 | + fn bar() {} |
| 20 | + |
| 21 | + // @has - '//a[@class="macro"]' 'visible_macro' |
| 22 | + // @!has - '//a[@class="macro"]' 'non_visible_macro' |
| 23 | + // @has 'foo/macro.visible_macro.html' |
| 24 | + // @!has 'foo/macro.non_visible_macro.html' |
| 25 | + #[macro_export] |
| 26 | + macro_rules! visible_macro { |
| 27 | + () => {} |
| 28 | + } |
| 29 | + |
| 30 | + macro_rules! non_visible_macro { |
| 31 | + () => {} |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +// @has 'foo/index.html' |
| 36 | +// @has - '//a[@href="struct.Bar.html"]' 'Bar' |
| 37 | +struct Bar; |
| 38 | + |
| 39 | +const BAR: i32 = { |
| 40 | + // @!has - '//a[@href="fn.yo.html"]' 'yo' |
| 41 | + // @!has 'foo/fn.yo.html' |
| 42 | + fn yo() {} |
| 43 | + |
| 44 | + // @!has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' |
| 45 | + // @!has 'foo/trait.Foo.html' |
| 46 | + trait Foo { |
| 47 | + fn babar() {} |
| 48 | + } |
| 49 | + impl Foo for Bar {} |
| 50 | + |
| 51 | + // @has 'foo/struct.Bar.html' |
| 52 | + // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' |
| 53 | + // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 |
| 54 | + // We now check that the `Foo` trait is not documented nor visible on `Bar` page. |
| 55 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Implementations' |
| 56 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Auto Trait Implementations' |
| 57 | + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Blanket Implementations' |
| 58 | + // @!has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' |
| 59 | + impl Bar { |
| 60 | + fn foo() {} |
| 61 | + } |
| 62 | + |
| 63 | + 1 |
| 64 | +}; |
0 commit comments