-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #110450 - GuillaumeGomez:fix-nested-items-on-private-…
…doc, r=notriddle,jyn514 rustdoc: Fix invalid handling of nested items with `--document-private-items` Fixes #110422. The problem is that only impl block and re-exported `macro_rules!` items are "visible" as nested items. This PR adds the missing checks to handle this correctly. cc `@compiler-errors` r? `@notriddle`
- Loading branch information
Showing
4 changed files
with
106 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// check-pass | ||
|
||
fn f() -> impl Sized { | ||
enum E { //~ ERROR | ||
enum E { | ||
V(E), | ||
} | ||
|
||
unimplemented!() | ||
} |
16 changes: 0 additions & 16 deletions
16
tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/110422>. | ||
// This test ensures that inner items (except for implementations and macros) | ||
// don't appear in documentation. | ||
|
||
// compile-flags: --document-private-items | ||
|
||
#![crate_name = "foo"] | ||
|
||
// @has 'foo/index.html' | ||
// Checking there is no "trait" entry. | ||
// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 4 | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Functions' | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Macros' | ||
|
||
// @has - '//a[@href="fn.foo.html"]' 'foo' | ||
fn foo() { | ||
fn bar() {} | ||
|
||
// @has - '//a[@class="macro"]' 'visible_macro' | ||
// @!has - '//a[@class="macro"]' 'non_visible_macro' | ||
// @has 'foo/macro.visible_macro.html' | ||
// @!has 'foo/macro.non_visible_macro.html' | ||
#[macro_export] | ||
macro_rules! visible_macro { | ||
() => {} | ||
} | ||
|
||
macro_rules! non_visible_macro { | ||
() => {} | ||
} | ||
} | ||
|
||
// @has 'foo/index.html' | ||
// @has - '//a[@href="struct.Bar.html"]' 'Bar' | ||
struct Bar; | ||
|
||
const BAR: i32 = { | ||
// @!has - '//a[@href="fn.yo.html"]' 'yo' | ||
// @!has 'foo/fn.yo.html' | ||
fn yo() {} | ||
|
||
// @!has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' | ||
// @!has 'foo/trait.Foo.html' | ||
trait Foo { | ||
fn babar() {} | ||
} | ||
impl Foo for Bar {} | ||
|
||
// @has 'foo/struct.Bar.html' | ||
// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' | ||
// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 | ||
// We now check that the `Foo` trait is not documented nor visible on `Bar` page. | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Implementations' | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Auto Trait Implementations' | ||
// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Blanket Implementations' | ||
// @!has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' | ||
impl Bar { | ||
fn foo() {} | ||
} | ||
|
||
1 | ||
}; |