Skip to content

Rustdoc reports non accessable items in blocks with --document-private-items, even with #[doc(hidden)] #106373

Closed
@aDotInTheVoid

Description

@aDotInTheVoid
Member
#![allow(unused_macros, dead_code)]

#[doc(hidden)]
const _: () = {
    macro_rules! stry {
        () => {};
    }

    struct ShouldBeHidden;

    impl Bar for Foo {
        fn bar(&self) {
            struct SHouldAlsoBeHidden;
        }
    }
};

pub struct Foo;

pub trait Bar {
    fn bar(&self);
}

Produces with rustdoc +nightly src/lib.rs --document-private-items

image

which erroniously includes stry, ShouldBeHidden, and ShouldAlsoBeHidden.

Stable (1.66.0) gets this right

image

It's debatable what the semantics of --document-private-items should be for items in blocks without #[doc(hidden)] 1, but here, we're just wrong.

We also can't just ignore all items in #[doc(hidden)] blocks, as this would break a load of users, eg serde.

Zulip Discussion

Probably, caused by #104889, cc @GuillaumeGomez

Footnotes

  1. FWIW, I think they should still be hidden, as their not accessible outside the block.

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Jan 2, 2023
GuillaumeGomez

GuillaumeGomez commented on Jan 2, 2023

@GuillaumeGomez
Member

Tricky indeed. I see two ways of handling this problem:

  1. Hide all items inside the block: if we pick this way, then how to unhide items which are declared into a block like this if you only want to hide the "block owner" and not the items in the block.
  2. Keep the current behaviour and only hide items which have #[doc(hidden)] and their direct children, therefore excluding blocks since they're not children of the item.
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 16, 2023
removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 18, 2023
added a commit that references this issue on Jan 20, 2023

Auto merge of rust-lang#107083 - GuillaumeGomez:revert-104889, r=notr…

added a commit that references this issue on Feb 2, 2023

Auto merge of rust-lang#107000 - GuillaumeGomez:fix-items-in-doc-hidd…

6c991b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @GuillaumeGomez@apiraino@jyn514@aDotInTheVoid@rustbot

      Issue actions

        Rustdoc reports non accessable items in blocks with `--document-private-items`, even with `#[doc(hidden)]` · Issue #106373 · rust-lang/rust