Skip to content

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

Closed
@aDotInTheVoid

Description

@aDotInTheVoid
#![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.

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

    No branches or pull requests

    Issue actions