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 inlining trait when it should not be. #46506

Closed
sgrif opened this issue Dec 4, 2017 · 1 comment · Fixed by #110611
Closed

Rustdoc inlining trait when it should not be. #46506

sgrif opened this issue Dec 4, 2017 · 1 comment · Fixed by #110611
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

@sgrif
Copy link
Contributor

sgrif commented Dec 4, 2017

I originally noticed this when chasing down dead links on Diesel's docs. Currently https://docs.rs/diesel/1.0.0-beta1/diesel/prelude/trait.GroupedBy.html looks for a JavaScript file that doesn't exist. The reason for that is because this trait is being rendered in the wrong module. The module structure that led to this is:

pub mod associations {
    mod belongs_to {
        pub trait GroupedBy {}
    }
    pub use self::belongs_to::GroupedBy;
}

pub mod prelude {
    pub use associations::GroupedBy;
}

I would expect that rustdoc would treat the "public" location of this trait as associations::GroupedBy, and not inline it anywhere else unless there's a #[doc(inline)].

Interestingly, there's also a pub use self::prelude::*; so this appears to not affect glob imports.

@QuietMisdreavus QuietMisdreavus added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-dev-tools-rustdoc labels Dec 4, 2017
@QuietMisdreavus
Copy link
Member

If i remember rustdoc's reasoning correctly, it looks at the original declaration of GroupedBy whenever it sees a re-export of it. If the original declaration is publicly reachable, then it will not inline it. If not, then it will. This causes a problem here because GroupedBy is originally declared in a private module, then re-exported in its "proper" place, as well as the prelude. From rustdoc's perspective, though, either one could be the proper place for it! The actual declaration is hidden, so it can't know!

You can hint to rustdoc by applying #[doc(inline)] and #[doc(no_inline)] to the re-exports to tell it which ones should render the full docs and which ones should render just a pub use statement in the module. There's currently no way to tell rustdoc that a given re-export is the "canonical" location, though.

@ehuss ehuss removed the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label Jan 18, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Apr 20, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 21, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#110365 (ship tools with sysroot)
 - rust-lang#110555 (Substitute missing trait items suggestion correctly)
 - rust-lang#110578 (fix(error): normalize whitespace during msg_to_buffer)
 - rust-lang#110597 (remove unused ftl messages)
 - rust-lang#110611 (Add regression test for rust-lang#46506)
 - rust-lang#110618 (Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in ea01135 Apr 21, 2023
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

Successfully merging a pull request may close this issue.

3 participants