Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustdoc generate files for items not used in documentation #111249

Open
GuillaumeGomez opened this issue May 5, 2023 · 2 comments
Open

Rustdoc generate files for items not used in documentation #111249

GuillaumeGomez opened this issue May 5, 2023 · 2 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented May 5, 2023

As demonstrated in the following codes:

// @!has 'foo/hidden/index.html'

// The following two should not fail!
// @!has 'foo/hidden/inner/index.html'
// @!has 'foo/hidden/inner/trait.Foo.html'
#[doc(hidden)]
pub mod hidden {
    pub mod inner {
        pub trait Foo {
            /// Hello, world!
            fn test();
        }
    }
}

// @has 'foo/visible/index.html'
// @has 'foo/visible/trait.Foo.html'
#[doc(inline)]
pub use hidden::inner as visible;

// @has 'foo/struct.Bar.html'
// @count - '//*[@id="impl-Foo-for-Bar"]' 1
pub struct Bar;

impl visible::Foo for Bar {
    fn test() {}
}

And the other example:

// None of the following checks should fail.
// @!has 'foo/hidden/index.html'
// @!has 'foo/hidden/inner/index.html'
// @!has 'foo/hidden/inner/trait.Foo.html'
#[doc(hidden)]
pub mod hidden {
    pub mod inner {
        pub trait Foo {
            /// Hello, world!
            fn test();
        }
    }
}

// @has 'foo/trait.Foo.html'
#[doc(inline)]
pub use hidden::inner::Foo;

// @has 'foo/struct.Bar.html'
// @count - '//*[@id="impl-Foo-for-Bar"]' 1
pub struct Bar;

impl Foo for Bar {
    fn test() {}
}

Examples come from #111249.

@GuillaumeGomez GuillaumeGomez added C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 5, 2023
@GuillaumeGomez
Copy link
Member Author

Also, don't forget to update issue-111064-reexport-trait-from-hidden-2.rs.

@notriddle
Copy link
Contributor

notriddle commented May 11, 2023

All assertions in this test case pass:

#![crate_name="foo"]

// @!has "foo/struct.Foo.html"
#[doc(hidden)]
pub struct Foo;

// @has "foo/struct.Bar.html"
pub use crate::Foo as Bar;

// @!has "foo/struct.Baz.html"
#[doc(hidden)]
pub use crate::Foo as Baz;

This test case fails:

#![crate_name="foo"]

// This assertion fails. The file gets generated.
// @!has "foo/foo/index.html"
#[doc(hidden)]
pub mod foo {}

// This assertion passes.
// @has "foo/bar/index.html"
pub use crate::foo as bar;

// This assertion also fails. The file gets generated.
// @!has "foo/baz/index.html"
#[doc(hidden)]
pub use crate::foo as baz;

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 21, 2023
…e-creation, r=notriddle

[rustdoc] partially fix invalid files creation

Part of rust-lang#111249. It only removes generation for modules which shouldn't exist. For files, we need the compiler to keep re-export information alive for external items so we can actually have the right path to their location as it's currently not generating them correctly.

In case the item is inlined, it shouldn't (and neither should its children) get a file generated.

r? `@notriddle`
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 21, 2023
…e-creation, r=notriddle

[rustdoc] partially fix invalid files creation

Part of rust-lang#111249. It only removes generation for modules which shouldn't exist. For files, we need the compiler to keep re-export information alive for external items so we can actually have the right path to their location as it's currently not generating them correctly.

In case the item is inlined, it shouldn't (and neither should its children) get a file generated.

r? ``@notriddle``
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 21, 2023
…e-creation, r=notriddle

[rustdoc] partially fix invalid files creation

Part of rust-lang#111249. It only removes generation for modules which shouldn't exist. For files, we need the compiler to keep re-export information alive for external items so we can actually have the right path to their location as it's currently not generating them correctly.

In case the item is inlined, it shouldn't (and neither should its children) get a file generated.

r? ```@notriddle```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants